From cfa86d52c2c9800967a1616c72251493e2966886 Mon Sep 17 00:00:00 2001 From: aaron Date: Mon, 19 Oct 2009 18:21:00 +0000 Subject: [PATCH] ensure that in the indel case we don't allow identification as both an insertion and deletion at the same location in the VCF ROD git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1875 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/refdata/RodVCF.java | 9 +++++++-- .../sting/gatk/refdata/RodVCFTest.java | 18 ++++++++++++++++-- .../utils/genotype/vcf/VCFReaderTest.java | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java index 46322d3e0..172e30c52 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java @@ -77,6 +77,10 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod, return vcf; } + public void assertBiAllelic() { + if (!this.isBiallelic()) throw new StingException("We're not bi-allelic."); + } + /** * get the frequency of this variant * @@ -116,8 +120,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod, @Override public boolean isSNP() { this.assertNotNull(); - if (!mCurrentRecord.hasAlternateAllele()) - return false; + assertBiAllelic(); for (VCFGenotypeEncoding alt : this.mCurrentRecord.getAlternateAlleles()) { if (alt.getType() != VCFGenotypeEncoding.TYPE.SINGLE_BASE) return false; @@ -133,6 +136,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod, @Override public boolean isInsertion() { this.assertNotNull(); + assertBiAllelic(); if (!mCurrentRecord.hasAlternateAllele()) return false; for (VCFGenotypeEncoding alt : this.mCurrentRecord.getAlternateAlleles()) { @@ -150,6 +154,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod, @Override public boolean isDeletion() { this.assertNotNull(); + assertBiAllelic(); if (!mCurrentRecord.hasAlternateAllele()) return false; for (VCFGenotypeEncoding alt : this.mCurrentRecord.getAlternateAlleles()) { diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/RodVCFTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/RodVCFTest.java index 0c77a5aea..aa3083ee2 100755 --- a/java/test/org/broadinstitute/sting/gatk/refdata/RodVCFTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/RodVCFTest.java @@ -113,7 +113,7 @@ public class RodVCFTest extends BaseTest { } @Test - public void testType() { + public void testInsertion() { RodVCF vcf = getVCFObject(); Iterator iter = vcf.createIterator("VCF", vcfFile); RodVCF rec = iter.next(); @@ -123,10 +123,24 @@ public class RodVCFTest extends BaseTest { rec = iter.next(); rec = iter.next(); Assert.assertTrue(rec.isIndel()); - Assert.assertTrue(rec.isInsertion()); Assert.assertTrue(rec.isDeletion()); } + @Test + public void testDeletion() { + RodVCF vcf = getVCFObject(); + Iterator iter = vcf.createIterator("VCF", vcfFile); + RodVCF rec = iter.next(); + Assert.assertTrue(rec.isSNP()); + rec = iter.next(); + rec = iter.next(); + rec = iter.next(); + rec = iter.next(); + rec = iter.next(); + + Assert.assertTrue(rec.isIndel()); + Assert.assertTrue(rec.isInsertion()); + } @Test public void testGetGenotypes() { RodVCF vcf = getVCFObject(); diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java index 1e8e810e6..ba004237e 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderTest.java @@ -22,7 +22,7 @@ public class VCFReaderTest extends BaseTest { counter++; reader.next(); } - Assert.assertEquals(5, counter); + Assert.assertEquals(6, counter); } @Test