10
10
require 'rubyXL/convenience_methods/workbook'
11
11
require 'rubyXL/convenience_methods/worksheet'
12
12
13
-
14
13
### Define modules and classes here
15
14
16
15
def parse_json ( filename )
@@ -24,6 +23,7 @@ def parse_json(filename)
24
23
opts = OptionParser . new ( )
25
24
opts . banner = "Reads reports and makes a table"
26
25
opts . separator ""
26
+ opts . on ( "-o" , "--outfile" , "=OUTFILE" , "Output file" ) { |argument | options . outfile = argument }
27
27
opts . on ( "-h" , "--help" , "Display the usage information" ) {
28
28
puts opts
29
29
exit
@@ -67,15 +67,53 @@ def parse_json(filename)
67
67
68
68
end
69
69
70
+ workbook = RubyXL ::Workbook . new
71
+ page = 0
72
+
70
73
bucket . each do |rule , reports |
71
74
75
+ sheet = workbook . worksheets [ page ]
76
+ sheet . sheet_name = rule
77
+
78
+ row = 0
79
+ col = 0
80
+
81
+ sheet . add_cell ( row , col , "Probe" )
82
+ col += 1
83
+ sheet . add_cell ( row , col , "Vsearch/Blast" )
84
+ col += 1
85
+ sheet . add_cell ( row , col , "Bwa2/Freebayes" )
86
+
87
+
72
88
reports . group_by { |r | r [ "Sample" ] } . sort . each do |sample , data |
73
89
74
- puts sample
90
+ row += 1
91
+ col = 0
92
+
93
+ sheet . add_cell ( row , col , sample )
94
+ col += 1
95
+
96
+ blast = data . find { |d | d [ "Befund" ] . include? ( "Amplicon" ) }
97
+ freebayes = data . find { |d | d [ "Befund" ] . include? ( "Varianten" ) }
98
+
99
+ blast ? b = blast [ "Anteil Variante %" ] : b = "Kein Nachweis"
100
+ # Here we remove noisy results below 1%
101
+ if !b . to_s . include? ( "Nachweis" )
102
+ b = "Kein Nachweis" if b . to_f < 1.0
103
+ end
104
+ freebayes ? f = freebayes [ "Anteil Variante %" ] : f = "Kein Nachweis"
105
+
106
+ sheet . add_cell ( row , col , b )
107
+ col += 1
108
+
109
+ sheet . add_cell ( row , col , f )
75
110
76
111
end
77
- end
78
112
113
+ page += 1
114
+
115
+ end
79
116
117
+ workbook . write ( options . outfile )
80
118
81
119
0 commit comments