From 9f2468afe7b45cd20472fb41b18ebeff3e4e908d Mon Sep 17 00:00:00 2001 From: gebele Date: Fri, 4 Aug 2017 14:02:40 +0000 Subject: script to convert mol to mmol -log10 in training dataset --- scripts/mol2mmol-log10.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 scripts/mol2mmol-log10.rb (limited to 'scripts') diff --git a/scripts/mol2mmol-log10.rb b/scripts/mol2mmol-log10.rb new file mode 100755 index 0000000..04f64ad --- /dev/null +++ b/scripts/mol2mmol-log10.rb @@ -0,0 +1,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 -- cgit v1.2.3