summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2010-05-21 15:58:31 +0200
committerChristoph Helma <helma@in-silico.ch>2010-05-21 15:58:31 +0200
commitacf5094b1eb8ee5cc105128dd16a1e330bd74864 (patch)
tree09091844e0d0aa46c6cbd8d3acedc49f1d8fed03
parent928ce9f7fda7cd650ba010efd7d86d739e565b6d (diff)
READMEs updated
-rw-r--r--README14
-rw-r--r--application.rb28
2 files changed, 23 insertions, 19 deletions
diff --git a/README b/README
index 30b3e36..f2721fc 100644
--- a/README
+++ b/README
@@ -20,24 +20,24 @@ Supported MIME formats (http://chemical-mime.sourceforge.net/):
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
+ curl -X POST -H "Content-Type:chemical/x-daylight-smiles" --data-binary "c1ccccc1" http://webservices.in-silico.ch/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
+ curl -X POST -H "Content-Type:chemical/x-mdl-sdfile" --data-binary @my.sdf http://webservices.in-silico.ch/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
+ curl -X POST -H "Content-Type:text/plain" --data-binary "Benzene" http://webservices.in-silico.ch/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
+ curl -X POST -H "Content-Type:text/plain" --data-binary "71-43-2" http://webservices.in-silico.ch/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
+ curl http://webservices.in-silico.ch/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
+ curl -H "Accept:chemical/x-mdl-sdfile" http://webservices.in-silico.ch/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
+ curl -H "Accept:text/plain" http://webservices.in-silico.ch/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 73d1702..e19f680 100644
--- a/application.rb
+++ b/application.rb
@@ -23,7 +23,6 @@ get %r{/(.+)} do |inchi| # catches all remaining get requests
when "image/gif"
response['Content-Type'] = "image/gif"
OpenTox::Compound.new(:inchi => inchi).image
- #"#{CACTUS_URI}#{inchi}/image"
when "text/plain"
response['Content-Type'] = "text/plain"
uri = File.join CACTUS_URI,inchi,"names"
@@ -37,17 +36,22 @@ post '/?' do
input = request.env["rack.input"].read
response['Content-Type'] = 'text/uri-list'
- case request.content_type
- when /chemical\/x-daylight-smiles/
- OpenTox::Compound.new(:smiles => input).uri + "\n"
- when /chemical\/x-inchi/
- OpenTox::Compound.new(:inchi => input).uri + "\n"
- when /chemical\/x-mdl-sdfile|chemical\/x-mdl-molfile/
- OpenTox::Compound.new(:sdf => input).uri + "\n"
- when /text\/plain/
- OpenTox::Compound.new(:name => input).uri + "\n"
- else
+ begin
+ case request.content_type
+ when /chemical\/x-daylight-smiles/
+ OpenTox::Compound.new(:smiles => input).uri + "\n"
+ when /chemical\/x-inchi/
+ OpenTox::Compound.new(:inchi => input).uri + "\n"
+ when /chemical\/x-mdl-sdfile|chemical\/x-mdl-molfile/
+ OpenTox::Compound.new(:sdf => input).uri + "\n"
+ when /text\/plain/
+ OpenTox::Compound.new(:name => input).uri + "\n"
+ else
+ status 400
+ "Unsupported MIME type '#{request.content_type}'"
+ end
+ rescue
status 400
- "Unsupported MIME type '#{request.content_type}'"
+ "Cannot process request '#{input}' for content type '#{request.content_type}'"
end
end