diff --git a/public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java b/public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java index d0fdae639..fb05a6b04 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java +++ b/public/java/src/org/broadinstitute/sting/gatk/io/storage/VariantContextWriterStorage.java @@ -107,8 +107,10 @@ public class VariantContextWriterStorage implements Storage foo.bcf * foo.xxx => foo.xxx.bcf * + * If the resulting BCF file cannot be written, return null. Happens + * when vcfFile = /dev/null for example + * * @param vcfFile - * @return + * @return the BCF */ @Requires("vcfFile != null") @Ensures("result != null") @@ -209,8 +212,10 @@ public final class BCF2Utils { final String path = vcfFile.getAbsolutePath(); if ( path.contains(".vcf") ) return new File(path.replace(".vcf", ".bcf")); - else - return new File( path + ".bcf" ); + else { + final File bcf = new File( path + ".bcf" ); + return bcf.canWrite() ? bcf : null; + } } @Ensures("BCF2Type.INTEGERS.contains(result)")