9 $file{$_} = openfile
($_);
11 print STDERR
"Read file list complete!\n";
14 foreach (sort keys %file) {
15 if (/sam.gz$/ or /bam$/) {
16 $thread{$_} = threads
->new(\
&countsam
, $file{$_});
17 } elsif (/fq.gz$/ or /cut.gz$/) {
18 $thread{$_} = threads
->new(\
&countfq
, $file{$_});
23 foreach (sort keys %thread) {
24 $count{$_} = $thread{$_}->join;
25 print STDERR
"Count $_ complete!\n";
28 foreach (sort keys %count) {
29 print $_, "\t", (join "\t", @
{$count{$_}}), "\n";
35 if ($filename =~ /.bam$/) {
36 open $infile, "-|", "samtools view $filename" or die "Error opening $filename: $!\n";
37 } elsif ($filename =~ /.sam.gz$/) {
38 open $infile, "-|", "samtools view -S $filename" or die "Error opening $filename: $!\n";
40 open $infile, "-|", "gzip -dc $filename" or die "Error opening $filename: $!\n";
47 my ($reads, $empty, $bp) = (0, 0, 0);
49 chomp (my $seq = <$in>);
52 my $length = length $seq;
54 ++$empty unless $length;
58 my $a = [$reads, $empty, $bp];
64 my ($aligned_reads, $aligned_bp) = (0, 0);
67 ++$aligned_reads if $a[3];
68 my @b = $a[5] =~ /(\d+)[MI]/g;
69 $aligned_bp += $_ foreach @b;
72 my $a = [$aligned_reads, $aligned_bp];