diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-05-15 15:20:45 +0200 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-05-15 15:20:45 +0200 |
commit | 2ffd6d893a363ebd30b357fafb43484c0bf56417 (patch) | |
tree | 47eed9b4407674e4277bb40a345aeb588a96eca7 | |
parent | d2397c0d6682989ff720bd0eb04be8b596d6b392 (diff) | |
parent | 1863df7fad6785d0ca471e3286b874ee80ad2d19 (diff) |
Merge branch 'bbrc-sample' of github.com:opentox/opentox-ruby into bbrc-sample
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/compound.rb | 22 |
2 files changed, 15 insertions, 11 deletions
@@ -8,11 +8,11 @@ v3.1.0 2012-02-24 * task.rb: Polling with increasing interval * parser.rb: CSV up and download fixed * transform.rb: routines to create machine learning data matrices - * algorithm.rb: SVM parameter grid search, cos similarity as algorithm, gauss() removed + * algorithm.rb: SVM parameter grid search, cos similarity as algorithm, gauss() removed v3.0.1 2011-10-19 * feature: model registration to ontology service * ontology lib gets endpoints from ontology service v3.0.0 2011-09-23 - * datasets stored as json (with Yajl) to improve performance
\ No newline at end of file + * datasets stored as json (with Yajl) to improve performance diff --git a/lib/compound.rb b/lib/compound.rb index a08d541..b4df335 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -18,16 +18,20 @@ module OpenTox # @return [Compound] Compound def initialize(uri=nil) @uri = uri - case @uri - when /InChI/ # shortcut for IST services - @inchi = @uri.sub(/^.*InChI/, 'InChI') + if (@uri =~ URI::regexp) || @uri.nil? + case @uri + when /InChI/ # shortcut for IST services + @inchi = @uri.sub(/^.*InChI/, 'InChI') + else + @inchi = RestClientWrapper.get(@uri, :accept => 'chemical/x-inchi').to_s.chomp if @uri + end + + if @uri and @inchi.to_s.size==0 + LOGGER.warn "REMOVE ABMIT HACK: no inchi for compound "+@uri.to_s+", load via smiles" + @inchi = Compound.smiles2inchi(Compound.smiles(@uri)) + end else - @inchi = RestClientWrapper.get(@uri, :accept => 'chemical/x-inchi').to_s.chomp if @uri - end - - if @uri and @inchi.to_s.size==0 - LOGGER.warn "REMOVE ABMIT HACK: no inchi for compound "+@uri.to_s+", load via smiles" - @inchi = Compound.smiles2inchi(Compound.smiles(@uri)) + raise "Not able to create compound with uri: #{@uri}" end end |