Search in sources :

Example 6 with SynchronousReferenceLookupAdapter

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

the class Manual method assembly_scoring_should_be_symmetrical.

// @Test
@Category(Hg19Tests.class)
public void assembly_scoring_should_be_symmetrical() throws FileNotFoundException {
    File sam = new File("W:/debug/test.bam");
    File ref = Hg19Tests.findHg19Reference();
    ProcessingContext pc = new ProcessingContext(getFSContext(), ref, new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref)), null, getConfig());
    SAMEvidenceSource ses = new SAMEvidenceSource(pc, sam, null, 0);
    List<SAMRecord> reads = getRecords(new File("W:/debug/test.bam.gridss.working/test.bam.sv.bam"));
    List<SplitReadEvidence> list = ses.iterator().stream().filter(e -> e instanceof SplitReadEvidence).map(e -> (SplitReadEvidence) e).filter(e -> e.getSAMRecord().getReadName().equals("variant.chr12-art1000553")).collect(Collectors.toList());
    for (SplitReadEvidence e : list) {
        e.getBreakpointQual();
    }
}
Also used : Iterator(java.util.Iterator) Header(htsjdk.samtools.metrics.Header) IOException(java.io.IOException) SynchronousReferenceLookupAdapter(au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter) Category(org.junit.experimental.categories.Category) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) SAMRecord(htsjdk.samtools.SAMRecord) ArrayList(java.util.ArrayList) GridssConfiguration(au.edu.wehi.idsv.configuration.GridssConfiguration) List(java.util.List) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) Assert(org.junit.Assert) ConfigurationException(org.apache.commons.configuration.ConfigurationException) SAMRecord(htsjdk.samtools.SAMRecord) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) SynchronousReferenceLookupAdapter(au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter) Category(org.junit.experimental.categories.Category)

Example 7 with SynchronousReferenceLookupAdapter

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

the class ExtractSVReadsTest method regression_should_extract_split_read_alignments_as_group.

// @Test
@Category(Hg38Tests.class)
public void regression_should_extract_split_read_alignments_as_group() throws IOException {
    File ref = Hg38Tests.findHg38Reference();
    ReferenceLookup lookup = new SynchronousReferenceLookupAdapter(new IndexedFastaSequenceFile(ref));
    Files.copy(new File("src/test/resources/sa.split/test1.sam"), input);
    ExtractSVReads extract = new ExtractSVReads();
    // new ProcessingContext(getFSContext(), ref, lookup, null, getConfig());
    extract.setReference(lookup);
    extract.MIN_CLIP_LENGTH = 4;
    extract.INSERT_SIZE_METRICS = new File("src/test/resources/sa.split/test.insert_size_metrics");
    extract.READ_PAIR_CONCORDANCE_METHOD = ReadPairConcordanceMethod.PERCENTAGE;
    extract.OUTPUT = output;
    extract.INPUT = input;
    try (SamReader reader = SamReaderFactory.make().open(input)) {
        extract.setup(reader.getFileHeader(), input);
    }
    List<SAMRecord> records = getRecords(input);
    List<Boolean> result = records.stream().map(r -> extract.shouldExtract(ImmutableList.of(r), lookup)[0]).collect(Collectors.toList());
    /*
		for (int i = 0; i < records.size(); i++) {
			SAMRecord r = records.get(i);
			System.out.print(r.getSupplementaryAlignmentFlag() ? "S" : " ");
			System.out.print(r.getFirstOfPairFlag() ? "1" : "2");
			System.out.print(" Extracted=" + (result.get(i) ? "y" : "n"));
			System.out.print(" HasConcPair=" + (ExtractSVReads.hasReadPairingConsistentWithReference(extract.getReadPairConcordanceCalculator(), ImmutableList.of(r)) ? "y" : "n"));
			boolean[] ra = ExtractSVReads.hasReadAlignmentConsistentWithReference(ImmutableList.of(r));
			System.out.print(" HasConcRead=" + (ra[0] ? "y" : "n") + (ra[1] ? "y" : "n"));
			System.out.println(" " + new ChimericAlignment(r).toString());
		}
		*/
    Assert.assertEquals(records.stream().map(r -> r.getSecondOfPairFlag()).collect(Collectors.toList()), result);
    lookup.close();
}
Also used : FixedSizeReadPairConcordanceCalculator(au.edu.wehi.idsv.FixedSizeReadPairConcordanceCalculator) Iterables(com.google.common.collect.Iterables) ReadPairConcordanceMethod(au.edu.wehi.idsv.ReadPairConcordanceMethod) Iterators(com.google.common.collect.Iterators) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Files(com.google.common.io.Files) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) StructuralVariantReadMetrics(gridss.analysis.StructuralVariantReadMetrics) ChimericAlignment(au.edu.wehi.idsv.sam.ChimericAlignment) ReferenceLookup(au.edu.wehi.idsv.picard.ReferenceLookup) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) SynchronousReferenceLookupAdapter(au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter) Category(org.junit.experimental.categories.Category) SamReader(htsjdk.samtools.SamReader) MetricsFile(htsjdk.samtools.metrics.MetricsFile) Collectors(java.util.stream.Collectors) File(java.io.File) SAMRecord(htsjdk.samtools.SAMRecord) List(java.util.List) Hg38Tests(au.edu.wehi.idsv.Hg38Tests) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) Assert.assertFalse(org.junit.Assert.assertFalse) Assert(org.junit.Assert) SamReaderFactory(htsjdk.samtools.SamReaderFactory) Assert.assertEquals(org.junit.Assert.assertEquals) SamReader(htsjdk.samtools.SamReader) ReferenceLookup(au.edu.wehi.idsv.picard.ReferenceLookup) SAMRecord(htsjdk.samtools.SAMRecord) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) SynchronousReferenceLookupAdapter(au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter) Category(org.junit.experimental.categories.Category)

Aggregations

SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)7 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)7 File (java.io.File)7 Category (org.junit.experimental.categories.Category)7 SAMRecord (htsjdk.samtools.SAMRecord)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 IOException (java.io.IOException)4 Assert (org.junit.Assert)4 Test (org.junit.Test)4 Lists (com.google.common.collect.Lists)3 SamReader (htsjdk.samtools.SamReader)3 SamReaderFactory (htsjdk.samtools.SamReaderFactory)3 Header (htsjdk.samtools.metrics.Header)3 FileNotFoundException (java.io.FileNotFoundException)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 FixedSizeReadPairConcordanceCalculator (au.edu.wehi.idsv.FixedSizeReadPairConcordanceCalculator)2 Hg38Tests (au.edu.wehi.idsv.Hg38Tests)2