5 die "<fasta file><depth file><window><output file>\n";
8 or die "can't open the fasta file:$!\n";
10 or die "can't open depth file:$!\n";
12 or die "the result can't write:$!\n";
17 my ($GC_num,$N_num,$gc_rate,$avg_depth,$seat,$chrom);
19 my (@gcs,@depth,@Ns,@line);
20 my (%hash_seq,%hash_num,%hash);
26 if(/(^>.*$)/&&$total_num<$sum)
31 $seat=$chrom."+"."$sum";
35 $seat=$chrom."+"."$sum";
36 $gc_rate=int(100*$GC_num/($win-$N_num));
37 @
{$hash_seq{$seat}}=($N_num,$gc_rate);
49 $GC_num+=$_=~s/(G|C)/$1/gi;
50 $N_num+=$_=~s/(N)/$1/gi;
54 $GC_num+=substr($_, 0, $sum-$total_num+$len)=~s/(G|C)/$1/gi;
55 $N_num+=substr($_, 0, $sum-$total_num+$len)=~s/(N)/$1/gi;
58 $gc_rate=int(100*$GC_num/($win-$N_num));
60 $seat=$chrom."+"."$sum";
61 @
{$hash_seq{$seat}}=($N_num,$gc_rate);
62 $GC_num=substr($_,$sum-$total_num+$len,$total_num-$sum+1)=~s/(G|C)/$1/gi;
63 $N_num=substr($_,$sum-$total_num+$len,$total_num-$sum+1)=~s/(N)/$1/gi;
69 $seat=$chrom."+"."$sum";
70 $gc_rate=int(100*$GC_num/($win-$N_num));
71 @
{$hash_seq{$seat}}=($N_num,$gc_rate);
73 #foreach my $key(keys %hash_seq)
75 # print "@{$hash_seq{$key}}\n";
81 if(/(^>.*$)/&&$total_num<$sum)
87 $seat=$chrom."+"."$sum";
91 $seat=$chrom."+"."$sum";
92 if((exists $hash_seq{$seat})&&($total_num-$sum+$win-${$hash_seq{$seat}}[0])!=0)
94 push @
{$hash{${$hash_seq{$seat}}[1]}},$sum_depth/($total_num-$sum+$win-${$hash_seq{$seat}}[0]);
102 my ($len,$temp_len); #$len表示$_这一行的数字的总和,$temp_len表示$_这一行数字的个数
111 $total_num+=$temp_len;
116 for(my $i=0;$i<$sum-$total_num+$temp_len;$i++)
118 $sum_depth+=$line[$i];
120 $seat=$chrom."+"."$sum";
121 if((exists $hash_seq{$seat})&&($win-${$hash_seq{$seat}}[0])!=0)
123 push @
{$hash{${$hash_seq{$seat}}[1]}},$sum_depth/($win-${$hash_seq{$seat}}[0]);
126 for(my $i=$sum-$total_num+$len;$i<$temp_len;$i++)
128 $sum_depth+=$line[$i];
135 $seat=$chrom."+"."$sum";
136 if((exists $hash_seq{$seat})&&($total_num-$sum+$win-${$hash_seq{$seat}}[0]+1)!=0)
138 push @
{$hash{${$hash_seq{$seat}}[1]}},$sum_depth/($total_num-$sum+$win-${$hash_seq{$seat}}[0]+1);
141 #foreach my $key(keys %hash)
143 # print "@{$hash{$key}}\n";
147 my @gc_key; #@gc_key存放gc值
148 foreach my $key(sort keys %hash)
152 print OUT
"@gc_key\n";
156 for(my $i=0;$i<=$#gc_key;$i++)
158 if(@
{$hash{$gc_key[$i]}}) #此处改动了原来为$hash{$gc_key[$i]}||$hash{$gc_key[$i]}==0
160 my $tem=shift @
{$hash{$gc_key[$i]}} ;
161 $mark+=@
{$hash{$gc_key[$i]}};
185 /panfs/GAG
/zhangxm/stat
/depth
.pl