RightAlignMicrohomology implements Consumer<SageVariant> { boolean realign(@NotNull final SageVariant variant) { if (!variant.isPassing()) { return false; } final boolean isInframeDel = variant.variant().isInframeIndel() && variant.alt().length() == 1; if (!isInframeDel) { return false; } final String microhomology = variant.microhomology(); final int microhomologyLength = microhomology.length(); if (microhomologyLength == 0) { return false; } final Optional<HmfExonRegion> maybeLeftAlignedRegion = PhasedInframeIndel.selectExon(selector, variant.position() + 1); if (maybeLeftAlignedRegion.isPresent()) { return false; } final VariantHotspot rightAligned = rightAlignDel(variant.variant(), microhomology); final Optional<HmfTranscriptRegion> maybeRightAlignedTranscript = selector.select(rightAligned.position() + 1); if (!maybeRightAlignedTranscript.isPresent()) { return false; } final HmfTranscriptRegion rightAlignedTranscript = maybeRightAlignedTranscript.get(); if (rightAligned.position() + 1 < rightAlignedTranscript.codingStart() || rightAligned.position() + 1 > rightAlignedTranscript.codingEnd()) { return false; } final Optional<HmfExonRegion> maybeRightAlignedExon = Optional.ofNullable(PhasedInframeIndel.selectExon(rightAligned.position() + 1, rightAlignedTranscript)); if (!maybeRightAlignedExon.isPresent()) { return false; } final SageVariant realignedVariant = new SageVariant(variant.tier(), rightAligned, variant.filters(), variant.normalAltContexts(), variant.tumorAltContexts()); realignedVariant.realigned(true); rightAlignedList.add(realignedVariant); return true; } RightAlignMicrohomology(final Consumer<SageVariant> consumer, final List<HmfTranscriptRegion> transcripts); @Override void accept(final SageVariant variant); void flush();  }
@Test public void testKit() { final List<HmfTranscriptRegion> transcriptRegions = HmfGenePanelSupplier.allGeneList37().stream().filter(x -> x.chromosome().equals("4")).collect(Collectors.toList()); final List<SageVariant> collector = Lists.newArrayList(); final RightAlignMicrohomology victim = new RightAlignMicrohomology(collector::add, transcriptRegions); final VariantHotspot leftAligned = ImmutableVariantHotspotImpl.builder() .chromosome("4") .position(55593579) .ref("CAGAAACCCATGTATGAAGTACAGTGGA") .alt("C") .build(); ReadContextCounter counter = MixedGermlineTest.dummyCounter(leftAligned, "AG"); SageVariant variant = new SageVariant(SageVariantTier.PANEL, leftAligned, Sets.newHashSet(), Lists.newArrayList(), Lists.newArrayList(counter)); assertTrue(victim.realign(variant)); }