comparison scripts/pickUniqPos.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)=$f[11]=~/XT:A:(.)/;
17
18 my $strand="+";
19 ## revcomp
20 if($f[1]=~/r/)
21 {
22 my $seq=Bio::Seq->new(-seq=>$f[9], -alphabet => 'dna');
23 $f[9]=$seq->revcom->seq;
24 $strand="-";
25 }
26
27 ## parse CIGAR
28 if($xt eq "U")
29 {
30 # CIGAR
31 my (@cigar_m)=$f[5]=~/(\d+)M/g;
32 my (@cigar_d)=$f[5]=~/(\d+)D/g;
33 my (@cigar_s)=$f[5]=~/(\d+)S/g;
34 my (@cigar_i)=$f[5]=~/(\d+)I/g;
35 my $aln_ln=sum(@cigar_m,@cigar_d);
36
37 print $f[2],"\t",$f[3]-1,"\t",$f[3]-1+$aln_ln,"\t$f[0]/$rnum\t",$f[9],"\t",$strand,"\n";
38 }
39 }
40 close in;
41