ExtendDiploidBAF { @VisibleForTesting static double minorOrMajorMovedTargetPloidy(@NotNull final FittedRegion source, @NotNull final FittedRegion primary, @NotNull final FittedRegion secondary) { boolean isMinorDifferent = isMinorAlleleDifferent(primary, secondary); boolean isMajorDifferent = isMajorAlleleDifferent(primary, secondary); assert (isMinorDifferent || isMajorDifferent); if (isMinorDifferent && isMajorDifferent) { if (Doubles.lessThan(Math.abs(primary.minorAlleleCopyNumber() - secondary.majorAlleleCopyNumber()), MIN_COPY_NUMBER_CHANGE)) { double average = (primary.minorAlleleCopyNumber() + secondary.majorAlleleCopyNumber()) / 2; return closestAllele(average, source); } if (Doubles.lessThan(Math.abs(primary.majorAlleleCopyNumber() - secondary.minorAlleleCopyNumber()), MIN_COPY_NUMBER_CHANGE)) { double average = (primary.majorAlleleCopyNumber() + secondary.minorAlleleCopyNumber()) / 2; return closestAllele(average, source); } } if (isMajorDifferent) { return source.minorAlleleCopyNumber(); } return source.majorAlleleCopyNumber(); } ExtendDiploidBAF(@NotNull final List<StructuralVariant> simpleVariants); @VisibleForTesting  ExtendDiploidBAF(@NotNull final Map<Long, Long> simpleDupMap);   }
@Test public void testMinorOrMajorMovedTargetPloidyWithCommonMinor() { final FittedRegion left = create(1.01, 2.01); final FittedRegion right = create(1.02, 3.02); final FittedRegion sourceLikeLeft = create(1.03, 2.03); final FittedRegion sourceLikeRight = create(1.04, 3.04); assertEquals(1.01, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(left, left, right), EPSILON); assertEquals(1.02, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(right, left, right), EPSILON); assertEquals(1.03, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeLeft, left, right), EPSILON); assertEquals(1.04, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeRight, left, right), EPSILON); }
@Test public void testMinorOrMajorMovedTargetPloidyWithCommonMajor() { final FittedRegion left = create(1.01, 2.01); final FittedRegion right = create(0.02, 2.02); final FittedRegion sourceLikeLeft = create(1.03, 2.03); final FittedRegion sourceLikeRight = create(0.04, 2.04); assertEquals(2.01, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(left, left, right), EPSILON); assertEquals(2.02, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(right, left, right), EPSILON); assertEquals(2.03, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeLeft, left, right), EPSILON); assertEquals(2.04, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeRight, left, right), EPSILON); }
@Test public void testMinorOrMajorMovedTargetPloidyWithMajorMinorCross() { final FittedRegion left = create(1.01, 2.01); final FittedRegion right = create(2.02, 3.02); final FittedRegion sourceLikeLeft = create(1.03, 2.03); final FittedRegion sourceLikeRight = create(2.04, 3.04); assertEquals(2.01, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(left, left, right), EPSILON); assertEquals(2.02, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(right, left, right), EPSILON); assertEquals(2.03, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeLeft, left, right), EPSILON); assertEquals(2.04, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeRight, left, right), EPSILON); }
@Test public void testMinorOrMajorMovedTargetPloidyWithMinorMajorCross() { final FittedRegion left = create(1.01, 2.01); final FittedRegion right = create(0.02, 1.02); final FittedRegion sourceLikeLeft = create(0.03, 1.03); final FittedRegion sourceLikeRight = create(0.04, 1.04); assertEquals(1.01, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(left, left, right), EPSILON); assertEquals(1.02, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(right, left, right), EPSILON); assertEquals(1.03, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeLeft, left, right), EPSILON); assertEquals(1.04, ExtendDiploidBAF.minorOrMajorMovedTargetPloidy(sourceLikeRight, left, right), EPSILON); }