summaryrefslogtreecommitdiff
path: root/scripts/noael_loael2mmol.rb
blob: 3d79aae5c1cfd3a43ed2f0a78696cd1788ca0bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ruby
require_relative '../../lazar/lib/lazar'
include OpenTox
csv_in =  CSV.read(ARGV[0], :encoding => 'windows-1251:utf-8')
head = csv_in.shift
data = []
csv_in.each do |line|
  smi = line[11]
  mg = line[19]
  unless mg.to_f == 0.0
    c = Compound.from_smiles smi
    # round to 5 significant digits in order to detect duplicates 
    mmol = c.mg_to_mmol(mg.to_f).signif(5)
    data << [c.smiles, mmol,"swiss"]
  end
end
data.sort!{|a,b| a[1] <=> b[1]}
puts ["SMILES","LOAEL","Dataset"].join ","
puts data.collect{|row| row.join ","}.join "\n"