Search in sources :

Example 1 with IdsvVariantContextBuilder

use of au.edu.wehi.idsv.IdsvVariantContextBuilder in project gridss by PapenfussLab.

the class VariantCallingConfigurationTest method V.

public VariantContextDirectedBreakpoint V(BreakpointSummary bs, String untemplated) {
    IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(getContext());
    builder.breakpoint(bs, untemplated);
    return (VariantContextDirectedBreakpoint) builder.make();
}
Also used : IdsvVariantContextBuilder(au.edu.wehi.idsv.IdsvVariantContextBuilder) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint)

Example 2 with IdsvVariantContextBuilder

use of au.edu.wehi.idsv.IdsvVariantContextBuilder in project gridss by PapenfussLab.

the class SimulatedChromosome method create.

protected IdsvVariantContextBuilder create(BreakpointSummary bp, String event) {
    IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(context);
    builder.breakpoint(bp, "").id(event + (bp.isLowBreakend() ? "o" : "h")).attribute(VcfSvConstants.BREAKEND_EVENT_ID_KEY, event).attribute(VcfSvConstants.PARTNER_BREAKEND_ID_KEY, event + (bp.isLowBreakend() ? "h" : "o")).attribute(VcfSvConstants.MATE_BREAKEND_ID_KEY, event + (bp.isLowBreakend() ? "h" : "o"));
    return builder;
}
Also used : IdsvVariantContextBuilder(au.edu.wehi.idsv.IdsvVariantContextBuilder)

Example 3 with IdsvVariantContextBuilder

use of au.edu.wehi.idsv.IdsvVariantContextBuilder in project gridss by PapenfussLab.

the class BreakpointHomology method annotate.

public static VariantContextDirectedBreakpoint annotate(ProcessingContext context, VariantContextDirectedBreakpoint bp) {
    if (!bp.isBreakendExact())
        return bp;
    IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(context, bp);
    BreakpointHomology bh = BreakpointHomology.calculate(context.getReference(), bp.getBreakendSummary().getNominalPosition(), bp.getUntemplatedSequence(), context.getVariantCallingParameters().maxBreakendHomologyLength, context.getVariantCallingParameters().breakendHomologyAlignmentMargin);
    int[] bounds;
    if (bp.getBreakendSummary().direction == BreakendDirection.Forward) {
        bounds = new int[] { -bh.getLocalHomologyLength(), bh.getRemoteHomologyLength() };
    } else {
        bounds = new int[] { -bh.getRemoteHomologyLength(), bh.getLocalHomologyLength() };
    }
    builder.attribute(VcfInfoAttributes.INEXACT_HOMPOS, bounds);
    return (VariantContextDirectedBreakpoint) builder.make();
}
Also used : IdsvVariantContextBuilder(au.edu.wehi.idsv.IdsvVariantContextBuilder) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint)

Example 4 with IdsvVariantContextBuilder

use of au.edu.wehi.idsv.IdsvVariantContextBuilder in project gridss by PapenfussLab.

the class TruthAnnotator method annotate.

