StructuralVariantLegsFactory { @NotNull private static StructuralVariantLeg reduce(@NotNull final GenomePosition position, @NotNull final Collection<ModifiableStructuralVariantLegs> legs) { final List<StructuralVariantLeg> leg = Lists.newArrayList(); for (ModifiableStructuralVariantLegs modifiableStructuralVariantLegs : legs) { modifiableStructuralVariantLegs.start().filter(x -> isDuplicate(position, x)).ifPresent(leg::add); modifiableStructuralVariantLegs.end().filter(x -> isDuplicate(position, x)).ifPresent(leg::add); } return reduce(position, leg); }    }
@Test public void testReduce() { final StructuralVariantLeg largePositive = createLeg(1, 0.9); final StructuralVariantLeg smallPositive = createLeg(1, 0.1); final StructuralVariantLeg largeNegative = createLeg(-1, 0.8); final StructuralVariantLeg smallNegative = createLeg(-1, 0.2); assertReduce(largePositive, Lists.newArrayList(largePositive, smallPositive)); assertReduce(largePositive, Lists.newArrayList(smallPositive, largePositive)); assertReduce(largeNegative, Lists.newArrayList(largeNegative, smallNegative)); assertReduce(largeNegative, Lists.newArrayList(smallNegative, largeNegative)); assertReduce(createLeg(1, 0.7), Lists.newArrayList(smallNegative, largePositive)); assertReduce(createLeg(1, 0.1), Lists.newArrayList(largeNegative, largePositive)); assertReduce(createLeg(-1, 0.7), Lists.newArrayList(largeNegative, smallPositive)); }