Skip to content

Commit

Permalink
Gracefully handle empty VCFs
Browse files Browse the repository at this point in the history
  • Loading branch information
ckandoth committed Nov 13, 2016
1 parent c366af2 commit c507ea3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vcf2maf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ sub GetBiotypePriority {

# samtools runs faster when passed many loci at a time, but limited to around 125k args, at least
# on CentOS 6. If there are too many loci, split them into 100k chunks and run separately
my ( $lines, @regions_split );
my ( $lines, @regions_split ) = ( "", ());
my @regions = keys %uniq_regions;
my $chr_prefix_in_use = ( $regions[0] =~ m/^chr/ ? 1 : 0 );
my $chr_prefix_in_use = ( @regions and $regions[0] =~ m/^chr/ ? 1 : 0 );
push( @regions_split, [ splice( @regions, 0, 100000 ) ] ) while @regions;
map{ my $region = join( " ", @{$_} ); $lines .= `$samtools faidx $ref_fasta $region` } @regions_split;
foreach my $line ( grep( length, split( ">", $lines ))) {
Expand All @@ -324,7 +324,8 @@ sub GetBiotypePriority {

# If flanking_bps is entirely empty, then it's most likely that the user chose the wrong ref-fasta
# Or it's also possible that an outdated samtools was unable to parse the gzipped FASTA files
( %flanking_bps ) or die "ERROR: You're either using an outdated samtools, or --ref-fasta is not the same genome build as your --input-vcf.";
# ::NOTE:: If input had no variants, don't break here, so we can continue to create an empty MAF
( !@regions or %flanking_bps ) or die "ERROR: You're either using an outdated samtools, or --ref-fasta is not the same genome build as your --input-vcf.";

# Skip filtering if not handling GRCh37, and filter-vcf is pointing to the default GRCh37 ExAC VCF
if( $ncbi_build eq "GRCh37" or ( $filter_vcf and $filter_vcf ne "$ENV{HOME}/.vep/ExAC_nonTCGA.r0.3.1.sites.vep.vcf.gz" )) {
Expand Down

0 comments on commit c507ea3

Please sign in to comment.