From 0ddd04c32280e6fd166a52fa6da653df24aabf99 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 23 Nov 2016 15:10:58 +0000 Subject: added delog10;generalized mmol2-log10 --- scripts/mmol2-log10.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'scripts/mmol2-log10.rb') diff --git a/scripts/mmol2-log10.rb b/scripts/mmol2-log10.rb index ec0fdf5..188d8cb 100755 --- a/scripts/mmol2-log10.rb +++ b/scripts/mmol2-log10.rb @@ -1,22 +1,29 @@ #!/usr/bin/env ruby require_relative '../lib/lazar' include OpenTox -newfile = ARGV[0].sub(/.csv/,"_log10.csv") + +newfile = ARGV[0].sub(/.csv/,"_log10.csv") p newfile CSV.open(newfile, "wb") do |csv| i = 1 CSV.read(ARGV[0]).each do |line| - smi,mmol = line + type,mmol = line if i == 1 - csv << [smi, "-log10(#{mmol})"] + csv << [type, "-log10(#{mmol})"] + @type = type else if mmol.numeric? - c = Compound.from_smiles smi + if @type =~ /smiles/i + c = Compound.from_smiles type + elsif @type =~ /inchi/i + c = Compound.from_inchi type + else + p "Unknown type '#{@type}' at line #{i}." + end mmol = -Math.log10(mmol.to_f) - csv << [smi, mmol] + csv << [type, mmol] else p "Line #{i}: '#{mmol}' is not a numeric value." - #csv << [smi, ""] end end i += 1 -- cgit v1.2.3