Module: Sylfy::Service::UniChem::REST
- Defined in:
- lib/sylfy/service/unichemrest.rb
Constant Summary collapse
- NAMEURIMAPPING =
{ chembl: "chembl.compound", drugbank: "drugbank", pdb: "pdb", iuphar: "iuphar.ligand", kegg_ligand: "kegg.compound", chebi: "chebi", #emolecules: "", #ibm: "", #atlas: "", #patents: "", #fdasrs: "", #surechem: "", pharmgkb: "pharmgkb.drug", #pubchem_tpharma: "", hmdb: "hmdb", pubchem: "pubchem.compound" #mcule: "" }
- @@baseuri =
"https://www.ebi.ac.uk/unichem/rest"
Class Method Summary collapse
- .inchikey(key, all = false) ⇒ Object
- .inchikey_all(key) ⇒ Object
- .mapping(src_id, to_src_id) ⇒ Object
- .perform(input) ⇒ Object
- .src_compound_id(src_cpd_id, src_id = 1, to_src_id = nil, all = false) ⇒ Object
- .src_compound_id_all(src_cpd_id, src_id = 1, to_src_id = nil) ⇒ Object
- .structure(src_cpd_id, src_id) ⇒ Object
- .verbose_inchikey(key) ⇒ Object
Class Method Details
.inchikey(key, all = false) ⇒ Object
68 69 70 71 |
# File 'lib/sylfy/service/unichemrest.rb', line 68 def inchikey(key, all = false) input = "inchikey#{all == true ? "_all" : ''}/#{key}" return perform(input) end |
.inchikey_all(key) ⇒ Object
73 74 75 |
# File 'lib/sylfy/service/unichemrest.rb', line 73 def inchikey_all(key) return inchikey(key, true) end |
.mapping(src_id, to_src_id) ⇒ Object
63 64 65 66 |
# File 'lib/sylfy/service/unichemrest.rb', line 63 def mapping(src_id, to_src_id) input = "mapping/#{src_id}/#{to_src_id}" return perform(input) end |
.perform(input) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sylfy/service/unichemrest.rb', line 43 def perform(input) uri = "#{@@baseuri}/#{input}" begin return JSON.parse(open(uri, "content_type" => 'application/json').read().strip()) rescue OpenURI::HTTPError return JSON.parse("{}") end end |
.src_compound_id(src_cpd_id, src_id = 1, to_src_id = nil, all = false) ⇒ Object
54 55 56 57 |
# File 'lib/sylfy/service/unichemrest.rb', line 54 def src_compound_id(src_cpd_id, src_id = 1, to_src_id = nil, all = false) input = "src_compound_id#{all == true ? "_all" : ''}/#{src_cpd_id}/#{src_id}#{to_src_id != nil ? "/#{to_src_id}" : ""}" return perform(input) end |
.src_compound_id_all(src_cpd_id, src_id = 1, to_src_id = nil) ⇒ Object
59 60 61 |
# File 'lib/sylfy/service/unichemrest.rb', line 59 def src_compound_id_all(src_cpd_id, src_id = 1, to_src_id = nil) return src_compound_id(src_cpd_id, src_id, to_src_id, true) end |
.structure(src_cpd_id, src_id) ⇒ Object
77 78 79 80 |
# File 'lib/sylfy/service/unichemrest.rb', line 77 def structure(src_cpd_id, src_id) input = "structure/#{src_cpd_id}/#{src_id}" return perform(input) end |
.verbose_inchikey(key) ⇒ Object
82 83 84 85 |
# File 'lib/sylfy/service/unichemrest.rb', line 82 def verbose_inchikey(key) input = "verbose_inchikey/#{key}" return perform(input) end |