idclight 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/.project +17 -0
- data/LICENSE +20 -0
- data/README.rdoc +36 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/convert.rb +35 -0
- data/bin/hugo_to_entrez.rb +32 -0
- data/lib/idclight.rb +86 -0
- data/test/helper.rb +10 -0
- data/test/test_idclight.rb +7 -0
- metadata +100 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.project
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>idclight</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>org.rubypeople.rdt.core.rubybuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>org.rubypeople.rdt.core.rubynature</nature>
|
16
|
+
</natures>
|
17
|
+
</projectDescription>
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Preston Lee
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= idclight
|
2
|
+
|
3
|
+
A Ruby gem for accessing the freely available IDClight (IDConverter Light) web service, which convert between different types of gene IDs such as Hugo and Entrez. Queries are screen scraped from http://idclight.bioinfo.cnio.es.
|
4
|
+
|
5
|
+
== Command-Line Usage
|
6
|
+
|
7
|
+
hugo_to_entrez BRCA2
|
8
|
+
|
9
|
+
== Application Usage
|
10
|
+
|
11
|
+
=== Converting a Hugo ID to an Entrez ID
|
12
|
+
|
13
|
+
require 'idclight'
|
14
|
+
include IDConverter::Light
|
15
|
+
hugo_id_to_entrez_id('BRCA2')
|
16
|
+
|
17
|
+
=== Getting Raw Data With Advanced Queries
|
18
|
+
|
19
|
+
require 'idclight'
|
20
|
+
include IDConverter::Light
|
21
|
+
data = search(@@HUGO, id, @@MOUSE)
|
22
|
+
# See +IDConverter::Light+ for a full list of supported constants.
|
23
|
+
|
24
|
+
== Note on Patches/Pull Requests
|
25
|
+
|
26
|
+
* Fork the project.
|
27
|
+
* Make your feature addition or bug fix.
|
28
|
+
* Add tests for it. This is important so I don't break it in a
|
29
|
+
future version unintentionally.
|
30
|
+
* Commit, do not mess with rakefile, version, or history.
|
31
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
32
|
+
* Send me a pull request. Bonus points for topic branches.
|
33
|
+
|
34
|
+
== Copyright
|
35
|
+
|
36
|
+
Copyright (c) 2010 Preston Lee. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "idclight"
|
8
|
+
gem.summary = %Q{Ruby programmnig interface to the IDCLight online database.}
|
9
|
+
gem.description = %Q{A Ruby gem for accessing the freely available IDClight (IDConverter Light) web service, which convert between different types of gene IDs such as Hugo and Entrez. Queries are screen scraped from http://idclight.bioinfo.cnio.es.}
|
10
|
+
gem.email = "conmotto@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/preston/idclight"
|
12
|
+
gem.authors = ["Preston Lee"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.add_dependency "hpricot", ">= 0.8"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "idclight #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/convert.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
current_dir = File.dirname(File.expand_path(__FILE__))
|
4
|
+
lib_path = File.join(current_dir, '..', 'lib')
|
5
|
+
$LOAD_PATH.unshift lib_path
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
|
9
|
+
require 'idclight'
|
10
|
+
|
11
|
+
include IDConverter::Light
|
12
|
+
|
13
|
+
|
14
|
+
code = 0
|
15
|
+
puts "\n"
|
16
|
+
puts "IDCLight (IDConverter Light) command-line converter utility. (Uses http://idclight.bioinfo.cnio.es for data.)"
|
17
|
+
org = @@HUMAN
|
18
|
+
if ARGV.length >= 2 and ARGV.length <= 3
|
19
|
+
id_type = ARGV[0]
|
20
|
+
id = ARGV[1]
|
21
|
+
org = ARGV[2] unless ARGV[2].nil?
|
22
|
+
r = convert(id_type, id, org)
|
23
|
+
if r.nil?
|
24
|
+
puts "No result. Bad input, perhaps? :/"
|
25
|
+
code = 1
|
26
|
+
else
|
27
|
+
puts "\n"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
puts "\n\tUsage: #{__FILE__} <id_type> <id> [organism (defaults to human)]"
|
31
|
+
end
|
32
|
+
puts "\n"
|
33
|
+
|
34
|
+
exit(code)
|
35
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
current_dir = File.dirname(File.expand_path(__FILE__))
|
4
|
+
lib_path = File.join(current_dir, '..', 'lib')
|
5
|
+
$LOAD_PATH.unshift lib_path
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
|
9
|
+
require 'idclight'
|
10
|
+
|
11
|
+
include IDConverter::Light
|
12
|
+
|
13
|
+
|
14
|
+
code = 0
|
15
|
+
puts "\n"
|
16
|
+
puts "IDCLight (IDConverter Light) command-line converter utility, by Preston Lee. (Screen scapes http://idclight.bioinfo.cnio.es for data.)"
|
17
|
+
if ARGV.length == 1
|
18
|
+
id = ARGV[0]
|
19
|
+
r = hugo_id_to_entrez_id(id)
|
20
|
+
if r.nil?
|
21
|
+
puts "No result. Bad input, perhaps? :("
|
22
|
+
code = 1
|
23
|
+
else
|
24
|
+
puts "\n#{r}"
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts "\n\tUsage: #{__FILE__} <id_type> <id> [organism (defaults to human)]"
|
28
|
+
end
|
29
|
+
puts "\n"
|
30
|
+
|
31
|
+
exit(code)
|
32
|
+
|
data/lib/idclight.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# For XPath support.
|
2
|
+
# require 'rexml/document' # ...was choking too much on bad XML.
|
3
|
+
require 'hpricot'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module IDConverter
|
7
|
+
|
8
|
+
module Light
|
9
|
+
|
10
|
+
# Organism type constants
|
11
|
+
@@HUMAN = 'Hs'
|
12
|
+
@@MOUSE = 'Mm'
|
13
|
+
@@RAT = 'Rn'
|
14
|
+
|
15
|
+
# ID type constants.
|
16
|
+
@@UNIGENE = 'ug'
|
17
|
+
@@ENTREZ = 'entrez'
|
18
|
+
@@ENSEMBL = 'ensumbl'
|
19
|
+
@@HUGO = 'hugo'
|
20
|
+
@@GENBANK = 'acc'
|
21
|
+
@@CLONE = 'clone'
|
22
|
+
@@AFFYMETRIX = 'affy'
|
23
|
+
@@REFSEQ_RNA = 'rsdna'
|
24
|
+
@@REFSEQ_PEPTIDE = 'rspep'
|
25
|
+
@@SWISSPROT = 'swissp'
|
26
|
+
|
27
|
+
|
28
|
+
# Originally taken from http://idclight.bioinfo.cnio.es/
|
29
|
+
# idtype refers to the type of ID from which you want to obtain further information. Current options are:
|
30
|
+
# ug (UniGene cluster)
|
31
|
+
# entrez (EntrezGene ID)
|
32
|
+
# ensembl (Ensembl Gene)
|
33
|
+
# hugo (HUGO Gene Name)
|
34
|
+
# acc (GenBank accession)
|
35
|
+
# clone (Clone ID)
|
36
|
+
# affy (Affymetrix ID)
|
37
|
+
# rsdna (RefSeq_RNA)
|
38
|
+
# rspep (RefSeq_peptide)
|
39
|
+
# swissp (SwissProt name)
|
40
|
+
# id is the ID of the gene or clone for which more information is required.
|
41
|
+
# org is the organism you are working with. Three different organisms are available Hs (Human - Homo sapiens), Mm (Mouse - Mus musculus), and Rn (Rat - Rattus norvegicus).
|
42
|
+
def search(id_type, id, organism = @@HUMAN)
|
43
|
+
return nil if id.nil? || id_type.nil? || organism.nil?
|
44
|
+
url = "http://idclight.bioinfo.cnio.es/idclight.prog?id=#{id}&idtype=#{id_type}&org=#{organism}"
|
45
|
+
data = nil
|
46
|
+
|
47
|
+
begin
|
48
|
+
doc = Hpricot(URI.parse(url).read)
|
49
|
+
elements = doc.search("//table[@class='sample']//tr")
|
50
|
+
data = {}
|
51
|
+
# last = nil
|
52
|
+
elements.each do |e|
|
53
|
+
tds = e/'td'
|
54
|
+
tds.size == 2
|
55
|
+
t1 = tds[0].inner_html
|
56
|
+
t2 = tds[1].inner_html
|
57
|
+
if t1.nil? || t1 == ''
|
58
|
+
# TODO
|
59
|
+
else
|
60
|
+
data[t1] = t2
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue SocketError => e
|
64
|
+
data =nil
|
65
|
+
end
|
66
|
+
data
|
67
|
+
end
|
68
|
+
|
69
|
+
def hugo_id_to_entrez_id(id, organism = @@HUMAN)
|
70
|
+
data = search(@@HUGO, id, organism)
|
71
|
+
id = nil
|
72
|
+
ent = data['Entrez Gene']
|
73
|
+
if ent
|
74
|
+
doc = Hpricot(ent)
|
75
|
+
doc.search('//a').each do |e|
|
76
|
+
tmp = e.inner_html.to_i
|
77
|
+
id = tmp if tmp != 0
|
78
|
+
end
|
79
|
+
end
|
80
|
+
id
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: idclight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Preston Lee
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-10 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: hpricot
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
- 8
|
42
|
+
version: "0.8"
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id002
|
45
|
+
description: A Ruby gem for accessing the freely available IDClight (IDConverter Light) web service, which convert between different types of gene IDs such as Hugo and Entrez. Queries are screen scraped from http://idclight.bioinfo.cnio.es.
|
46
|
+
email: conmotto@gmail.com
|
47
|
+
executables:
|
48
|
+
- convert.rb
|
49
|
+
- hugo_to_entrez.rb
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- LICENSE
|
54
|
+
- README.rdoc
|
55
|
+
files:
|
56
|
+
- .document
|
57
|
+
- .gitignore
|
58
|
+
- .project
|
59
|
+
- LICENSE
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- bin/convert.rb
|
64
|
+
- bin/hugo_to_entrez.rb
|
65
|
+
- lib/idclight.rb
|
66
|
+
- test/helper.rb
|
67
|
+
- test/test_idclight.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/preston/idclight
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --charset=UTF-8
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Ruby programmnig interface to the IDCLight online database.
|
98
|
+
test_files:
|
99
|
+
- test/helper.rb
|
100
|
+
- test/test_idclight.rb
|