From b2703cc8be43b00725919b7366d35f8009d71267 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 25 Aug 2010 14:49:33 +0200 Subject: opentox-api-wrapper bumped to 1.6.6 --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 58106d1..869b4f9 100644 --- a/application.rb +++ b/application.rb @@ -7,7 +7,7 @@ ENV["CLASSPATH"] = "#{ENV["CLASSPATH"]}:#{java_dir}:#{cdk}:#{jchempaint}" require 'rubygems' require 'rjb' -gem "opentox-ruby-api-wrapper", "= 1.6.5" +gem "opentox-ruby-api-wrapper", "= 1.6.6" require 'opentox-ruby-api-wrapper' #set :lock, true # avoid JVM memory allocation problems -- cgit v1.2.3 From f86fbd186b17860d98af7de79915132e48753b8a Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 22 Oct 2010 16:38:10 +0200 Subject: new API with support for external services (initial version) --- application.rb | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/application.rb b/application.rb index 869b4f9..badab34 100644 --- a/application.rb +++ b/application.rb @@ -10,9 +10,6 @@ require 'rjb' gem "opentox-ruby-api-wrapper", "= 1.6.6" require 'opentox-ruby-api-wrapper' -#set :lock, true # avoid JVM memory allocation problems -# -Xmx64m - get "/display/activating/(.+)$" do content_type "image/png" attachment "#{params["smiles"]}.png" @@ -42,7 +39,6 @@ get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)/highlight/(.*)$} do s.match_activating(activating) unless activating.empty? s.match(smarts) s.show - #s = nil end get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |smiles,activating,deactivating| @@ -55,7 +51,6 @@ get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |smiles,activa s.match_deactivating(deactivating) s.match_activating(activating) s.show - #s = nil end get %r{/smiles/(.+)/smarts/(.*)/(.*activating)$} do |smiles,allsmarts,effect| @@ -94,7 +89,7 @@ get %r{/smiles/(.+)} do |smiles| end get %r{/(.+)/image} do |inchi| # catches all remaining get requests - smiles = OpenTox::Compound.new(:inchi => inchi).smiles + smiles = OpenTox::Compound.from_inchi(inchi).smiles content_type "image/png" attachment "#{smiles}.png" Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems @@ -106,22 +101,22 @@ get %r{/(.+)} do |inchi| # catches all remaining get requests case request.env['HTTP_ACCEPT'] when "*/*" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.new(:inchi => inchi).smiles + OpenTox::Compound.from_inchi(inchi).smiles when "chemical/x-daylight-smiles" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.new(:inchi => inchi).smiles + OpenTox::Compound.from_inchi(inchi).smiles when "chemical/x-inchi" response['Content-Type'] = "chemical/x-inchi" inchi when "chemical/x-mdl-sdfile" response['Content-Type'] = "chemical/x-mdl-sdfile" - OpenTox::Compound.new(:inchi => inchi).sdf + OpenTox::Compound.from_inchi(inchi).sdf when "image/gif" response['Content-Type'] = "image/gif" - OpenTox::Compound.new(:inchi => inchi).gif + OpenTox::Compound.from_inchi(inchi).gif when "image/png" response['Content-Type'] = "image/png" - OpenTox::Compound.new(:inchi => inchi).png + OpenTox::Compound.from_inchi(inchi).png when "text/plain" response['Content-Type'] = "text/plain" uri = File.join @@cactus_uri,inchi,"names" @@ -138,13 +133,13 @@ post '/?' do begin case request.content_type when /chemical\/x-daylight-smiles/ - OpenTox::Compound.new(:smiles => input).uri + "\n" + OpenTox::Compound.from_smiles(input).uri + "\n" when /chemical\/x-inchi/ - OpenTox::Compound.new(:inchi => input).uri + "\n" + OpenTox::Compound.from_inchi(input).uri + "\n" when /chemical\/x-mdl-sdfile|chemical\/x-mdl-molfile/ - OpenTox::Compound.new(:sdf => input).uri + "\n" + OpenTox::Compound.from_sdf(input).uri + "\n" when /text\/plain/ - OpenTox::Compound.new(:name => input).uri + "\n" + OpenTox::Compound.from_name(input).uri + "\n" else status 400 "Unsupported MIME type '#{request.content_type}'" -- cgit v1.2.3 From 340a9152c99daffe27aa86a8ee6826f78610ebe0 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 10 Nov 2010 15:40:09 +0100 Subject: yardoc documantation added an obsolete methods removed --- application.rb | 107 ++++++++++++++++++--------------------------------------- 1 file changed, 34 insertions(+), 73 deletions(-) diff --git a/application.rb b/application.rb index badab34..17f7faa 100644 --- a/application.rb +++ b/application.rb @@ -10,38 +10,16 @@ require 'rjb' gem "opentox-ruby-api-wrapper", "= 1.6.6" require 'opentox-ruby-api-wrapper' -get "/display/activating/(.+)$" do - content_type "image/png" - attachment "#{params["smiles"]}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(params["smiles"],150) - s.match_activating(params["smarts"]) - s.show -end - -post "/display/deactivating" do - content_type "image/png" - attachment "#{params["smiles"]}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(params["smiles"],150) - s.match_deactivating(params["smarts"]) - s.show +before do + @inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." end -get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)/highlight/(.*)$} do |smiles,activating,deactivating,smarts| - activating = activating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} - deactivating = deactivating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} - content_type "image/png" - attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(smiles,150) - s.match_deactivating(deactivating) unless deactivating.empty? - s.match_activating(activating) unless activating.empty? - s.match(smarts) - s.show -end - -get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |smiles,activating,deactivating| +# Display activating (red) and deactivating (green) substructures. Overlaps betwen activating and deactivating structures are marked in yellow. +# @example +# curl http://webservices.in-silico.ch/compound/compound/InChI=1S/C6H5NO2/c8-7(9)6-4-2-1-3-5-6/h1-5H/smarts/activating/cN/ccN/deactivating/cc" > img.png +# @return [image/png] Image with highlighted substructures +get %r{/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |inchi,activating,deactivating| + smiles = OpenTox::Compound.from_inchi(@inchi).smiles activating = activating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} deactivating = deactivating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} content_type "image/png" @@ -53,42 +31,10 @@ get %r{/smiles/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |smiles,activa s.show end -get %r{/smiles/(.+)/smarts/(.*)/(.*activating)$} do |smiles,allsmarts,effect| - LOGGER.debug "String:" - LOGGER.debug allsmarts - smarts = allsmarts.to_s.split(/\//) - smarts.collect!{|s| s.gsub(/"/,'')} - LOGGER.debug "Smarts:" - LOGGER.debug smarts.to_yaml - content_type "image/png" - attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(smiles,150) - if effect == "activating" - s.match_activating(smarts) - elsif effect == "deactivating" - s.match_deactivating(smarts) - end - s.show -end - -get %r{/smiles/(.+)/smarts/(.*)$} do |smiles,smarts| - content_type "image/png" - attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(smiles,150) - s.match(smarts) - s.show -end - -get %r{/smiles/(.+)} do |smiles| - content_type "image/png" - attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - Rjb::import('Structure').new(smiles,150).show -end - +# Get png image +# @return [image/png] Image data get %r{/(.+)/image} do |inchi| # catches all remaining get requests + inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." smiles = OpenTox::Compound.from_inchi(inchi).smiles content_type "image/png" attachment "#{smiles}.png" @@ -96,36 +42,51 @@ get %r{/(.+)/image} do |inchi| # catches all remaining get requests Rjb::import('Structure').new(smiles,150).show end +# Get compound representation +# @param [optinal, HEADER] Accept one of `chemical/x-daylight-smiles, chemical/x-inchi, chemical/x-mdl-sdfile, chemical/x-mdl-molfile, text/plain, image/gif, image/png`, defaults to chemical/x-daylight-smiles +# @example Get smiles +# curl http://webservices.in-silico.ch/compound/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H +# @example Get all known names +# curl -H "Accept:text/plain" http://webservices.in-silico.ch/compound/InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H +# @return [chemical/x-daylight-smiles, chemical/x-inchi, chemical/x-mdl-sdfile, chemical/x-mdl-molfile, text/plain, image/gif, image/png] Compound representation get %r{/(.+)} do |inchi| # catches all remaining get requests - inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." + #inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." case request.env['HTTP_ACCEPT'] when "*/*" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.from_inchi(inchi).smiles + OpenTox::Compound.from_inchi(@inchi).smiles when "chemical/x-daylight-smiles" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.from_inchi(inchi).smiles + OpenTox::Compound.from_inchi(@inchi).smiles when "chemical/x-inchi" response['Content-Type'] = "chemical/x-inchi" - inchi + @inchi when "chemical/x-mdl-sdfile" response['Content-Type'] = "chemical/x-mdl-sdfile" - OpenTox::Compound.from_inchi(inchi).sdf + OpenTox::Compound.from_inchi(@inchi).sdf when "image/gif" response['Content-Type'] = "image/gif" - OpenTox::Compound.from_inchi(inchi).gif + OpenTox::Compound.from_inchi(@inchi).gif when "image/png" response['Content-Type'] = "image/png" - OpenTox::Compound.from_inchi(inchi).png + OpenTox::Compound.from_inchi(@inchi).png when "text/plain" response['Content-Type'] = "text/plain" - uri = File.join @@cactus_uri,inchi,"names" + uri = File.join @@cactus_uri,@inchi,"names" RestClient.get(uri).body else halt 400, "Unsupported MIME type '#{request.env['HTTP_ACCEPT']}'" end end +# Create a new compound URI (compounds are not saved at the compound service) +# @param [HEADER] Content-type one of `chemical/x-daylight-smiles, chemical/x-inchi, chemical/x-mdl-sdfile, chemical/x-mdl-molfile, text/plain` +# @example Create compound from Smiles string +# curl -X POST -H "Content-type:chemical/x-daylight-smiles" --data "c1ccccc1" http://webservices.in-silico.ch/compound +# @example Create compound from name, uses an external lookup service and should work also with trade names, CAS numbers, ... +# curl -X POST -H "Content-type:text/plain" --data "Benzene" http://webservices.in-silico.ch/compound +# @param [BODY] - string with identifier/data in selected Content-type +# @return [text/uri-list] compound URI post '/?' do input = request.env["rack.input"].read -- cgit v1.2.3 From 472ba74cd8f78a09563880f366dc6fc01744ccaf Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 10 Nov 2010 17:41:56 +0100 Subject: Format conversion functions adapted to new wrapper version --- application.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application.rb b/application.rb index 17f7faa..0847276 100644 --- a/application.rb +++ b/application.rb @@ -19,7 +19,7 @@ end # curl http://webservices.in-silico.ch/compound/compound/InChI=1S/C6H5NO2/c8-7(9)6-4-2-1-3-5-6/h1-5H/smarts/activating/cN/ccN/deactivating/cc" > img.png # @return [image/png] Image with highlighted substructures get %r{/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |inchi,activating,deactivating| - smiles = OpenTox::Compound.from_inchi(@inchi).smiles + smiles = OpenTox::Compound.from_inchi(@inchi).to_smiles activating = activating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} deactivating = deactivating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} content_type "image/png" @@ -35,7 +35,7 @@ end # @return [image/png] Image data get %r{/(.+)/image} do |inchi| # catches all remaining get requests inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." - smiles = OpenTox::Compound.from_inchi(inchi).smiles + smiles = OpenTox::Compound.from_inchi(inchi).to_smiles content_type "image/png" attachment "#{smiles}.png" Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems @@ -54,22 +54,22 @@ get %r{/(.+)} do |inchi| # catches all remaining get requests case request.env['HTTP_ACCEPT'] when "*/*" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.from_inchi(@inchi).smiles + OpenTox::Compound.from_inchi(@inchi).to_smiles when "chemical/x-daylight-smiles" response['Content-Type'] = "chemical/x-daylight-smiles" - OpenTox::Compound.from_inchi(@inchi).smiles + OpenTox::Compound.from_inchi(@inchi).to_smiles when "chemical/x-inchi" response['Content-Type'] = "chemical/x-inchi" @inchi when "chemical/x-mdl-sdfile" response['Content-Type'] = "chemical/x-mdl-sdfile" - OpenTox::Compound.from_inchi(@inchi).sdf + OpenTox::Compound.from_inchi(@inchi).to_sdf when "image/gif" response['Content-Type'] = "image/gif" - OpenTox::Compound.from_inchi(@inchi).gif + OpenTox::Compound.from_inchi(@inchi).to_gif when "image/png" response['Content-Type'] = "image/png" - OpenTox::Compound.from_inchi(@inchi).png + OpenTox::Compound.from_inchi(@inchi).to_png when "text/plain" response['Content-Type'] = "text/plain" uri = File.join @@cactus_uri,@inchi,"names" -- cgit v1.2.3 From 0338a925cd2111140c10dc79967e2f49d1349ba2 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 19 Nov 2010 14:42:29 +0100 Subject: lazar predictions and toxcreate are working --- application.rb | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/application.rb b/application.rb index 0847276..545bf60 100644 --- a/application.rb +++ b/application.rb @@ -11,7 +11,7 @@ gem "opentox-ruby-api-wrapper", "= 1.6.6" require 'opentox-ruby-api-wrapper' before do - @inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." + @inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'').sub(/\/image/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." end # Display activating (red) and deactivating (green) substructures. Overlaps betwen activating and deactivating structures are marked in yellow. @@ -24,22 +24,29 @@ get %r{/(.+)/smarts/activating/(.*)/deactivating/(.*)$} do |inchi,activating,dea deactivating = deactivating.to_s.split(/\//).collect{|s| s.gsub(/"/,'')} content_type "image/png" attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - s = Rjb::import('Structure').new(smiles,150) - s.match_deactivating(deactivating) - s.match_activating(activating) - s.show + begin + Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems + s = Rjb::import('Structure').new(smiles,150) + s.match_deactivating(deactivating) + s.match_activating(activating) + s.show + rescue => e + LOGGER.warn e.message + end end # Get png image # @return [image/png] Image data get %r{/(.+)/image} do |inchi| # catches all remaining get requests - inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." - smiles = OpenTox::Compound.from_inchi(inchi).to_smiles - content_type "image/png" - attachment "#{smiles}.png" - Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems - Rjb::import('Structure').new(smiles,150).show + smiles = OpenTox::Compound.from_inchi(@inchi).to_smiles + content_type "image/png" + attachment "#{smiles}.png" + begin + Rjb.load(nil,["-Xmx64m"])# avoid JVM memory allocation problems + Rjb::import('Structure').new(smiles,150).show + rescue + LOGGER.warn e.message + end end # Get compound representation -- cgit v1.2.3 From 6989492ceeb3ba8e882bf9ad3773812894bdf31a Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 24 Nov 2010 13:10:52 +0100 Subject: opentox-ruby-api-wrapper renamed to opentox-ruby --- application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index 545bf60..867fa6a 100644 --- a/application.rb +++ b/application.rb @@ -7,8 +7,8 @@ ENV["CLASSPATH"] = "#{ENV["CLASSPATH"]}:#{java_dir}:#{cdk}:#{jchempaint}" require 'rubygems' require 'rjb' -gem "opentox-ruby-api-wrapper", "= 1.6.6" -require 'opentox-ruby-api-wrapper' +gem "opentox-ruby", "~> 0" +require 'opentox-ruby' before do @inchi = URI.unescape request.env['REQUEST_URI'].sub(/^\//,'').sub(/.*compound\//,'').sub(/\/smarts.*$/,'').sub(/\/image/,'') # hack to avoid sinatra's URI/CGI unescaping, splitting, ..." -- cgit v1.2.3 From 27851bf191e20614921610132c164391c1ddb5e7 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 24 Nov 2010 14:43:20 +0100 Subject: opentox-ruby gem in config.ru --- Rakefile | 3 +-- config.ru | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index fbfcd62..d43e8f3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ require 'rubygems' require 'rake' -require 'opentox-ruby-api-wrapper' -#require 'tasks/opentox' +require 'opentox-ruby' @gems = "sinatra rest-client emk-sinatra-url-for sinatra-respond_to" diff --git a/config.ru b/config.ru index ec0402a..67d8493 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ require 'rubygems' -require 'opentox-ruby-api-wrapper' +require 'opentox-ruby' require 'config/config_ru' run Sinatra::Application -- cgit v1.2.3 From 8f5d206faa9dfecd32936d57baf9d571f504d802 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 20 Jan 2011 11:23:41 +0100 Subject: disable sinatra built in error handling to allow new ot error handling --- config.ru | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.ru b/config.ru index 67d8493..a1aab0d 100644 --- a/config.ru +++ b/config.ru @@ -2,3 +2,5 @@ require 'rubygems' require 'opentox-ruby' require 'config/config_ru' run Sinatra::Application +set :raise_errors, false +set :show_exceptions, false \ No newline at end of file -- cgit v1.2.3 From 431a1abe3ed7327704e22bc45ef9968b6ef8949a Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 9 Mar 2011 12:00:09 +0100 Subject: version bumped to 1.0.0 --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 867fa6a..0a3794a 100644 --- a/application.rb +++ b/application.rb @@ -7,7 +7,7 @@ ENV["CLASSPATH"] = "#{ENV["CLASSPATH"]}:#{java_dir}:#{cdk}:#{jchempaint}" require 'rubygems' require 'rjb' -gem "opentox-ruby", "~> 0" +gem "opentox-ruby", "~> 1" require 'opentox-ruby' before do -- cgit v1.2.3