diff options
author | ch <ch@ch.in-silico.ch> | 2015-07-12 12:14:13 +0200 |
---|---|---|
committer | ch <ch@ch.in-silico.ch> | 2015-07-12 12:14:13 +0200 |
commit | f850712765a67bf31b1327401e3eddf59e3e6f50 (patch) | |
tree | 18933386be18e87758486745369a978a75ddc1a3 /lib/compound.rb | |
parent | 723d731bc08d90a82f22474c9fafcc504eb424d3 (diff) |
initial dataset tests
Diffstat (limited to 'lib/compound.rb')
-rw-r--r-- | lib/compound.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/compound.rb b/lib/compound.rb index f63e127..82ea94e 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -5,8 +5,13 @@ module OpenTox # Ruby wrapper for OpenTox Compound Webservices (http://opentox.org/dev/apis/api-1.2/structure). class Compound + def initialize uri + @data = {} + @data["uri"] = uri + end + def ==(c) - @uri == c.uri + @data["uri"] == c.uri end # Create a compound from smiles string @@ -45,25 +50,25 @@ module OpenTox # Get InChI # @return [String] InChI string def inchi - @inchi ||= RestClientWrapper.get(@uri,{},{:accept => 'chemical/x-inchi'}).chomp + @inchi ||= RestClientWrapper.get(@data["uri"],{},{:accept => 'chemical/x-inchi'}).chomp end # Get InChIKey # @return [String] InChI string def inchikey - @inchikey ||= RestClientWrapper.get(@uri,{},{:accept => 'chemical/x-inchikey'}).chomp + @inchikey ||= RestClientWrapper.get(@data["uri"],{},{:accept => 'chemical/x-inchikey'}).chomp end # Get (canonical) smiles # @return [String] Smiles string def smiles - @smiles ||= RestClientWrapper.get(@uri,{},{:accept => 'chemical/x-daylight-smiles'}).chomp + @smiles ||= RestClientWrapper.get(@data["uri"],{},{:accept => 'chemical/x-daylight-smiles'}).chomp end # Get sdf # @return [String] SDF string def sdf - RestClientWrapper.get(@uri,{},{:accept => 'chemical/x-mdl-sdfile'}).chomp + RestClientWrapper.get(@data["uri"],{},{:accept => 'chemical/x-mdl-sdfile'}).chomp end # Get gif image @@ -77,13 +82,13 @@ module OpenTox # image = compound.png # @return [image/png] Image data def png - RestClientWrapper.get(File.join @uri, "image") + RestClientWrapper.get(File.join @data["uri"], "image") end # Get URI of compound image # @return [String] Compound image URI def image_uri - File.join @uri, "image" + File.join @data["uri"], "image" end # Get all known compound names. Relies on an external service for name lookups. |