10 &usage if (@ARGV < 1);
12 my $command = shift(@ARGV);
13 my %func = (indelFilter=>\&indelFilter, showALEN=>\&showALEN);
15 die("Unknown command \"$command\".\n") if (!defined($func{$command}));
24 die(qq/Usage: samtools.pl showALEN <in.sam>\n/) if (@ARGV == 0 && -t STDIN);
29 s/(\d+)[SMI]/$l+=$1/eg;
30 print join("\t", @t[0..5]), "\t$l\t", join("\t", @t[6..$#t]), "\n";
39 my %opts = (D=>100, m=>10, r=>undef, s=>100);
40 getopts('D:m:rs:', \%opts); # -s for scaling factor in score calculation
43 Usage: samtools.pl indelFilter [options] <in.indel>\n
44 Options: -D INT maximum read depth [$opts{D}]
45 -m INT minimum distance between two adjacent indels [$opts{m}]
46 \n/) if (@ARGV == 0 && -t STDIN);
49 my ($curr, $last) = (\@arr1, \@arr2);
50 my $is_ref = defined($opts{r})? 1 : 0;
53 next if ($t[2] ne '*');
55 next if ($t[3] eq '*/*');
58 next if ($t[7] > $opts{D});
59 # calculate indel score
61 $score += $opts{s} * $t[10] if ($t[8] ne '*');
62 $score += $opts{s} * $t[11] if ($t[9] ne '*');
63 @$curr = ($t[0], $t[1], $score, $_);
65 if (defined $last->[0]) {
66 if ($curr->[0] eq $last->[0] && $last->[1] + $opts{m} > $curr->[1]) {
67 $do_swap = 0 if ($last->[2] > $curr->[2]);
73 my $tmp = $curr; $curr = $last; $last = $tmp;
76 print $last->[3] if (defined $last->[0]);
81 Usage: samtools.pl <command> [<arguments>]\n
82 Command: indelFilter filter indels generated by `pileup -c'
83 showALEN print alignment length (ALEN) following CIGAR