WholeGenomeDuplication { static double averageMajorAlleleCopyNumber(@NotNull final List<PurpleCopyNumber> copyNumbers) { double weightedMajorAllelePloidy = 0; long totalBafCount = 0; for (PurpleCopyNumber copyNumber : copyNumbers) { weightedMajorAllelePloidy += copyNumber.majorAlleleCopyNumber() * copyNumber.bafCount(); totalBafCount += copyNumber.bafCount(); } return totalBafCount > 0 ? weightedMajorAllelePloidy / totalBafCount : 0; }  static boolean wholeGenomeDuplication(@NotNull final List<PurpleCopyNumber> copyNumbers);  }
@Test public void testAverageMajorAlleleCopyNumberIsBafCountWeighted() { PurpleCopyNumber one = create("1", 1, 1000); PurpleCopyNumber two = create("1", 2, 3000); PurpleCopyNumber three = create("1", 3, 0); assertEquals(1.75, averageMajorAlleleCopyNumber(Lists.newArrayList(one, two, three)), EPSILON); }