Search in sources :

Example 1 with VariantContextDirectedBreakpoint

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

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

the class AllocateEvidenceTest method should_annotate_reads.

@Test
public void should_annotate_reads() throws IOException {
    final ProcessingContext pc = getCommandlineContext();
    pc.getVariantCallingParameters().minScore = 0;
    pc.getVariantCallingParameters().minSize = 0;
    createInput(RP(0, 1, 10), DP(0, 1, "5M5S", true, 1, 10, "5M", true), DP(0, 2, "5M5S", true, 1, 10, "5M", true));
    SAMEvidenceSource ses = new SAMEvidenceSource(getContext(), input, null, 0);
    ses.ensureMetrics();
    File assemblyFile = new File(testFolder.getRoot(), "assembly.bam");
    AssemblyEvidenceSource aes = new AssemblyEvidenceSource(pc, ImmutableList.of(ses), assemblyFile);
    aes.assembleBreakends(null);
    aes.ensureExtracted();
    VariantCaller caller = new VariantCaller(pc, ImmutableList.of(ses), aes);
    caller.callBreakends(output, MoreExecutors.newDirectExecutorService());
    AllocateEvidence cmd = new AllocateEvidence();
    cmd.INPUT_VCF = output;
    cmd.setContext(pc);
    cmd.setAssemblySource(aes);
    cmd.setSamEvidenceSources(ImmutableList.of(ses));
    cmd.OUTPUT_VCF = new File(testFolder.getRoot(), "annotated.vcf");
    List<VariantContextDirectedBreakpoint> vcfs = Lists.newArrayList(Iterables.filter(getVcf(output, null), VariantContextDirectedBreakpoint.class));
    // both breakends
    assertEquals(2 * 1, vcfs.size());
    assertSymmetrical(vcfs);
    List<VariantContextDirectedBreakpoint> results = Lists.newArrayList(cmd.iterator(new AutoClosingIterator<>(vcfs.iterator()), MoreExecutors.newDirectExecutorService()));
    assertSymmetrical(results);
    assertEquals(vcfs.size(), results.size());
    VariantContextDirectedBreakpoint e = results.get(0);
    assertEquals(2, e.getBreakpointEvidenceCount());
    assertEquals(2, e.getBreakendEvidenceCountSoftClip());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) VariantCaller(au.edu.wehi.idsv.VariantCaller) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Example 3 with VariantContextDirectedBreakpoint

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

the class AllocateEvidenceTest method should_apply_filters.

@Test
public void should_apply_filters() throws IOException {
    final ProcessingContext pc = getCommandlineContext();
    pc.getVariantCallingParameters().minScore = 0;
    pc.getVariantCallingParameters().minSize = 0;
    createInput(RP(0, 1, 10), DP(0, 1, "5M5S", true, 1, 10, "5M", true));
    SAMEvidenceSource ses = new SAMEvidenceSource(getContext(), input, null, 0);
    ses.ensureMetrics();
    File assemblyFile = new File(testFolder.getRoot(), "assembly.bam");
    AssemblyEvidenceSource aes = new AssemblyEvidenceSource(pc, ImmutableList.of(ses), assemblyFile);
    aes.assembleBreakends(null);
    aes.ensureExtracted();
    VariantCaller caller = new VariantCaller(pc, ImmutableList.of(ses), aes);
    caller.callBreakends(output, MoreExecutors.newDirectExecutorService());
    AllocateEvidence cmd = new AllocateEvidence();
    cmd.INPUT_VCF = output;
    cmd.setContext(pc);
    cmd.setAssemblySource(aes);
    cmd.setSamEvidenceSources(ImmutableList.of(ses));
    cmd.OUTPUT_VCF = new File(testFolder.getRoot(), "annotated.vcf");
    List<VariantContextDirectedBreakpoint> vcfs = Lists.newArrayList(Iterables.filter(getVcf(output, null), VariantContextDirectedBreakpoint.class));
    // both breakends
    assertEquals(2 * 1, vcfs.size());
    assertSymmetrical(vcfs);
    List<VariantContextDirectedBreakpoint> results = Lists.newArrayList(cmd.iterator(new AutoClosingIterator<>(vcfs.iterator()), MoreExecutors.newDirectExecutorService()));
    assertSymmetrical(results);
    // single read support
    assertEquals(0, results.size());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) VariantCaller(au.edu.wehi.idsv.VariantCaller) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Example 4 with VariantContextDirectedBreakpoint

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

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

