GCAccumulator implements Consumer<GCProfile> { double averageGCContent() { return count == 0 ? 0 : totalContent / count; } GCAccumulator(final GenomeRegion region); @Override void accept(final GCProfile gcProfile);  }
@Test public void testStandard() { final GenomeRegion region = GenomeRegions.create(CHROMOSOME, 1001, 10000); final GCAccumulator victim = new GCAccumulator(region); final GenomeRegionSelector<GCProfile> selector = selector(profile(1001, 0.30), profile(4001, 0.31), profile(9001, 0.35)); selector.select(region, victim); assertEquals(0.32, victim.averageGCContent(), EPSILON); }
@Test public void testExcludeUnmappable() { final GenomeRegion region = GenomeRegions.create(CHROMOSOME, 1001, 3000); final GCAccumulator victim = new GCAccumulator(region); final GenomeRegionSelector<GCProfile> selector = selector(profile(1001, 0.90), unmappableProfile(2001, 0.91)); selector.select(region, victim); assertEquals(0.90, victim.averageGCContent(), EPSILON); }
@Test public void testExcludeOverlapAtStart() { final GenomeRegion region = GenomeRegions.create(CHROMOSOME, 1100, 3000); final GCAccumulator victim = new GCAccumulator(region); final GenomeRegionSelector<GCProfile> selector = selector(profile(1001, 0.90), profile(2001, 0.91)); selector.select(region, victim); assertEquals(0.91, victim.averageGCContent(), EPSILON); }
@Test public void testExcludeOverlapFromEnd() { final GenomeRegion region = GenomeRegions.create(CHROMOSOME, 1001, 2999); final GCAccumulator victim = new GCAccumulator(region); final GenomeRegionSelector<GCProfile> selector = selector(profile(1001, 0.90), profile(2001, 0.91)); selector.select(region, victim); assertEquals(0.90, victim.averageGCContent(), EPSILON); }
@Test public void testExcludeFromBothEnds() { final GenomeRegion region = GenomeRegions.create(CHROMOSOME, 1100, 2999); final GCAccumulator victim = new GCAccumulator(region); final GenomeRegionSelector<GCProfile> selector = selector(profile(1001, 0.90), profile(2001, 0.91)); selector.select(region, victim); assertEquals(0, victim.averageGCContent(), EPSILON); }