diff scripts/pickClippedFastq.pl @ 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 28d1a6f8143f
children
line wrap: on
line diff
--- a/scripts/pickClippedFastq.pl	Wed Oct 26 07:24:45 2016 -0400
+++ b/scripts/pickClippedFastq.pl	Mon Dec 05 09:58:47 2016 -0500
@@ -38,7 +38,7 @@
     my $upper=$a[2]+15;
     if (($lower > 0)&&($upper > 0))
     {
-	system("samtools view -hXf 0x2 $ARGV[0].sorted.bam $a[0]\:$lower\-$upper > temp.sam");
+	system("samtools view -hf 0x2 $ARGV[0].sorted.bam $a[0]\:$lower\-$upper > temp.sam");
 	
 	open in,"temp.sam";
 	my %pe1;
@@ -48,7 +48,9 @@
 	    chomp;
 	    my @f=split/\t/,$_,12;
 	    ## read number 1 or 2
-	    my ($rnum)=$f[1]=~/(\d)$/;
+	    #my ($rnum)=$f[1]=~/(\d)$/;
+	    my $rnum=1;
+	    if (($f[1] & 128) == 128) {$rnum=2;}
 	    
 	    ## XT:A:* 
 	    my ($xt)=$f[11]=~/XT:A:(.)/;
@@ -62,7 +64,7 @@
 		my $clipseq="";
 		my @z=split(/M/, $f[5]);
 		
-		if (($f[5]=~/S$/)&&($f[1]=~/r/))
+		if (($f[5]=~/S$/)&&(($f[1] & 16) == 16))
 		{
 		    my (@cigar_m)=$f[5]=~/(\d+)M/g;
 		    my (@cigar_d)=$f[5]=~/(\d+)D/g;
@@ -79,7 +81,7 @@
 		    }
 		}
 
-                elsif (($f[1]=~/R/)&&($z[0]=~/S/))
+                elsif ((($f[1] & 32) == 32)&&($z[0]=~/S/))
                 {
                     $coor=$f[3]; $strand="+";
 
@@ -121,7 +123,9 @@
         {
             chomp;
             my @f=split/\t/,$_,12;
-            my ($rnum)=$f[1]=~/(\d)$/;
+            #my ($rnum)=$f[1]=~/(\d)$/;
+	    my $rnum=1;
+	    if (($f[1] & 128) == 128) {$rnum=2;}
             my ($xt)=$f[11]=~/XT:A:(.)/;
 
             if ($f[5]=~/S/) {
@@ -132,7 +136,7 @@
                 my $clipseq="";
                 my @z=split(/M/, $f[5]);
 
-                if (($f[5]=~/S$/)&&($f[1]=~/r/))
+                if (($f[5]=~/S$/)&&(($f[1] & 16) == 16))
                 {
                     my (@cigar_m)=$f[5]=~/(\d+)M/g;
                     my (@cigar_d)=$f[5]=~/(\d+)D/g;
@@ -149,7 +153,7 @@
                     }
                 }
 
-                elsif (($f[1]=~/R/)&&($z[0]=~/S/))
+                elsif ((($f[1] & 32) == 32)&&($z[0]=~/S/))
                 {
                     $coor=$f[3]; $strand="+";