From de849d5b6cc553cc6969dd6b9b486b808ac89f3d Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 23 Apr 2018 10:58:39 +0000 Subject: batch download with extra duplicate on ID message column --- batch.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'batch.rb') 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 -- cgit v1.2.3