public VariantContextDirectedEvidence annotate(VariantContextDirectedEvidence variant) {
    BreakendSummary variantBreakend = variant.getBreakendSummary();
    BreakpointSummary variantBreakpoint = null;
    if (variantBreakend instanceof BreakpointSummary) {
        variantBreakpoint = (BreakpointSummary) variantBreakend;
        variantBreakend = variantBreakpoint.localBreakend();
    }
    HashSet<String> breakpointHits = Sets.newHashSet();
    HashSet<String> breakendHits = Sets.newHashSet();
    for (IdsvVariantContext truthVariant : truth) {
        if ((truthVariant.hasAttribute(VcfSvConstants.SV_TYPE_KEY) && truthVariant.getAttributeAsString(VcfSvConstants.SV_TYPE_KEY, "").equals("INS")) || (truthVariant.hasAttribute(VcfSvConstants.SV_TYPE_KEY) && truthVariant.getAttributeAsString(VcfSvConstants.SV_TYPE_KEY, "").equals("DEL"))) {
            int svLen = truthVariant.getAttributeAsInt(VcfSvConstants.SV_LENGTH_KEY, 0);
            int untemplatedSequence = 0;
            if (variant instanceof VariantContextDirectedEvidence) {
                untemplatedSequence = ((VariantContextDirectedEvidence) variant).getBreakendSequence().length;
            }
            // two breakpoints: forward & backward
            BreakendSummary truthBreakendStart = new BreakendSummary(truthVariant.getReferenceIndex(), BreakendDirection.Forward, truthVariant.getStart());
            int endOffset = Math.max(0, -truthVariant.getAttributeAsInt(VcfSvConstants.SV_LENGTH_KEY, 0));
            endOffset = truthVariant.getStart() + endOffset + 1;
            BreakendSummary truthBreakendEnd = new BreakendSummary(truthVariant.getReferenceIndex(), BreakendDirection.Backward, endOffset);
            BreakpointSummary truthBreakpoint = new BreakpointSummary(truthBreakendStart, truthBreakendEnd);
            if (matches(truthBreakpoint, variantBreakpoint, svLen, untemplatedSequence)) {
                breakpointHits.add(truthVariant.getID());
            } else if (matches(truthBreakpoint, variantBreakend, svLen, untemplatedSequence)) {
                breakendHits.add(truthVariant.getID());
            }
        } else {
            throw new RuntimeException(String.format("Matching of truth variant at %s:%d not yet implemented.", truthVariant.getContig(), truthVariant.getStart()));
        }
    }
    if (!breakpointHits.isEmpty() || !breakendHits.isEmpty()) {
        IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(processContext, variant);
        builder.attribute("TRUTH_MATCHES", Lists.newArrayList(breakpointHits));
        builder.attribute("TRUTH_MISREALIGN", Lists.newArrayList(breakendHits));
        return (VariantContextDirectedEvidence) builder.make();
    }
    return variant;
}
Also used : IdsvVariantContextBuilder(au.edu.wehi.idsv.IdsvVariantContextBuilder) VariantContextDirectedEvidence(au.edu.wehi.idsv.VariantContextDirectedEvidence) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary)

Example 5 with IdsvVariantContextBuilder

use of au.edu.wehi.idsv.IdsvVariantContextBuilder in project gridss by PapenfussLab.

the class AnnotateInexactHomologyTest method should_calculate_inexact_homology.

@Test
public void should_calculate_inexact_homology() {
    ProcessingContext pc = getContext();
    StructuralVariationCallBuilder builder = new StructuralVariationCallBuilder(pc, (VariantContextDirectedEvidence) new IdsvVariantContextBuilder(getContext()) {

        {
            breakpoint(new BreakpointSummary(2, FWD, 78, 6, BWD, 79), "");
            phredScore(50);
        }
    }.make());
    builder.addEvidence(SR(Read(2, 78, "1M1S"), Read(6, 79, "1M")));
    VariantContextDirectedBreakpoint e = (VariantContextDirectedBreakpoint) builder.make();
    AnnotateInexactHomology aih = new AnnotateInexactHomology();
    aih.setContext(pc);
    ExecutorService threadpool = Executors.newSingleThreadExecutor();
    e = aih.iterator(new AutoClosingIterator<>(ImmutableList.of(e).iterator()), threadpool).next();
    assertEquals(-78, ((int[]) e.getAttribute(VcfInfoAttributes.INEXACT_HOMPOS.attribute()))[0]);
    assertEquals(300, ((int[]) e.getAttribute(VcfInfoAttributes.INEXACT_HOMPOS.attribute()))[1]);
    threadpool.shutdown();
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) IdsvVariantContextBuilder(au.edu.wehi.idsv.IdsvVariantContextBuilder) StructuralVariationCallBuilder(au.edu.wehi.idsv.StructuralVariationCallBuilder) ExecutorService(java.util.concurrent.ExecutorService) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) Test(org.junit.Test)

Aggregations

IdsvVariantContextBuilder (au.edu.wehi.idsv.IdsvVariantContextBuilder)5 VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)3 BreakpointSummary (au.edu.wehi.idsv.BreakpointSummary)2 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)1 IdsvVariantContext (au.edu.wehi.idsv.IdsvVariantContext)1 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)1 StructuralVariationCallBuilder (au.edu.wehi.idsv.StructuralVariationCallBuilder)1 VariantContextDirectedEvidence (au.edu.wehi.idsv.VariantContextDirectedEvidence)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.Test)1