Search in sources :

Example 6 with DirectedEvidence

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

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

Example 8 with DirectedEvidence

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

the class PositionalAssemblerTest method rp_anchor_should_set_non_reference_bases_as_anchoring.

@Test
public void rp_anchor_should_set_non_reference_bases_as_anchoring() {
    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
    // TTTTTGCAACGTTGGTTAA
    input.add(SCE(FWD, withSequence("ACGTTGGTTA", Read(0, 10, "5M5S"))[0]));
    input.add(SCE(FWD, withSequence("TTTTTGCAACGTTGGTTAA", Read(0, 2, "13M6S"))[0]));
    input.add(NRRP(withSequence("TTTTTGCAACGTTGGTTAA", DP(0, 2, "13M6S", true, 1, 1, "19M", false))));
    input.sort(DirectedEvidenceOrder.ByStartEnd);
    List<SingleReadEvidence> r = asAssemblyEvidence(aes, Lists.newArrayList(new PositionalAssembler(pc, aes, new SequentialIdGenerator("asm"), input.iterator())));
    assertEquals(2, r.size());
    // race condition w.r.t which assembly returns first
    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 9 with DirectedEvidence

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

the class AnnotateVariants method writeAssemblyBreakends.

public static void writeAssemblyBreakends(File file, AssemblyEvidenceSource assemblyEvidence) throws IOException {
    log.info("Writing breakend assembly support.");
    File tmp = gridss.Defaults.OUTPUT_TO_TEMP_FILE ? FileSystemContext.getWorkingFileFor(file) : file;
    try (BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(tmp))) {
        try (CloseableIterator<DirectedEvidence> it = assemblyEvidence.iterator()) {
            while (it.hasNext()) {
                SingleReadEvidence ass = (SingleReadEvidence) it.next();
                if (!ass.getSAMRecord().isSecondaryOrSupplementary()) {
                    writer.write('>');
                    writer.write(ass.getEvidenceID().getBytes(StandardCharsets.US_ASCII));
                    writer.write('\n');
                    if (ass.getBreakendSummary().direction == BreakendDirection.Forward) {
                        writer.write(ass.getAnchorSequence(), 0, ass.getAnchorSequence().length);
                        writer.write(ass.getBreakendSequence(), 0, ass.getBreakendSequence().length);
                    } else {
                        writer.write(ass.getBreakendSequence(), 0, ass.getBreakendSequence().length);
                        writer.write(ass.getAnchorSequence(), 0, ass.getAnchorSequence().length);
                    }
                    writer.write('\n');
                }
            }
        }
    }
    if (tmp != file) {
        Files.move(tmp, file);
    }
    log.info("Writing breakend assembly support complete.");
}
Also used : DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) FileOutputStream(java.io.FileOutputStream) SingleReadEvidence(au.edu.wehi.idsv.SingleReadEvidence) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 10 with DirectedEvidence

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

the class AllocateEvidence method annotate.

private VariantContextDirectedBreakpoint annotate(VariantEvidenceSupport ves) {
    VariantCallingConfiguration vc = getContext().getConfig().getVariantCalling();
    StructuralVariationCallBuilder builder = new StructuralVariationCallBuilder(getContext(), ves.variant);
    for (DirectedEvidence e : ves.support) {
        boolean shouldExclude = false;
        if (!shouldExclude) {
            builder.addEvidence(e);
        }
    }
    VariantContextDirectedBreakpoint bp = (VariantContextDirectedBreakpoint) builder.make();
    if (!vc.writeFiltered) {
        if (bp.getBreakpointQual() < vc.minScore)
            return null;
        if (bp.getBreakpointEvidenceCount() < vc.minReads)
            return null;
        if (bp.isFiltered())
            return null;
    }
    bp = (VariantContextDirectedBreakpoint) vc.applyConfidenceFilter(getContext(), bp);
    return bp;
}
Also used : StructuralVariationCallBuilder(au.edu.wehi.idsv.StructuralVariationCallBuilder) VariantCallingConfiguration(au.edu.wehi.idsv.configuration.VariantCallingConfiguration) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint)

Aggregations

DirectedEvidence (au.edu.wehi.idsv.DirectedEvidence)22 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)18 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)14 SAMRecord (htsjdk.samtools.SAMRecord)14 AssemblyEvidenceSource (au.edu.wehi.idsv.AssemblyEvidenceSource)9 SequentialIdGenerator (au.edu.wehi.idsv.SequentialIdGenerator)8 File (java.io.File)6 Lists (com.google.common.collect.Lists)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 NonReferenceReadPair (au.edu.wehi.idsv.NonReferenceReadPair)4 SAMEvidenceSource (au.edu.wehi.idsv.SAMEvidenceSource)4 SoftClipEvidence (au.edu.wehi.idsv.SoftClipEvidence)4 IOException (java.io.IOException)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)3 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)3 SingleReadEvidence (au.edu.wehi.idsv.SingleReadEvidence)3