Fix exception when writing gVCF to stdout

This commit is contained in:
Ron Levine 2015-12-29 15:02:42 -05:00
parent 7089824e1b
commit aa5e88a393
2 changed files with 18 additions and 3 deletions

View File

@ -104,6 +104,7 @@ import org.broadinstitute.gatk.utils.sam.GATKSAMRecord;
import org.broadinstitute.gatk.utils.sam.ReadUtils; import org.broadinstitute.gatk.utils.sam.ReadUtils;
import org.broadinstitute.gatk.utils.variant.*; import org.broadinstitute.gatk.utils.variant.*;
import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.*; import java.util.*;
@ -1245,10 +1246,15 @@ public class HaplotypeCaller extends ActiveRegionWalker<List<VariantContext>, In
/** /**
* Is writing to an output GVCF file? * Is writing to an output GVCF file?
* *
* @return true if the VCF output file has a .g.vcf or .g.vcf.gz extension * @return true if the VCF output file has a .g.vcf or .g.vcf.gz extension or if no output file
*/ */
private boolean isGVCF() { private boolean isGVCF() {
String fileName = ((VariantContextWriterStub) vcfWriter).getOutputFile().getName(); final File file = ((VariantContextWriterStub) vcfWriter).getOutputFile();
return ( fileName.endsWith("." + GATKVCFUtils.GVCF_EXT) || fileName.endsWith("." + GATKVCFUtils.GVCF_GZ_EXT) ); if ( file == null ){
return true;
} else {
final String fileName = file.getName();
return ( fileName.endsWith("." + GATKVCFUtils.GVCF_EXT) || fileName.endsWith("." + GATKVCFUtils.GVCF_GZ_EXT) );
}
} }
} }

View File

@ -368,6 +368,15 @@ public class HaplotypeCallerIntegrationTest extends WalkerTest {
executeTest("testGraphBasedNoSuchEdgeBugFix", spec); executeTest("testGraphBasedNoSuchEdgeBugFix", spec);
} }
@Test
public void testWriteGVCFStdout() {
final String commandLine = String.format("-T HaplotypeCaller -R %s -I %s -L %s -dontTrimActiveRegions -ERC GVCF ",
b37KGReferenceWithDecoy, privateTestDir + "graphbased_no_such_edge_bug.bam", privateTestDir + "graphbased_no_such_edge_bug.intervals.bed");
final WalkerTestSpec spec = new WalkerTestSpec(commandLine, Arrays.asList(""));
spec.disableShadowBCF();
executeTest("testWriteGVCFStdout", spec);
}
// This test takes longer than 15 secs ... ~ 25-35 , // This test takes longer than 15 secs ... ~ 25-35 ,
@Test @Test
public void testLackSensitivityDueToBadHaplotypeSelectionFix() { public void testLackSensitivityDueToBadHaplotypeSelectionFix() {