Mercurial > repos > portiahollyoak > temp
comparison scripts/pickUniqPairFastq.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 | |
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], -alphabet => 'dna'); | |
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; |