diff options
Diffstat (limited to 'scripts/pa-table.rb')
-rwxr-xr-x | scripts/pa-table.rb | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/scripts/pa-table.rb b/scripts/pa-table.rb new file mode 100755 index 0000000..559f99f --- /dev/null +++ b/scripts/pa-table.rb @@ -0,0 +1,92 @@ +#!/usr/bin/env ruby + +puts ' +%\documentclass{article} +%\usepackage{color, colortbl, a4wide} +%\usepackage{longtable} +%\begin{document} +\pagestyle{empty} +\definecolor{red}{rgb}{1,0,0} +\definecolor{lightred}{rgb}{0.5,0,0} +\definecolor{green}{rgb}{0,1,0} +\definecolor{lightgreen}{rgb}{0,0.5,0} +\definecolor{grey}{rgb}{0.5,0.5,0.5} +\tiny +\begin{longtable}{rcccccc} +%\begin{tabular}{cccccc} + & & \multicolumn{2}{c}{lazar} & \multicolumn{3}{c}{R} \\\\ +' +#header = ["ID","measured","lazar"] +header = ["ID","Measured","MP2D","PaDEL"] +tab = [] +=begin +File.read("pyrrolizidine-alkaloids/180920_PA_complete_SMILES.csv").each_line do |l| + unless l.match("SMILES") + #tab << '\verb '+l.chomp.split(";")[2].sub('1: ','')#+'}' + tab << l.chomp.split(";")[0] + end +end +i = 0 +=end +File.read("pyrrolizidine-alkaloids/lazar/pa-mp2d-predictions.csv").each_line do |l| + unless l.match("SMILES") + id,smi,exp,mut,p0,p1,max_sim,nn = l.chomp.split(",") + row = id + if exp == "1" + row += ' & \cellcolor{red} ' + elsif exp == "0" + row += ' & \cellcolor{green} ' + else + row += ' & \cellcolor{grey} ' + end + if mut == "1" + max_sim.to_f < 0.5 ? row += '& \cellcolor{lightred} ' : row += '& \cellcolor{red} ' + elsif mut == "0" + max_sim.to_f < 0.5 ? row += '& \cellcolor{lightgreen} ' : row += '& \cellcolor{green} ' + else #if mut.nil? or mut.empty? + row += '& \cellcolor{grey} ' + end + tab << row + #i += 1 + end +end +i=0 +File.read("pyrrolizidine-alkaloids/lazar/pa-padel-predictions.csv").each_line do |l| + smi,exp,mut,p0,p1,max_sim,nn = l.chomp.split(",") + #p mut + if mut == "1" + max_sim.to_f < 0.5 ? tab[i] += '& \cellcolor{lightred} ' : tab[i] += '& \cellcolor{red} ' + elsif mut == "0" + max_sim.to_f < 0.5 ? tab[i] += '& \cellcolor{lightgreen} ' : tab[i] += '& \cellcolor{green} ' + else #if mut.nil? or mut.empty? + tab[i] += '& \cellcolor{grey} ' + end + i += 1 +end +Dir["pyrrolizidine-alkaloids/PA.*.outcome.csv"].each do |r| + header << r.sub('pyrrolizidine-alkaloids/PA.','').sub('.outcome.csv','') + i = 0 + File.read(r).each_line do |l| + if i > 0 + items = l.chomp.split(";") + items.shift + if items.uniq.include? "1" + tab[i-1] << ' & \cellcolor{red}' + elsif items.uniq.include? "0" + tab[i-1] << ' & \cellcolor{green}' + end + end + i += 1 + end +end +#tab.collect!{|t| t + '\cellcolor{grey} \\\\'} +puts header.join(" & ")+" \\\\" +puts '\hline' +puts '\renewcommand{\arraystretch}{0.075}' +tab.collect!{|t| t + ''} +puts tab.join(" \\\\ \n") +puts ' +%\end{tabular} +\end{longtable} +%\end{document} +' |