# Class SamRecordIntervalIteratorFactory

java.lang.Object
htsjdk.samtools.util.SamRecordIntervalIteratorFactory

public class SamRecordIntervalIteratorFactory extends Object
Create an iterator over a `SamReader` that only returns reads that overlap one of the intervals in an interval list.

## Constructor Summary

Constructors
Constructor
Description
`SamRecordIntervalIteratorFactory()`

## Method Summary

Modifier and Type
Method
Description
`CloseableIterator<SAMRecord>`
`makeSamRecordIntervalIterator(SamReader samReader, List<Interval> uniqueIntervals, boolean useIndex)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SamRecordIntervalIteratorFactory

public SamRecordIntervalIteratorFactory()

## Method Details

### makeSamRecordIntervalIterator

public CloseableIterator<SAMRecord> makeSamRecordIntervalIterator(SamReader samReader, List<Interval> uniqueIntervals, boolean useIndex)

Parameters:
  `samReader` -
  `uniqueIntervals` - list of intervals of interest, with overlaps merged, in coordinate order
  `useIndex` - if false, do not use a BAM index even if it is present.
Returns:
  an iterator that will be filtered so that only SAMRecords overlapping the intervals in uniqueIntervals will be returned. If a BAM index is available, it will be used to improve performance. Note however that if there are many intervals that cover a great deal of the genome, using the BAM index may actually make performance worse.