blob: 188d8cb7da320daa5f3cbc0c7994e371230b6b11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/env ruby
require_relative '../lib/lazar'
include OpenTox
newfile = ARGV[0].sub(/.csv/,"_log10.csv")
p newfile
CSV.open(newfile, "wb") do |csv|
i = 1
CSV.read(ARGV[0]).each do |line|
type,mmol = line
if i == 1
csv << [type, "-log10(#{mmol})"]
@type = type
else
if mmol.numeric?
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 << [type, mmol]
else
p "Line #{i}: '#{mmol}' is not a numeric value."
end
end
i += 1
end
end
|