Mercurial > repos > romaingred > pirna_pipeline
comparison bin/align.pm @ 19:39b039d82743 draft
Uploaded
author | romaingred |
---|---|
date | Thu, 19 Oct 2017 04:39:33 -0400 |
parents | 42bc59c7db3a |
children | 08bbde9d0c9d |
comparison
equal
deleted
inserted
replaced
18:fcaea740c23a | 19:39b039d82743 |
---|---|
300 } | 300 } |
301 | 301 |
302 sub sam_to_bam_bg | 302 sub sam_to_bam_bg |
303 { | 303 { |
304 my ( $sam, $scale, $number_of_cpus ) = @_; | 304 my ( $sam, $scale, $number_of_cpus ) = @_; |
305 my ( $bam_sorted, $bedgraphM, $bedgraphP ) = ( '', '', '' ); | 305 my ( $bam_sorted, $bedgraphM, $bedgraphP, $view_err, $sort_err ) = ( '', '', '', '', '' ); |
306 if ( $sam =~ /(.*?).sam$/ ) | 306 if ( $sam =~ /(.*?).sam$/ ) |
307 { | 307 { |
308 $bam_sorted = $1.'_sorted.bam'; | 308 $bam_sorted = $1.'_sorted.bam'; |
309 $bedgraphP= $1.'_plus.bedgraph'; | 309 $bedgraphP= $1.'_plus.bedgraph'; |
310 $bedgraphM = $1.'_minus.bedgraph'; | 310 $bedgraphM = $1.'_minus.bedgraph'; |
311 $view_err = $1.'_view.err'; | |
312 $sort_err = $1.'_sort.err'; | |
311 } | 313 } |
312 `samtools view -Shb --threads $number_of_cpus $sam | samtools sort -O BAM --threads $number_of_cpus /dev/stdin > $bam_sorted`; | 314 `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`; |
313 `bedtools genomecov -scale $scale -strand + -bga -ibam $bam_sorted > $bedgraphP`; | 315 `bedtools genomecov -scale $scale -strand + -bga -ibam $bam_sorted > $bedgraphP`; |
314 `bedtools genomecov -scale $scale -strand - -bga -ibam $bam_sorted > $bedgraphM`; | 316 `bedtools genomecov -scale $scale -strand - -bga -ibam $bam_sorted > $bedgraphM`; |
315 } | 317 } |
316 | 318 |
317 sub sam_sorted_bam | 319 sub sam_sorted_bam |
318 { | 320 { |
319 my ( $sam, $number_of_cpus ) = @_; | 321 my ( $sam, $number_of_cpus ) = @_; |
320 my $bam_sorted =''; | 322 my ( $bam_sorted, $view_err, $sort_err ) = ( '', '', '' ); |
321 if ( $sam =~ /(.*?).sam$/ ) | 323 if ( $sam =~ /(.*?).sam$/ ) |
322 { | 324 { |
323 $bam_sorted = $1.'_sorted.bam'; | 325 $bam_sorted = $1.'_sorted.bam'; |
324 } | 326 $view_err = $1.'_view.err'; |
325 `samtools view -Shb --threads $number_of_cpus $sam | samtools sort -O BAM --threads $number_of_cpus /dev/stdin > $bam_sorted`; | 327 $sort_err = $1.'_sort.err'; |
328 | |
329 } | |
330 `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`; | |
326 } | 331 } |
327 | 332 |
328 sub BWA_call | 333 sub BWA_call |
329 { | 334 { |
330 my ( $index, $fastq, $sam, $mismatches, $number_of_cpus, $report ) = @_; | 335 my ( $index, $fastq, $sam, $mismatches, $number_of_cpus, $report ) = @_; |
399 if ($line[1] & 16) | 404 if ($line[1] & 16) |
400 { | 405 { |
401 $arn =reverse($arn); | 406 $arn =reverse($arn); |
402 $arn =~ tr/atgcuATGCU/tacgaTACGA/; | 407 $arn =~ tr/atgcuATGCU/tacgaTACGA/; |
403 } | 408 } |
404 #&& $line[11] eq "XT:A:U" ) | 409 |
405 if ( ( $line[1] == 16 || $line[1] == 0 ) ) | 410 if ( ( $line[1] == 16 || $line[1] == 0 ) ) |
406 { | 411 { |
407 print $f_out "\@".$line[0]."\n".$arn."\n+\n".$line[10]."\n" ; | 412 print $f_out "\@".$line[0]."\n".$arn."\n+\n".$line[10]."\n" ; |
408 print $s_out $_ if defined ($hashRef); | 413 print $s_out $_ if defined ($hashRef); |
409 if ( $line[11] eq "XT:A:U" ) | 414 if ( $line[11] eq "XT:A:U" ) |