annotate rapsodyn/mpileupfilterandstat.pl @ 5:b0cbb9d21aa9 draft

Uploaded
author mcharles
date Mon, 22 Sep 2014 10:19:53 -0400
parents 442a7c88b886
children 3f7b0788a1c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
1 #!/usr/bin/perl
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
2 use strict;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
3 use Getopt::Long;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
4
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
5 #
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
6 # Filter a pileup file on forward/reverse presence and %read having the variant
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
7 # The error code
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
8 # 1 : multiple variant type detected insertion/deletion/mutation
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
9 # 1i : inconsistency in insertion
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
10 # 1d : inconsistency in deletion
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
11 # 1m : inconsistency in mutation
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
12 # 2 : insufficient depth
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
13 # 3 : insufficient variant frequency
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
14 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
15 # 5 : variant with other variant in neighbourhood
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
16 # 6 : too much depth
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
17 # 8 : parsing error (couldn't parse the mpileup line correctly)
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
18 # 9 : parsing error (couldn't parse the readbase string correctly)
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
19
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
20
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
21 my $inputfile;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
22 my $logfile;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
23 my $MIN_DISTANCE=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
24 my $MIN_VARIANTFREQUENCY=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
25 my $MIN_FORWARDREVERSE=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
26 my $MIN_DEPTH=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
27 my $MAX_DEPTH=500;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
28 my $VERBOSE=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
29 my $ONLY_UNFILTERED_VARIANT="OFF";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
30 my $DO_STAT="NO";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
31
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
32
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
33 my $STAT_MIN_DEPTH_MIN = 2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
34 my $STAT_MIN_DEPTH_MAX = 10;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
35 my $STAT_MIN_DEPTH_STEP = 2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
36 my $STAT_MAX_DEPTH_MIN = 100;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
37 my $STAT_MAX_DEPTH_MAX = 200;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
38 my $STAT_MAX_DEPTH_STEP = 100;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
39 my $STAT_FREQ_MIN = 0.8;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
40 my $STAT_FREQ_MAX = 1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
41 my $STAT_FREQ_STEP = 0.1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
42 my $STAT_DIST_MIN = 0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
43 my $STAT_DIST_MAX = 50;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
44 my $STAT_DIST_STEP = 50;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
45
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
46 GetOptions (
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
47 "input_file=s" => \$inputfile,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
48 "log_file=s" => \$logfile,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
49 "min_depth=i" => \$MIN_DEPTH,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
50 "max_depth=i" => \$MAX_DEPTH,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
51 "min_frequency=f" => \$MIN_VARIANTFREQUENCY,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
52 "min_distance=i" => \$MIN_DISTANCE,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
53 "min_forward_and_reverse=i" => \$MIN_FORWARDREVERSE,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
54 "variant_only=s" => \$ONLY_UNFILTERED_VARIANT,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
55 "v=i" => \$VERBOSE,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
56 "do_stat=s" => \$DO_STAT,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
57 "stat_min_depth_min=i" => \$STAT_MIN_DEPTH_MIN,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
58 "stat_min_depth_max=i" => \$STAT_MIN_DEPTH_MAX,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
59 "stat_min_depth_step=i" => \$STAT_MIN_DEPTH_STEP,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
60 "stat_max_depth_min=i" => \$STAT_MAX_DEPTH_MIN,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
61 "stat_max_depth_max=i" => \$STAT_MAX_DEPTH_MAX,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
62 "stat_max_depth_step=i" => \$STAT_MAX_DEPTH_STEP,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
63 "stat_freq_min=f" => \$STAT_FREQ_MIN,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
64 "stat_freq_max=f" => \$STAT_FREQ_MAX,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
65 "stat_freq_step=f" => \$STAT_FREQ_STEP,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
66 "stat_dist_min=i" => \$STAT_DIST_MIN,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
67 "stat_dist_max=i" => \$STAT_DIST_MAX,
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
68 "stat_dist_step=i" => \$STAT_DIST_STEP
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
69 ) or die("Error in command line arguments\n");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
70
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
71 open(IF, $inputfile) or die("Can't open $inputfile\n");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
72
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
73 my @tbl_line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
74 my %USR_PARAM;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
75 $USR_PARAM{"min_depth"} = $MIN_DEPTH;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
76 $USR_PARAM{"max_depth"} = $MAX_DEPTH;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
77 $USR_PARAM{"min_freq"} = $MIN_VARIANTFREQUENCY;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
78 $USR_PARAM{"min_dist"} = $MIN_DISTANCE;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
79 $USR_PARAM{"min_fr"} = $MIN_FORWARDREVERSE;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
80
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
81
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
82
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
83 #Extraction des variants
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
84 my $nb_line=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
85 while (my $line=<IF>){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
86 $nb_line++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
87 if (($nb_line % 1000000 == 0)&&($VERBOSE==1)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
88 print "$nb_line\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
89 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
90 my $error_code=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
91 if ($line=~/(.*?)\s+(\d+)\s+([ATGCN])\s+(\d+)\s+(.*?)\s+(.*?)$/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
92 my $current_chromosome = $1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
93 my $current_position = $2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
94 my $current_refbase = $3;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
95 my $current_coverage = $4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
96 my $current_readbase_string = $5;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
97 my $current_quality_string = $6;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
98
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
99 #Suppression of mPileUp special character
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
100 $current_readbase_string =~ s/\$//g; #the read start at this position
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
101 $current_readbase_string =~ s/\^.//g; #the read end at this position followed by quality char
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
102
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
103 if ($current_readbase_string =~ /[ATGCNatgcn\d]/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
104 my %variant;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
105 $variant{"line"} = $line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
106 $variant{"chr"} = $current_chromosome;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
107 $variant{"pos"} = $current_position;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
108 $variant{"refbase"} = $current_refbase;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
109 $variant{"coverage"} = $current_coverage;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
110 $variant{"readbase"} = $current_readbase_string;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
111 $variant{"quality"} = $current_quality_string;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
112 push(@tbl_line,\%variant);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
113
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
114 if ($ONLY_UNFILTERED_VARIANT eq "ON"){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
115 print $line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
116 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
117
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
118 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
119 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
120 #Position with no variant
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
121 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
122
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
123 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
124 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
125 #Error Parsing
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
126 print STDERR "$line #8";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
127 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
128 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
129 close(IF);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
130
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
131 if ($ONLY_UNFILTERED_VARIANT eq "ON"){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
132 exit(0);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
133 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
134
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
135 ####Checking the distance between variant and other filter
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
136
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
137
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
138 my @error;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
139 for (my $i=0;$i<=$#tbl_line;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
140 # print "ligne : $tbl_line[$i]\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
141 my $before="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
142 my $after="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
143 my %line = %{$tbl_line[$i]};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
144
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
145 if ($tbl_line[$i-1]){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
146 $before = $tbl_line[$i-1];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
147 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
148 if ($tbl_line[$i+1]){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
149 $after = $tbl_line[$i+1];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
150 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
151 my $error_code = check_error($tbl_line[$i],$before,$after,\%USR_PARAM);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
152 if ($error_code == 0){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
153 print $line{"line"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
154 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
155 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
156 push(@error,$error_code,"\t",$line{"line"});
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
157 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
158 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
159
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
160 ### LOG
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
161 open(LF,">$logfile") or die ("Can't open $logfile\n");
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
162
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
163 if ($DO_STAT eq "YES"){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
164 for (my $idx_min_depth=$STAT_MIN_DEPTH_MIN;$idx_min_depth<=$STAT_MIN_DEPTH_MAX;$idx_min_depth = $idx_min_depth + $STAT_MIN_DEPTH_STEP ){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
165 for (my $idx_max_depth=$STAT_MAX_DEPTH_MIN;$idx_max_depth<=$STAT_MAX_DEPTH_MAX;$idx_max_depth = $idx_max_depth + $STAT_MAX_DEPTH_STEP ){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
166 for (my $idx_freq = $STAT_FREQ_MIN;$idx_freq<=$STAT_FREQ_MAX;$idx_freq= $idx_freq+$STAT_FREQ_STEP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
167 for (my $idx_dist=$STAT_DIST_MIN;$idx_dist<=$STAT_DIST_MAX;$idx_dist = $idx_dist + $STAT_DIST_STEP){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
168 for (my $idx_fr=0;$idx_fr<=1;$idx_fr++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
169 my %stat_param;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
170 $stat_param{"min_depth"}=$idx_min_depth;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
171 $stat_param{"max_depth"}=$idx_max_depth;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
172 $stat_param{"min_freq"}=$idx_freq;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
173 $stat_param{"min_fr"}=$idx_fr;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
174 $stat_param{"min_dist"}=$idx_dist;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
175
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
176 print LF "#SNP = ",&test_check(\@tbl_line,\%stat_param),"\tdepth (min/max) = ",$stat_param{"min_depth"}," / ",$stat_param{"max_depth"},"\tmin_dist=",$stat_param{"min_dist"},"\tmin_freq=",$stat_param{"min_freq"},"\tmin_forwardreverse = ",$stat_param{"min_fr"},"\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
177 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
178 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
179 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
180 print "\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
181 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
182 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
183 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
184
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
185
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
186 for (my $i=0;$i<=$#error;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
187 print LF $error[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
188 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
189 close (LF);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
190
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
191
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
192
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
193
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
194 sub test_check{
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
195 my $ref_tbl_line = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
196 my $ref_param = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
197 my @tbl_line = @$ref_tbl_line;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
198 my %param = %$ref_param;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
199 my $nb=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
200
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
201 for (my $i=0;$i<=$#tbl_line;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
202 my $before="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
203 my $after="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
204 my %line = %{$tbl_line[$i]};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
205
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
206 if ($tbl_line[$i-1]){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
207 $before = $tbl_line[$i-1];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
208 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
209 if ($tbl_line[$i+1]){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
210 $after = $tbl_line[$i+1];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
211 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
212 my $error_code = check_error($tbl_line[$i],$before,$after,\%param);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
213 if ($error_code == 0){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
214 $nb++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
215 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
216 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
217
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
218 return $nb;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
219 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
220
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
221 sub check_error{
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
222 my $refline = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
223 my %line = %$refline;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
224 my $refbefore = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
225 my $refafter = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
226 my $refparam = shift;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
227 my %param = %$refparam;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
228
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
229
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
230 my $current_chromosome = $line{"chr"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
231 my $current_position = $line{"pos"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
232 my $current_refbase = $line{"refbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
233 my $current_coverage = $line{"coverage"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
234 my $current_readbase_string = $line{"readbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
235
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
236
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
237 my $min_depth = $param{"min_depth"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
238 my $max_depth = $param{"max_depth"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
239 my $min_variant_frequency = $param{"min_freq"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
240 my $min_forward_reverse = $param{"min_fr"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
241 my $min_dist = $param{"min_dist"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
242
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
243 #Verification of neightbourhood
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
244 if ($refbefore){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
245 my %compareline = %$refbefore;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
246 my $compare_chromosome = $compareline{"chr"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
247 my $compare_position = $compareline{"pos"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
248 my $compare_refbase = $compareline{"refbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
249 my $compare_coverage = $compareline{"coverage"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
250 my $compare_readbase_string = $compareline{"readbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
251
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
252 if (($current_chromosome eq $compare_chromosome )&&($compare_position + $min_dist >= $current_position)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
253 return 5;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
254 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
255 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
256
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
257 if ($refafter){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
258 my %compareline = %$refafter;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
259 my $compare_chromosome = $compareline{"chr"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
260 my $compare_position = $compareline{"pos"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
261 my $compare_refbase = $compareline{"refbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
262 my $compare_coverage = $compareline{"coverage"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
263 my $compare_readbase_string = $compareline{"readbase"};
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
264
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
265 if (($current_chromosome eq $compare_chromosome )&&($current_position + $min_dist >= $compare_position)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
266 return 5;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
267 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
268 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
269
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
270
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
271
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
272
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
273 #Extraction of insertions
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
274
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
275 ##################################################################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
276 # my @IN = $current_readbase_string =~ m/\+[0-9]+[ACGTNacgtn]+/g;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
277 # my @DEL = $current_readbase_string =~ m/\-[0-9]+[ACGTNacgtn]+/g;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
278 # print "IN : @IN\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
279 # print "DEL :@DEL\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
280 #$current_readbase_string=~s/[\+\-][0-9]+[ACGTNacgtn]+//g;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
281 ##################################################################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
282 #!!! marche pas : exemple .+1Ct. correspond a . / +1C / t /. mais le match de l'expression vire +1Ct
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
283 ##################################################################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
284
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
285 # => parcours de boucle
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
286 my @readbase = split(//,$current_readbase_string);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
287 my $cleaned_readbase_string="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
288 my @IN;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
289 my @DEL;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
290 my $current_IN="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
291 my $current_DEL="";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
292 my $current_size=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
293
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
294 for (my $i=0;$i<=$#readbase;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
295 if ($readbase[$i] eq "+"){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
296 #Ouverture de IN
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
297 $current_IN="+";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
298
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
299 #Recuperation de la taille
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
300 my $sub = substr $current_readbase_string,$i;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
301 if ($sub=~/^\+(\d+)/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
302 $current_size = $1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
303 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
304 my $remaining_size = $current_size;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
305 while (($remaining_size>0)&&($i<=$#readbase)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
306 $i++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
307 $current_IN.=$readbase[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
308 if ($readbase[$i]=~ /[ATGCNatgcn]/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
309 $remaining_size--;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
310 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
311 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
312 push(@IN,$current_IN);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
313 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
314 elsif ($readbase[$i] eq "-"){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
315 #Ouverture de DEL
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
316 $current_DEL="-";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
317
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
318 #Recuperation de la taille
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
319 my $sub = substr $current_readbase_string,$i;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
320 if ($sub=~/^\-(\d+)/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
321 $current_size = $1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
322 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
323 my $remaining_size = $current_size;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
324 while (($remaining_size>0)&&($i<=$#readbase)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
325 $i++;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
326 $current_DEL.=$readbase[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
327 if ($readbase[$i]=~ /[ATGCNatgcn]/){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
328 $remaining_size--;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
329 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
330 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
331 push(@DEL,$current_DEL);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
332
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
333 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
334 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
335 #Ajout a la string
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
336 $cleaned_readbase_string .= $readbase[$i];
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
337 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
338 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
339
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
340
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
341 # print "IN : @IN\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
342 # print "DEL :@DEL\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
343 # print "$cleaned_readbase_string\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
344
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
345 my @current_readbase_array = split(//,$cleaned_readbase_string);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
346
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
347 #Filtering : error detection
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
348
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
349 if ($#current_readbase_array+1 != $current_coverage){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
350 return 9;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
351 #parsing error (couldn't parse the readbase string correctly)
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
352 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
353 elsif ($current_coverage<$min_depth){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
354 return 2;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
355 # 2 : insufficient depth
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
356 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
357 elsif ($current_coverage>$max_depth){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
358 return 6;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
359 # 6 : too much depth
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
360 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
361 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
362 if ($#IN>=0){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
363 if (($cleaned_readbase_string=~/[ACGTNacgtn]/)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
364 return 1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
365 # 1 : variant type overload (multiple variant type detected insertion/deletion/mutation)
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
366 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
367 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
368 ########## TEST de coherence des insertions ################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
369 # for (my $i=0;$i<=$#IN;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
370 # if (uc($IN[0]) ne uc($IN[$i])){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
371 # print uc($IN[0]),"\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
372 # print uc($IN[$i]),"\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
373 # return "1i";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
374 # }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
375 # }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
376 ###########################################################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
377
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
378 if($#IN+1 < $current_coverage*$min_variant_frequency ){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
379 return 3;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
380 # 3 : insufficient variant frequency
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
381 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
382 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
383 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
384 elsif ($#DEL>=0){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
385 if (($cleaned_readbase_string=~/[ACGTNacgtn]/)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
386 return 1;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
387 # 1 : variant type overload (multiple variant type detected insertion/deletion/mutation)
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
388 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
389 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
390 ########## TEST de coherence des deletions ################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
391 # for (my $i=0;$i<=$#DEL;$i++){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
392 # if (uc($DEL[0]) ne uc($DEL[$i])){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
393 # print uc($DEL[0]),"\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
394 # print uc($DEL[$i]),"\n";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
395 # return "1d";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
396 # }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
397 # }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
398 ###########################################################
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
399
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
400 if($#DEL+1 < $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
401 return 3;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
402 # 3 : insufficient variant frequency
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
403 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
404 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
405 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
406 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
407 my $nbA=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
408 $nbA++ while ($current_readbase_string =~ m/A/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
409 my $nbC=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
410 $nbC++ while ($current_readbase_string =~ m/C/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
411 my $nbT=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
412 $nbT++ while ($current_readbase_string =~ m/T/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
413 my $nbG=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
414 $nbG++ while ($current_readbase_string =~ m/G/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
415 my $nbN=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
416 $nbN++ while ($current_readbase_string =~ m/N/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
417 my $nba=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
418 $nba++ while ($current_readbase_string =~ m/a/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
419 my $nbc=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
420 $nbc++ while ($current_readbase_string =~ m/c/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
421 my $nbt=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
422 $nbt++ while ($current_readbase_string =~ m/t/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
423 my $nbg=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
424 $nbg++ while ($current_readbase_string =~ m/g/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
425 my $nbn=0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
426 $nbn++ while ($current_readbase_string =~ m/n/g);
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
427
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
428 if (($nbA+$nba>0)&&($nbT+$nbt+$nbG+$nbg+$nbC+$nbc+$nbN+$nbn>0)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
429 return "1m";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
430 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
431 if (($nbT+$nbt>0)&&($nbA+$nba+$nbG+$nbg+$nbC+$nbc+$nbN+$nbn>0)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
432 return "1m";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
433 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
434 if (($nbG+$nbg>0)&&($nbA+$nba+$nbT+$nbt+$nbC+$nbc+$nbN+$nbn>0)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
435 return "1m";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
436 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
437 if (($nbC+$nbc>0)&&($nbA+$nba+$nbT+$nbt+$nbG+$nbg+$nbN+$nbn>0)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
438 return "1m";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
439 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
440 if (($nbN+$nbn>0)&&($nbA+$nba+$nbT+$nbt+$nbG+$nbg+$nbC+$nbc>0)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
441 return "1m";
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
442 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
443
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
444 if ($nbA+$nba >= $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
445 if (($nbA<$min_forward_reverse)||($nba<$min_forward_reverse)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
446 return 4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
447 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
448 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
449 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
450 elsif ($nbT+$nbt >= $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
451 if (($nbT<$min_forward_reverse)||($nbt<$min_forward_reverse)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
452 return 4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
453 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
454 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
455 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
456 elsif ($nbG+$nbg >= $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
457 if (($nbG<$min_forward_reverse)||($nbg<$min_forward_reverse)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
458 return 4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
459 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
460 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
461 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
462 elsif ($nbC+$nbc >= $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
463 if (($nbC<$min_forward_reverse)||($nbc<$min_forward_reverse)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
464 return 4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
465 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
466 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
467 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
468 elsif ($nbN+$nbn >= $current_coverage*$min_variant_frequency){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
469 if (($nbN<$min_forward_reverse)||($nbn<$min_forward_reverse)){
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
470 return 4;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
471 # 4 : variant position not covered by forward and reverse reads
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
472 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
473 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
474 else {
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
475 return 3;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
476 # 3 : insufficient variant frequency
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
477 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
478 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
479 }
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
480
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
481 return 0;
442a7c88b886 Uploaded
mcharles
parents:
diff changeset
482 }