summaryrefslogtreecommitdiff
path: root/batch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'batch.rb')
-rw-r--r--batch.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/batch.rb b/batch.rb
index 2dd9359..0002279 100644
--- a/batch.rb
+++ b/batch.rb
@@ -65,12 +65,22 @@ module OpenTox
compound = nil
end
if compound.nil? # compound parsers may return nil
- #warn "Cannot parse #{compound_format} compound '#{identifier}' at line #{i+2} of #{source}, all entries are ignored."
- batch.compounds << "Cannot parse #{compound_format} compound '#{identifier}' at line #{i+2} of #{source}."
+ batch.warnings << "Cannot parse #{compound_format} compound '#{identifier}' at line #{i+2} of #{source}."
next
end
batch.compounds << compound.id
end
+ batch.compounds.duplicates.each do |duplicate|
+ dup = Compound.find duplicate
+ positions = []
+ batch.compounds.each_with_index do |co,i|
+ c = Compound.find co
+ if !c.blank? and c.inchi and c.inchi == dup.inchi
+ positions << i+1
+ end
+ end
+ batch.warnings << "Duplicate compound at ID #{positions.join(' and ')}."
+ end
batch.save
end
batch