summaryrefslogtreecommitdiff
path: root/scripts/mg2mmol.rb
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mg2mmol.rb')
-rwxr-xr-xscripts/mg2mmol.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/mg2mmol.rb b/scripts/mg2mmol.rb
new file mode 100755
index 0000000..dc6b953
--- /dev/null
+++ b/scripts/mg2mmol.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require_relative '../lazar/lib/lazar'
+include OpenTox
+newfile = ARGV[0].sub(/.csv/,"_mmol.csv")
+p newfile
+CSV.open(newfile, "wb") do |csv|
+ CSV.read(ARGV[0]).each do |line|
+ smi,mg = line
+ if mg.numeric?
+ c = Compound.from_smiles smi
+ mmol = c.mg_to_mmol mg.to_f
+ csv << [smi, mmol]
+ else
+ csv << [smi, mg.gsub(/mg/,'mmol')]
+ end
+ end
+end