3 use Time
::HiRes qw
( gettimeofday tv_interval
);
5 my ($depth_file,$fa_file,$out_file,$win_size,$help);
7 "depth:s"=>\
$depth_file,
9 "output:s"=>\
$out_file,
13 if(!$depth_file || !$fa_file || !$out_file || !$win_size || $help)
15 print "\t -depth: the depth file\n";
16 print "\t -fa: the .fa file\n";
17 print "\t -output: the output file\n";
18 print "\t -win: the window size\n";
19 print "\t -help: if you need the help";
23 my $str_time=[gettimeofday
];
25 print "Begin to count average of depth\n";
30 open(IN
,"<$depth_file")or die "can not open $depth_file :$!\n";
39 if($num==65535){$num=0;}
60 print "Finish the depth counting\n";
66 print "Begin to count the gc\n";
67 open(IN
,"<$fa_file")or die "can not open $fa_file:$!";
78 my $aver=int($sum/$cnt*100);
85 my $dis=$cnt-$win_size;
89 for(my $i=$len-$dis;$i<$len;$i++)
96 my $aver=int(($sum-$count)/$win_size*100);
114 foreach(@
{"gc$chrname"})
116 my $dep=shift @
{$chrname};
127 open(OUT
,">$out_file")or die "$!\n";
128 for(my $i=$str;$i<=$end;$i++)
136 for(my $j=$str;$j<=$end;$j++)
139 if(!defined $dep){$dep="NA";$na++;}
140 else{$max_depth+=$dep;$cnt_depth++;}
147 $max_depth/=$cnt_depth/2;
148 $max_depth=(int($max_depth/50)+1)*50;
150 foreach(1..$max_depth/50)
155 open(OUT
,">$out_file.R")or die;
156 print OUT
'a=read.delim("',"$out_file",'");',"\n";
157 print OUT
'pdf("',"$out_file.pdf",'",width=8,height=6,paper="special");',"\n";
158 print OUT
"boxplot(a,ylim=c(0,$max_depth),xlim=c(0,90),axes=FALSE,outline=FALSE,xlab='GC%',ylab='Depth');\n";
159 print OUT
"axis(1,at=c(0,10,20,30,40,50,60,70,80),labels=c(0,10,20,30,40,50,60,70,80),las=0);\n";
160 print OUT
"axis(2,at=c($area),labels=c($area),las=2);\nq();\nn\n";
162 `Rscript $out_file.R`;
163 my $end_time=[gettimeofday
];
164 my $time=tv_interval
($str_time,$end_time);