5 die "usage: $0 <file prefix>\n" unless @ARGV == 1;
8 open CNT
,'<',$ARGV[0].'.sam.gc.stat' or die $!;
9 open REF
,'<',$ARGV[0].'.ref.gc.stat' or die $!;
11 while(<CNT
>) { last if /^#COL=higher/; }
22 while(<REF
>) { last if /^#COL=higher/; }
32 $cnt[$_][$_] *= 2 for (0..100);
33 $ref[$_][$_] *= 2 for (0..100);
37 return 0 if $range > 2;
38 my ($points,$sum)=(0,0);
39 for my $i ($h-$range .. $h+$range) {
40 next unless $div[$i][$i];
46 for my $i ($h-$range .. $h+$range) {
47 print $div[$i][$i],' ';
49 print "\n",$sum / $points,"\n",'*' x
75,"\n";
50 return $sum / $points;
52 return &dePepperC
($h,++$range);
58 my ($points,$sum)=(0,0);
59 for my $i ($h-$range .. $h+$range) {
60 for my $j ($l-$range .. $l+$range) {
61 next unless $div[$i][$j];
62 next if $i==$h and $j==$l;
68 for my $i ($h-$range .. $h+$range) {
69 for my $j ($l-$range .. $l+$range) {
70 print $div[$i][$j],' ';
74 print $sum / $points,"\n",'=' x
75,"\n";
75 return $sum / $points;
82 my ($points,$sum)=(0,0);
83 for my $i ($h-$range .. $h+$range) {
84 for my $j ($l-$range .. $l+$range) {
85 next unless $ref[$i][$j];
86 next if $i==$h and $j==$l;
92 for my $i ($h-$range .. $h+$range) {
93 for my $j ($l-$range .. $l+$range) {
94 print $ref[$i][$j],' ';
98 print $sum / $points,"\n";
99 return $sum / $points;
101 return &dePepper
($h,$l,++$range);
108 #print "$h,$l\tCnt:$cnt[$h][$l]\tRef:$ref[$h][$l]\n";
109 #next unless $cnt[$h][$l];
110 $refvalue = $ref[$h][$l];
114 $refvalue = &dePepper
($h,$l,1);
116 } else {$refvalue=1;}
118 $div[$h][$l] = $cnt[$h][$l] / $refvalue;
126 } elsif ($div[$h][$l]) {
127 $divOut[$h][$l] = $div[$h][$l];
129 $divOut[$h][$l] = &dePepperA
($h,$l);
130 if ($h == $l and $divOut[$h][$l] == 0) {
131 $divOut[$h][$l] = &dePepperC
($h,1);
137 open OUT
,'>',$ARGV[0].'.div.gc.stat' or die $!;
138 print OUT
"#COL=higher_GC%_read, ROW=lower_GC%_read\n";
139 print OUT
join("\t",'#',0..100),"\n";
140 print OUT
"$_\t",join("\t",@
{$divOut[$_]}),"\n" for (0..100);
142 #print "$_: [",scalar @{$cnt[$_]},']',join(' ',@{$cnt[$_]}),"\n" for (0 .. $#cnt);
143 #print "$_: [",scalar @{$ref[$_]},']',join(' ',@{$ref[$_]}),"\n" for (0 .. $#ref);