summaryrefslogtreecommitdiff
path: root/lib/compound.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2010-01-22 11:16:13 +0100
committerChristoph Helma <helma@in-silico.de>2010-01-22 11:16:13 +0100
commit09974c5a920bbb07475d8e48a725ef3780e60dbe (patch)
treee0992268d21f872eb554452da4a73d8d3acb9b2c /lib/compound.rb
parentc86df1faf22bcd90a8f318632c368d5ce474dbf8 (diff)
central config.ru, generic compound API
Diffstat (limited to 'lib/compound.rb')
-rw-r--r--lib/compound.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index 4385a7d..0a90663 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -20,14 +20,19 @@ module OpenTox
@inchi = RestClient.get("#{@@cactus_uri}#{params[:name]}/stdinchi").chomp
@uri = File.join(@@config[:services]["opentox-compound"],URI.escape(@inchi))
elsif params[:uri]
- @inchi = params[:uri].sub(/^.*InChI/, 'InChI')
+ if params[:uri].match(/InChI/) # shortcut for IST services
+ @inchi = params[:uri].sub(/^.*InChI/, 'InChI')
+ else
+ @inchi = RestClient.get @uri, :accept => 'chemical/x-inchi'
+ end
@uri = params[:uri]
end
end
# Get the (canonical) smiles
def smiles
- obconversion(@inchi,'inchi','can')
+ RestClient.get(@uri, :accept => 'chemical/x-daylight-smiles').split(/\s+/).first # fix ambit output
+ #obconversion(@inchi,'inchi','can')
end
def sdf