diff options
author | Christoph Helma <helma@in-silico.de> | 2009-11-30 16:54:09 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2009-11-30 16:54:09 +0100 |
commit | 89c96b76e56e064b96687e906c8a71030c9477cf (patch) | |
tree | f337bfc336e2c80de0df281c623064dc64b5fce4 | |
parent | f21aabdc79c631b07b06092e137ffc95ba67eb8d (diff) |
names retrieval fixed, examples for README
-rw-r--r-- | README | 25 | ||||
-rw-r--r-- | application.rb | 4 |
2 files changed, 27 insertions, 2 deletions
@@ -15,6 +15,29 @@ Supported MIME formats (http://chemical-mime.sourceforge.net/): * chemical/x-inchi * chemical/x-mdl-sdfile * text/plain (chemical names) - * link to image/gif (output only) + * image/gif (returns image uri, output only) + +Examples: + + Create a compound_uri from smiles: + curl -X POST -H "Content-Type:chemical/x-daylight-smiles" --data-binary "c1ccccc1" http://webservices.in-silico.ch/test/compound + + Create a compound_uri from a SD file: + curl -X POST -H "Content-Type:chemical/x-mdl-sdfile" --data-binary @my.sdf http://webservices.in-silico.ch/test/compound + + Create a compound_uri from name (or any other identifier that can be resolved with the Cactus service): + curl -X POST -H "Content-Type:text/plain" --data-binary "Benzene" http://webservices.in-silico.ch/test/compound + + Create a compound_uri from CAS: + curl -X POST -H "Content-Type:text/plain" --data-binary "71-43-2" http://webservices.in-silico.ch/test/compound + + Get SMILES for a compound_uri: + curl http://webservices.in-silico.ch/test/compound/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H + + Get a SD file for a compound_uri: + curl -H "Accept:chemical/x-mdl-sdfile" http://webservices.in-silico.ch/test/compound/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H + + Get all names for a compound_uri: + curl -H "Accept:text/plain" http://webservices.in-silico.ch/test/compound/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H Installation: http://wiki.github.com/helma/opentox-documentation/installation-of-opentox-webservices diff --git a/application.rb b/application.rb index 7829fff..e6ee6c7 100644 --- a/application.rb +++ b/application.rb @@ -1,6 +1,8 @@ require 'rubygems' require 'opentox-ruby-api-wrapper' +CACTUS_URI="http://cactus.nci.nih.gov/chemical/structure/" + get %r{/(.+)} do |inchi| # catches all remaining get requests inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." case request.env['HTTP_ACCEPT'] @@ -15,7 +17,7 @@ get %r{/(.+)} do |inchi| # catches all remaining get requests when "image/gif" "#{CACTUS_URI}#{inchi}/image" when "text/plain" - RestClient.get "#{CACTUS_URI}#{inchi}/names" + RestClient.get("#{CACTUS_URI}#{inchi}/names").to_s else status 400 "Unsupported MIME type '#{request.content_type}'" |