Search in sources :

Example 1 with AssemblyEvidenceSource

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

the class NonReferenceContigAssemblerTest method create.

private NonReferenceContigAssembler create(ProcessingContext pc, boolean collapse, DirectedEvidence... input) {
    Arrays.sort(input, DirectedEvidence.ByStartEnd);
    AssemblyEvidenceSource aes = new AssemblyEvidenceSource(pc, Arrays.stream(input).map(e -> (SAMEvidenceSource) e.getEvidenceSource()).collect(Collectors.toList()), new File("NonReferenceContigAssemblerTest.bam"));
    int maxEvidenceWidth = aes.getMaxConcordantFragmentSize() - aes.getMinConcordantFragmentSize() + 1;
    int maxReadLength = maxReadLength(input);
    int k = pc.getAssemblyParameters().k;
    int maxPathLength = pc.getAssemblyParameters().positional.maxPathLengthInBases(maxReadLength);
    int maxPathCollapseLength = pc.getAssemblyParameters().errorCorrection.maxPathCollapseLengthInBases(maxReadLength);
    tracker = new EvidenceTracker();
    SupportNodeIterator supportIt = new SupportNodeIterator(k, Arrays.stream(input).iterator(), aes.getMaxConcordantFragmentSize(), tracker, pc.getAssemblyParameters().includePairAnchors, pc.getAssemblyParameters().pairAnchorMismatchIgnoreEndBases);
    AggregateNodeIterator agIt = new AggregateNodeIterator(supportIt);
    Iterator<KmerPathNode> pnIt = new PathNodeIterator(agIt, maxPathLength, k);
    if (collapse) {
        pnIt = new PathCollapseIterator(pnIt, k, maxPathCollapseLength, pc.getAssemblyParameters().errorCorrection.maxBaseMismatchForCollapse, pc.getAssemblyParameters().errorCorrection.collapseBubblesOnly, 0);
        pnIt = new PathSimplificationIterator(pnIt, maxPathLength, maxEvidenceWidth);
    }
    caller = new NonReferenceContigAssembler(pnIt, 0, maxEvidenceWidth + maxReadLength + 2, maxReadLength, k, aes, new SequentialIdGenerator("asm"), tracker, "test");
    return caller;
}
Also used : AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) SequentialIdGenerator(au.edu.wehi.idsv.SequentialIdGenerator) File(java.io.File)

Example 2 with AssemblyEvidenceSource

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

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

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

the class PositionalAssemblerTest method should_assemble_simple_forward_soft_clips.

@Test
public void should_assemble_simple_forward_soft_clips() {
    ProcessingContext pc = getContext();
    pc.getAssemblyParameters().anchorLength = 1;
    AssemblyEvidenceSource aes = AES(pc);
    pc.getAssemblyParameters().k = 4;
    List<DirectedEvidence> input = new ArrayList<DirectedEvidence>();
    // 12345678901234567890
    // ACGTTGGTTA
    // MMMMMSSSSS
    // GCAACGTTGGTTAA
    // MMMMMMMMSSSSSS
    input.add(SCE(FWD, withSequence("ACGTTGGTTA", Read(0, 10, "5M5S"))[0]));
    input.add(SCE(FWD, withSequence("TTTTTGCAACGTTGGTTAA", Read(0, 2, "13M6S"))[0]));
    input.sort(DirectedEvidenceOrder.ByStartEnd);
    List<SingleReadEvidence> r = asAssemblyEvidence(aes, Lists.newArrayList(new PositionalAssembler(pc, aes, new SequentialIdGenerator("asm"), input.iterator())));
    assertEquals(1, r.size());
    assertEquals(new BreakendSummary(0, FWD, 14), r.get(0).getBreakendSummary());
    // anchor length to match breakend length
    assertEquals("AACGTT", S(r.get(0).getAnchorSequence()));
    assertEquals("GGTTAA", S(r.get(0).getBreakendSequence()));
    assertEquals("AACGTTGGTTAA", S(r.get(0).getSAMRecord().getReadBases()));
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) ArrayList(java.util.ArrayList) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) SequentialIdGenerator(au.edu.wehi.idsv.SequentialIdGenerator) SingleReadEvidence(au.edu.wehi.idsv.SingleReadEvidence) Test(org.junit.Test)

Example 5 with AssemblyEvidenceSource

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

the class PositionalAssemblerTest method should_assemble_simple_input.

@Test
public void should_assemble_simple_input() {
    ProcessingContext pc = getContext();
    AssemblyEvidenceSource aes = AES(pc);
    pc.getAssemblyParameters().k = 4;
    List<DirectedEvidence> input = new ArrayList<DirectedEvidence>();
    input.add(SCE(BWD, Read(0, 10, "5S5M")));
    input.add(SCE(FWD, Read(0, 10, "5M5S")));
    input.add(SCE(BWD, Read(0, 100, "5S5M")));
    input.add(SCE(FWD, Read(0, 100, "5M5S")));
    input.sort(DirectedEvidenceOrder.ByStartEnd);
    ArrayList<SAMRecord> r = Lists.newArrayList(new PositionalAssembler(pc, aes, new SequentialIdGenerator("asm"), input.iterator()));
    assertEquals(4, r.size());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) SAMRecord(htsjdk.samtools.SAMRecord) ArrayList(java.util.ArrayList) SequentialIdGenerator(au.edu.wehi.idsv.SequentialIdGenerator) Test(org.junit.Test)

Aggregations

AssemblyEvidenceSource (au.edu.wehi.idsv.AssemblyEvidenceSource)15 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)13 Test (org.junit.Test)11 SAMEvidenceSource (au.edu.wehi.idsv.SAMEvidenceSource)7 SequentialIdGenerator (au.edu.wehi.idsv.SequentialIdGenerator)7 File (java.io.File)7 DirectedEvidence (au.edu.wehi.idsv.DirectedEvidence)6 ArrayList (java.util.ArrayList)6 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)5 VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)5 VariantCaller (au.edu.wehi.idsv.VariantCaller)4 AutoClosingIterator (au.edu.wehi.idsv.util.AutoClosingIterator)4 SAMRecord (htsjdk.samtools.SAMRecord)4 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)2 SingleReadEvidence (au.edu.wehi.idsv.SingleReadEvidence)2 SequentialCoverageAnnotator (au.edu.wehi.idsv.SequentialCoverageAnnotator)1 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)1 Category (org.junit.experimental.categories.Category)1 BuildBamIndex (picard.sam.BuildBamIndex)1