5 die "Usage: $0 <filled sam> <output>\n" if @ARGV <1;
7 $out=$in.'o' unless $out;
8 warn "From [$in] to [$out]\n";
13 if ($filename=~/.bz2$/) {
14 open( $infile,"-|","bzip2 -dc $filename") or die "Error opening $filename: $!\n";
15 } elsif ($filename=~/.gz$/) {
16 open( $infile,"-|","gzip -dc $filename") or die "Error opening $filename: $!\n";
17 } else {open( $infile,"<",$filename) or die "Error opening $filename: $!\n";}
21 my (%Count,$CountRF,$Reads);
22 ($CountRF,$Reads,$Count{0},$Count{1},$Count{-1})=(0,0,0,0,0);
25 next if /^@\w\w\t\w\w:/;
27 my @read=split /\t/, $_;
28 my $Alternativehits='';
30 if (/^XA:Z:([\w,+-;]+)$/) { #XA:Z:chrX,+1144912,100M,0;
31 $Alternativehits = $1;
35 my @Alt=split ';',$Alternativehits;
39 my ($chr,$pos,$CIGAR,$NM)=split /,/;
40 if (substr($pos,-2) eq '01') {
50 open O
,'>',"$out" or die "[x]Error opening $out: $!\n";
51 print O
$Count{1}+$Count{-1}," ,RF:$CountRF\t+$Count{1},-$Count{-1},z$Count{0}\t$Reads\t$in\n";
53 print $Count{1}+$Count{-1}," ,RF:$CountRF\t+$Count{1},-$Count{-1},z$Count{0}\t$Reads\n";
55 find
. -name
'*.r'|xargs
-n1
./samrstat
.pl
56 find
. -name
'*.ro'|xargs
-n1 cat
|sort -n