annotate rapsodyn/mpileupfilterandstat.pl @ 15:56d328bce3a7 draft default tip

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