10 open my $in, "-|", "samtools view -f 64 -F 1796 $file" or die "Error opening $file: $!\n";
12 my @align = split /\t/;
13 my @match = $align[5] =~ /(\d+)M/g;
15 $sum_match += $_ foreach @match;
16 next if $sum_match < 64;
17 @match = sort {$b <=> $a} @match;
18 next if $match[0] < 30;
19 if ($align[1] & 0x10) {
20 next if $align[5] =~ /[NHP=X]/;
21 next unless $align[5] =~ /(\d+)M$/;
23 my @del = $align[5] =~ /(\d+)D/g;
25 $sum_del += $_ foreach @del;
26 my $c = $align[3] + $sum_match + $sum_del - 1;
27 $count{$align[2]}{$c}[0] = 1;
29 next unless $align[5] =~ /^(\d+)M/;
31 $count{$align[2]}{$align[3]+3}[1] = 1;
36 print STDERR
"$t\tCount file $file complete!\n";
44 $thread{$_} = threads
->new (\
&SiteCover
, $_);
47 print STDERR
"$t\tDestribute threads completed!\n";
51 foreach (keys %thread) {
52 $all{$_} = $thread{$_}->join;
55 print STDERR
"$t\tRead all file completed!\n";
58 foreach my $i (keys %all) {
61 foreach my $s (keys %{$all{$i}}) {
62 foreach my $c (keys %{$all{$i}{$s}}) {
63 ++$stat_site{$s}{$c}[0] if $all{$i}{$s}{$c}[0];
64 ++$stat_site{$s}{$c}[1] if $all{$i}{$s}{$c}[1];
70 foreach my $s (keys %stat_site) {
71 foreach my $c (keys %{$stat_site{$s}}) {
72 ++$PstI if ($stat_site{$s}{$c}[0] and $stat_site{$s}{$c}[1]);
77 print STDERR
"$t\tCount PstI complete!\n";
78 print STDERR
"Number of PstI is $PstI\n";