Skip to content

Commit

Permalink
Merge branch 'hotfix/v3.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranmraine committed Nov 22, 2018
2 parents 41fa2a9 + a1be7c2 commit 1850681
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGES

## 3.0.4

Output bug for pindel BAM/CRAM corrected. When more than 1 chr in output files had no reads.

## 3.0.3

Changes to how germline filter determined resulted in dummy germline bed file not being generated as previously.
Expand Down
2 changes: 1 addition & 1 deletion perl/bin/pindel_merge_vcf_bam.pl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sub setup {
push @{$opts{'vcf'}}, $file;
}
elsif($file =~ m/_([mw]t)\.sam(.gz)?$/) {
next if($file =~ m/^FINAL_MERGED\.sam$/); # this is transient for each type
next if($file =~ m/^FINAL_MERGED\.sam.gz$/); # this is transient for each type
push @{$opts{$1}}, $file;
}
}
Expand Down
Binary file modified perl/docs.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion perl/lib/Sanger/CGP/Pindel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use strict;
use Const::Fast qw(const);

use base 'Exporter';
our $VERSION = '3.0.3';
our $VERSION = '3.0.4';
our @EXPORT = qw($VERSION);

1;
4 changes: 3 additions & 1 deletion perl/lib/Sanger/CGP/Pindel/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ sub fragmented_files {
my $file_count = scalar @{$files};
return $files if($file_count <= 100);
warn "Extreme number of files, slow merging of $file_count files required\n";
my $grep_non_header = qq{zgrep -v '^$hprefix' %s >> %s};
my $extra = ' | gzip -c ';
$extra = q{} if($outfile =~ m/vcf$/);
my $grep_non_header = qq{zgrep -v '^$hprefix' %s $extra >> %s};
my $header_count;

my $merged_file = $base_dir.$outfile;
Expand Down
25 changes: 21 additions & 4 deletions perl/lib/Sanger/CGP/Pindel/OutputGen/BamUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const my $BAMSORT => ' inputformat=%s outputformat=%s reference=%s | tee %s | md

sub sam_to_sorted_bam {
my ($path_prefix, $base_dir, $sam_files, $as_cram, $as_csi, $ref) = @_;
$sam_files = Sanger::CGP::Pindel::Implement::fragmented_files($base_dir, $sam_files, '@', 'FINAL_MERGED.sam');
$sam_files = Sanger::CGP::Pindel::Implement::fragmented_files($base_dir, $sam_files, '@', 'FINAL_MERGED.sam.gz');
update_header_when_no_reads($base_dir, $sam_files);
my $aln_fmt = 'bam';
my $idx_fmt = 'bai';
Expand All @@ -60,13 +60,24 @@ sub sam_to_sorted_bam {
my $aln_idx = $aln_out.'.'.$idx_fmt;
my $aln_md5 = $aln_out.'.md5';
my $command = q{};
$command .= "cd $base_dir; " unless($sam_files->[0] =~ m/FINAL_MERGED[.]sam$/);
$command .= sprintf ' zcat %s | ', join q{ }, @{$sam_files};
if($sam_files->[0] =~ m/FINAL_MERGED[.]sam.gz$/) {
$command .= sprintf ' zcat %s | ', $sam_files->[0];
}
else {
my $first_file = shift @{$sam_files};
$command .= "cd $base_dir; ";
$command .= sprintf q{ (zcat %s ; zgrep -v '^@' %s) | }, $first_file, join q{ }, @{$sam_files};
}

$command .= which('bamsort');
$command .= sprintf $BAMSORT, 'sam', $aln_fmt, $ref, $aln_out, $aln_md5;

$command = sprintf q{bash -c "set -o pipefail; %s"}, $command;
warn "running: $command";
system($command);

$command = sprintf 'samtools index %s %s %s', $idx_switch, $aln_out, $aln_idx;
warn "running: $command";
system($command);

return 1;
Expand All @@ -75,7 +86,13 @@ sub sam_to_sorted_bam {
sub update_header_when_no_reads {
my ($base_dir, $sam_files) = @_;
for my $sam_file (@{$sam_files}) {
my $sam = $base_dir.$sam_file;
my $sam;
if($sam_file =~ m/FINAL_MERGED[.]sam.gz$/) {
$sam = $sam_file
}
else {
$sam = $base_dir.$sam_file;
}
my @header;
my $has_records = 0;
open my $IN, '<:gzip', $sam || die $!;
Expand Down

0 comments on commit 1850681

Please sign in to comment.