Search in sources :

Example 11 with BreakpointSummary

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

the class ModelsTest method calculateBreakend_should_ignore_overlaps_resulting_in_no_breakend.

@Test
public void calculateBreakend_should_ignore_overlaps_resulting_in_no_breakend() {
    BreakendSummary bs = Models.calculateBreakend(getContext().getLinear(), Lists.newArrayList(new MockDirectedBreakpoint(new BreakpointSummary(0, FWD, 1, 1, 4, 1, BWD, 2, 2, 2)), new MockDirectedEvidence(new BreakendSummary(0, FWD, 3, 3, 5)), new MockDirectedEvidence(new BreakendSummary(0, FWD, 5, 5, 5))));
    assertEquals(new BreakendSummary(0, FWD, 3, 3, 4), bs);
}
Also used : MockDirectedEvidence(au.edu.wehi.idsv.MockDirectedEvidence) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) MockDirectedBreakpoint(au.edu.wehi.idsv.MockDirectedBreakpoint) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) Test(org.junit.Test)

Example 12 with BreakpointSummary

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

the class ReadsToBedpe method asBedPe.

private String asBedPe(SAMSequenceDictionary dict, DirectedBreakpoint e, int mapq, String source) {
    StringBuilder sb = new StringBuilder();
    Integer size = e.getBreakendSummary().getEventSize();
    if (size == null || Math.abs(size) < MIN_SIZE)
        return null;
    if (e.getLocalMapq() < MIN_MAPQ || e.getRemoteMapq() < MIN_MAPQ)
        return null;
    BreakpointSummary bp = e.getBreakendSummary();
    sb.append(dict.getSequence(bp.referenceIndex).getSequenceName());
    sb.append('	');
    sb.append(Integer.toString(bp.start - 1));
    sb.append('	');
    sb.append(Integer.toString(bp.end));
    sb.append('	');
    sb.append(dict.getSequence(bp.referenceIndex2).getSequenceName());
    sb.append('	');
    sb.append(Integer.toString(bp.start2 - 1));
    sb.append('	');
    sb.append(Integer.toString(bp.end2));
    sb.append('	');
    if (UNIQUE_IDENTIFIER) {
        sb.append(e.getEvidenceID());
    } else {
        sb.append('.');
    }
    sb.append('	');
    sb.append(Integer.toString(mapq));
    sb.append('	');
    sb.append(bp.direction == BreakendDirection.Forward ? '+' : '-');
    sb.append('	');
    sb.append(bp.direction2 == BreakendDirection.Forward ? '+' : '-');
    sb.append('	');
    sb.append(source);
    sb.append('	');
    sb.append(e.getUntemplatedSequence().length());
    return sb.toString();
}
Also used : BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary)

Example 13 with BreakpointSummary

use of au.edu.wehi.idsv.BreakpointSummary 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 14 with BreakpointSummary

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

the class BreakpointHomologyTest method should_report_homology_on_both_sides.

@Test
public void should_report_homology_on_both_sides() {
    InMemoryReferenceSequenceFile ref = new InMemoryReferenceSequenceFile(new String[] { "0", "1" }, new byte[][] { B("CCCAATGGGCCC"), B("TTTAATGGGAAA") });
    // 123456789012
    // >
    // <
    BreakpointHomology bh = BreakpointHomology.calculate(ref, new BreakpointSummary(0, FWD, 6, 1, BWD, 7), "", 100, 0);
    assertEquals(6, bh.getRemoteHomologyLength() + bh.getLocalHomologyLength());
    assertEquals(3, bh.getLocalHomologyLength());
    assertEquals(3, bh.getRemoteHomologyLength());
}
Also used : InMemoryReferenceSequenceFile(au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) Test(org.junit.Test)

Example 15 with BreakpointSummary

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

the class BreakpointHomologyTest method should_require_exact_local_breakpoint.

@Test(expected = IllegalArgumentException.class)
public void should_require_exact_local_breakpoint() {
    InMemoryReferenceSequenceFile ref = new InMemoryReferenceSequenceFile(new String[] { "0", "1" }, new byte[][] { B("CCCAATGGGCCC"), B("TTTAATGGGAAA") });
    // >
    // <
    BreakpointHomology.calculate(ref, new BreakpointSummary(0, FWD, 6, 6, 7, 1, BWD, 7, 7, 7), "", 100, 0);
}
Also used : InMemoryReferenceSequenceFile(au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) Test(org.junit.Test)

Aggregations

BreakpointSummary (au.edu.wehi.idsv.BreakpointSummary)25 Test (org.junit.Test)19 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)10 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)7 MockDirectedBreakpoint (au.edu.wehi.idsv.MockDirectedBreakpoint)4 BreakendDirection (au.edu.wehi.idsv.BreakendDirection)2 IdsvVariantContext (au.edu.wehi.idsv.IdsvVariantContext)2 IdsvVariantContextBuilder (au.edu.wehi.idsv.IdsvVariantContextBuilder)2 MockDirectedEvidence (au.edu.wehi.idsv.MockDirectedEvidence)2 VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)2 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)1 StructuralVariationCallBuilder (au.edu.wehi.idsv.StructuralVariationCallBuilder)1 VariantContextDirectedEvidence (au.edu.wehi.idsv.VariantContextDirectedEvidence)1 Node (au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node)1 TwoBitBufferedReferenceSequenceFile (au.edu.wehi.idsv.picard.TwoBitBufferedReferenceSequenceFile)1 VcfFilter (au.edu.wehi.idsv.vcf.VcfFilter)1 VariantContext (htsjdk.variant.variantcontext.VariantContext)1 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1