Search in sources :

Example 1 with DiscordantReadPair

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

the class NonReferenceContigAssemblerTest method should_call_simple_fwd_RP.

@Test
public void should_call_simple_fwd_RP() {
    ProcessingContext pc = getContext();
    pc.getAssemblyParameters().k = 4;
    SAMEvidenceSource ses = SES(100, 200);
    DiscordantReadPair e = (DiscordantReadPair) NRRP(ses, withSequence("ACGTGGTCGACC", DP(0, 50, "12M", true, 1, 1, "12M", false)));
    List<SAMRecord> output = go(pc, true, e);
    assertEquals(1, output.size());
    SoftClipEvidence ass = SoftClipEvidence.create(AES(ses), FWD, output.get(0));
    assertEquals(e.getBreakendSummary().localBreakend(), ass.getBreakendSummary());
    assertEquals("ACGTGGTCGACC", S(ass.getBreakendSequence()));
    assertEquals("", S(ass.getAnchorSequence()));
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) SAMRecord(htsjdk.samtools.SAMRecord) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) Test(org.junit.Test)

Example 2 with DiscordantReadPair

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

the class PathNodeIteratorTest method should_overlapping_adjacent_sc_rp.

@Test
public void should_overlapping_adjacent_sc_rp() {
    SoftClipEvidence sc = SCE(FWD, withSequence("ACGTGGTCGACC", Read(0, 50, "6M6S")));
    DiscordantReadPair rp = (DiscordantReadPair) NRRP(SES(13, 200), withSequence("TCGACCTCCGGAA", DP(0, 25, "13M", true, 1, 1, "13M", false)));
    List<KmerPathNode> result = asCheckedKPN(5, 1000, sc, rp);
    assertCompleteGraph(result, 5);
    assertEquals(5, result.size());
    assertEquals(4, result.stream().mapToInt(n -> n.next().size()).sum());
    assertEquals(4, result.stream().mapToInt(n -> n.prev().size()).sum());
}
Also used : SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) Test(org.junit.Test)

Example 3 with DiscordantReadPair

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

the class ContigCallerTest method should_assemble_overlapping_sc_rp.

@Test
public void should_assemble_overlapping_sc_rp() {
    SoftClipEvidence sc = SCE(FWD, withSequence("ACGTGGTCGACC", Read(0, 50, "6M6S")));
    DiscordantReadPair rp = (DiscordantReadPair) NRRP(SES(10, 200), withSequence("GACCTCCGGAA", DP(0, 25, "11M", true, 1, 1, "11M", false)));
    ArrayList<KmerPathNode> in = Lists.newArrayList(asKPN(4, 1000, sc, rp));
    String result = S(getCaller(in, 1000).bestContig(Integer.MAX_VALUE), 4);
    // assertEquals(3, result.size()); // SC+RP, RP starting before SC, RP starting after SC
    assertEquals("TGGTCGACCTCCGGAA", result);
// assertEquals("GACCTCCGGAA", result.get(1));
// assertEquals("GACCTCCGGAA", result.get(2));
}
Also used : SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) Test(org.junit.Test)

Example 4 with DiscordantReadPair

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

the class ContigCallerTest method should_preference_anchored_paths.

@Test
public void should_preference_anchored_paths() {
    // both sides anchored
    SoftClipEvidence spanf = SCE(FWD, withSequence("TGTTAATTGT", Read(0, 1, "4M6S")));
    SoftClipEvidence spanb = SCE(BWD, withSequence("TGTTAATTGT", Read(0, 7, "6S4M")));
    // start anchored
    SoftClipEvidence scf = SCE(FWD, withSequence("ACGTGGTCGACC", Read(0, 5, "6M6S")));
    // end anchored (but less support)
    SoftClipEvidence scb = SCE(BWD, withSequence("GTCAGTC", Read(0, 5, "3S4M")));
    // unanchored
    DiscordantReadPair e = (DiscordantReadPair) NRRP(SES(20, 30), withSequence("GACCTCTACT", DP(0, 25, "10M", true, 1, 1, "10M", false)));
    String result = S(getCaller(Lists.newArrayList(asKPN(4, 100, spanf, spanb, scf, scb, e)), 100).bestContig(Integer.MAX_VALUE), 4);
    // assertEquals(4, result.size());
    // only returns the unanchored kmers
    assertEquals("GTTAATTG", result);
// assertEquals("TGGTCGACC", result.get(1));
// assertEquals("GTCAGT", result.get(2));
// assertEquals("GACCTCTACT", result.get(3));
}
Also used : SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) Test(org.junit.Test)

Example 5 with DiscordantReadPair

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

the class AllocateEvidenceTest method should_uniquely_assign.

