Search in sources :

Example 1 with DirectedEvidence

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

the class NonReferenceContigAssemblerTest method should_call_suboptimal_contigs_if_graph_size_limit_exceeded.

@Test
public void should_call_suboptimal_contigs_if_graph_size_limit_exceeded() {
    ProcessingContext pc = getContext();
    MockSAMEvidenceSource ses = SES(10, 10);
    pc.getAssemblyParameters().k = 4;
    pc.getAssemblyParameters().maxExpectedBreakendLengthMultiple = 1;
    pc.getAssemblyParameters().positional.retainWidthMultiple = 1;
    pc.getAssemblyParameters().positional.flushWidthMultiple = 2;
    List<DirectedEvidence> e = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < i + 1; j++) {
            e.add(SCE(FWD, ses, withReadName(String.format("%d-%d", i, j), withSequence("AACCGGTT", Read(0, i, "4M4S")))[0]));
        }
    }
    List<SAMRecord> output = go(pc, false, e.toArray(new DirectedEvidence[0]));
    assertEquals(100, output.size());
    // unbounded execution would call high->low thus call the last contig first
    // bounded execution will force the early calls to be made first
    List<Integer> startPos = output.stream().map(x -> x.getAlignmentStart()).collect(Collectors.toList());
    assertFalse(Ordering.natural().reverse().isOrdered(startPos));
}
Also used : AssemblyAttributes(au.edu.wehi.idsv.AssemblyAttributes) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) Arrays(java.util.Arrays) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) SequentialIdGenerator(au.edu.wehi.idsv.SequentialIdGenerator) SAMRecordUtil(au.edu.wehi.idsv.sam.SAMRecordUtil) ArrayList(java.util.ArrayList) TestHelper(au.edu.wehi.idsv.TestHelper) Lists(com.google.common.collect.Lists) ProcessingContext(au.edu.wehi.idsv.ProcessingContext) NonReferenceReadPair(au.edu.wehi.idsv.NonReferenceReadPair) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) File(java.io.File) SAMRecord(htsjdk.samtools.SAMRecord) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) List(java.util.List) Ordering(com.google.common.collect.Ordering) Assert.assertFalse(org.junit.Assert.assertFalse) Assert(org.junit.Assert) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) Assert.assertEquals(org.junit.Assert.assertEquals) ProcessingContext(au.edu.wehi.idsv.ProcessingContext) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) SAMRecord(htsjdk.samtools.SAMRecord) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with DirectedEvidence

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

the class NonReferenceContigAssemblerTest method should_not_remove_misassembled_partial_paths_when_could_be_collapsed_with_adjacent_read.

@Test
public void should_not_remove_misassembled_partial_paths_when_could_be_collapsed_with_adjacent_read() {
    ProcessingContext pc = getContext();
    MockSAMEvidenceSource ses = SES(10, 10);
    pc.getAssemblyParameters().k = 2;
    pc.getAssemblyParameters().maxExpectedBreakendLengthMultiple = 5;
    pc.getAssemblyParameters().removeMisassembledPartialContigsDuringAssembly = true;
    pc.getAssemblyParameters().positional.flushWidthMultiple = 100000;
    pc.getAssemblyParameters().positional.maxPathLengthMultiple = 4;
    List<DirectedEvidence> e = new ArrayList<>();
    for (int i = 1; i < 1000; i += 1) {
        SAMRecord[] rp = OEA(0, i, "2M", true);
        rp[0].setReadBases(B("GG"));
        // expect reverse comp of read sequence
        rp[1].setReadBases(B("AA"));
        e.add(NRRP(ses, rp));
    }
    go(pc, true, e.toArray(new DirectedEvidence[0]));
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) SAMRecord(htsjdk.samtools.SAMRecord) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with DirectedEvidence

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

the class NonReferenceContigAssemblerTest method should_remove_fully_reference_evidence_before_end.

@Test
public void should_remove_fully_reference_evidence_before_end() {
    ProcessingContext pc = getContext();
    pc.getAssemblyParameters().k = 4;
    int n = 8;
    DirectedEvidence[] input = new DirectedEvidence[2 * n];
    for (int i = 0; i < n; i++) {
        input[2 * i] = SCE(FWD, withSequence("ACGTGGTCGACC", Read(0, 1000 * i, "6M6S")));
        input[2 * i + 1] = SCE(FWD, withSequence("AACGTGG", Read(0, 1000 * i - 1, "6M1S")));
    }
    NonReferenceContigAssembler caller = create(pc, true, input);
    for (int i = 0; i < n / 2; i++) {
        caller.next();
    }
    assertTrue(caller.tracking_activeNodes() <= 3);
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) Test(org.junit.Test)

