Search in sources :

Example 6 with SegmentedGenome

use of org.broadinstitute.hellbender.tools.exome.SegmentedGenome in project gatk-protected by broadinstitute.

the class AlleleFractionDataUnitTest method testData.

@Test
public void testData() {
    final List<AllelicCount> ac = new ArrayList<>();
    final List<SimpleInterval> segments = new ArrayList<>();
    // segment 0: hets 0-2
    segments.add(new SimpleInterval("chr", 1, 5));
    ac.add(new AllelicCount(new SimpleInterval("chr", 1, 1), 0, 5));
    ac.add(new AllelicCount(new SimpleInterval("chr", 2, 2), 5, 0));
    ac.add(new AllelicCount(new SimpleInterval("chr", 3, 3), 5, 5));
    // segment 1: hets 3-4
    segments.add(new SimpleInterval("chr", 10, 15));
    ac.add(new AllelicCount(new SimpleInterval("chr", 10, 10), 1, 1));
    ac.add(new AllelicCount(new SimpleInterval("chr", 11, 11), 2, 2));
    final Genome genome = new Genome(AlleleFractionSimulatedData.TRIVIAL_TARGETS, ac);
    final SegmentedGenome segmentedGenome = new SegmentedGenome(segments, genome);
    final AlleleFractionData dc = new AlleleFractionData(segmentedGenome);
    Assert.assertEquals(dc.getNumSegments(), 2);
    Assert.assertEquals(dc.getRefCount(0), 0);
    Assert.assertEquals(dc.getAltCount(0), 5);
    Assert.assertEquals(dc.getReadCount(2), 10);
    Assert.assertEquals(dc.getReadCount(3), 2);
    Assert.assertEquals(dc.getRefCount(4), 2);
    Assert.assertEquals(dc.getAltCount(4), 2);
    Assert.assertEquals(dc.getAllelicCount(0).getAltReadCount(), 5);
    Assert.assertEquals(dc.getAllelicCount(1).getAltReadCount(), 0);
    Assert.assertEquals(dc.getAllelicCount(3).getRefReadCount(), 1);
    Assert.assertEquals(dc.getAllelicCount(4).getRefReadCount(), 2);
    Assert.assertEquals(dc.getCountsInSegment(0).get(1).getRefReadCount(), 5);
    Assert.assertEquals(dc.getCountsInSegment(0).get(1).getAltReadCount(), 0);
    final List<Integer> hetsInSegment0 = dc.getHetsInSegment(0);
    Assert.assertEquals(hetsInSegment0.size(), 3);
    Assert.assertEquals((int) hetsInSegment0.get(0), 0);
    Assert.assertEquals((int) hetsInSegment0.get(2), 2);
    final List<Integer> hetsInSegment1 = dc.getHetsInSegment(1);
    Assert.assertEquals(hetsInSegment1.size(), 2);
    Assert.assertEquals((int) hetsInSegment1.get(0), 3);
    Assert.assertEquals((int) hetsInSegment1.get(1), 4);
}
Also used : SegmentedGenome(org.broadinstitute.hellbender.tools.exome.SegmentedGenome) ArrayList(java.util.ArrayList) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Genome(org.broadinstitute.hellbender.tools.exome.Genome) SegmentedGenome(org.broadinstitute.hellbender.tools.exome.SegmentedGenome) AllelicCount(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount) Test(org.testng.annotations.Test)

Aggregations

Genome (org.broadinstitute.hellbender.tools.exome.Genome)6 SegmentedGenome (org.broadinstitute.hellbender.tools.exome.SegmentedGenome)6 Test (org.testng.annotations.Test)6 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)4 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)4 PosteriorSummary (org.broadinstitute.hellbender.utils.mcmc.PosteriorSummary)4 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 Log (htsjdk.samtools.util.Log)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 FileUtils (org.apache.commons.io.FileUtils)2 Mean (org.apache.commons.math3.stat.descriptive.moment.Mean)2 SparkContextFactory (org.broadinstitute.hellbender.engine.spark.SparkContextFactory)2 UserException (org.broadinstitute.hellbender.exceptions.UserException)2