From 7ed120361d8341eb7a69a80133627abb50e498ff Mon Sep 17 00:00:00 2001 From: Menachem Fromer Date: Fri, 12 Aug 2011 12:23:44 -0400 Subject: [PATCH] Fixed bug that required symbolic alleles to be padded with reference base and added integration test to test parsing and output of symbolic alleles --- .../sting/utils/exceptions/UserException.java | 2 +- .../utils/variantcontext/VariantContext.java | 5 ++- .../CNV/SymbolicAllelesIntegrationTest.java | 39 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 public/java/test/org/broadinstitute/sting/gatk/walkers/CNV/SymbolicAllelesIntegrationTest.java diff --git a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java index b3524c0d8..274c64f42 100755 --- a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java +++ b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java @@ -170,7 +170,7 @@ public class UserException extends ReviewedStingException { } public MalformedVCF(String message, int lineNo) { - super(String.format("The provided VCF file is malformed at line nmber %d: %s", lineNo, message)); + super(String.format("The provided VCF file is malformed at line number %d: %s", lineNo, message)); } } diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java index 23478cc2b..ca3399c78 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContext.java @@ -1209,7 +1209,10 @@ public class VariantContext implements Feature { // to enable tribble intergrati } private void validateReferencePadding() { - boolean needsPadding = hasSymbolicAlleles() || (getReference().length() == getEnd() - getStart()); // off by one because padded base was removed + if (hasSymbolicAlleles()) // symbolic alleles don't need padding... + return; + + boolean needsPadding = (getReference().length() == getEnd() - getStart()); // off by one because padded base was removed if ( needsPadding && !hasReferenceBaseForIndel() ) throw new ReviewedStingException("Badly formed variant context at location " + getChr() + ":" + getStart() + "; no padded reference base was provided."); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/CNV/SymbolicAllelesIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/CNV/SymbolicAllelesIntegrationTest.java new file mode 100644 index 000000000..b4a8498e1 --- /dev/null +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/CNV/SymbolicAllelesIntegrationTest.java @@ -0,0 +1,39 @@ +package org.broadinstitute.sting.gatk.walkers.CNV; + +import org.broadinstitute.sting.WalkerTest; +import org.testng.annotations.Test; + +import java.util.Arrays; + +public class SymbolicAllelesIntegrationTest extends WalkerTest { + + public static String baseTestString(String reference, String VCF) { + return "-T CombineVariants" + + " -R " + reference + + " --variant:vcf " + validationDataLocation + VCF + + " -filteredRecordsMergeType KEEP_IF_ANY_UNFILTERED" + + " -genotypeMergeOptions REQUIRE_UNIQUE" + + " -setKey null" + + " -o %s" + + " -NO_HEADER"; + } + + + @Test + public void test1() { + WalkerTestSpec spec = new WalkerTestSpec( + baseTestString(b36KGReference, "symbolic_alleles_1.vcf"), + 1, + Arrays.asList("89a1c56f264ac27a2a4be81072473b6f")); + executeTest("Test symbolic alleles", spec); + } + + @Test + public void test2() { + WalkerTestSpec spec = new WalkerTestSpec( + baseTestString(b36KGReference, "symbolic_alleles_2.vcf"), + 1, + Arrays.asList("6645babc8c7d46be0da223477c7b1291")); + executeTest("Test symbolic alleles mixed in with non-symbolic alleles", spec); + } +}