Example 4 with DirectedEvidence

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

the class AggregateNodeIteratorTest method should_aggregate_kmer_weights.

@Test
public void should_aggregate_kmer_weights() {
    int k = 4;
    SAMEvidenceSource ses = SES(30, 60);
    List<DirectedEvidence> input = new ArrayList<DirectedEvidence>();
    input.add(NRRP(ses, withQual(new byte[] { 1, 1, 1, 1, 1 }, withSequence("ACGTT", DP(0, 1, "5M", false, 1, 1, "5M", false)))));
    input.add(NRRP(ses, withQual(new byte[] { 1, 1, 1, 1, 1 }, withSequence("ACGTT", DP(0, 2, "5M", false, 1, 1, "5M", false)))));
    Collections.sort(input, DirectedEvidence.ByStartEnd);
    List<KmerSupportNode> snList = Lists.newArrayList(new SupportNodeIterator(k, input.iterator(), ses.getMaxConcordantFragmentSize(), null, false, 0));
    List<KmerNode> anList = Lists.newArrayList(new AggregateNodeIterator(snList.iterator()));
    assertTrue(KmerNodeUtil.ByLastStart.isOrdered(anList));
    assertEquals(4, snList.size());
    assertEquals(6, anList.size());
}
Also used : DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) ArrayList(java.util.ArrayList) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) Test(org.junit.Test)

Example 5 with DirectedEvidence

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

the class CallVariantsTest method test_sr_rp_assembly.

@Test
public void test_sr_rp_assembly() throws IOException {
    List<DirectedEvidence> in = new ArrayList<DirectedEvidence>();
    in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "5M6S"))));
    in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "6M5S"))));
    in.add(NRRP(withSequence("AACCGGTTCTA", DP(0, 1, "11M", true, 1, 100, "11M", false))));
    in.add(NRRP(withSequence("AACCGGTTCTA", DP(0, 2, "11M", true, 1, 100, "11M", false))));
    List<SAMRecord> insam = in.stream().flatMap(de -> {
        if (de instanceof SoftClipEvidence)
            return ImmutableList.<SAMRecord>of(((SoftClipEvidence) de).getSAMRecord()).stream();
        if (de instanceof NonReferenceReadPair)
            return ImmutableList.<SAMRecord>of(((NonReferenceReadPair) de).getNonReferenceRead(), ((NonReferenceReadPair) de).getLocalledMappedRead()).stream();
        throw new RuntimeException("NYI");
    }).collect(Collectors.toList());
    insam.addAll(Lists.newArrayList(RP(0, 1, 100, 10)));
    createInput(insam);
    File propfile = testFolder.newFile("custom.properties");
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(propfile))) {
        writer.write("assembly.k=5\n");
        writer.write("softclip.minLength=1\n");
        writer.write("minAnchorShannonEntropy=0\n");
        writer.write("softclip.minAnchorIdentity=0\n");
        writer.write("softclip.minAverageQual=0\n");
        writer.write("realignment.aligner=\n");
    }
    File assembly = new File(testFolder.getRoot(), "assembly.bam");
    String[] args = new String[] { "INPUT=" + input.toString(), "ASSEMBLY=" + assembly.toString(), "REFERENCE_SEQUENCE=" + reference.toString(), "OUTPUT=" + output.toString(), "TMP_DIR=" + super.testFolder.getRoot().toString(), "WORKING_DIR=" + super.testFolder.getRoot().toString(), "CONFIGURATION_FILE=" + propfile.toString(), "INPUT_MIN_FRAGMENT_SIZE=10", "INPUT_MAX_FRAGMENT_SIZE=100" };
    assertEquals(0, new CallVariants().instanceMain(args));
    List<SAMRecord> breakendAssemblies = getRecords(assembly);
    assertEquals(1, breakendAssemblies.size());
    assembly.delete();
}
Also used : IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) NonReferenceReadPair(au.edu.wehi.idsv.NonReferenceReadPair) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) File(java.io.File) SAMRecord(htsjdk.samtools.SAMRecord) ArrayList(java.util.ArrayList) SortOrder(htsjdk.samtools.SAMFileHeader.SortOrder) List(java.util.List) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) Assert.assertEquals(org.junit.Assert.assertEquals) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) BufferedWriter(java.io.BufferedWriter) NonReferenceReadPair(au.edu.wehi.idsv.NonReferenceReadPair) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) DirectedEvidence(au.edu.wehi.idsv.DirectedEvidence) SAMRecord(htsjdk.samtools.SAMRecord) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

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