Package htsjdk.samtools
Class CRAMBAIIndexer
java.lang.Object
htsjdk.samtools.CRAMBAIIndexer
- All Implemented Interfaces:
CRAMIndexer
Class for both constructing BAM index content and writing it out.
There are two usage patterns:
1) Building a bam index (BAI) while building the CRAM file
2) Building a bam index (BAI) from an existing CRAI file
1) is driven by
CRAMContainerStreamWriter
and proceeds by calling processContainer(htsjdk.samtools.cram.structure.Container, htsjdk.samtools.ValidationStringency)
after each Container
is built, and finish()
is called at the end.
2) is driven by CRAIIndex.openCraiFileAsBaiStream(InputStream, SAMSequenceDictionary)
and proceeds by processing CRAIEntry
elements obtained from
CRAMCRAIIndexer.readIndex(InputStream)
. processBAIEntry(BAIEntry)
is called on each CRAIEntry
and finish()
is called at the end.
NOTE: a third pattern of building a BAI from a CRAM file is also supported by this class,
but it is unused. This would be accomplished via createIndex(SeekableStream, File, Log, ValidationStringency)
.-
Constructor Summary
ConstructorsConstructorDescriptionCRAMBAIIndexer
(OutputStream output, SAMFileHeader fileHeader) Create a CRAM indexer that writes BAI to a stream. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
createIndex
(SeekableStream stream, File output, Log log, ValidationStringency validationStringency) Generates a BAI index file from an input CRAM streamvoid
finish()
After all the slices have been processed, finish is called.final void
processBAIEntry
(BAIEntry baiEntry) void
processContainer
(Container container, ValidationStringency validationStringency) Index a container, any of mapped, unmapped and multiple references are allowed.
-
Constructor Details
-
CRAMBAIIndexer
Create a CRAM indexer that writes BAI to a stream.- Parameters:
output
- Index will be written here. output will be closed when finish() method is called.fileHeader
- header for the corresponding bam file.
-
-
Method Details
-
processContainer
Index a container, any of mapped, unmapped and multiple references are allowed. The only requirement is sort order by coordinate. For multiref containers the method reads the container through unpacking all reads. This is slower than single reference but should be faster than normal reading.- Specified by:
processContainer
in interfaceCRAMIndexer
- Parameters:
container
- container to be indexedvalidationStringency
- stringency for validating records (used when processing multi-reference slices, since creating an index on a multi-ref slices requires actually decoding the records in order to resove the constituent reference spans}
-
processBAIEntry
-
finish
public void finish()After all the slices have been processed, finish is called. Writes any final information and closes the output file.- Specified by:
finish
in interfaceCRAMIndexer
-
createIndex
public static void createIndex(SeekableStream stream, File output, Log log, ValidationStringency validationStringency) Generates a BAI index file from an input CRAM stream- Parameters:
stream
- CRAM stream to indexoutput
- File for output index filelog
- optionalLog
to output progress
-