Skip to content

Commit

Permalink
Merge branch 'release/1.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
David Jones committed Feb 4, 2016
2 parents db0c84d + 30904b8 commit ef08c43
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 19 deletions.
39 changes: 31 additions & 8 deletions bin/caveman.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ BEGIN
const my $IDS_SNPS => q{%s.snps.ids.vcf};
const my $IDS_SNPS_GZ => q{%s.snps.ids.vcf.gz};
const my $IDS_SNPS_TBI => q{%s.snps.ids.vcf.gz.tbi};
const my $IDS_MUTS_GZ => q{%s.muts.ids.vcf.gz};
const my $IDS_MUTS_TBI => q{%s.muts.ids.vcf.gz.tbi};
const my $NO_ANALYSIS => q{%s.no_analysis.bed};
const my $SP_ASS_MESSAGE => qq{%s defined at commandline (%s) does not match that in the BAM file (%s). Defaulting to BAM file value.\n};

Expand Down Expand Up @@ -161,13 +163,22 @@ BEGIN
}

#Flag the results.
if(!exists $options->{'process'} || $options->{'process'} eq 'flag'){
if((!exists $options->{'process'} || $options->{'process'} eq 'flag')
&& (!defined $options->{'noflag'} || $options->{'noflag'} != 1)){
$options->{'for_flagging'} = $options->{'ids_muts_file'};
$options->{'flagged'} = sprintf($FLAGGED_MUTS,$options->{'out_file'});
Sanger::CGP::Caveman::Implement::caveman_flag($options);
#finally cleanup after ourselves by removing the temporary output folder, split files etc.
cleanup($options);
}

if((!exists $options->{'process'}) #We aren't specifying steps
|| ($options->{'process'} eq 'flag') #We've flagged so we are done anyway
|| (defined $options->{'noflag'} && $options->{'noflag'} == 1 && $options->{'process'} eq 'add_ids')){ #No flagging wanted and preflagging step done
#finally cleanup after ourselves by removing the temporary output folder, split files etc.
#TODO Zip the snps files with IDs
Sanger::CGP::Caveman::Implement::pre_cleanup_zip($options);
cleanup($options);
}

}

