public class CRAMFileReader extends SamReader.ReaderImplementation implements SamReader.Indexing
BAMFileReader analogue for CRAM files.
Supports random access using BAI index file formats.| Constructor and Description |
|---|
CRAMFileReader(java.io.File cramFile,
CRAMReferenceSource referenceSource)
Create a CRAMFileReader from a file using the supplied reference source.
|
CRAMFileReader(java.io.File cramFile,
java.io.File indexFile,
CRAMReferenceSource referenceSource)
Create a CRAMFileReader from a file and optional index file using the supplied reference source.
|
CRAMFileReader(java.io.File cramFile,
java.io.File indexFile,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
Create a CRAMFileReader from a CRAM file and optional index file using the supplied reference
source and validation stringency.
|
CRAMFileReader(java.io.File cramFile,
java.io.InputStream inputStream)
Create a CRAMFileReader from either a file or input stream using the reference source returned by
getDefaultCRAMReferenceSource. |
CRAMFileReader(java.io.File cramFile,
java.io.InputStream inputStream,
CRAMReferenceSource referenceSource)
Create a CRAMFileReader from either a file or input stream using the supplied reference source.
|
CRAMFileReader(java.io.InputStream stream,
java.io.File indexFile,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
Create a CRAMFileReader from an input stream and optional index file using the supplied reference
source and validation stringency.
|
CRAMFileReader(java.io.InputStream inputStream,
SeekableStream indexInputStream,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
Create a CRAMFileReader from an input stream and optional index stream using the supplied reference
source and validation stringency.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
CloseableIterator<SAMRecord> |
createIndexIterator(QueryInterval[] intervals,
boolean contained,
long[] filePointers)
Prepare to iterate through SAMRecords that match the intersection of the given intervals and chunk boundaries.
|
BrowseableBAMIndex |
getBrowseableIndex()
Gets an index tagged with the BrowseableBAMIndex interface.
|
SAMFileHeader |
getFileHeader() |
SAMFileSpan |
getFilePointerSpanningReads()
Gets a pointer spanning all reads in the BAM file.
|
BAMIndex |
getIndex()
Retrieves the index for the given file type.
|
SAMRecordIterator |
getIterator() |
CloseableIterator<SAMRecord> |
getIterator(SAMFileSpan fileSpan) |
ValidationStringency |
getValidationStringency() |
boolean |
hasBrowseableIndex()
Returns true if the supported index is browseable, meaning the bins in it can be traversed
and chunk data inspected and retrieved.
|
boolean |
hasIndex() |
SAMRecordIterator |
iterator(SAMFileSpan fileSpan)
Iterate through the given chunks in the file.
|
CloseableIterator<SAMRecord> |
query(QueryInterval[] intervals,
boolean contained) |
CloseableIterator<SAMRecord> |
queryAlignmentStart(java.lang.String sequence,
int start) |
CloseableIterator<SAMRecord> |
queryUnmapped() |
SamReader.Type |
type() |
public CRAMFileReader(java.io.File cramFile,
java.io.InputStream inputStream)
getDefaultCRAMReferenceSource.cramFile - CRAM file to openinputStream - CRAM stream to readjava.lang.IllegalArgumentException - if the cramFile and the inputStream are both nulljava.lang.IllegalStateException - if a default
reference source cannot be acquiredpublic CRAMFileReader(java.io.File cramFile,
java.io.InputStream inputStream,
CRAMReferenceSource referenceSource)
cramFile - CRAM file to readinputStream - CRAM stream to readreferenceSource - a source of
reference sequences. May not be null.java.lang.IllegalArgumentException - if the cramFile and the inputStream are both null
or if the CRAMReferenceSource is nullpublic CRAMFileReader(java.io.File cramFile,
java.io.File indexFile,
CRAMReferenceSource referenceSource)
cramFile - CRAM file to read. May not be null.indexFile - index file to be used for random access. May be null.referenceSource - a source of
reference sequences. May not be null.java.lang.IllegalArgumentException - if the cramFile or the CRAMReferenceSource is nullpublic CRAMFileReader(java.io.File cramFile,
CRAMReferenceSource referenceSource)
cramFile - CRAM file to read. Can not be null.referenceSource - a source of
reference sequences. May not be null.java.lang.IllegalArgumentException - if the cramFile or the CRAMReferenceSource is nullpublic CRAMFileReader(java.io.InputStream inputStream,
SeekableStream indexInputStream,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
throws java.io.IOException
inputStream - CRAM stream to read. May not be null.indexInputStream - index stream to be used for random access. May be null.referenceSource - a source of
reference sequences. May not be null.validationStringency - Validation stringency to be used when readingjava.lang.IllegalArgumentException - if the inputStream or the CRAMReferenceSource is nulljava.io.IOExceptionpublic CRAMFileReader(java.io.InputStream stream,
java.io.File indexFile,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
throws java.io.IOException
stream - CRAM stream to read. May not be null.indexFile - index file to be used for random access. May be null.referenceSource - a source of
reference sequences. May not be null.validationStringency - Validation stringency to be used when readingjava.lang.IllegalArgumentException - if the inputStream or the CRAMReferenceSource is nulljava.io.IOExceptionpublic CRAMFileReader(java.io.File cramFile,
java.io.File indexFile,
CRAMReferenceSource referenceSource,
ValidationStringency validationStringency)
throws java.io.IOException
cramFile - CRAM stream to read. May not be null.indexFile - index file to be used for random access. May be null.referenceSource - a source of
reference sequences. May not be null.validationStringency - Validation stringency to be used when readingjava.lang.IllegalArgumentException - if the cramFile or the CRAMReferenceSource is nulljava.io.IOExceptionpublic boolean hasIndex()
hasIndex in interface SamReader.PrimitiveSamReaderpublic BAMIndex getIndex()
SamReader.IndexinggetIndex in interface SamReader.IndexinggetIndex in interface SamReader.PrimitiveSamReaderpublic boolean hasBrowseableIndex()
SamReader.IndexinghasBrowseableIndex in interface SamReader.Indexingpublic BrowseableBAMIndex getBrowseableIndex()
SamReader.IndexinggetBrowseableIndex in interface SamReader.Indexingpublic SAMRecordIterator iterator(SAMFileSpan fileSpan)
SamReader.Indexingiterator in interface SamReader.IndexingfileSpan - List of chunks for which to retrieve data.public SAMFileHeader getFileHeader()
getFileHeader in interface SamReader.PrimitiveSamReaderpublic SAMRecordIterator getIterator()
getIterator in interface SamReader.PrimitiveSamReaderpublic CloseableIterator<SAMRecord> getIterator(SAMFileSpan fileSpan)
getIterator in interface SamReader.PrimitiveSamReaderpublic SAMFileSpan getFilePointerSpanningReads()
SamReader.IndexinggetFilePointerSpanningReads in interface SamReader.IndexinggetFilePointerSpanningReads in interface SamReader.PrimitiveSamReaderpublic CloseableIterator<SAMRecord> queryAlignmentStart(java.lang.String sequence, int start)
queryAlignmentStart in interface SamReader.PrimitiveSamReaderpublic CloseableIterator<SAMRecord> queryUnmapped()
queryUnmapped in interface SamReader.PrimitiveSamReaderpublic void close()
close in interface SamReader.PrimitiveSamReaderpublic ValidationStringency getValidationStringency()
getValidationStringency in interface SamReader.PrimitiveSamReaderpublic CloseableIterator<SAMRecord> query(QueryInterval[] intervals, boolean contained)
query in interface SamReader.PrimitiveSamReaderpublic SamReader.Type type()
type in interface SamReader.PrimitiveSamReaderpublic CloseableIterator<SAMRecord> createIndexIterator(QueryInterval[] intervals, boolean contained, long[] filePointers)
intervals - the intervals to restrict reads tocontained - if true, return records that are strictly
contained in the intervals, otherwise return records that overlapfilePointers - file pointer pairs corresponding to chunk boundaries for the
intervals