Bugfix for shadow BCFs to not attempt to write to /dev/null.bcf

This commit is contained in:
Mark DePristo 2012-06-22 11:32:18 -04:00
parent 6e9a81aabe
commit 7dbba465ee
2 changed files with 12 additions and 5 deletions

View File

@ -107,8 +107,10 @@ public class VariantContextWriterStorage implements Storage<VariantContextWriter
// TODO -- remove me when argument generateShadowBCF is removed
if ( stub.alsoWriteBCFForTest() && ! VariantContextWriterFactory.isBCFOutput(file, options)) {
final File bcfFile = BCF2Utils.shadowBCF(file);
VariantContextWriter bcfWriter = VariantContextWriterFactory.create(bcfFile, stub.getMasterSequenceDictionary(), options);
writer = new TestWriter(writer, bcfWriter);
if ( bcfFile != null ) {
VariantContextWriter bcfWriter = VariantContextWriterFactory.create(bcfFile, stub.getMasterSequenceDictionary(), options);
writer = new TestWriter(writer, bcfWriter);
}
}
return writer;

View File

@ -200,8 +200,11 @@ public final class BCF2Utils {
* foo.vcf => 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)")