diff bin/align.pm @ 19:39b039d82743 draft

Uploaded
author romaingred
date Thu, 19 Oct 2017 04:39:33 -0400
parents 42bc59c7db3a
children 08bbde9d0c9d
line wrap: on
line diff
--- a/bin/align.pm	Thu Oct 19 04:39:18 2017 -0400
+++ b/bin/align.pm	Thu Oct 19 04:39:33 2017 -0400
@@ -302,14 +302,16 @@
 sub sam_to_bam_bg
 {
 	my ( $sam, $scale, $number_of_cpus ) = @_;
-	my ( $bam_sorted, $bedgraphM, $bedgraphP ) = ( '', '', '' );
+	my ( $bam_sorted, $bedgraphM, $bedgraphP, $view_err, $sort_err ) = ( '', '', '', '', '' );
 	if ( $sam =~ /(.*?).sam$/ )
 	{
 		$bam_sorted = $1.'_sorted.bam';
 		$bedgraphP= $1.'_plus.bedgraph';
 		$bedgraphM = $1.'_minus.bedgraph';
+		$view_err = $1.'_view.err';
+		$sort_err = $1.'_sort.err';
 	}	
-	`samtools view -Shb   --threads $number_of_cpus $sam | samtools sort  -O BAM --threads $number_of_cpus  /dev/stdin  > $bam_sorted`;
+	`samtools view -Shb   --threads $number_of_cpus $sam 2> $view_err | samtools sort  -O BAM --threads $number_of_cpus  /dev/stdin 2> $sort_err  > $bam_sorted`;
 	`bedtools genomecov -scale $scale -strand + -bga -ibam $bam_sorted > $bedgraphP`;	
 	`bedtools genomecov -scale $scale -strand - -bga -ibam $bam_sorted > $bedgraphM`;
 }
@@ -317,12 +319,15 @@
 sub sam_sorted_bam
 {
 	my ( $sam, $number_of_cpus ) = @_;
-	my $bam_sorted ='';
+	my ( $bam_sorted, $view_err, $sort_err ) = ( '', '', '' );
 	if ( $sam =~ /(.*?).sam$/ )
 	{
 		$bam_sorted = $1.'_sorted.bam';
+		$view_err = $1.'_view.err';
+		$sort_err = $1.'_sort.err';
+
 	}
-	`samtools view -Shb   --threads $number_of_cpus $sam | samtools sort  -O BAM --threads $number_of_cpus  /dev/stdin  > $bam_sorted`;
+	`samtools view -Shb   --threads $number_of_cpus $sam 2> $view_err | samtools sort  -O BAM --threads $number_of_cpus  /dev/stdin  2> $sort_err  > $bam_sorted`;
 }
 
 sub BWA_call
@@ -401,7 +406,7 @@
         $arn =reverse($arn);
         $arn =~ tr/atgcuATGCU/tacgaTACGA/;
       }
-      #&& $line[11] eq "XT:A:U" )
+
       if  ( ( $line[1] == 16 || $line[1] == 0 ) )
 			{
       	print $f_out "\@".$line[0]."\n".$arn."\n+\n".$line[10]."\n" ;