comparison rapsodyn/mpileupfilterandstat.pl @ 25:39376c7204be draft

Uploaded
author mcharles
date Wed, 10 Sep 2014 05:12:05 -0400
parents e8e6b962c1f2
children 7b8646f46010
comparison
equal deleted inserted replaced
24:e8e6b962c1f2 25:39376c7204be
27 my $MAX_DEPTH=500; 27 my $MAX_DEPTH=500;
28 my $VERBOSE=0; 28 my $VERBOSE=0;
29 my $ONLY_UNFILTERED_VARIANT="OFF"; 29 my $ONLY_UNFILTERED_VARIANT="OFF";
30 my $DO_STAT="NO"; 30 my $DO_STAT="NO";
31 31
32 if ($#ARGV<0){ 32
33 print "\n"; 33 my $STAT_MIN_DEPTH_MIN = 2;
34 print "perl 020_FilterPileupv6 -input_file <mpileup_file> [OPTION]\n"; 34 my $STAT_MIN_DEPTH_MAX = 10;
35 print "-input_file \tinputfile in mpileup format\n"; 35 my $STAT_MIN_DEPTH_STEP = 2;
36 print "-log_file \tlogfile containing discarded mpileup lines and the errorcode associated\n"; 36 my $STAT_MAX_DEPTH_MIN = 100;
37 print "-min_depth \tminimum depth required [1]\n"; 37 my $STAT_MAX_DEPTH_MAX = 200;
38 print "-max_depth \tmaximim depth (position with more coverage will be discarded) [100]\n"; 38 my $STAT_MAX_DEPTH_STEP = 100;
39 print "-min_frequency \tminimum variant frequency (0->1) [1] (default 1 => 100% reads show the variant at this position)\n"; 39 my $STAT_FREQ_MIN = 0.8;
40 print "-min_distance \tminimum distance between variant [0]\n"; 40 my $STAT_FREQ_MAX = 1;
41 print "-min_forward_and_reverse \tminimum number of reads in forward and reverse covering the variant required [0]\n"; 41 my $STAT_FREQ_STEP = 0.1;
42 print "\n"; 42 my $STAT_DIST_MIN = 0;
43 exit(0); 43 my $STAT_DIST_MAX = 50;
44 } 44 my $STAT_DIST_STEP = 50;
45 45
46 GetOptions ( 46 GetOptions (
47 "input_file=s" => \$inputfile, 47 "input_file=s" => \$inputfile,
48 "log_file=s" => \$logfile, 48 "log_file=s" => \$logfile,
49 "min_depth=i" => \$MIN_DEPTH, 49 "min_depth=i" => \$MIN_DEPTH,
51 "min_frequency=f" => \$MIN_VARIANTFREQUENCY, 51 "min_frequency=f" => \$MIN_VARIANTFREQUENCY,
52 "min_distance=i" => \$MIN_DISTANCE, 52 "min_distance=i" => \$MIN_DISTANCE,
53 "min_forward_and_reverse=i" => \$MIN_FORWARDREVERSE, 53 "min_forward_and_reverse=i" => \$MIN_FORWARDREVERSE,
54 "variant_only=s" => \$ONLY_UNFILTERED_VARIANT, 54 "variant_only=s" => \$ONLY_UNFILTERED_VARIANT,
55 "v=i" => \$VERBOSE, 55 "v=i" => \$VERBOSE,
56 "do_stat=s" => \$DO_STAT 56 "do_stat=s" => \$DO_STAT,
57 "stat_min_depth_min=i" => \$STAT_MIN_DEPTH_MIN,
58 "stat_min_depth_max=i" => \$STAT_MIN_DEPTH_MAX,
59 "stat_min_depth_step=i" => \$STAT_MIN_DEPTH_STEP,
60 "stat_max_depth_min=i" => \$STAT_MAX_DEPTH_MIN,
61 "stat_max_depth_max=i" => \$STAT_MAX_DEPTH_MAX,
62 "stat_max_depth_step=i" => \$STAT_MAX_DEPTH_STEP,
63 "stat_freq_min=f" => \$STAT_FREQ_MIN,
64 "stat_freq_max=f" => \$STAT_FREQ_MAX,
65 "stat_freq_step=f" => \$STAT_FREQ_STEP,
66 "stat_dist_min=i" => \$STAT_DIST_MIN,
67 "stat_dist_max=i" => \$STAT_DIST_MAX,
68 "stat_dist_step=i" => \$STAT_DIST_STEP
57 ) or die("Error in command line arguments\n"); 69 ) or die("Error in command line arguments\n");
58
59 70
60 open(IF, $inputfile) or die("Can't open $inputfile\n"); 71 open(IF, $inputfile) or die("Can't open $inputfile\n");
61 72
62 my @tbl_line; 73 my @tbl_line;
63 my %USR_PARAM; 74 my %USR_PARAM;
148 159
149 ### LOG 160 ### LOG
150 open(LF,">$logfile") or die ("Can't open $logfile\n"); 161 open(LF,">$logfile") or die ("Can't open $logfile\n");
151 162
152 if ($DO_STAT eq "YES"){ 163 if ($DO_STAT eq "YES"){
153 for (my $idx_min_depth=2;$idx_min_depth<=32;$idx_min_depth = $idx_min_depth*2){ 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 ){
154 for (my $idx_freq = 0.5;$idx_freq<=1;$idx_freq= $idx_freq+0.1){ 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 ){
155 for (my $idx_dist=0;$idx_dist<=50;$idx_dist = $idx_dist + 50){ 166 for (my $idx_freq = $STAT_FREQ_MIN;$idx_freq<=$STAT_FREQ_MAX;$idx_freq= $idx_freq+$STAT_FREQ_STEP){
156 for (my $idx_fr=0;$idx_fr<=1;$idx_fr++){ 167 for (my $idx_dist=$STAT_DIST_MIN;$idx_dist<=$STAT_DIST_MAX;$idx_dist = $idx_dist + $STAT_DIST_STEP){
157 my %stat_param; 168 for (my $idx_fr=0;$idx_fr<=1;$idx_fr++){
158 $stat_param{"min_depth"}=$idx_min_depth; 169 my %stat_param;
159 $stat_param{"max_depth"}=250; 170 $stat_param{"min_depth"}=$idx_min_depth;
160 $stat_param{"min_freq"}=$idx_freq; 171 $stat_param{"max_depth"}=$idx_max_depth;
161 $stat_param{"min_fr"}=$idx_fr; 172 $stat_param{"min_freq"}=$idx_freq;
162 $stat_param{"min_dist"}=$idx_dist; 173 $stat_param{"min_fr"}=$idx_fr;
163 174 $stat_param{"min_dist"}=$idx_dist;
164 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"; 175
165 } 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";
166 } 177 }
167 } 178 }
168 print "\n"; 179 }
180 print "\n";
181 }
169 } 182 }
170 } 183 }
171 184
172 185
173 for (my $i=0;$i<=$#error;$i++){ 186 for (my $i=0;$i<=$#error;$i++){