Module: IDConverter::Light
- Defined in:
- lib/idclight.rb
Constant Summary collapse
- @@HUMAN =
Organism type constants
'Hs'
- @@MOUSE =
'Mm'
- @@RAT =
'Rn'
- @@UNIGENE =
ID type constants.
'ug'
- @@ENTREZ =
'entrez'
- @@ENSEMBL =
'ensembl'
- @@HUGO =
'hugo'
- @@GENBANK =
'acc'
- @@CLONE =
'clone'
- @@AFFYMETRIX =
'affy'
- @@REFSEQ_RNA =
'rsdna'
- @@REFSEQ_PEPTIDE =
'rspep'
- @@SWISSPROT =
'swissp'
Instance Method Summary collapse
- #ensembl_id_to_entrez_id(id, organism = @@HUMAN) ⇒ Object
- #ensembl_id_to_hugo_id(id, organism = @@HUMAN) ⇒ Object
- #extract_ensembl_id(data) ⇒ Object
- #extract_entrez_id(data) ⇒ Object
- #extract_hugo_id(data) ⇒ Object
- #extract_last_link_text(ent) ⇒ Object
- #hugo_id_to_ensembl_id(id, organism = @@HUMAN) ⇒ Object
- #hugo_id_to_entrez_id(id, organism = @@HUMAN) ⇒ Object
-
#search(id_type, id, organism = @@HUMAN) ⇒ Object
Originally taken from idclight.bioinfo.cnio.es/ idtype refers to the type of ID from which you want to obtain further information.
Instance Method Details
#ensembl_id_to_entrez_id(id, organism = @@HUMAN) ⇒ Object
79 80 81 82 |
# File 'lib/idclight.rb', line 79 def ensembl_id_to_entrez_id(id, organism = @@HUMAN) data = search(@@ENSEMBL, id, organism) extract_entrez_id(data) end |
#ensembl_id_to_hugo_id(id, organism = @@HUMAN) ⇒ Object
84 85 86 87 |
# File 'lib/idclight.rb', line 84 def ensembl_id_to_hugo_id(id, organism = @@HUMAN) data = search(@@ENSEMBL, id, organism) extract_hugo_id(data) end |
#extract_ensembl_id(data) ⇒ Object
107 108 109 110 |
# File 'lib/idclight.rb', line 107 def extract_ensembl_id(data) ent = data['Ensembl'] extract_last_link_text(ent) end |
#extract_entrez_id(data) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/idclight.rb', line 89 def extract_entrez_id(data) ent = data['Entrez Gene'] id = nil if ent doc = Hpricot(ent) doc.search('//a').each do |e| tmp = e.inner_html.to_i id = tmp if tmp != 0 end end id end |
#extract_hugo_id(data) ⇒ Object
102 103 104 105 |
# File 'lib/idclight.rb', line 102 def extract_hugo_id(data) ent = data['HUGO'] extract_last_link_text(ent) end |
#extract_last_link_text(ent) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/idclight.rb', line 112 def extract_last_link_text(ent) id = nil if ent doc = Hpricot(ent) doc.search('//a').each do |e| tmp = e.inner_html id = tmp if !tmp.nil? && tmp != '' end end id end |
#hugo_id_to_ensembl_id(id, organism = @@HUMAN) ⇒ Object
74 75 76 77 |
# File 'lib/idclight.rb', line 74 def hugo_id_to_ensembl_id(id, organism = @@HUMAN) data = search(@@HUGO, id, organism) extract_ensembl_id(data) end |
#hugo_id_to_entrez_id(id, organism = @@HUMAN) ⇒ Object
69 70 71 72 |
# File 'lib/idclight.rb', line 69 def hugo_id_to_entrez_id(id, organism = @@HUMAN) data = search(@@HUGO, id, organism) extract_entrez_id(data) end |
#search(id_type, id, organism = @@HUMAN) ⇒ Object
Originally taken from idclight.bioinfo.cnio.es/ idtype refers to the type of ID from which you want to obtain further information. Current options are: ug (UniGene cluster) entrez (EntrezGene ID) ensembl (Ensembl Gene) hugo (HUGO Gene Name) acc (GenBank accession) clone (Clone ID) affy (Affymetrix ID) rsdna (RefSeq_RNA) rspep (RefSeq_peptide) swissp (SwissProt name) id is the ID of the gene or clone for which more information is required. 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/idclight.rb', line 42 def search(id_type, id, organism = @@HUMAN) return nil if id.nil? || id_type.nil? || organism.nil? url = "http://idclight.bioinfo.cnio.es/idclight.prog?id=#{id}&idtype=#{id_type}&org=#{organism}" data = nil begin doc = Hpricot(URI.parse(url).read) elements = doc.search("//table[@class='sample']//tr") data = {} # last = nil elements.each do |e| tds = e/'td' tds.size == 2 t1 = tds[0].inner_html t2 = tds[1].inner_html if t1.nil? || t1 == '' # TODO else data[t1] = t2 end end rescue SocketError => e data =nil end data end |