From 3b1c33740185150acf2da4781c6a0937ebd81a9a Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 19 Mar 2014 19:11:40 -0400 Subject: [PATCH] Have CombineVariants throw a UserError when trying to combine GVCFs from the HaplotypeCaller. Was previously throwing an IllegalArgumentException (in the wrong place in the code). Error message tells users to use CombineGVCFs. --- .../CombineVariantsIntegrationTest.java | 13 +++++++++++++ .../gatk/walkers/variantutils/CombineVariants.java | 3 +++ .../utils/variant/GATKVariantContextUtils.java | 4 ---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/protected/gatk-protected/src/test/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java b/protected/gatk-protected/src/test/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java index fb54ab400..91952ec43 100644 --- a/protected/gatk-protected/src/test/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java +++ b/protected/gatk-protected/src/test/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java @@ -204,4 +204,17 @@ public class CombineVariantsIntegrationTest extends WalkerTest { Arrays.asList("f8c014d0af7e014475a2a448dc1f9cef")); cvExecuteTest("combineLeavesUnfilteredRecordsUnfiltered: ", spec, false); } + + @Test + public void combiningGVCFsFails() { + try { + WalkerTestSpec spec = new WalkerTestSpec( + "-T CombineVariants --no_cmdline_in_header -o %s " + + " -R " + b37KGReference + + " -V " + privateTestDir + "gvcfExample1.vcf", + 1, + Arrays.asList("FAILFAILFAILFAILFAILFAILFAILFAIL")); + executeTest("combiningGVCFsFails", spec); + } catch (Exception e) { } // do nothing + } } \ No newline at end of file diff --git a/public/gatk-framework/src/main/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java b/public/gatk-framework/src/main/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java index 152128022..c3e773dcd 100644 --- a/public/gatk-framework/src/main/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java +++ b/public/gatk-framework/src/main/java/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariants.java @@ -326,6 +326,9 @@ public class CombineVariants extends RodWalker implements Tree if ( mergedVC == null ) continue; + if ( mergedVC.hasAllele(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE) ) + throw new UserException("CombineVariants should not be used to merge gVCFs produced by the HaplotypeCaller; use CombineGVCFs instead"); + final VariantContextBuilder builder = new VariantContextBuilder(mergedVC); // re-compute chromosome counts VariantContextUtils.calculateChromosomeCounts(builder, false); diff --git a/public/gatk-framework/src/main/java/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java b/public/gatk-framework/src/main/java/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java index fb5564ab3..5670f5871 100644 --- a/public/gatk-framework/src/main/java/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java +++ b/public/gatk-framework/src/main/java/org/broadinstitute/sting/utils/variant/GATKVariantContextUtils.java @@ -1921,10 +1921,6 @@ public class GATKVariantContextUtils { final HashMap> mappedVCs = new HashMap<>(); for ( final VariantContext vc : VCs ) { VariantContext.Type vcType = vc.getType(); - if( vc.hasAllele(NON_REF_SYMBOLIC_ALLELE) ) { - if( vc.getAlternateAlleles().size() > 1 ) { throw new IllegalStateException("Reference records should not have more than one alternate allele"); } - vcType = VariantContext.Type.NO_VARIATION; - } // look at previous variant contexts of different type. If: // a) otherVC has alleles which are subset of vc, remove otherVC from its list and add otherVC to vc's list