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