Class: RejectedReport
- Inherits:
-
Object
- Object
- RejectedReport
- Defined in:
- lib/seqtrimnext_report/classes/rejected_report.rb
Instance Method Summary collapse
-
#initialize(stats, plugin_fix_hash, output_files, output_latex) ⇒ RejectedReport
constructor
A new instance of RejectedReport.
- #load_plugins_info(stats, rejected_hash, input_seqs, plugin_fix_hash) ⇒ Object
- #write_plugin_json ⇒ Object
Constructor Details
#initialize(stats, plugin_fix_hash, output_files, output_latex) ⇒ RejectedReport
Returns a new instance of RejectedReport.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/seqtrimnext_report/classes/rejected_report.rb', line 3 def initialize(stats,plugin_fix_hash,output_files, output_latex) # write_plugin_json output3=File.open(File.join(output_latex,'rejected.tex'), 'w') output3.puts "%!TEX root = FinalReport.tex\n\n" input_seqs = stats['sequences']['count']['input_count'].to_i rejected_seqs = stats['sequences']['count']['rejected'].to_i output_seqs = stats['sequences']['count']['output_seqs'].to_i output_seqs_paired = 0 total_output_seqs = 0 if (!stats['sequences']['count']['output_seqs_paired'].nil?) output_seqs_paired = stats['sequences']['count']['output_seqs_paired'].to_i # solo cuando hay pareadas total_output_seqs = output_seqs_paired+output_seqs end low_complex = 0 if (!stats['sequences']['count']['output_seqs_low_complexity'].nil?) low_complex = stats['sequences']['count']['output_seqs_low_complexity'].to_i # no hay cuando es genomico end rejected_hash = {} data_hash = {} data_hash['value'] = rejected_seqs data_hash['warning'] = 'OK' data_hash['warning_msg'] = '' data_hash['percent'] = sprintf("%0.3f", (rejected_seqs.to_f*100/input_seqs.to_f)) rejected_hash['rejected']=data_hash if (!stats['sequences']['rejected'].nil?) rejected_hash2 = load_plugins_info(stats, rejected_hash, input_seqs, plugin_fix_hash) #-------------------------------------------------- build table output3.puts '\begin{table}[H]' output3.puts '\begin{center}' output3.puts '\begin{tabular}{r r}' output3.puts "Input sequences & #{input_seqs}\\\\" output3.puts "Output sequences & #{output_seqs}\\\\" output3.puts "Rejected sequences & #{rejected_seqs}\\\\" if (output_seqs_paired != 0) output3.puts "Output paired sequences & #{output_seqs_paired} \\\\" output3.puts "Total output sequences & #{total_output_seqs} \\\\" end if (low_complex != 0) output3.puts "Low complexity sequences & #{low_complex} \\\\" end output3.puts '\end{tabular}' output3.puts '\label{table:input_seqs}' output3.puts '\end{center}' output3.puts '\end{table}'+"\n\n" #-------------------------------------------------- end table #-------------------------------------------------- build table output3.puts '\begin{table}[H]' output3.puts '\caption{Summary of reads removed in every plugin.}' output3.puts '\begin{center}' output3.puts '\begin{tabular}{l r r c}' output3.puts '\hline' output3.puts 'Case & Number of sequences & Percent & Warnings \\\\ [0.5ex]' output3.puts '\hline' #the hash of hashes is ordered by value (number of sequences rejected) rejected_ordered = rejected_hash2.sort {|a,b| b[1]['value']<=>a[1]['value']} rejected_ordered.each do |plugin| my_name = plugin[1]['name'] my_value = plugin[1]['value'] my_percent = plugin[1]['percent'] my_warning = plugin[1]['warning'] output3.puts "#{my_name}&#{my_value}&#{my_percent} \\%&#{my_warning}\\\\" end output3.puts '\hline' output3.puts "Total rejected&#{rejected_hash['rejected']['value']}&#{rejected_hash['rejected']['percent']} \\%&#{rejected_hash['rejected']['warning']}\\\\ [1ex]" output3.puts '\hline' output3.puts '\end{tabular}' output3.puts '\end{center}' output3.puts '\label{table:reads_removed}' output3.puts '\end{table}'+"\n\n" #-------------------------------------------------- end table rejected_ordered.each do |plugin| if (plugin[1]['warning'] != 'OK') if (!rejected_hash2[plugin[0]].nil?) plugin[1]['warning_msg'].gsub!('my_percent',"#{rejected_hash2["#{plugin[0]}"]['percent']}") output3.puts '\noindent\fcolorbox{black}{yellow}{'+"\n"+'\begin{minipage}{\linewidth}{'+"\n"+'\textbf{'+"#{plugin[1]['warning']} #{plugin[1]['warning_msg']}"+'}'+"\n"+'}'+"\n"+'\end{minipage}'+"\n"+'}\\\\\\\\' end end end else output3.puts 'There are not rejected sequences\\\\' end output3.close puts "Information about rejected sequences was added to the report" end |
Instance Method Details
#load_plugins_info(stats, rejected_hash, input_seqs, plugin_fix_hash) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/seqtrimnext_report/classes/rejected_report.rb', line 106 def load_plugins_info(stats, rejected_hash, input_seqs, plugin_fix_hash) data_hash = {} stats['sequences']['rejected'].each do |rejected| data_hash = {} if plugin_fix_hash[rejected[0]] data_hash['name'] = plugin_fix_hash[rejected[0]]['name'] data_hash['value'] = rejected[1] data_hash['warning'] = 'OK' data_hash['warning_msg'] = '' data_hash['percent'] = sprintf("%0.3f", (rejected[1].to_f*100/input_seqs.to_f)) rejected_hash[rejected[0]]=data_hash end end rejected_hash.each_key do |key| if (rejected_hash[key]['percent'].to_f >= plugin_fix_hash[key]['threshold'] ) rejected_hash[key]['warning'] = plugin_fix_hash[key]['warning'] rejected_hash[key]['warning_msg'] = plugin_fix_hash[key]['msg'] end end return rejected_hash end |
#write_plugin_json ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/seqtrimnext_report/classes/rejected_report.rb', line 130 def write_plugin_json plugin_fix_hash = {} msgs_hash = {} msgs_hash['msg'] = "Warning!, there are a my_percent \\% of repeated sequences" msgs_hash['threshold'] = 9 msgs_hash['warning'] = 'W1' plugin_fix_hash['repeated'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are too short" msgs_hash['threshold'] = 10 msgs_hash['warning'] = 'W2' plugin_fix_hash['short insert'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are empty (without an insert)" msgs_hash['warning'] = 'W3' msgs_hash['threshold'] = 1 plugin_fix_hash['empty insert'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are from a contaminant organism or from organelles" msgs_hash['warning'] = 'W4' msgs_hash['threshold'] = 1 plugin_fix_hash['contaminated'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are no valid sequences" msgs_hash['threshold'] = 0.1 msgs_hash['warning'] = 'W5' plugin_fix_hash['No valid inserts found'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are low complexity sequences" msgs_hash['warning'] = 'W6' msgs_hash['threshold'] = 1 plugin_fix_hash['low complexity by polyt'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences contain a vector in an unexpected position" msgs_hash['warning'] = 'W7' msgs_hash['threshold'] = 1 plugin_fix_hash['unexpected vector'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences contain too much indeterminations" msgs_hash['threshold'] = 0.1 msgs_hash['warning'] = 'W8' plugin_fix_hash['Indeterminations in middle of sequence'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "Warning!, a my_percent \\% of your sequences are too big or too small" msgs_hash['threshold'] = 1 msgs_hash['warning'] = 'W9' plugin_fix_hash['size out of limits'] = msgs_hash msgs_hash = {} msgs_hash['msg'] = "WT Warning!, a my_percent \\% of your sequences were rejected!" msgs_hash['threshold'] = 25 msgs_hash['warning'] = 'WT' plugin_fix_hash['rejected'] = msgs_hash msgs_hash = {} puts JSON.pretty_generate(plugin_fix_hash) end |