sub cleanup{
Expand All @@ -187,16 +198,22 @@ sub cleanup{
move (sprintf($NO_ANALYSIS,$options->{'out_file'}),sprintf($NO_ANALYSIS,$final_loc))
|| die "Error trying to move no analysis file '".sprintf($NO_ANALYSIS,$options->{'out_file'})."' -> '".sprintf($NO_ANALYSIS,$final_loc)."': $!";

move (sprintf($IDS_MUTS_GZ,$options->{'out_file'}),sprintf($IDS_MUTS_GZ,$final_loc))
|| die "Error trying to move raw SNPs file '".sprintf($IDS_MUTS_GZ,$options->{'out_file'})."' -> '".sprintf($IDS_MUTS_GZ,$final_loc)."': $!";
move (sprintf($IDS_MUTS_TBI,$options->{'out_file'}),sprintf($IDS_MUTS_TBI,$final_loc))
|| die "Error trying to move raw SNPs file '".sprintf($IDS_MUTS_TBI,$options->{'out_file'})."' -> '".sprintf($IDS_MUTS_TBI,$final_loc)."': $!";

move (sprintf($IDS_SNPS_GZ,$options->{'out_file'}),sprintf($IDS_SNPS_GZ,$final_loc))
|| die "Error trying to move raw SNPs file '".sprintf($IDS_SNPS_GZ,$options->{'out_file'})."' -> '".sprintf($IDS_SNPS_GZ,$final_loc)."': $!";
move (sprintf($IDS_SNPS_TBI,$options->{'out_file'}),sprintf($IDS_SNPS_TBI,$final_loc))
|| die "Error trying to move raw SNPs file '".sprintf($IDS_SNPS_TBI,$options->{'out_file'})."' -> '".sprintf($IDS_SNPS_TBI,$final_loc)."': $!";

move (sprintf($FLAGGED_MUTS_GZ,$options->{'out_file'}),sprintf($FLAGGED_MUTS_GZ,$final_loc))
|| die "Error trying to move flagged muts file '".sprintf($FLAGGED_MUTS_GZ,$options->{'out_file'})."' -> '".sprintf($FLAGGED_MUTS_GZ,$final_loc)."': $!";
move (sprintf($FLAGGED_MUTS_TBI,$options->{'out_file'}),sprintf($FLAGGED_MUTS_TBI,$final_loc))
|| die "Error trying to move flagged muts file '".sprintf($FLAGGED_MUTS_TBI,$options->{'out_file'})."' -> '".sprintf($FLAGGED_MUTS_TBI,$final_loc)."': $!";

if(defined($options->{'noflag'}) && $options->{'noflag'} != 1 ){
move (sprintf($FLAGGED_MUTS_GZ,$options->{'out_file'}),sprintf($FLAGGED_MUTS_GZ,$final_loc))
|| die "Error trying to move flagged muts file '".sprintf($FLAGGED_MUTS_GZ,$options->{'out_file'})."' -> '".sprintf($FLAGGED_MUTS_GZ,$final_loc)."': $!";
move (sprintf($FLAGGED_MUTS_TBI,$options->{'out_file'}),sprintf($FLAGGED_MUTS_TBI,$final_loc))
|| die "Error trying to move flagged muts file '".sprintf($FLAGGED_MUTS_TBI,$options->{'out_file'})."' -> '".sprintf($FLAGGED_MUTS_TBI,$final_loc)."': $!";
}
move ($options->{'logs'},File::Spec->catdir($options->{'outdir'},'logs'))
|| die "Error trying to move logs directory '$options->{logs}' -> '".File::Spec->catdir($options->{'outdir'},'logs')."': $!";

Expand Down Expand Up @@ -267,6 +284,7 @@ sub setup {
'NP|normal-platform=s' => \$opts{'tplat'},
'TP|tumour-platform=s' => \$opts{'nplat'},
'st|seqType=s' => \$opts{'seqType'},
'noflag|no-flagging' => \$opts{'noflag'},
) or pod2usage(2);

pod2usage(-verbose => 1) if(defined $opts{'h'});
Expand Down Expand Up @@ -485,6 +503,7 @@ =head1 SYNOPSIS
-prior-snp-probability -ps Prior germline mutant probability
-normal-platform -NP Normal platform to override bam value
-tumour-platform -TP Tumour platform to override bam value
-no-flagging -noflag Do not flag, instead cleanup at the end of the merged results after estep.
Optional flagging parameters: [default to those found in cgpCaVEManPostProcessing]
-flagConfig -c Config ini file to use for flag list and settings
Expand Down Expand Up @@ -603,6 +622,10 @@ =head1 OPTIONS
Tumour platform to override bam value
=item B<-no-flagging>
Don't flag the data, just cleanup after merging results
=item B<-help>
Print a brief help message and exits.
Expand Down
Binary file modified docs.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/Sanger/CGP/Caveman.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ package Sanger::CGP::Caveman;
use strict;
use Const::Fast qw(const);

our $VERSION = '1.8.1';
our $VERSION = '1.9.0';

1;
31 changes: 25 additions & 6 deletions lib/Sanger/CGP/Caveman/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,45 @@ sub caveman_flag{
$flag .= ' -p '.$options->{'apid'} if(defined $options->{'apid'});
if($options->{'seqType'} eq 'pulldown') {
die "ERROR: Pulldown flagging requires annotation BED files" unless(defined $options->{'annot-bed'});
$flag .= ' -ab '.$options->{'annot-bed'};
}
$flag .= ' -ab '.$options->{'annot-bed'}; }

my $vcf_gz = $flagged.'.gz';
my $bgzip = _which('bgzip');
$bgzip .= sprintf ' -c %s > %s', $flagged, $vcf_gz;

my $tabix = _which('tabix');
$tabix .= sprintf ' -p vcf %s', $vcf_gz;


my @commands = ($flag, $bgzip, $tabix);

PCAP::Threaded::external_process_handler(File::Spec->catdir($tmp, 'logs'), \@commands, 0);
return PCAP::Threaded::touch_success(File::Spec->catdir($tmp, 'progress'), 0);
}

sub pre_cleanup_zip {
# uncoverable subroutine
my $options = shift;
my $tmp = $options->{'tmp'};

return 1 if PCAP::Threaded::success_exists(File::Spec->catdir($tmp, 'progress'), 0);

my $vcf_muts_gz = $options->{'ids_muts_file'}.'.gz';
my $bgzip_muts = _which('bgzip');
$bgzip_muts .= sprintf ' -c %s > %s', $options->{'ids_muts_file'}, $vcf_muts_gz;

my $tabix_muts = _which('tabix');
$tabix_muts .= sprintf ' -p vcf %s', $vcf_muts_gz;

my $vcf_snps_gz = $options->{'ids_snps_file'}.'.gz';
my $bgzip_snps = _which('bgzip');
$bgzip_snps .= sprintf ' -c %s > %s', $options->{'ids_snps_file'}, $vcf_snps_gz;

my $tabix_snps = _which('tabix');
$tabix_snps .= sprintf ' -p vcf %s', $vcf_snps_gz;

my @commands = ($flag, $bgzip, $tabix, $bgzip_snps, $tabix_snps);

PCAP::Threaded::external_process_handler(File::Spec->catdir($tmp, 'logs'), \@commands, 0);
my @commands = ($bgzip_muts, $tabix_muts, $bgzip_snps, $tabix_snps);

PCAP::Threaded::external_process_handler(File::Spec->catdir($tmp, 'logs'), \@commands, 0);
return PCAP::Threaded::touch_success(File::Spec->catdir($tmp, 'progress'), 0);
}

Expand Down
5 changes: 1 addition & 4 deletions prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


set -eu # exit on first error or undefined value in subtitution
set -o pipefail

# get current directory
INIT_DIR=`pwd`
Expand All @@ -47,10 +48,6 @@ export HARNESS_PERL_SWITCHES=-MDevel::Cover=-db,reports,-ignore,'t/.*\.t'
rm -rf docs
mkdir -p docs/reports_text
prove --nocolor -I ./lib | sed 's/^/ /' # indent output of prove
if [[ $? -ne 0 ]] ; then
echo "\n\tERROR: TESTS FAILED\n"
exit 1
fi

echo '### Generating test/pod coverage reports ###'
# removed 'condition' from coverage as '||' 'or' doesn't work properly
Expand Down

0 comments on commit ef08c43

Please sign in to comment.