summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavor <vorgrimmlerdavid@gmx.de>2012-05-15 11:37:47 +0200
committerdavor <vorgrimmlerdavid@gmx.de>2012-05-15 11:37:47 +0200
commit9cc85cd21d4c400b2a5c20068efaac5cde56a476 (patch)
treec22161ec975a6ef71377676a72735b3784c065c4
parent1747f27dc73bf39c900e07d43efbf7a1f7267e0c (diff)
parent6e016d24bf6d0272d235c466e0dab3f196f0c0d4 (diff)
Merge branch 'master' into development
Conflicts: ChangeLog
-rw-r--r--ChangeLog4
-rw-r--r--lib/compound.rb22
2 files changed, 15 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ed5b85..b45a9d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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