the class BreakpointFilterTracker method isValidBreakpoint.

private boolean isValidBreakpoint(T be1, T be2) {
    String be1value = "";
    String be2value = "";
    if (!be1.getFilters().equals(be2.getFilters())) {
        be1value += " {" + be1.getFilters().toString() + "}";
        be2value += " {" + be2.getFilters().toString() + "}";
    }
    if (!breakendsMatchs(be1, be2)) {
        be1value += be1.getBreakendSummary().toString();
        be2value += be2.getBreakendSummary().toString();
    }
    if (Math.abs(be1.getPhredScaledQual() - be2.getPhredScaledQual()) > 0.01) {
        be1value += " Q:" + be1.getPhredScaledQual();
        be2value += " Q:" + be2.getPhredScaledQual();
    }
    if (be1 instanceof VariantContextDirectedBreakpoint && be2 instanceof VariantContextDirectedBreakpoint) {
        VariantContextDirectedBreakpoint bp1 = (VariantContextDirectedBreakpoint) be1;
        VariantContextDirectedBreakpoint bp2 = (VariantContextDirectedBreakpoint) be2;
        if (bp1.getBreakpointEvidenceCountAssembly() != bp2.getBreakpointEvidenceCountAssembly()) {
            be1value += " AS:" + bp1.getBreakpointEvidenceCountLocalAssembly() + " RAS:" + bp1.getBreakpointEvidenceCountRemoteAssembly();
            be2value += " AS:" + bp2.getBreakpointEvidenceCountLocalAssembly() + " RAS:" + bp2.getBreakpointEvidenceCountRemoteAssembly();
        }
        if (bp1.getBreakpointEvidenceCountSoftClip() != bp2.getBreakpointEvidenceCountSoftClip()) {
            be1value += " SC:" + bp1.getBreakpointEvidenceCountSoftClip();
            be2value += " SC:" + bp2.getBreakpointEvidenceCountSoftClip();
        }
        if (bp1.getBreakpointEvidenceCountReadPair() != bp2.getBreakpointEvidenceCountReadPair()) {
            be1value += " RP:" + bp1.getBreakpointEvidenceCountReadPair();
            be2value += " RP:" + bp2.getBreakpointEvidenceCountReadPair();
        }
        if (bp1.getHomologySequence().length() != bp2.getHomologySequence().length()) {
            be1value += " HOMSEQ:" + bp1.getHomologySequence();
            be2value += " HOMSEQ:" + bp2.getHomologySequence();
        }
    }
    if (be1value.length() > 0) {
        String msg = String.format("Breakend mismatch between %s %s and %s %s", be1.getID(), be1value, be2.getID(), be2value);
        log.error(msg);
        return !doAssert;
    }
    return true;
}
Also used : VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint)

Aggregations

VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)13 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)7 AutoClosingIterator (au.edu.wehi.idsv.util.AutoClosingIterator)7 AssemblyEvidenceSource (au.edu.wehi.idsv.AssemblyEvidenceSource)6 SAMEvidenceSource (au.edu.wehi.idsv.SAMEvidenceSource)6 Test (org.junit.Test)6 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)5 VariantCaller (au.edu.wehi.idsv.VariantCaller)5 File (java.io.File)5 IdsvVariantContext (au.edu.wehi.idsv.IdsvVariantContext)3 IdsvVariantContextBuilder (au.edu.wehi.idsv.IdsvVariantContextBuilder)3 DirectedEvidence (au.edu.wehi.idsv.DirectedEvidence)2 StructuralVariationCallBuilder (au.edu.wehi.idsv.StructuralVariationCallBuilder)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 VCFFileReader (htsjdk.variant.vcf.VCFFileReader)2 ExecutorService (java.util.concurrent.ExecutorService)2 BreakpointSummary (au.edu.wehi.idsv.BreakpointSummary)1 DirectedEvidenceOrder (au.edu.wehi.idsv.DirectedEvidenceOrder)1 DiscordantReadPair (au.edu.wehi.idsv.DiscordantReadPair)1 NonReferenceReadPair (au.edu.wehi.idsv.NonReferenceReadPair)1