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
|
#!/usr/bin/env ruby
predictions = {}
lines = File.readlines(ARGV[0])
lines.shift
lines.each do |line|
smi,prob = line.chomp.split(",")
prob.to_f < 0.5 ? predictions[smi] = 0 : predictions[smi] = 1
end
lines = File.readlines(File.join("mutagenicity","mutagenicity.csv"))
lines.shift
lines.each do |line|
smi,exp = line.chomp.split(",")
if predictions[smi] == 1 and exp == "1"
puts [smi,"TP"].join(",")
elsif predictions[smi] == 0 and exp == "0"
puts [smi,"TN"].join(",")
elsif predictions[smi] == 1 and exp == "0"
puts [smi,"FP"].join(",")
elsif predictions[smi] == 0 and exp == "1"
puts [smi,"FN"].join(",")
else
puts [smi,"NA"].join(",")
end
end
|