ExtendDiploidBAF { @NotNull static InferRegion nextRegion(boolean crossCentromere, @NotNull final List<CombinedRegion> regions) { int leftSource = -1; boolean shouldInfer = false; int leftTarget = Integer.MAX_VALUE; for (int i = 0; i < regions.size(); i++) { CombinedRegion suspect = regions.get(i); if (suspect.support() == SegmentSupport.CENTROMERE && !crossCentromere) { if (shouldInfer && leftSource > -1) { return new InferRegion(leftSource, leftTarget, i - 1, -1); } else { leftSource = -1; shouldInfer = false; leftTarget = Integer.MAX_VALUE; } } if (suspect.bafCount() == 0 && !suspect.isInferredBAF()) { shouldInfer = true; leftTarget = Math.min(leftTarget, i); } else if (shouldInfer) { return new InferRegion(leftSource, leftTarget, i - 1, i); } else { leftSource = i; } } return shouldInfer ? new InferRegion(leftSource, leftTarget, regions.size() - 1, -1) : INVALID_PAIR; } ExtendDiploidBAF(@NotNull final List<StructuralVariant> simpleVariants); @VisibleForTesting  ExtendDiploidBAF(@NotNull final Map<Long, Long> simpleDupMap);   }
@Test public void testShortArm() { CombinedRegion cr1 = create(1, 1000, SegmentSupport.NONE, 0); CombinedRegion cr2 = create(1001, 2000, SegmentSupport.NONE, 0); CombinedRegion cr3 = create(2001, 3000, SegmentSupport.CENTROMERE, 100); CombinedRegion cr4 = create(3001, 4000, SegmentSupport.NONE, 0); CombinedRegion cr5 = create(4001, 5000, SegmentSupport.NONE, 1); assertInferRegion(ExtendDiploidBAF.nextRegion(true, Lists.newArrayList(cr1, cr2, cr3, cr4, cr5)), -1, 0, 1, 2); assertInferRegion(ExtendDiploidBAF.nextRegion(false, Lists.newArrayList(cr1, cr2, cr3, cr4, cr5)), 2, 3, 3, 4); assertInferRegion(ExtendDiploidBAF.nextRegion(false, Lists.newArrayList(cr1, cr2, cr3, cr4)), 2, 3, 3, -1); }