Search in sources :

Example 11 with SoftClipEvidence

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

Example 12 with SoftClipEvidence

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

the class KmerEvidenceTest method createAnchor_should_check_reference_overrun.

@Test
public void createAnchor_should_check_reference_overrun() {
    SoftClipEvidence placholderEvidence = SCE(BWD, Read(0, 1, "2S5M2S"));
    assertEquals(5, nodesNotNull(KmerEvidence.createAnchor(placholderEvidence, 1, Read(0, 1, "2S5M2S"), BWD, 2, SMALL_FA)));
    assertEquals(5, nodesNotNull(KmerEvidence.createAnchor(placholderEvidence, 1, Read(0, 1, "2S5M2S"), FWD, 2, SMALL_FA)));
    // overruns on both end
    assertEquals(2, nodesNotNull(KmerEvidence.createAnchor(placholderEvidence, 1, Read(0, -10, "10M"), FWD, 4, SMALL_FA)));
    // end overrun
    assertEquals(1, nodesNotNull(KmerEvidence.createAnchor(placholderEvidence, 1, Read(0, 10000, "10M"), FWD, 10, SMALL_FA)));
}
Also used : SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) Test(org.junit.Test)

Example 13 with SoftClipEvidence

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

the class CallVariantsTest method should_handle_unpaired_libraries.

@Test
public void should_handle_unpaired_libraries() throws IOException {
    List<DirectedEvidence> in = new ArrayList<DirectedEvidence>();
    in.add(SCE(FWD, withSequence("AACCGGTTCTA", Read(0, 15, "5M6S"))));
    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());
    createInput(insam);
    File assembly = new File(testFolder.getRoot(), "assembly.bam");
    createBAM(assembly, SortOrder.coordinate);
    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() };
    assertEquals(0, new CallVariants().instanceMain(args));
    assertTrue(output.exists());
    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) ArrayList(java.util.ArrayList) 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)

Example 14 with SoftClipEvidence

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

the class NonReferenceContigAssemblerTest method should_truncate_anchored_polyA_expansion_bwd.

@Test
public void should_truncate_anchored_polyA_expansion_bwd() {
    ProcessingContext pc = getContext();
    pc.getAssemblyParameters().k = 4;
    SoftClipEvidence sce = SCE(BWD, withSequence("AAAAGTAC", Read(0, 100, "4S4M")));
    DiscordantReadPair dp = (DiscordantReadPair) NRRP(SES(11, 100), withSequence("CAAAAG", DP(0, 110, "6M", false, 1, 1, "6M", true)));
    List<SAMRecord> output = go(pc, true, sce, dp);
    assertEquals(1, output.size());
    assertEquals("AAAAGTAC", S(output.get(0).getReadBases()));
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) SAMRecord(htsjdk.samtools.SAMRecord) DiscordantReadPair(au.edu.wehi.idsv.DiscordantReadPair) Test(org.junit.Test)

Example 15 with SoftClipEvidence

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

the class NonReferenceContigAssemblerTest method should_remove_fully_reference_evidence.

@Test
public void should_remove_fully_reference_evidence() {
    ProcessingContext pc = getContext();
    pc.getAssemblyParameters().k = 4;
    SoftClipEvidence sce = SCE(FWD, withSequence("ACGTGGTCGACC", Read(0, 50, "6M6S")));
    SoftClipEvidence fullref = SCE(FWD, withSequence("ACGTGG", Read(0, 50, "5M1S")));
    List<SAMRecord> output = go(pc, true, sce, fullref);
    assertEquals(1, output.size());
    assertEquals("ACGTGGTCGACC", S(output.get(0).getReadBases()));
    assertEquals(2, tracker.tracking_evidenceTotal());
    assertEquals(0, tracker.tracking_evidenceActive());
    assertEquals(0, caller.tracking_activeNodes());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) SoftClipEvidence(au.edu.wehi.idsv.SoftClipEvidence) SAMRecord(htsjdk.samtools.SAMRecord) Test(org.junit.Test)

Aggregations

SoftClipEvidence (au.edu.wehi.idsv.SoftClipEvidence)22 Test (org.junit.Test)22 SAMRecord (htsjdk.samtools.SAMRecord)14 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)12 DiscordantReadPair (au.edu.wehi.idsv.DiscordantReadPair)10 DirectedEvidence (au.edu.wehi.idsv.DirectedEvidence)3 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)2 NonReferenceReadPair (au.edu.wehi.idsv.NonReferenceReadPair)2 ImmutableList (com.google.common.collect.ImmutableList)2 Lists (com.google.common.collect.Lists)2 SortOrder (htsjdk.samtools.SAMFileHeader.SortOrder)2 BufferedWriter (java.io.BufferedWriter)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2