Package htsjdk.samtools

# Class CRAMIterator

java.lang.Object
htsjdk.samtools.CRAMIterator

All Implemented Interfaces:
  `SAMRecordIterator`, `CloseableIterator<SAMRecord>`, `Closeable`, `AutoCloseable`, `Iterator<SAMRecord>`

public class CRAMIterator extends Object implements SAMRecordIterator, Closeable

## Constructor Summary

Constructors
Constructor
Description
`CRAMIterator(SeekableStream seekableStream, CRAMReferenceSource referenceSource, ValidationStringency validationStringency, QueryInterval[] queryIntervals, long[] coordinates)`
`CRAMIterator(InputStream inputStream, CRAMReferenceSource referenceSource, ValidationStringency validationStringency)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`advanceToAlignmentInContainer(int refIndex, int pos)`
Skip cached records until given alignment start position.
`SAMRecordIterator`
`assertSorted(SAMFileHeader.SortOrder sortOrder)`
Establishes that records returned by this iterator are expected to be in the specified sort order.
`void`
`close()`
Should be implemented to close/release any underlying resources.
`CramHeader`
`getCramHeader()`
`SamReader`
`getFileSource()`
`long`
`getFirstContainerOffset()`
`SAMFileHeader`
`getSAMFileHeader()`
`ValidationStringency`
`getValidationStringency()`
`boolean`
`hasNext()`
`SAMRecord`
`next()`
`void`
`remove()`
`void`
`setFileSource(SamReader mReader)`
`void`
`setValidationStringency(ValidationStringency validationStringency)`

### 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 Details

### CRAMIterator

public CRAMIterator(InputStream inputStream, CRAMReferenceSource referenceSource, ValidationStringency validationStringency)

### CRAMIterator

public CRAMIterator(SeekableStream seekableStream, CRAMReferenceSource referenceSource, ValidationStringency validationStringency, QueryInterval[] queryIntervals, long[] coordinates)

## Method Details

### advanceToAlignmentInContainer

public boolean advanceToAlignmentInContainer(int refIndex, int pos)
Skip cached records until given alignment start position.

Parameters:
  `refIndex` - reference sequence index
  `pos` - alignment start to skip to

### hasNext

public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<SAMRecord>`

### next

public SAMRecord next()

Specified by:
  `next` in interface `Iterator<SAMRecord>`

### remove

public void remove()

Specified by:
  `remove` in interface `Iterator<SAMRecord>`

### close

public void close()
Description copied from interface: `CloseableIterator`
Should be implemented to close/release any underlying resources.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `CloseableIterator<SAMRecord>`

### getFirstContainerOffset

public long getFirstContainerOffset()

### assertSorted

public SAMRecordIterator assertSorted(SAMFileHeader.SortOrder sortOrder)
Description copied from interface: `SAMRecordIterator`
Establishes that records returned by this iterator are expected to be in the specified sort order. If this method has been called, then implementers must throw an IllegalStateException from next() when a record is read that violates the sort order. This method may be called multiple times over the course of an iteration, changing the expected sort, if desired -- from the time it is called, it validates whatever sort is set, or stops validating if it is set to null or SAMFileHeader.SortOrder.unsorted. If this method is not called, then no validation of the iterated records is done.

Specified by:
  `assertSorted` in interface `SAMRecordIterator`
Parameters:
  `sortOrder` - The order in which records are expected to be returned
Returns:
  This SAMRecordIterator

### getCramHeader

public CramHeader getCramHeader()

### getValidationStringency

public ValidationStringency getValidationStringency()

### setValidationStringency

public void setValidationStringency(ValidationStringency validationStringency)

### getFileSource

public SamReader getFileSource()

### setFileSource

public void setFileSource(SamReader mReader)

### getSAMFileHeader

public SAMFileHeader getSAMFileHeader()