AlleleTolerance implements CopyNumberTolerance { @VisibleForTesting static double relativeCopyNumberChange(double firstCopyNumber, double secondCopyNumber) { final double absCopyNumberDifference = Math.abs(Math.max(firstCopyNumber, secondCopyNumber) - Math.min(firstCopyNumber, secondCopyNumber)); if (Doubles.isZero(absCopyNumberDifference)) { return 0; } if (Doubles.isZero(firstCopyNumber) || Doubles.isZero(secondCopyNumber)) { return 1; } return absCopyNumberDifference / Math.abs(Math.min(firstCopyNumber, secondCopyNumber)); } AlleleTolerance(@NotNull final PurityAdjuster purityAdjuster); @Override boolean inTolerance(@NotNull final FittedRegion first, @NotNull final FittedRegion second);  }
@Test public void testRelativeChangeToNegativeCopyNumber() { assertEquals(6, AlleleTolerance.relativeCopyNumberChange(2.5, -0.5), 0.01); }