summaryrefslogtreecommitdiff
path: root/batch.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-04-23 10:58:39 +0000
committergebele <gebele@in-silico.ch>2018-04-23 10:58:39 +0000
commitde849d5b6cc553cc6969dd6b9b486b808ac89f3d (patch)
tree85010b2683179df101cd643318978924fb41a937 /batch.rb
parent19eb655f4af1a4631692989a30a59b7b78e6669b (diff)
batch download with extra duplicate on ID message column
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