summaryrefslogtreecommitdiff
path: root/scripts/mmol2-log10.rb
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mmol2-log10.rb')
-rwxr-xr-xscripts/mmol2-log10.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/scripts/mmol2-log10.rb b/scripts/mmol2-log10.rb
index f28ff8f..ec0fdf5 100755
--- a/scripts/mmol2-log10.rb
+++ b/scripts/mmol2-log10.rb
@@ -3,18 +3,21 @@ require_relative '../lib/lazar'
include OpenTox
newfile = ARGV[0].sub(/.csv/,"_log10.csv")
p newfile
-i = 1
CSV.open(newfile, "wb") do |csv|
+ i = 1
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]
+ if i == 1
+ csv << [smi, "-log10(#{mmol})"]
else
- #csv << [smi, "-log10(#{mmol})"]
- p "Line #{i}: '#{mmol}' is not a numeric value."
- csv << [smi, ""]
+ if mmol.numeric?
+ c = Compound.from_smiles smi
+ mmol = -Math.log10(mmol.to_f)
+ csv << [smi, mmol]
+ else
+ p "Line #{i}: '#{mmol}' is not a numeric value."
+ #csv << [smi, ""]
+ end
end
i += 1
end