diff options
author | Christoph Helma <helma@in-silico.de> | 2010-02-26 00:30:29 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2010-02-26 00:30:29 +0100 |
commit | 987b7ccd630ce527d472808b1cbeccb96b7917d4 (patch) | |
tree | 3b047d7e2213365cf924f0c6d34303257087fe5d | |
parent | 0f8039d1f4f35857cd36cc7582014690373ea71a (diff) |
initial openbabel services added
-rw-r--r-- | application.rb | 1 | ||||
-rw-r--r-- | openbabel.rb | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/application.rb b/application.rb index 5309060..a32cb8f 100644 --- a/application.rb +++ b/application.rb @@ -5,6 +5,7 @@ require 'opentox-ruby-api-wrapper' #require 'smarts.rb' #require 'similarity.rb' +require 'openbabel.rb' require 'fminer.rb' require 'lazar.rb' diff --git a/openbabel.rb b/openbabel.rb new file mode 100644 index 0000000..a261866 --- /dev/null +++ b/openbabel.rb @@ -0,0 +1,28 @@ +get '/openbabel/:smiles/:property/?' do + obconversion = OpenBabel::OBConversion.new + obmol = OpenBabel::OBMol.new + obconversion.set_in_and_out_formats 'smi', 'can' + case params[:property] + when 'logP' + #logP = OpenBabel::OBLogP.new + #logP.predict(obmol) + "not yet implemented" + when 'psa' + #psa = OpenBabel::OBPSA.new + "not yet implemented" + when 'mr' + #mr = OpenBabel::OBMR.new + "not yet implemented" + else + begin + obconversion.read_string obmol, params[:smiles] + rescue + halt 404, "Incorrect Smiles string #{params[:smiles]}" + end + begin + eval("obmol.#{params[:property]}").to_s + rescue + halt 404, "Could not calculate property #{params[:property]}" + end + end +end |