Bugfix for shadow BCFs to not attempt to write to /dev/null.bcf
This commit is contained in:
parent
6e9a81aabe
commit
7dbba465ee
|
|
@ -107,8 +107,10 @@ public class VariantContextWriterStorage implements Storage<VariantContextWriter
|
||||||
// TODO -- remove me when argument generateShadowBCF is removed
|
// TODO -- remove me when argument generateShadowBCF is removed
|
||||||
if ( stub.alsoWriteBCFForTest() && ! VariantContextWriterFactory.isBCFOutput(file, options)) {
|
if ( stub.alsoWriteBCFForTest() && ! VariantContextWriterFactory.isBCFOutput(file, options)) {
|
||||||
final File bcfFile = BCF2Utils.shadowBCF(file);
|
final File bcfFile = BCF2Utils.shadowBCF(file);
|
||||||
VariantContextWriter bcfWriter = VariantContextWriterFactory.create(bcfFile, stub.getMasterSequenceDictionary(), options);
|
if ( bcfFile != null ) {
|
||||||
writer = new TestWriter(writer, bcfWriter);
|
VariantContextWriter bcfWriter = VariantContextWriterFactory.create(bcfFile, stub.getMasterSequenceDictionary(), options);
|
||||||
|
writer = new TestWriter(writer, bcfWriter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return writer;
|
return writer;
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,11 @@ public final class BCF2Utils {
|
||||||
* foo.vcf => foo.bcf
|
* foo.vcf => foo.bcf
|
||||||
* foo.xxx => foo.xxx.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
|
* @param vcfFile
|
||||||
* @return
|
* @return the BCF
|
||||||
*/
|
*/
|
||||||
@Requires("vcfFile != null")
|
@Requires("vcfFile != null")
|
||||||
@Ensures("result != null")
|
@Ensures("result != null")
|
||||||
|
|
@ -209,8 +212,10 @@ public final class BCF2Utils {
|
||||||
final String path = vcfFile.getAbsolutePath();
|
final String path = vcfFile.getAbsolutePath();
|
||||||
if ( path.contains(".vcf") )
|
if ( path.contains(".vcf") )
|
||||||
return new File(path.replace(".vcf", ".bcf"));
|
return new File(path.replace(".vcf", ".bcf"));
|
||||||
else
|
else {
|
||||||
return new File( path + ".bcf" );
|
final File bcf = new File( path + ".bcf" );
|
||||||
|
return bcf.canWrite() ? bcf : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ensures("BCF2Type.INTEGERS.contains(result)")
|
@Ensures("BCF2Type.INTEGERS.contains(result)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue