summaryrefslogtreecommitdiff
path: root/scripts/mol2mmol-log10.rb
blob: 04f64adf9377f1dfbc3ff50539f68d51e0b7682d (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 '../lib/lazar.rb'
include OpenTox
newfile = ARGV[0].sub(/.csv/,"_mmol_log10.csv") 
p newfile
CSV.open(newfile, "wb") do |csv|
  CSV.read(ARGV[0]).each do |line|
    smi,mol = line
    if mol.numeric?
      c = Compound.from_smiles smi
      #delog = 10**(-1*mol.to_f) #if values already -log10 but mol
      mmol = mol.to_f*1000
      log = -Math.log10(mmol)
      csv << [smi, log]
    else
      csv << [smi, mol.gsub(/mol/,'mmol')]
    end
  end
end