Skip to content

Commit

Permalink
Merge pull request #20 from cancerit/dev
Browse files Browse the repository at this point in the history
Corrected header vs command line checks
  • Loading branch information
David Jones committed Feb 13, 2015
2 parents 9bc19d8 + fbbb445 commit d6234fa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion MYMETA.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
}
},
"release_status" : "stable",
"version" : "v1.3.1"
"version" : "v1.4.0"
}
2 changes: 1 addition & 1 deletion MYMETA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ requires:
Pod::Coverage: '0.23'
Test::Fatal: '0.013'
Try::Tiny: '0.19'
version: v1.3.1
version: v1.4.0
38 changes: 17 additions & 21 deletions bin/caveman.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BEGIN
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 $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};

const my @VALID_PROTOCOLS => qw(WGS WXS RNA);
const my $DEFAULT_PROTOCOL => 'WGS';
Expand Down Expand Up @@ -204,33 +205,26 @@ sub cleanup{

sub getSpeciesAssemblyFromBam{
my ($opts) = @_;
my ($species,$assembly) = undef;
my $bam = Bio::DB::Sam->new(-bam =>$opts->{'tumbam'});
my $head = $bam->header->text;
my @split_head = split(/\n/,$head);
foreach my $line(@split_head){
if($line =~ m/^\@SQ/){
$assembly = $line =~ /AS:([^\t]+)/;
$species = $line =~ /SP:([^\t]+)/;
if($line =~ /AS:([^\t]+)/) {
my $assembly = $1;
warn sprintf $SP_ASS_MESSAGE, 'Assembly', $opts->{'species-assembly'}, $assembly
if(defined $opts->{'species-assembly'} && $opts->{'species-assembly'} ne $assembly);
$opts->{'species-assembly'} = $assembly;
}
if($line =~ /SP:([^\t]+)/) {
my $species = $1;
warn sprintf $SP_ASS_MESSAGE, 'Species', $opts->{'species'}, $species
if(defined $opts->{'species'} && $opts->{'species'} ne $species);
$opts->{'species'} = $species;
}
last;
}
}
if(defined($opts->{'species'})){
if(defined($species)){
warn "Species defined at commandline (".$opts->{'species'}.") does not match that in the BAM file ($species). Defaulting to BAM file valie.\n" if($species ne $opts->{'species'});
}else{
$species = $opts->{'species'};
}
}
if(defined($opts->{'species-assembly'})){
if(defined($assembly)){
warn "Assembly defined at commandline (".$opts->{'species-assembly'}.") does not match that in the BAM file ($assembly). Defaulting to BAM file valie.\n" if($assembly ne $opts->{'species-assembly'});
}else{
$species = $opts->{'species-assembly'};
}
}
$opts->{'species'} = $species;
$opts->{'species-assembly'} = $assembly;
return;
}

Expand All @@ -256,6 +250,7 @@ sub setup {
'i|index=i' => \$opts{'index'},
'l|limit=i' => \$opts{'limit'},
'b|flag-bed-files=s' => \$opts{'flag-bed'},
'ab|annot-bed-files=s' => \$opts{'annot-bed'},
'in|germline-indel=s' => \$opts{'germindel'},
'u|unmatched-vcf=s' => \$opts{'unmatchedvcf'},
'np|normal-protocol=s' => \$opts{'normprot'},
Expand Down Expand Up @@ -301,8 +296,8 @@ sub setup {
#Get bam header, species/assembly
getSpeciesAssemblyFromBam(\%opts);

pod2usage(-msg => "\nERROR: 'species' must be defined, see BAM header /options.\n", -verbose => 2, -output => \*STDERR) unless(defined $opts{'species'});
pod2usage(-msg => "\nERROR: 'species-assembly' must be defined, see BAM header /options.\n", -verbose => 2, -output => \*STDERR) unless(defined $opts{'species-assembly'});
pod2usage(-msg => "\nERROR: 'species' must be defined, see BAM header options.\n", -verbose => 2, -output => \*STDERR) unless(defined $opts{'species'});
pod2usage(-msg => "\nERROR: 'species-assembly' must be defined, see BAM header options.\n", -verbose => 2, -output => \*STDERR) unless(defined $opts{'species-assembly'});
pod2usage(-msg => "\nERROR: 'seqType' must be defined.\n", -verbose => 2, -output => \*STDERR) unless(defined $opts{'seqType'});

#check the reference is the fasta fai file.
Expand Down Expand Up @@ -453,6 +448,7 @@ =head1 SYNOPSIS
-tumour-protocol -tp Tumour protocol [WGS|WXS|RNA] (default WGS)
-tum-cn-default -td Default tumour CN to use with gaps or no file provided
-norm-cn-default -nd Default normal CN to use with gaps or no file provided
-annot-bed-files -ab Annotation BED files - required for pulldown/WXS
Optional flagging parameters: [default to those found in cgpCaVEManPostProcessing]
-flagConfig -c Config ini file to use for flag list and settings
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.3.1';
our $VERSION = '1.4.0';

1;
4 changes: 4 additions & 0 deletions lib/Sanger/CGP/Caveman/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ sub caveman_flag{
);
$flag .= ' -c '.$options->{'flagConfig'} if(defined $options->{'flagConfig'});
$flag .= ' -v '.$options->{'flagToVcfConfig'} if(defined $options->{'flagToVcfConfig'});
if($options->{'seqType'} eq 'pulldown') {
die "ERROR: Pulldown flagging requires annotation BED files" unless(defined $options->{'annot-bed'});
$flag .= ' -ab '.$options->{'annot-bed'};
}

my $vcf_gz = $flagged.'.gz';
my $bgzip = _which('bgzip');
Expand Down

0 comments on commit d6234fa

Please sign in to comment.