diff options
author | Christoph Helma <helma@in-silico.de> | 2009-09-08 11:15:50 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2009-09-08 11:15:50 +0200 |
commit | 525a9229395070f04c54fe6aec3c2cd5e64235cd (patch) | |
tree | d942bde22ccc03e66223b9e284354387f64e4dcb /compound.rb | |
parent | 55d99f141275fc34019a621d1f0c444804ebc053 (diff) |
tests successful
Diffstat (limited to 'compound.rb')
-rw-r--r-- | compound.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/compound.rb b/compound.rb new file mode 100644 index 0000000..9c1552e --- /dev/null +++ b/compound.rb @@ -0,0 +1,33 @@ +mime :uid, "text/plain" +mime :smiles, "chemical/x-daylight-smiles" +mime :inchi, "chemical/x-inchi" +mime :sdf, "chemical/x-mdl-sdfile" +mime :image, "image/gif" +mime :names, "text/plain" + +set :default_content, :smiles + +get '/compound/*/match/*' do + "#{OpenTox::Compound.new(:inchi => params[:splat][0]).match(params[:splat][1])}" +end + +get %r{/compound/(.+)} do |inchi| # catches all remaining get requests + inchi.gsub!(/ /,'+') # fix CGI? escaping of + signs + respond_to do |format| + format.smiles { inchi2smiles inchi } + format.names { RestClient.get "#{CACTUS_URI}#{inchi}/names" } + format.inchi { inchi } + format.sdf { RestClient.get "#{CACTUS_URI}#{inchi}/sdf" } + format.image { "#{CACTUS_URI}#{inchi}/image" } + end +end + +post '/compound/?' do + if params[:smiles] + OpenTox::Compound.new(:smiles => params[:smiles]).uri + elsif params[:inchi] + OpenTox::Compound.new(:inchi => params[:inchi]).uri + elsif params[:name] + OpenTox::Compound.new(:name => params[:name]).uri + end +end |