Skip to content

Commit

Permalink
feat(bwamem2): Remove samtools view
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Aug 21, 2020
1 parent c8aed46 commit e4147b7
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions lib/MIP/Recipes/Analysis/Bwa_mem.pm
Expand Up @@ -25,7 +25,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.26;
our $VERSION = 1.27;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_bwa_mem analysis_bwa_mem2 analysis_run_bwa_mem };
Expand Down Expand Up @@ -573,6 +573,7 @@ sub analysis_bwa_mem2 {
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Bwa qw{ bwa_mem2_mem };
use MIP::Program::Gnu::Coreutils qw{ gnu_rm };
use MIP::Program::Samtools
qw{ samtools_index samtools_stats samtools_sort samtools_view };
use MIP::Sample_info qw{
Expand Down Expand Up @@ -735,8 +736,8 @@ sub analysis_bwa_mem2 {
## Add missing "@RG"
$rg_header_line =
$DOUBLE_QUOTE . q{@RG} . q{\t} . $rg_header_line . $DOUBLE_QUOTE;
my $samtools_view_outfile_path =
$outfile_path_prefix . $UNDERSCORE . q{mem} . $outfile_suffix;
my $bwa_mem_outfile_path =
$outfile_path_prefix . $UNDERSCORE . q{mem} . $DOT . q{sam};

# Prior to ALTs in reference genome
bwa_mem2_mem(
Expand All @@ -749,37 +750,21 @@ sub analysis_bwa_mem2 {
read_group_header => $rg_header_line,
soft_clip_sup_align => $active_parameter_href->{bwa_soft_clip_sup_align},
second_infile_path => $second_fastq_file_path,
stdoutfile_path => $bwa_mem_outfile_path,
thread_number => $recipe_resource{core_number},
}
);

# Pipe SAM to BAM conversion of aligned reads
print {$filehandle} $PIPE . $SPACE;

samtools_view(
{
auto_detect_input_format => 1,
filehandle => $filehandle,
infile_path => q{-},
outfile_path => $samtools_view_outfile_path,
thread_number => $recipe_resource{core_number},
uncompressed_bam_output => $uncompressed_bam_output,
with_header => 1,
}
);
say {$filehandle} $NEWLINE;

## Set samtools sort input; Pipe from samtools view
my $samtools_sort_infile = $samtools_view_outfile_path;

## Increment paired end tracker
$paired_end_tracker++;

## Sort the output from bwa mem
samtools_sort(
{
filehandle => $filehandle,
infile_path => $samtools_sort_infile,
infile_path => $bwa_mem_outfile_path,
outfile_path => $outfile_path,
output_format => $output_format,
temp_file_path_prefix =>
Expand Down Expand Up @@ -817,6 +802,14 @@ sub analysis_bwa_mem2 {
}
);
say {$filehandle} $AMPERSAND . $NEWLINE;

gnu_rm(
{
filehandle => $filehandle,
infile_path => $bwa_mem_outfile_path,
}
);
say {$filehandle} $AMPERSAND . $NEWLINE;
}
say {$filehandle} q{wait} . $NEWLINE;

Expand Down

0 comments on commit e4147b7

Please sign in to comment.