diff options
Diffstat (limited to 'scripts/noael_loael2mmol.rb')
-rwxr-xr-x | scripts/noael_loael2mmol.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/noael_loael2mmol.rb b/scripts/noael_loael2mmol.rb new file mode 100755 index 0000000..3d79aae --- /dev/null +++ b/scripts/noael_loael2mmol.rb @@ -0,0 +1,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" |