summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2013-07-04 19:30:09 +0200
committergebele <gebele@in-silico.ch>2013-07-04 19:30:09 +0200
commit08058d3c08d2afba0068e88727901ca639454568 (patch)
tree89f9683c90795900eebd20c8bc8a30dce7b19ff7
parenta3b4eb8ac2e606304e1d5632ae867f0728f78b8b (diff)
added check for compounds
-rw-r--r--helper.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/helper.rb b/helper.rb
index aac7af0..5ac00f1 100644
--- a/helper.rb
+++ b/helper.rb
@@ -109,9 +109,19 @@ module OpenTox
when /URI|URL/i
compound_uri = compound
when /SMILES/i
- compound_uri = OpenTox::Compound.from_smiles(compound).uri
+ c = OpenTox::Compound.from_smiles(compound)
+ if c.inchi.empty?
+ @warnings << "Cannot parse compound '#{compound}' at position #{j+2}, all entries are ignored."
+ else
+ compound_uri = c.uri
+ end
when /InChI/i
- compound_uri = OpenTox::Compound.from_inchi(compound).uri
+ compound = OpenTox::Compound.from_inchi(compound)
+ if c.inchi.empty?
+ @warnings << "Cannot parse compound '#{compound}' at position #{j+2}, all entries are ignored."
+ else
+ compound_uri = c.uri
+ end
when ""
@warnings << "Cannot parse compound '#{compound}' at position #{j+2}, all entries are ignored." # be careful with double quotes in literals! \C in smiles is an illegal Turtle string
next
@@ -142,7 +152,6 @@ module OpenTox
ntriples << "#{value_node} <#{RDF::OT.value}> \"#{v}\" ."
end
-
end
compound_uris.duplicates.each do |uri|
positions = []