diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java index 3d3299053..4738f01c7 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCaller.java @@ -1204,9 +1204,10 @@ public class HaplotypeCaller extends ActiveRegionWalker, In /** * Is writing to an output GVCF file? * - * @return true if the VCF output file has a .g.vcf extension + * @return true if the VCF output file has a .g.vcf or .g.vcf.gz extension */ private boolean isGVCF() { - return ((VariantContextWriterStub) vcfWriter).getOutputFile().getName().endsWith("." + GATKVCFUtils.GVCF_EXT); + String fileName = ((VariantContextWriterStub) vcfWriter).getOutputFile().getName(); + return ( fileName.endsWith("." + GATKVCFUtils.GVCF_EXT) || fileName.endsWith("." + GATKVCFUtils.GVCF_GZ_EXT) ); } } diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java index 42c8c6285..6f5634b56 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/haplotypecaller/HaplotypeCallerGVCFIntegrationTest.java @@ -224,6 +224,18 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest { executeTest("testGVCFIndexNoThrow", spec); } + /** + * Test HaplotypeCaller to ensure it does not throw an exception when a .g.vcf.gz output file is specified and the indexing arguments are omitted + */ + @Test() + public void testGVCFGzIndexNoThrow() { + final String commandLine = String.format("-T HaplotypeCaller --pcr_indel_model NONE -pairHMMSub %s %s -R %s -I %s -L %s -ERC GVCF", + HMM_SUB_IMPLEMENTATION, ALWAYS_LOAD_VECTOR_HMM, b37KGReference, privateTestDir + "noCallRefModel.bam", "20:17000000-17000100"); + final WalkerTestSpec spec = new WalkerTestSpec(commandLine + " -o %s", Arrays.asList(GATKVCFUtils.GVCF_GZ_EXT), Arrays.asList("")); + spec.disableShadowBCF(); + executeTest("testGVCFIndexNoThrow", spec); + } + @Test() public void testWrongParameterGVCFIndexException() { final String commandLine = String.format("-T HaplotypeCaller --pcr_indel_model NONE -pairHMMSub %s %s -R %s -I %s -L %s -ERC GVCF -variant_index_type %s -variant_index_parameter %d", diff --git a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/GATKVCFUtils.java b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/GATKVCFUtils.java index da3763f1a..4d05d824e 100644 --- a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/GATKVCFUtils.java +++ b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/GATKVCFUtils.java @@ -69,8 +69,9 @@ public class GATKVCFUtils { public final static GATKVCFIndexType DEFAULT_GVCF_INDEX_TYPE = GATKVCFIndexType.LINEAR; public final static Integer DEFAULT_GVCF_INDEX_PARAMETER = 128000; - // GVCF file extension + // GVCF file extensions public final static String GVCF_EXT = "g.vcf"; + public final static String GVCF_GZ_EXT = "g.vcf.gz"; // Message for using the deprecated --variant_index_type or --variant_index_parameter arguments. public final static String DEPRECATED_INDEX_ARGS_MSG = "Naming your output file using the .g.vcf extension will automatically set the appropriate values " + @@ -389,7 +390,7 @@ public class GATKVCFUtils { indexType = variantIndexType; indexParameter = variantIndexParameter; logger.warn(DEPRECATED_INDEX_ARGS_MSG); - } else if (outputFile.getName().endsWith("." + GVCF_EXT)) { + } else if (outputFile.getName().endsWith("." + GVCF_EXT) || outputFile.getName().endsWith("." + GVCF_GZ_EXT)) { indexType = DEFAULT_GVCF_INDEX_TYPE; indexParameter = DEFAULT_GVCF_INDEX_PARAMETER; } diff --git a/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/CatVariantsIntegrationTest.java b/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/CatVariantsIntegrationTest.java index 18a2d6c12..69ae7a472 100644 --- a/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/CatVariantsIntegrationTest.java +++ b/public/gatk-tools-public/src/test/java/org/broadinstitute/gatk/tools/CatVariantsIntegrationTest.java @@ -246,4 +246,20 @@ public class CatVariantsIntegrationTest { ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine)); pc.execAndCheck(ps); } + + @Test() + public void testCatVariantsGVCFGzIndexCreation() throws IOException{ + + String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s", + StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar), + CatVariants.class.getCanonicalName(), + BaseTest.b37KGReference, + CatVariantsVcf1, + CatVariantsVcf2, + BaseTest.createTempFile("CatVariantsGVCFIndexCreationTest", "." + GATKVCFUtils.GVCF_GZ_EXT)); + + ProcessController pc = ProcessController.getThreadLocal(); + ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine)); + pc.execAndCheck(ps); + } } \ No newline at end of file