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