Search in sources :

Example 6 with AutoClosingIterator

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

the class SAMEvidenceSource method iterator.

public CloseableIterator<DirectedEvidence> iterator() {
    SamReader reader = getReader();
    SAMRecordIterator it = reader.iterator();
    it.assertSorted(SortOrder.coordinate);
    Iterator<DirectedEvidence> eit = asEvidence(it);
    return new AutoClosingIterator<>(eit, reader, it);
}
Also used : SamReader(htsjdk.samtools.SamReader) SAMRecordIterator(htsjdk.samtools.SAMRecordIterator) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator)

Example 7 with AutoClosingIterator

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

the class VcfTransformCommandLineProgram method getBreakpoints.

public CloseableIterator<VariantContextDirectedBreakpoint> getBreakpoints(File file) {
    VCFFileReader vcfReader = new VCFFileReader(file, false);
    CloseableIterator<VariantContext> it = vcfReader.iterator();
    Iterator<IdsvVariantContext> idsvIt = Iterators.transform(it, variant -> IdsvVariantContext.create(getContext(), null, variant));
    Iterator<VariantContextDirectedBreakpoint> bpit = Iterators.filter(idsvIt, VariantContextDirectedBreakpoint.class);
    // resort by evidence start
    bpit = new DirectEvidenceWindowedSortingIterator<>(getContext(), SAMEvidenceSource.maximumWindowSize(getContext(), getSamEvidenceSources(), getAssemblySource()), bpit);
    return new AutoClosingIterator<VariantContextDirectedBreakpoint>(bpit, it, vcfReader);
}
Also used : VCFFileReader(htsjdk.variant.vcf.VCFFileReader) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) VariantContext(htsjdk.variant.variantcontext.VariantContext) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) IdsvVariantContext(au.edu.wehi.idsv.IdsvVariantContext) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint)

Example 8 with AutoClosingIterator

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

the class AllocateEvidenceTest method should_filter_if_insufficient_reads.

@Test
public void should_filter_if_insufficient_reads() throws IOException {
    final ProcessingContext pc = getCommandlineContext();
    pc.getVariantCallingParameters().minScore = 0;
    pc.getVariantCallingParameters().minSize = 0;
    pc.getVariantCallingParameters().minReads = 3;
    createInput(RP(0, 1, 10), DP(0, 1, "5M5S", true, 1, 10, "5M", true));
    SAMEvidenceSource ses = new SAMEvidenceSource(getContext(), input, null, 0);
    ses.ensureMetrics();
    File assemblyFile = new File(testFolder.getRoot(), "assembly.bam");
    AssemblyEvidenceSource aes = new AssemblyEvidenceSource(pc, ImmutableList.of(ses), assemblyFile);
    aes.assembleBreakends(null);
    aes.ensureExtracted();
    VariantCaller caller = new VariantCaller(pc, ImmutableList.of(ses), aes);
    caller.callBreakends(output, MoreExecutors.newDirectExecutorService());
    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");
    List<VariantContextDirectedBreakpoint> vcfs = Lists.newArrayList(Iterables.filter(getVcf(output, null), VariantContextDirectedBreakpoint.class));
    List<VariantContextDirectedBreakpoint> results = Lists.newArrayList(cmd.iterator(new AutoClosingIterator<>(vcfs.iterator()), MoreExecutors.newDirectExecutorService()));
    assertEquals(2, vcfs.size());
    assertEquals(0, results.size());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) VariantCaller(au.edu.wehi.idsv.VariantCaller) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Example 9 with AutoClosingIterator

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

the class AllocateEvidenceTest method should_filter_if_insufficient_quality.

@Test
public void should_filter_if_insufficient_quality() throws IOException {
    final ProcessingContext pc = getCommandlineContext();
    pc.getVariantCallingParameters().minScore = 1000;
    pc.getVariantCallingParameters().minSize = 0;
    pc.getVariantCallingParameters().minReads = 0;
    createInput(RP(0, 1, 10), DP(0, 1, "5M5S", true, 1, 10, "5M", true));
    SAMEvidenceSource ses = new SAMEvidenceSource(getContext(), input, null, 0);
    ses.ensureMetrics();
    File assemblyFile = new File(testFolder.getRoot(), "assembly.bam");
    AssemblyEvidenceSource aes = new AssemblyEvidenceSource(pc, ImmutableList.of(ses), assemblyFile);
    aes.assembleBreakends(null);
    aes.ensureExtracted();
    VariantCaller caller = new VariantCaller(pc, ImmutableList.of(ses), aes);
    caller.callBreakends(output, MoreExecutors.newDirectExecutorService());
    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");
    List<VariantContextDirectedBreakpoint> vcfs = Lists.newArrayList(Iterables.filter(getVcf(output, null), VariantContextDirectedBreakpoint.class));
    List<VariantContextDirectedBreakpoint> results = Lists.newArrayList(cmd.iterator(new AutoClosingIterator<>(vcfs.iterator()), MoreExecutors.newDirectExecutorService()));
    assertEquals(0, results.size());
}
Also used : ProcessingContext(au.edu.wehi.idsv.ProcessingContext) AssemblyEvidenceSource(au.edu.wehi.idsv.AssemblyEvidenceSource) AutoClosingIterator(au.edu.wehi.idsv.util.AutoClosingIterator) VariantContextDirectedBreakpoint(au.edu.wehi.idsv.VariantContextDirectedBreakpoint) SAMEvidenceSource(au.edu.wehi.idsv.SAMEvidenceSource) VariantCaller(au.edu.wehi.idsv.VariantCaller) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Aggregations

AutoClosingIterator (au.edu.wehi.idsv.util.AutoClosingIterator)9 VariantContextDirectedBreakpoint (au.edu.wehi.idsv.VariantContextDirectedBreakpoint)6 File (java.io.File)5 AssemblyEvidenceSource (au.edu.wehi.idsv.AssemblyEvidenceSource)4 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)4 ProcessingContext (au.edu.wehi.idsv.ProcessingContext)4 SAMEvidenceSource (au.edu.wehi.idsv.SAMEvidenceSource)4 VariantCaller (au.edu.wehi.idsv.VariantCaller)4 Test (org.junit.Test)4 SAMRecordIterator (htsjdk.samtools.SAMRecordIterator)3 IdsvVariantContext (au.edu.wehi.idsv.IdsvVariantContext)2 SAMRecord (htsjdk.samtools.SAMRecord)2 SamReader (htsjdk.samtools.SamReader)2 VariantContextWindowedSortingIterator (au.edu.wehi.idsv.VariantContextWindowedSortingIterator)1 IntervalBed (au.edu.wehi.idsv.bed.IntervalBed)1 GridssConfiguration (au.edu.wehi.idsv.configuration.GridssConfiguration)1 SoftClipConfiguration (au.edu.wehi.idsv.configuration.SoftClipConfiguration)1 IdsvSamFileMetrics (au.edu.wehi.idsv.metrics.IdsvSamFileMetrics)1 ChimericAlignment (au.edu.wehi.idsv.sam.ChimericAlignment)1 CigarUtil (au.edu.wehi.idsv.sam.CigarUtil)1