Mercurial > repos > portiahollyoak > temp
comparison scripts/pickUniqPairFastq.pl @ 0:28d1a6f8143f draft
planemo upload for repository https://github.com/portiahollyoak/Tools commit 132bb96bba8e7aed66a102ed93b7744f36d10d37-dirty
author | portiahollyoak |
---|---|
date | Mon, 25 Apr 2016 13:08:56 -0400 |
parents | |
children | e19d9742c99b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:28d1a6f8143f |
---|---|
1 #!/share/bin/perl | |
2 use Bio::Seq; | |
3 | |
4 die "perl $0 <sam> <output prefix>\n" if @ARGV<1; | |
5 | |
6 open m1,">$ARGV[1].1.fastq"; | |
7 open m2,">$ARGV[1].2.fastq"; | |
8 | |
9 open in,$ARGV[0]; | |
10 my %pe; | |
11 while(<in>) | |
12 { | |
13 chomp; | |
14 my @f=split/\t/,$_,12; | |
15 ## read number 1 or 2 | |
16 my ($rnum)=$f[1]=~/(\d)$/; | |
17 | |
18 ## XT:A:* | |
19 my ($xt)=$f[11]=~/XT:A:(.)/; | |
20 | |
21 ## revcom the read mapped to the reverse strand | |
22 if($f[1]=~/r/) | |
23 { | |
24 my $seq=Bio::Seq->new(-seq=>$f[9]); | |
25 $f[9]=$seq->revcom->seq; | |
26 $f[10]=reverse $f[10]; | |
27 } | |
28 if (($rnum == 1) || ($rnum == 2)) | |
29 { | |
30 ${$pe{$f[0]}}[$rnum-1]=[$xt,$f[9],$f[10]]; | |
31 } | |
32 } | |
33 close in; | |
34 | |
35 foreach my $id (keys %pe) | |
36 { | |
37 my @rid=@{$pe{$id}}; | |
38 if (($rid[0][1] ne "") && ($rid[1][1] ne "") && (($rid[0][0] eq "U" || $rid[1][0] eq "U"))) | |
39 { | |
40 print m2 "@"."$id/2","\n",$rid[1][1],"\n","+$id/2","\n",$rid[1][2],"\n"; | |
41 print m1 "@"."$id/1","\n",$rid[0][1],"\n","+$id/1","\n",$rid[0][2],"\n"; | |
42 } | |
43 } | |
44 close m1; | |
45 close m2; |