summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/overwrite.rb5
-rwxr-xr-xscripts/mmol2-log10.rb19
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/overwrite.rb b/lib/overwrite.rb
index d0422ee..31d30c9 100644
--- a/lib/overwrite.rb
+++ b/lib/overwrite.rb
@@ -28,6 +28,11 @@ class Float
def signif(n)
Float("%.#{n}g" % self)
end
+
+ # converts -10 logarithmized values back
+ def delog10
+ 10**(-1*self)
+ end
end
module Enumerable
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