summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2016-11-23 15:10:58 +0000
committergebele <gebele@in-silico.ch>2016-11-23 15:10:58 +0000
commit0ddd04c32280e6fd166a52fa6da653df24aabf99 (patch)
treedc5086489af72038b9eb2c364a0a7e7ec181f632 /scripts
parent347ef2891876af871e101f9a9efc643e5f28da4c (diff)
added delog10;generalized mmol2-log10eNM
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mmol2-log10.rb19
1 files changed, 13 insertions, 6 deletions
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