diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/ConcordanceTruthTableTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/ConcordanceTruthTableTest.java new file mode 100755 index 000000000..7a3585b52 --- /dev/null +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/ConcordanceTruthTableTest.java @@ -0,0 +1,94 @@ +package org.broadinstitute.sting.playground.gatk.walkers; + +import org.junit.Test; +import org.junit.Assert; +import org.broadinstitute.sting.utils.genotype.Genotype; +import org.broadinstitute.sting.utils.genotype.BasicGenotype; +import org.broadinstitute.sting.utils.GenomeLoc; +import org.broadinstitute.sting.utils.Pair; +import org.broadinstitute.sting.playground.gatk.walkers.varianteval.ConcordanceTruthTable; +import org.broadinstitute.sting.BaseTest; + +import java.util.List; +import java.util.ArrayList; + +/** + * Created by IntelliJ IDEA. + * User: chartl + * Date: Nov 19, 2009 + * Time: 9:40:51 AM + * To change this template use File | Settings | File Templates. + */ +public class ConcordanceTruthTableTest extends BaseTest { + + @Test + public void testAlleleFrequencyCalculation() { + + ConcordanceTruthTable ctt = new ConcordanceTruthTable(3); + // this will test the count of non-reference alleles at a T/G polymorphic site + Genotype ref1 = new BasicGenotype(null,"GG",'G',30); + Genotype ref2 = new BasicGenotype(null,"GG",'G',30); + Genotype ref3 = new BasicGenotype(null,"GG",'G',30); + Genotype het1 = new BasicGenotype(null,"GT",'G',32); + Genotype het2 = new BasicGenotype(null,"GT",'G',28); + Genotype hom1 = new BasicGenotype(null,"TT",'G',40); + Genotype hom2 = new BasicGenotype(null,"TT",'G',27); + + List> oneHom = new ArrayList>(4); + oneHom.add(new Pair(ref1,null)); + oneHom.add(new Pair(ref2,null)); + oneHom.add(new Pair(ref3,null)); + oneHom.add(new Pair(hom2,null)); + + List> oneHet = new ArrayList>(4); + oneHet.add(new Pair(ref1,null)); + oneHet.add(new Pair(ref2,null)); + oneHet.add(new Pair(ref3,null)); + oneHet.add(new Pair(het1,null)); + + List> twoHetOneHom = new ArrayList>(5); + twoHetOneHom.add(new Pair(ref1,null)); + twoHetOneHom.add(new Pair(ref2,null)); + twoHetOneHom.add(new Pair(ref3,null)); + twoHetOneHom.add(new Pair(het1,null)); + twoHetOneHom.add(new Pair(het2,null)); + twoHetOneHom.add(new Pair(hom1,null)); + + List> twoHetTwoHom = new ArrayList>(7); + twoHetTwoHom.add(new Pair(ref1,null)); + twoHetTwoHom.add(new Pair(ref2,null)); + twoHetTwoHom.add(new Pair(ref3,null)); + twoHetTwoHom.add(new Pair(het1,null)); + twoHetTwoHom.add(new Pair(het2,null)); + twoHetTwoHom.add(new Pair(hom1,null)); + twoHetTwoHom.add(new Pair(hom2,null)); + + List> hetHomNoRef = new ArrayList>(2); + hetHomNoRef.add(new Pair(het2,null)); + hetHomNoRef.add(new Pair(hom2,null)); + + List> homNoRef = new ArrayList>(1); + homNoRef.add(new Pair(hom1,null)); + + Pair countShouldBeOne = ctt.getPooledAlleleFrequency(oneHet,'G'); + Pair countShouldBeTwo = ctt.getPooledAlleleFrequency(oneHom,'G'); + Pair countShouldBeFour = ctt.getPooledAlleleFrequency(twoHetOneHom,'G'); + Pair countShouldBeSix = ctt.getPooledAlleleFrequency(twoHetTwoHom,'G'); + Pair countShouldBeThree = ctt.getPooledAlleleFrequency(hetHomNoRef,'G'); + Pair countShouldBeTwoHereToo = ctt.getPooledAlleleFrequency(homNoRef, 'G'); + + + logger.warn("Testing single het"); + Assert.assertTrue(countShouldBeOne.getSecond() == 1); + logger.warn("Testing single hom"); + Assert.assertTrue(countShouldBeTwo.getSecond() == 2); + logger.warn("Testing two hets + hom"); + Assert.assertTrue(countShouldBeFour.getSecond() == 4); + logger.warn("Testing two hets + two homs"); + Assert.assertTrue(countShouldBeSix.getSecond() == 6); + logger.warn("Testing het + hom without ref"); + Assert.assertTrue(countShouldBeThree.getSecond() == 3); + logger.warn("Testing hom without ref"); + Assert.assertTrue(countShouldBeTwoHereToo.getSecond() == 2); + } +}