10
|
1 #!/usr/bin/perl
|
|
2 #V1.0.0
|
|
3 use strict;
|
|
4 use warnings;
|
|
5 use Getopt::Long;
|
|
6
|
|
7
|
|
8 my $input_log_files;
|
|
9 GetOptions (
|
|
10 "input_log_files=s" => \$input_log_files
|
|
11 ) or die("Error in command line arguments\n");
|
|
12
|
|
13 my @files = split(/,/,$input_log_files);
|
13
|
14
|
|
15
|
|
16
|
|
17 my $FastqPrep_detected=0;
|
|
18 my $FastqPrep_type="NA";
|
|
19 my $FastqPrep_before_read1_nbreads=0;
|
|
20 my $FastqPrep_before_read1_nbbases=0;
|
|
21 my $FastqPrep_before_read2_nbreads=0;
|
|
22 my $FastqPrep_before_read2_nbbases=0;
|
|
23 my $FastqPrep_after_read1_nbreads=0;
|
|
24 my $FastqPrep_after_read1_nbbases=0;
|
|
25 my $FastqPrep_after_read2_nbreads=0;
|
|
26 my $FastqPrep_after_read2_nbbases=0;
|
|
27
|
|
28 my $Samfilter_detected = 0;
|
|
29 my %Samfilter_before_hash;
|
|
30 my %Samfilter_after_hash;
|
|
31 my $Samfilter_before_nbreads=0;
|
|
32 my $Samfilter_after_nbreads=0;
|
|
33
|
|
34 my $Pileupvariant_detected = 0;
|
|
35 my $Pileupvariant="";
|
|
36
|
|
37 my $Listfiltering_detected = 0;
|
|
38 my $Listfiltering="";
|
|
39
|
|
40 my $Pileupfiltering_detected = 0;
|
|
41 my $Pileupfiltering="";
|
|
42
|
|
43 my $Blastfiltering_detected = 0;
|
|
44 my $Blastfiltering_checked = 0;
|
|
45 my $Blastfiltering_selected = 0;
|
|
46
|
|
47
|
|
48
|
|
49 for (my $f=0;$f<=$#files;$f++){
|
|
50 my $current_file = $files[$f];
|
|
51 open(IN, $current_file) or die ("Can't open $current_file\n");
|
|
52 if ( -z IN){
|
|
53 next;
|
|
54 }
|
|
55
|
|
56 while (my $line =<IN>){
|
|
57 if ($line =~ /Fastq preparation/){
|
|
58 $FastqPrep_detected=1;
|
|
59 my $line1 = <IN>;
|
|
60 my $line2 = <IN>;
|
|
61 my $line3 = <IN>;
|
|
62 my $line4 = <IN>;
|
|
63 my $line5 = <IN>;
|
|
64 my $line6 = <IN>;
|
|
65 my $line7 = <IN>;
|
|
66 if ($line1=~/Fastq format \:\s*(\w+)\s*/){
|
|
67 $FastqPrep_type=$1;
|
|
68 }
|
|
69 if ($line3=~/.*?\:\s*(\d+).*?\:\s*(\d+)/){
|
|
70 $FastqPrep_before_read1_nbreads += $1;
|
|
71 $FastqPrep_before_read1_nbbases += $2;
|
|
72 }
|
|
73 if ($line4=~/.*?\:\s*(\d+).*?\:\s*(\d+)/){
|
|
74 $FastqPrep_before_read2_nbreads += $1;
|
|
75 $FastqPrep_before_read2_nbbases += $2;
|
|
76 }
|
|
77 if ($line6=~/.*?\:\s*(\d+).*?\:\s*(\d+)/){
|
|
78 $FastqPrep_after_read1_nbreads += $1;
|
|
79 $FastqPrep_after_read1_nbbases += $2;
|
|
80 }
|
|
81 if ($line7=~/.*?\:\s*(\d+).*?\:\s*(\d+)/){
|
|
82 $FastqPrep_after_read2_nbreads += $1;
|
|
83 $FastqPrep_after_read2_nbbases += $2;
|
|
84 }
|
|
85
|
|
86 }
|
|
87 elsif ($line =~ /Blast filtering/){
|
|
88 $Blastfiltering_detected=1;
|
|
89 my $line1 = <IN>;
|
|
90 my $line2 = <IN>;
|
|
91 my $current_checked = 0;
|
|
92 my $current_selected = 0;
|
|
93 if ($line1=~/(\d+)/){
|
|
94 $current_checked = $1;
|
|
95 $Blastfiltering_checked += $current_checked;
|
|
96 }
|
|
97 if ($line2=~/(\d+)/){
|
|
98 $current_selected = $1;
|
|
99 $Blastfiltering_selected += $current_selected;
|
|
100 }
|
|
101
|
|
102 }
|
|
103 elsif ($line=~/Sam filtering/){
|
|
104 $Samfilter_detected=1;
|
|
105 my $line1 = <IN>;
|
|
106 my $line2 = <IN>;
|
|
107 my $line3 = <IN>;
|
|
108 my $line4 = <IN>;
|
|
109 my $line5 = <IN>;
|
|
110 my $line6 = <IN>;
|
|
111 my @tbl_score_before = split(/[\*\:]/,$line2);
|
|
112 my @tbl_number_before = split(/[\*\:]/,$line3);
|
|
113
|
|
114 my @tbl_score_after = split(/[\*\:]/,$line5);
|
|
115 my @tbl_number_after = split(/[\*\:]/,$line6);
|
|
116
|
|
117 if ($#tbl_score_before != $#tbl_number_before){
|
|
118 print STDERR "Error Formating in Sam Filtering\n";
|
|
119 exit(0);
|
|
120 }
|
|
121 else {
|
|
122 for (my $i=0;$i<=$#tbl_score_before;$i++){
|
|
123 if ($tbl_score_before[$i] =~ /(\d+)/){
|
|
124 my $current_score_before = $1;
|
|
125 if ($tbl_number_before[$i] =~ /(\d+)/){
|
|
126 my $current_number_before = $1;
|
|
127 $Samfilter_before_nbreads += $current_number_before;
|
|
128 if ($Samfilter_before_hash{$current_score_before}){
|
|
129 $Samfilter_before_hash{$current_score_before} += $current_number_before;
|
|
130 }
|
|
131 else {
|
|
132 $Samfilter_before_hash{$current_score_before} = $current_number_before;
|
|
133 }
|
|
134 }
|
|
135 else {
|
|
136 print STDERR "Error Formating in Sam Filtering\n";
|
|
137 exit(0);
|
|
138 }
|
|
139 }
|
|
140 else {
|
|
141 next;
|
|
142 }
|
|
143 }
|
|
144 }
|
|
145
|
|
146 if ($#tbl_score_after != $#tbl_number_after){
|
|
147 print STDERR "Error Formating in Sam Filtering\n";
|
|
148 exit(0);
|
|
149 }
|
|
150 else {
|
|
151 for (my $i=0;$i<=$#tbl_score_after;$i++){
|
|
152 if ($tbl_score_after[$i] =~ /(\d+)/){
|
|
153 my $current_score_after = $1;
|
|
154 if ($tbl_number_after[$i] =~ /(\d+)/){
|
|
155 my $current_number_after = $1;
|
|
156 $Samfilter_after_nbreads += $current_number_after;
|
|
157 if ($Samfilter_after_hash{$current_score_after}){
|
|
158 $Samfilter_after_hash{$current_score_after} += $current_number_after;
|
|
159 }
|
|
160 else {
|
|
161 $Samfilter_after_hash{$current_score_after} = $current_number_after;
|
|
162 }
|
|
163 }
|
|
164 else {
|
|
165 print STDERR "Error Formating in Sam Filtering\n";
|
|
166 exit(0);
|
|
167 }
|
|
168 }
|
|
169 else {
|
|
170 next;
|
|
171 }
|
|
172 }
|
|
173 }
|
|
174 }
|
|
175 elsif ($line=~/Variant extraction/){
|
|
176 $Pileupvariant_detected=1;
|
|
177 $Pileupvariant .= $line;
|
|
178 while ($line = <IN>){
|
|
179 $Pileupvariant .= $line;
|
|
180 if ($line=~/^\s*$/){
|
|
181 last;
|
|
182 }
|
|
183 }
|
|
184 }
|
|
185 elsif ($line=~/List Filtering/){
|
|
186 $Listfiltering_detected =1;
|
|
187 $Listfiltering .= $line;
|
|
188 while ($line = <IN>){
|
|
189 $Listfiltering .= $line;
|
|
190 if ($line=~/^\s*$/){
|
|
191 last;
|
|
192 }
|
|
193 }
|
|
194 }
|
|
195 elsif ($line=~/MPileup filtering/){
|
|
196 $Pileupfiltering_detected =1;
|
|
197 $Pileupfiltering.= $line;
|
|
198 while ($line = <IN>){
|
|
199 $Pileupfiltering .= $line;
|
|
200 if ($line=~/^\s*$/){
|
|
201 last;
|
|
202 }
|
|
203 }
|
|
204 }
|
|
205
|
|
206 }
|
|
207 close (IN);
|
|
208 }
|
|
209
|
|
210 if ($FastqPrep_detected == 1){
|
|
211 print "####\tFastq preparation\n";
|
|
212 print "Fastq format : ",$FastqPrep_type,"\n";
|
|
213 print "## Before preparation\n";
|
|
214 print "#Read1 : ",$FastqPrep_before_read1_nbreads,"\t#Base : ",$FastqPrep_before_read1_nbbases,"\n";
|
|
215 print "#Read2 : ",$FastqPrep_before_read2_nbreads,"\t#Base : ",$FastqPrep_before_read2_nbbases,"\n";
|
|
216 print "## After preparation\n";
|
|
217 print "#Read1 : ",$FastqPrep_after_read1_nbreads,"\t#Base : ",$FastqPrep_after_read1_nbbases,"\n";
|
|
218 print "#Read2 : ",$FastqPrep_after_read2_nbreads,"\t#Base : ",$FastqPrep_after_read2_nbbases,"\n";
|
|
219 print "\n";
|
|
220 }
|
|
221
|
|
222
|
|
223 if ($Samfilter_detected == 1){
|
|
224 print "#### Sam filtering \n";
|
|
225 print "## Before filtering ($Samfilter_before_nbreads)\n";
|
|
226 print "bitscore :";
|
|
227 foreach my $key (sort{$Samfilter_before_hash{$b}<=>$Samfilter_before_hash{$a}} keys %Samfilter_before_hash){
|
|
228 print "\t$key\t*";
|
|
229 }
|
|
230 print "\n";
|
|
231 print " number :";
|
|
232 foreach my $key (sort{$Samfilter_before_hash{$b}<=>$Samfilter_before_hash{$a}} keys %Samfilter_before_hash){
|
|
233 print "\t",$Samfilter_before_hash{$key},"\t*";
|
|
234 }
|
|
235 print "\n";
|
|
236 print "## After filtering ($Samfilter_after_nbreads)\n";
|
|
237 print "bitscore :";
|
|
238 foreach my $key (sort{$Samfilter_after_hash{$b}<=>$Samfilter_after_hash{$a}} keys %Samfilter_after_hash){
|
|
239 print "\t$key\t";
|
|
240 }
|
|
241 print "\n";
|
|
242 print " number :";
|
|
243 foreach my $key (sort{$Samfilter_after_hash{$b}<=>$Samfilter_after_hash{$a}} keys %Samfilter_after_hash){
|
|
244 print "\t",$Samfilter_after_hash{$key},"\t*";
|
|
245 }
|
|
246 print "\n";
|
|
247 print "\n";
|
|
248 }
|
|
249
|
|
250 if ($Pileupvariant_detected == 1){
|
|
251 print $Pileupvariant,"\n";
|
|
252 }
|
|
253
|
|
254 if ($Listfiltering_detected == 1){
|
|
255 print $Listfiltering,"\n";
|
|
256 }
|
|
257
|
|
258 if ($Blastfiltering_detected == 1){
|
|
259 print "#### Blast filtering\n";
|
|
260 print "Variant checked :\t$Blastfiltering_checked\n";
|
|
261 print "Variant selected :\t$Blastfiltering_selected\n";
|
|
262 print "\n";
|
|
263 }
|
|
264
|
|
265 if ($Pileupfiltering_detected == 1){
|
|
266 print $Pileupfiltering,"\n";
|
10
|
267 } |