Package htsjdk.samtools
Class MergingSamRecordIterator
- java.lang.Object
-
- htsjdk.samtools.MergingSamRecordIterator
-
- All Implemented Interfaces:
CloseableIterator<SAMRecord>
,Closeable
,AutoCloseable
,Iterator<SAMRecord>
public class MergingSamRecordIterator extends Object implements CloseableIterator<SAMRecord>
Provides an iterator interface for merging multiple underlying iterators into a single iterable stream. The underlying iterators/files must all have the same sort order unless the requested output format is unsorted, in which case any combination is valid.
-
-
Constructor Summary
Constructors Constructor Description MergingSamRecordIterator(SamFileHeaderMerger headerMerger, boolean forcePresorted)
Deprecated.MergingSamRecordIterator(SamFileHeaderMerger headerMerger, Collection<SamReader> readers, boolean assumeSorted)
Constructs a new merging iterator with the same set of readers and sort order as provided by the header merger parameter.MergingSamRecordIterator(SamFileHeaderMerger headerMerger, Map<SamReader,CloseableIterator<SAMRecord>> iterators, boolean assumeSorted)
Add a set of SAM file iterators to the merging iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close down all open iterators.SAMFileHeader
getMergedHeader()
Returns the merged header that the merging iterator is working from.boolean
hasNext()
Returns true if any of the underlying iterators has more records, otherwise false.SAMRecord
next()
Returns the next record from the top most iterator during merging.void
remove()
Unsupported operation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.samtools.util.CloseableIterator
stream, toList
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
MergingSamRecordIterator
@Deprecated public MergingSamRecordIterator(SamFileHeaderMerger headerMerger, boolean forcePresorted)
Deprecated.Constructs a new merging iterator with the same set of readers and sort order as provided by the header merger parameter.- Parameters:
headerMerger
- The merged header and contents of readers.forcePresorted
- True to ensure that the iterator checks the headers of the readers for appropriate sort order.
-
MergingSamRecordIterator
public MergingSamRecordIterator(SamFileHeaderMerger headerMerger, Collection<SamReader> readers, boolean assumeSorted)
Constructs a new merging iterator with the same set of readers and sort order as provided by the header merger parameter.- Parameters:
headerMerger
- The merged header and contents of readers.assumeSorted
- false ensures that the iterator checks the headers of the readers for appropriate sort order.
-
MergingSamRecordIterator
public MergingSamRecordIterator(SamFileHeaderMerger headerMerger, Map<SamReader,CloseableIterator<SAMRecord>> iterators, boolean assumeSorted)
Add a set of SAM file iterators to the merging iterator. Use this to restrict the merged iteration to a given genomic interval, rather than iterating over every read in the backing file or stream.- Parameters:
headerMerger
- The merged header and contents of readers.iterators
- Iterator traversing over reader contents.
-
-
Method Detail
-
close
public void close()
Close down all open iterators.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseableIterator<SAMRecord>
-
hasNext
public boolean hasNext()
Returns true if any of the underlying iterators has more records, otherwise false.
-
next
public SAMRecord next()
Returns the next record from the top most iterator during merging.
-
remove
public void remove()
Unsupported operation.
-
getMergedHeader
public SAMFileHeader getMergedHeader()
Returns the merged header that the merging iterator is working from.
-
-