blob: 9c1552e01e081ff5a70906ad5217ae8034687188 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
|