Search in sources :

Example 21 with BreakpointSummary

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

the class VariantCallingConfiguration method calculateBreakpointFilters.

public List<VcfFilter> calculateBreakpointFilters(VariantContextDirectedBreakpoint call) {
    List<VcfFilter> filters = Lists.newArrayList();
    BreakpointSummary bp = call.getBreakendSummary();
    if (call.getEventSize() != null && call.getEventSize() < minSize) {
        // over 90% of events are small. Since most SV analysis excludes such events
        // we allow the default output
        filters.add(VcfFilter.SMALL_EVENT);
    }
    if (bp.couldBeReferenceAllele() && call.getUntemplatedSequence().length() == 0) {
        filters.add(VcfFilter.REFERENCE_ALLELE);
    }
    if (call.getBreakpointQual() < minScore || call.getBreakpointEvidenceCount() == 0) {
        filters.add(VcfFilter.LOW_BREAKPOINT_SUPPORT);
    }
    if (call.getBreakpointEvidenceCountAssembly() == 0 && call.getBreakpointEvidenceCountReadPair() + call.getBreakpointEvidenceCountSoftClip() == 1) {
        filters.add(VcfFilter.SINGLE_SUPPORT);
    }
    return filters;
}
Also used : VcfFilter(au.edu.wehi.idsv.vcf.VcfFilter) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary)

Example 22 with BreakpointSummary

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

the class Models method calculateBreakend.

/**
 * Calculates the most likely breakend interval for the given evidence
 * @param evidence
 * @return breakend interval with highest total evidence quality
 */
public static BreakendSummary calculateBreakend(LinearGenomicCoordinate lgc, List<BreakendSummary> bs, List<Long> weights) {
    if (bs == null || bs.size() == 0)
        throw new IllegalArgumentException("No evidence supplied");
    if (weights.size() != bs.size())
        throw new IllegalArgumentException("Array lenght mismatch");
    Node fwd = maximalInterval(lgc, BreakendDirection.Forward, bs, weights);
    Node bwd = maximalInterval(lgc, BreakendDirection.Backward, bs, weights);
    if (fwd == null && bwd == null) {
        // all evidence is insignificant, just return something as we're going to get filtered anyway
        BreakendSummary fallback = bs.get(0);
        if (fallback instanceof BreakpointSummary) {
            BreakpointSummary bp = (BreakpointSummary) fallback;
            fallback = bp.localBreakend();
        }
        return fallback;
    }
    Node node = fwd;
    BreakendDirection dir = BreakendDirection.Forward;
    if (fwd == null || (bwd != null && fwd.weight < bwd.weight)) {
        node = bwd;
        dir = BreakendDirection.Backward;
    }
    assert (lgc.getReferenceIndex(node.start) == lgc.getReferenceIndex(node.stop));
    int start = lgc.getReferencePosition(node.start);
    int end = lgc.getReferencePosition(node.stop);
    return new BreakendSummary(lgc.getReferenceIndex(node.start), dir, MathUtil.average(start, end), start, end);
}
Also used : Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) BreakendDirection(au.edu.wehi.idsv.BreakendDirection) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary)

Example 23 with BreakpointSummary

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

the class SimulatedChromosome method assemble.

protected void assemble(File fasta, File vcf, List<Fragment> fragList, boolean includeReference) throws IOException {
    StringBuilder sb = new StringBuilder();
    if (includeReference) {
        sb.append(">");
        sb.append(getChr());
        sb.append("\n");
        sb.append(new String(seq, StandardCharsets.US_ASCII));
        sb.append("\n");
    }
    sb.append(">chromothripsis." + getChr() + "\n");
    List<IdsvVariantContext> calls = Lists.newArrayList();
    Fragment last = null;
    for (int i = 0; i < fragList.size(); i++) {
        Fragment f = fragList.get(i);
        sb.append(f.getSequence());
        if (last != null) {
            BreakpointSummary bp = new BreakpointSummary(last.getEndBreakend(), f.getStartBreakend());
            String event = String.format("truth_%d_", i);
            calls.add(create(bp, event).make());
            calls.add(create(bp.remoteBreakpoint(), event).make());
        }
        last = f;
    }
    Collections.sort(calls, IdsvVariantContext.ByLocationStart);
    Files.write(sb.toString(), fasta, StandardCharsets.US_ASCII);
    VariantContextWriter writer = context.getVariantContextWriter(vcf, true);
    for (VariantContext vc : calls) {
        writer.add(vc);
    }
    writer.close();
}
Also used : IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter)

Example 24 with BreakpointSummary

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

Example 25 with BreakpointSummary

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

the class TruthAnnotatorTest method match_should_match_both_breakpoint_breakends.

@Test
public void match_should_match_both_breakpoint_breakends() {
    assertTrue(TruthAnnotator.matches(new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), 0, 0));
    assertTrue(TruthAnnotator.matches(new BreakpointSummary(new BreakendSummary(0, BWD, 10), new BreakendSummary(0, FWD, 1)), new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), 0, 0));
}
Also used : BreakendSummary(au.edu.wehi.idsv.BreakendSummary) 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