summaryrefslogtreecommitdiff
path: root/scripts/lazar-cv-predictions.rb
blob: 9236becc0d54d5130596fffaff3aba18c6a37e07 (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

predictions = {}
minsim = ARGV[1].to_f
minsim ||= 0
Dir[File.join(ARGV[0],"crossvalidation","*","test","predictions")].each do |pred|
  File.readlines(pred).each_with_index do |l,i|
    smi,m,pred,pa,pi,maxsim,n = l.split(",")
    predictions[smi] = [pred,maxsim.to_f]
  end
end
lines = File.readlines(File.join("mutagenicity","mutagenicity.csv"))
lines.shift
lines.each do |line|
  smi,exp = line.chomp.split(",")
  if predictions[smi]
    if predictions[smi].first == "1" and exp == "1" and predictions[smi].last >= minsim
      puts [smi,"TP"].join(",")
    elsif predictions[smi].first == "0" and exp == "0" and predictions[smi].last >= minsim
      puts [smi,"TN"].join(",")
    elsif predictions[smi].first == "1" and exp == "0" and predictions[smi].last >= minsim
      puts [smi,"FP"].join(",")
    elsif predictions[smi].first == "0" and exp == "1" and predictions[smi].last >= minsim
      puts [smi,"FN"].join(",")
    else
      puts [smi,"NA"].join(",")
    end
  else
    puts [smi,"NA"].join(",")
  end
end