summaryrefslogtreecommitdiff
path: root/scripts/mmol2-log10.rb
blob: f28ff8f097bd064803085c90d260ba5cb2ea4827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby
require_relative '../lib/lazar'
include OpenTox
newfile = ARGV[0].sub(/.csv/,"_log10.csv") 
p newfile
i = 1
CSV.open(newfile, "wb") do |csv|
  CSV.read(ARGV[0]).each do |line|
    smi,mmol = line
    if mmol.numeric?
      c = Compound.from_smiles smi
      mmol = -Math.log10(mmol.to_f)
      csv << [smi, mmol]
    else
      #csv << [smi, "-log10(#{mmol})"]
      p "Line #{i}: '#{mmol}' is not a numeric value."
      csv << [smi, ""]
    end
    i += 1
  end
end