summaryrefslogtreecommitdiff
path: root/scripts/efsa2csv.rb
blob: 247faaca694ca94bf508b3a40bc07ccd19cbb86c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env ruby
require 'csv'
require_relative '../../lazar/lib/lazar.rb'

i = 0
db = {}
CSV.foreach(ARGV[0], :encoding => 'ISO-8859-1', :col_sep => "\t") do |row|
  begin
    if i > 0 and row[11]
      c = OpenTox::Compound.from_smiles(row[11]).smiles
      #c = row[11]
      if row[24].match(/Salmonella/i)
        if row[25].match("TA 98") or row[25].match("TA 100")
          if row[33].match(/Positiv/i)
            db[c] = 1 # at least one positive result in TA 98 or TA 100
          elsif row[33].match(/Negativ/i)
            db[c] ||= 0
          end
        end
      end
    end
  rescue
  end
  i += 1
end

db.each do |s,v|
  puts [s,v].join ","
end