diff options
author | Christoph Helma <helma@in-silico.ch> | 2010-11-19 14:42:29 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2010-11-19 14:42:29 +0100 |
commit | 0338a925cd2111140c10dc79967e2f49d1349ba2 (patch) | |
tree | dbbdf25da2958792b4e0359098e7cc7253900f43 | |
parent | 472ba74cd8f78a09563880f366dc6fc01744ccaf (diff) |
lazar predictions and toxcreate are working
-rw-r--r-- | application.rb | 31 |
1 files 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 |