@Test
public void should_uniquely_assign() throws IOException, InterruptedException, ExecutionException {
    final int fragSize = 4;
    final int testSize = 64;
    final List<SAMRecord> in = new ArrayList<SAMRecord>();
    final ProcessingContext pc = getCommandlineContext();
    pc.getVariantCallingParameters().writeFiltered = true;
    pc.getVariantCallingParameters().minScore = 0;
    StubSAMEvidenceSource ses = new StubSAMEvidenceSource(pc, input, 0, 0, fragSize);
    for (int i = 1; i < testSize; i++) {
        for (int j = 1; j < testSize; j++) {
            SAMRecord[] dp = withReadName(String.format("read-%d-%d", i, j), DP(0, i, "1M", true, 1, j, "1M", false));
            ses.evidence.add(NonReferenceReadPair.create(dp[0], dp[1], ses));
            ses.evidence.add(NonReferenceReadPair.create(dp[1], dp[0], ses));
            in.add(dp[0]);
            in.add(dp[1]);
        }
    }
    StubAssemblyEvidenceSource aes = new StubAssemblyEvidenceSource(pc);
    aes.fragSize = fragSize;
    Collections.sort(ses.evidence, DirectedEvidenceOrder.ByNatural);
    createInput(in);
    VariantCaller vc = new VariantCaller(pc, ImmutableList.<SAMEvidenceSource>of(ses), aes);
    ExecutorService threadpool = Executors.newSingleThreadExecutor();
    vc.callBreakends(output, threadpool);
    threadpool.shutdown();
    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");
    cmd.ASSEMBLY = new File(testFolder.getRoot(), "assembly.bam");
    // to shut up the command-line parsing
    createBAM(cmd.ASSEMBLY, SortOrder.coordinate, Collections.emptyList());
    cmd.doWork(null);
    // List<IdsvVariantContext> annotated = getVcf(new File(testFolder.getRoot(), "out.vcf"), null);
    List<IdsvVariantContext> rawcalls = getVcf(output, null);
    List<IdsvVariantContext> calls = getVcf(cmd.OUTPUT_VCF, null);
    assertSymmetrical(rawcalls.stream().map(x -> (VariantContextDirectedBreakpoint) x).collect(Collectors.toList()));
    assertSymmetrical(calls.stream().map(x -> (VariantContextDirectedBreakpoint) x).collect(Collectors.toList()));
    // with no filtering, annotation should not change call set
    double expectedEvidence = 0;
    for (DirectedEvidence e : ses.evidence) {
        DiscordantReadPair bp = (DiscordantReadPair) e;
        expectedEvidence += bp.getBreakpointQual();
    }
    double annotatedEvidence = 0;
    for (IdsvVariantContext e : calls) {
        annotatedEvidence += e.getPhredScaledQual();
    }
    double rawEvidence = rawcalls.stream().mapToDouble(e -> e.getPhredScaledQual()).sum();
    // unique assignment must result in the evidence total being, at most, the same
    assertTrue(annotatedEvidence <= rawEvidence);
    // each piece of evidence should be assigned to a single breakpoint so totals should match
    int rpCalls = calls.stream().mapToInt(v -> ((VariantContextDirectedBreakpoint) v).getBreakpointEvidenceCount()).sum();
    assertEquals(ses.evidence.size(), rpCalls);
    // floating point truncation on VCF is severe!
    assertEquals(expectedEvidence, annotatedEvidence, 20);
}
Also used : AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) DirectedEvidenceOrder(au.edu.wehi.idsv.DirectedEvidenceOrder) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) ArrayList(java.util.ArrayList) SortOrder(htsjdk.samtools.SAMFileHeader.SortOrder) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) Lists(com.google.common.collect.Lists) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) ImmutableList(com.google.common.collect.ImmutableList) ProcessingContext(au.edu.wehi.idsv.ProcessingContext) ExecutorService(java.util.concurrent.ExecutorService) VariantCaller(au.edu.wehi.idsv.VariantCaller) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) NonReferenceReadPair(au.edu.wehi.idsv.NonReferenceReadPair) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) File(java.io.File) Executors(java.util.concurrent.Executors) SAMRecord(htsjdk.samtools.SAMRecord) ExecutionException(java.util.concurrent.ExecutionException) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) List(java.util.List) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ProcessingContext(au.edu.wehi.idsv.ProcessingContext) ArrayList(java.util.ArrayList) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) SAMRecord(htsjdk.samtools.SAMRecord) ExecutorService(java.util.concurrent.ExecutorService) VariantCaller(au.edu.wehi.idsv.VariantCaller) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Aggregations

DiscordantReadPair (au.edu.wehi.idsv.DiscordantReadPair)11 Test (org.junit.Test)11 SoftClipEvidence (au.edu.wehi.idsv.SoftClipEvidence)10 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)7 SAMRecord (htsjdk.samtools.SAMRecord)7 SAMEvidenceSource (au.edu.wehi.idsv.SAMEvidenceSource)2 AssemblyEvidenceSource (au.edu.wehi.idsv.AssemblyEvidenceSource)1 DirectedEvidence (au.edu.wehi.idsv.DirectedEvidence)1 DirectedEvidenceOrder (au.edu.wehi.idsv.DirectedEvidenceOrder)1 IdsvVariantContext (au.edu.wehi.idsv.IdsvVariantContext)1 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)1 NonReferenceReadPair (au.edu.wehi.idsv.NonReferenceReadPair)1 VariantCaller (au.edu.wehi.idsv.VariantCaller)1 VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)1 AutoClosingIterator (au.edu.wehi.idsv.util.AutoClosingIterator)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SortOrder (htsjdk.samtools.SAMFileHeader.SortOrder)1