/** * Prepare to filter out SAMRecords that do not overlap the given list of intervals * @param intervals -- must be locus-ordered & non-overlapping */ public IntervalFilter(final List<Interval> intervals, final SAMFileHeader samHeader) { this.samHeader = samHeader; IntervalUtil.assertOrderedNonOverlapping(intervals.iterator(), samHeader.getSequenceDictionary()); this.intervals = intervals.iterator(); advanceInterval(); }
@Test(dataProvider = "testReadsData") public void testReads(final IntervalList list, final SAMFileHeader fileHeader, final Collection<SAMRecord> recordCollection, final int expectedPassing, final int expectedTotal ) { IntervalFilter intervalFilter = new IntervalFilter(list.getIntervals(), fileHeader); FilteringSamIterator filteringSamIterator = new FilteringSamIterator(recordCollection.iterator(), intervalFilter); // check that the total number of passing reads is the expected number Assert.assertEquals(filteringSamIterator.stream() // check that the reads that pass have the word "intersecting" in their name .peek(s -> Assert.assertTrue(s.getReadName().contains("intersecting"))) .count(), expectedPassing); //check that the total number of reads given in the Collection, is the expected number Assert.assertEquals(recordCollection.size(), expectedTotal); } }
stopAfterPosition = lastInterval.getEnd(); final IntervalFilter intervalFilter = new IntervalFilter(uniqueIntervals, samReader.getFileHeader()); return new StopAfterFilteringIterator(samReader.iterator(), intervalFilter, stopAfterSequence, stopAfterPosition); } else {
stopAfterPosition = lastInterval.getEnd(); final IntervalFilter intervalFilter = new IntervalFilter(uniqueIntervals, samReader.getFileHeader()); return new StopAfterFilteringIterator(samReader.iterator(), intervalFilter, stopAfterSequence, stopAfterPosition); } else {
/** * Prepare to filter out SAMRecords that do not overlap the given list of intervals * @param intervals -- must be locus-ordered & non-overlapping */ public IntervalFilter(final List<Interval> intervals, final SAMFileHeader samHeader) { this.samHeader = samHeader; IntervalUtil.assertOrderedNonOverlapping(intervals.iterator(), samHeader.getSequenceDictionary()); this.intervals = intervals.iterator(); advanceInterval(); }
stopAfterPosition = lastInterval.getEnd(); final IntervalFilter intervalFilter = new IntervalFilter(uniqueIntervals, samReader.getFileHeader()); return new StopAfterFilteringIterator(samReader.iterator(), intervalFilter, stopAfterSequence, stopAfterPosition); } else {
/** * Prepare to filter out SAMRecords that do not overlap the given list of intervals * @param intervals -- must be locus-ordered & non-overlapping */ public IntervalFilter(final List<Interval> intervals, final SAMFileHeader samHeader) { this.samHeader = samHeader; IntervalUtil.assertOrderedNonOverlapping(intervals.iterator(), samHeader.getSequenceDictionary()); this.intervals = intervals.iterator(); advanceInterval(); }
/** * Determines whether a SAMRecord matches this filter * * @param record the SAMRecord to evaluate * @return true if the SAMRecord matches the filter, otherwise false */ public boolean filterOut(final SAMRecord record) { while (currentInterval != null && (currentSequenceIndex < record.getReferenceIndex() || (currentSequenceIndex == record.getReferenceIndex() && currentInterval.getEnd() < record.getAlignmentStart()))) { advanceInterval(); } // Return true if record should be filtered out return !(currentInterval != null && currentSequenceIndex == record.getReferenceIndex() && currentInterval.getStart() <= record.getAlignmentEnd()); }
/** * Determines whether a SAMRecord matches this filter * * @param record the SAMRecord to evaluate * @return true if the SAMRecord matches the filter, otherwise false */ @Override public boolean filterOut(final SAMRecord record) { while (currentInterval != null && (currentSequenceIndex < record.getReferenceIndex() || (currentSequenceIndex == record.getReferenceIndex() && currentInterval.getEnd() < record.getAlignmentStart()))) { advanceInterval(); } // Return true if record should be filtered out return !(currentInterval != null && currentSequenceIndex == record.getReferenceIndex() && currentInterval.getStart() <= record.getAlignmentEnd()); }
/** * Determines whether a SAMRecord matches this filter * * @param record the SAMRecord to evaluate * @return true if the SAMRecord matches the filter, otherwise false */ @Override public boolean filterOut(final SAMRecord record) { while (currentInterval != null && (currentSequenceIndex < record.getReferenceIndex() || (currentSequenceIndex == record.getReferenceIndex() && currentInterval.getEnd() < record.getAlignmentStart()))) { advanceInterval(); } // Return true if record should be filtered out return !(currentInterval != null && currentSequenceIndex == record.getReferenceIndex() && currentInterval.getStart() <= record.getAlignmentEnd()); }