annotate rapsodyn/PrepareFastqLight.pl~ @ 7:3f7b0788a1c4 draft

Uploaded
author mcharles
date Tue, 07 Oct 2014 10:34:34 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
1 #!/usr/bin/perl
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
2 #V1.0.1 added log, option parameters
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
3 use strict;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
4 use warnings;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
5 use Getopt::Long;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
6
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
7 my $read1_file;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
8 my $read2_file;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
9 my $log_file;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
10 my $output1_file;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
11 my $output2_file;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
12
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
13 my $TYPE="sanger";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
14 my $MIN_LENGTH=30;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
15 my $MIN_QUALITY=30;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
16
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
17 my $VERBOSE = "OFF";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
18
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
19 GetOptions (
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
20 "read1_file=s" => \$read1_file,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
21 "read2_file=s" => \$read2_file,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
22 "log_file=s" => \$log_file,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
23 "output1_file=s" => \$output1_file,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
24 "output2_file=s" => \$output2_file,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
25 "type=s" => \$TYPE,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
26 "min_length=i" => \$MIN_LENGTH,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
27 "min_quality=i" => \$MIN_QUALITY,
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
28 "verbose=s" => \$VERBOSE
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
29 ) or die("Error in command line arguments\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
30
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
31
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
32 my $nb_read1=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
33 my $nb_base_read1=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
34 my $nb_read2=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
35 my $nb_base_read2=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
36
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
37 my $nb_read1_t=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
38 my $nb_base_read1_t=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
39 my $nb_read2_t=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
40 my $nb_base_read2_t=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
41
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
42 my $nb_base_current_t=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
43
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
44
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
45 open(READ1, $read1_file) or die ("Can't open $read1_file\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
46 open(READ2, $read2_file) or die ("Can't open $read2_file\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
47 open(OUT1, ">$output1_file") or die ("Can't open $output1_file\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
48 open(OUT2, ">$output2_file") or die ("Can't open $output2_file\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
49
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
50 my $error1=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
51 my $error2=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
52 my $error3=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
53 my $error4=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
54 my $error5=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
55 my $error6=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
56 my $error7=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
57 my $error8=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
58 my $error9=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
59 my $error10=0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
60
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
61 while (my $ligne1_r1 =<READ1>){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
62 my $ligne2_r1 =<READ1>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
63 my $ligne3_r1 =<READ1>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
64 my $ligne4_r1 =<READ1>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
65 my $ligne1_r2 =<READ2>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
66 my $ligne2_r2 =<READ2>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
67 my $ligne3_r2 =<READ2>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
68 my $ligne4_r2 =<READ2>;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
69
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
70 $nb_read1++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
71 $nb_read2++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
72
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
73 #@ 1 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
74 if ((!$ligne1_r1)||(!$ligne2_r1)||(!$ligne3_r1)||(!$ligne4_r1)||(!$ligne1_r2)||(!$ligne2_r2)||(!$ligne3_r2)||(!$ligne4_r2)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
75 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
76 print "Error in file format";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
77 if ($ligne1_r1){print $ligne1_r1;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
78 if ($ligne2_r1){print $ligne2_r1;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
79 if ($ligne3_r1){print $ligne3_r1;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
80 if ($ligne4_r1){print $ligne4_r1;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
81 if ($ligne1_r2){print $ligne1_r2;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
82 if ($ligne2_r2){print $ligne2_r2;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
83 if ($ligne3_r2){print $ligne3_r2;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
84 if ($ligne4_r2){print $ligne4_r2;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
85 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
86 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
87 $error1++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
88 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
89 elsif(($ligne1_r1 !~/^\@/)||($ligne1_r2 !~/^\@/)||($ligne3_r1 !~/^\+/)||($ligne3_r2 !~/^\+/)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
90 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
91 print "Error in header : format\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
92 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
93 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
94 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
95 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
96 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
97 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
98 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
99 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
100 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
101 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
102 $error2++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
103 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
104 #@ 1 - 2 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
105 else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
106
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
107 my $length_seq1 = length($ligne2_r1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
108 my $length_qual1 =length($ligne4_r1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
109 my $seq1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
110 my $qual1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
111
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
112 my $length_seq2 = length($ligne2_r2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
113 my $length_qual2 =length($ligne4_r2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
114 my $seq2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
115 my $qual2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
116 my $header1="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
117 my $header2="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
118 my $repheader1="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
119 my $repheader2="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
120
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
121
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
122 if ($ligne1_r1 =~/^\@(.*?)\#/){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
123 $header1 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
124 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
125
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
126 if ($ligne3_r1 =~/^\+(.*?)\#/){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
127 $repheader1 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
128 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
129
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
130 if ($ligne1_r2 =~/^\@(.*?)\#/){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
131 $header2 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
132 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
133
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
134 if ($ligne3_r2 =~/^\+(.*?)\#/){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
135 $repheader2 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
136 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
137 #@ 2 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
138
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
139 ### Verification de la coherence sequence /qualité @ 1 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
140 if (($TYPE eq "illumina")&&((!$header1)||(!$header2)||(!$repheader1)||(!$repheader2))){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
141 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
142 print "Error in header : empty\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
143 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
144 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
145 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
146 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
147 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
148 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
149 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
150 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
151 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
152 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
153 $error3++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
154 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
155 elsif (($TYPE eq "sanger")&&((!$header1)||(!$header2))){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
156 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
157 print "Error in header refgsd : empty\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
158 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
159 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
160 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
161 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
162 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
163 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
164 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
165 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
166 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
167 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
168 $error3++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
169 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
170 elsif (($TYPE eq "illumina")&&(($header1 ne $repheader1)||($header2 ne $repheader2)||($header1 ne $header2))){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
171 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
172 print "Error in header : different\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
173 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
174 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
175 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
176 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
177 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
178 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
179 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
180 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
181 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
182 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
183 $error4++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
184 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
185 elsif (($TYPE eq "sanger")&&($header1 ne $header2)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
186 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
187 print "Error in header : different\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
188 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
189 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
190 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
191 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
192 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
193 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
194 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
195 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
196 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
197 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
198 $error4++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
199 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
200 elsif (($length_seq1 != $length_qual1)||($length_seq2 != $length_qual2)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
201 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
202 print "Error in seq/qual length\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
203 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
204 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
205 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
206 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
207 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
208 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
209 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
210 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
211 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
212 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
213 $error5++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
214 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
215 #@ 1 - 2 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
216 else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
217 ### Parsing sequence & qualité
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
218 if ($ligne2_r1 =~ /^([ATGCNX]+)\s*$/i){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
219 $seq1 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
220 $nb_base_read1 += length($seq1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
221 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
222 if ($ligne2_r2 =~ /^([ATGCNX]+)\s*$/i){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
223 $seq2 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
224 $nb_base_read2 += length($seq2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
225 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
226 if ($ligne4_r1 =~ /^(.*)\s*$/i){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
227 $qual1 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
228 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
229 if ($ligne4_r2 =~ /^(.*)\s*$/i){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
230 $qual2 = $1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
231 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
232 #@ 2 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
233 ### Verification du parsing et de la coherence sequence /qualité (n°2)
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
234 if ((!$seq1)||(!$seq2)||(!$qual1)||(!$qual2)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
235 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
236 print "Error parsing seq / quality \n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
237 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
238 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
239 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
240 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
241 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
242 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
243 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
244 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
245 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
246 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
247 $error6++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
248 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
249 elsif ((length($seq1) != length($qual1))||(length($seq2) != length($qual2))){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
250 if ($VERBOSE eq "ON"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
251 print "Error in seq/qual length after parsing\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
252 print $ligne1_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
253 print $ligne2_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
254 print $ligne3_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
255 print $ligne4_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
256 print $ligne1_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
257 print $ligne2_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
258 print $ligne3_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
259 print $ligne4_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
260 print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
261 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
262 $error7++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
263 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
264 #@ <1 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
265 else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
266 my $fastq_lines_r1="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
267 my $fastq_lines_r2="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
268 my $nb_base_current_read1_t = 0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
269 my $nb_base_current_read2_t = 0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
270
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
271 $fastq_lines_r1 = &grooming_and_trimming($ligne1_r1,$seq1,$qual1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
272 $nb_base_current_read1_t = $nb_base_current_t;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
273 if ($fastq_lines_r1){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
274 $fastq_lines_r2 = &grooming_and_trimming($ligne1_r2,$seq2,$qual2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
275 $nb_base_current_read2_t = $nb_base_current_t;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
276 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
277 if ($fastq_lines_r2){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
278 print OUT1 $fastq_lines_r1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
279 print OUT2 $fastq_lines_r2;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
280
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
281 $nb_read1_t++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
282 $nb_read2_t++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
283 $nb_base_read1_t += $nb_base_current_read1_t;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
284 $nb_base_read2_t += $nb_base_current_read2_t;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
285
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
286
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
287 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
288 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
289 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
290
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
291
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
292 #@ 7 sec
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
293 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
294 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
295
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
296 close (READ1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
297 close (READ2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
298 close (OUT1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
299 close (OUT2);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
300
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
301 open (LF,">$log_file") or die("Can't open $log_file\n");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
302 print LF "\n####\t Fastq preparation \n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
303 print LF "## Before preparation\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
304 print LF "#Read1 :\t$nb_read1\t#Base :\t$nb_base_read1\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
305 print LF "#Read2 :\t$nb_read2\t#Base :\t$nb_base_read2\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
306 print LF "## After preparation\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
307 print LF "#Read1 :\t$nb_read1_t\t#Base :\t$nb_base_read1_t\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
308 print LF "#Read2 :\t$nb_read2_t\t#Base :\t$nb_base_read2_t\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
309 close (LF);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
310
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
311
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
312 sub grooming_and_trimming{
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
313 my $header = shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
314 my $seq = shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
315 my $quality = shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
316 my $quality_converted="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
317 my $quality_ori=$quality;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
318
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
319 my $lengthseq = length($seq);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
320 my $startTrim = 0;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
321 my $stopTrim = length($quality)-1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
322 my $startnoN = $startTrim;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
323 my $stopnoN = $stopTrim;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
324
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
325
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
326 my $chercheN = $seq;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
327 my @bad_position_N;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
328 my @bad_position_Q;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
329 my $current_index = index($chercheN,"N");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
330 my $abs_index = $current_index;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
331 while ($current_index >=0){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
332 push (@bad_position_N,$abs_index);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
333
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
334 if ($current_index<length($seq)){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
335 $chercheN = substr($chercheN,$current_index+1);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
336 $current_index = index($chercheN,"N");
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
337 $abs_index = $current_index + $bad_position_N[$#bad_position_N]+1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
338 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
339 else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
340 last;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
341 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
342 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
343
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
344 my @q = split(//,$quality);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
345 for (my $i=0;$i<=$#q;$i++){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
346 my $chr = $q[$i];
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
347 my $num = ord($q[$i]);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
348 if ($TYPE eq "illumina"){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
349 $num = $num - 31; # 31 comme la difference entre la plage sanger (33-> 93 / 0->60) et illumina (64->104 / 0->40)
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
350 $quality_converted .= chr($num);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
351 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
352
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
353 if ($num < $MIN_QUALITY + 33){ #33 comme le départ de la plage sanger
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
354 push(@bad_position_Q,$i);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
355 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
356 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
357 if ($quality_converted){$quality = $quality_converted;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
358
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
359 my @bad_position = (@bad_position_N, @bad_position_Q);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
360
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
361 if ($#bad_position>=0){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
362 @bad_position = sort {$a <=> $b} @bad_position;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
363 my %coord=%{&extract_longer_string_coordinates_from_bad_position(0,$stopTrim,\@bad_position)};
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
364 $startTrim = $coord{"start"};
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
365 $stopTrim = $coord{"stop"};
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
366 #print "$startTrim .. $stopTrim\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
367
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
368 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
369 my $lengthTrim = $stopTrim - $startTrim +1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
370
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
371 #if ($stats_length{$lengthTrim}){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
372 # $stats_length{$lengthTrim} = 1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
373 #}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
374 #else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
375 # $stats_length{$lengthTrim}++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
376 #}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
377 my $fastq_lines="";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
378
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
379 # if ($header =~ /GA8\-EAS671_0005\:3\:1\:1043\:4432/){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
380 # print "HEAD:\t$header";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
381 # print "SEQ:\n$seq\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
382 # print "$quality_ori\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
383 # print "$quality\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
384 # for (my $i=0;$i<=$#bad_position;$i++){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
385 # print $bad_position[$i]."(".$q[$bad_position[$i]]." : ".ord($q[$bad_position[$i]]).")"."\t";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
386 # }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
387 # print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
388 # print "$startTrim .. $stopTrim / $lengthTrim \n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
389 # print $fastq_lines;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
390 # print "\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
391 # }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
392
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
393 #for (my $i=$startTrim;$i<=$stopTrim;$i++){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
394 # if ($stats_quality{ord($q{$i])}){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
395 # $stats_quality{ord($q{$i])}=1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
396 # }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
397 # else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
398 # $stats_quality{ord($q{$i])}++;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
399 # }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
400 #}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
401
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
402 if ($lengthTrim >= $MIN_LENGTH){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
403 $fastq_lines .= $header;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
404 my $new_seq = substr($seq,$startTrim,$lengthTrim);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
405 # $nb_base_current_t = length($new_seq);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
406 $fastq_lines .= $new_seq."\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
407 $fastq_lines .= "+\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
408 my $new_q = substr($quality,$startTrim,$lengthTrim);
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
409 $fastq_lines .= $new_q."\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
410 return $fastq_lines;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
411
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
412 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
413 else {
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
414 #print "Insufficient length after trimming\n";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
415 return "";
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
416 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
417 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
418
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
419 sub extract_longer_string_coordinates_from_bad_position{
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
420 my $start=shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
421 my $stop =shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
422 my $refbad = shift;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
423 my @bad_position = @$refbad;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
424 my %coord;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
425
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
426 my $current_start = $start;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
427 my $current_stop = $bad_position[0]-1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
428 if ($current_stop < $start){$current_stop = $start;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
429
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
430
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
431 #debut -> premier N
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
432 my $current_length = $current_stop - $current_start +1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
433 my $test_length;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
434
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
435 #entre les N
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
436 for (my $i=1;$i<=$#bad_position;$i++){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
437 $test_length = $bad_position[$i]+1-$bad_position[$i-1]-1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
438 if ( $test_length > $current_length){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
439 $current_start = $bad_position[$i-1]+1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
440 $current_stop = $bad_position[$i]-1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
441 $current_length = $current_stop - $current_start +1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
442 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
443 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
444
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
445 #dernier N -> fin
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
446 $test_length = $stop-$bad_position[$#bad_position]+1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
447 if ( $test_length > $current_length){
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
448 $current_start = $bad_position[$#bad_position]+1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
449 if ($current_start > $stop){$current_start=$stop;}
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
450 $current_stop = $stop;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
451 }
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
452 $coord{"start"}=$current_start;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
453 $coord{"stop"}= $current_stop;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
454 $coord{"lenght"}=$current_stop-$current_start+1;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
455
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
456 return \%coord;
3f7b0788a1c4 Uploaded
mcharles
parents:
diff changeset
457 }