comparison scripts/pickUniqPos_MEM.pl.orig @ 21:9672fe07a232 draft default tip

planemo upload for repository https://github.com/portiahollyoak/Tools commit 0fea84d05f8976b8360a8b4943ecb01b87e3ade0-dirty
author mvdbeek
date Mon, 05 Dec 2016 09:58:47 -0500
parents
children
comparison
equal deleted inserted replaced
20:6e02b9179a24 21:9672fe07a232
1 #!/share/bin/perl
2 use Bio::Seq;
3 use List::Util qw(sum);
4
5 die "perl $0 <sam>\n" if @ARGV<1;
6 open in,$ARGV[0];
7 my %pe;
8 while(<in>)
9 {
10 chomp;
11 my @f=split/\t/,$_,12;
12 ## read number 1 or 2
13 my ($rnum)=$f[1]=~/(\d)$/;
14
15 ## XT:A:*
16 my $xt="";
17 my @a=split(/\s+/, $_);
18 my $as=0;
19 my $xs=0;
20 for my $i (11..$#a) {
21 if ($a[$i] =~ /^AS:i:/) {
22 $a[$i] =~ s/AS:i://;
23 $as=$a[$i];
24 }
25 elsif ($a[$i] =~ /^XS:i:/) {
26 $a[$i] =~ s/XS:i://;
27 $xs=$a[$i];
28 }
29 if (($xs > 0) && ($as-$xs <= $ARGV[1])) {$xt="R";}
30 elsif ($as > 0) {$xt="U";}
31 }
32
33 my $strand="+";
34 ## revcomp
35 if($f[1]=~/r/)
36 {
37 my $seq=Bio::Seq->new(-seq=>$f[9], -alphabet => 'dna');
38 $f[9]=$seq->revcom->seq;
39 $strand="-";
40 }
41
42 ## parse CIGAR
43 if($xt eq "U")
44 {
45 # CIGAR
46 my (@cigar_m)=$f[5]=~/(\d+)M/g;
47 my (@cigar_d)=$f[5]=~/(\d+)D/g;
48 my (@cigar_s)=$f[5]=~/(\d+)S/g;
49 my (@cigar_i)=$f[5]=~/(\d+)I/g;
50 my $aln_ln=sum(@cigar_m,@cigar_d);
51
52 print $f[2],"\t",$f[3]-1,"\t",$f[3]-1+$aln_ln,"\t$f[0]/$rnum\t",$f[9],"\t",$strand,"\n";
53 }
54 }
55 close in;
56