Package htsjdk.samtools
Class CRAMBAIIndexer
- java.lang.Object
-
- htsjdk.samtools.CRAMBAIIndexer
-
- All Implemented Interfaces:
CRAMIndexer
public class CRAMBAIIndexer extends Object implements 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 byCRAMContainerStreamWriter
and proceeds by callingprocessContainer(htsjdk.samtools.cram.structure.Container, htsjdk.samtools.ValidationStringency)
after eachContainer
is built, andfinish()
is called at the end. 2) is driven byCRAIIndex.openCraiFileAsBaiStream(InputStream, SAMSequenceDictionary)
and proceeds by processingCRAIEntry
elements obtained fromCRAMCRAIIndexer.readIndex(InputStream)
.processBAIEntry(BAIEntry)
is called on eachCRAIEntry
andfinish()
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 viacreateIndex(SeekableStream, File, Log, ValidationStringency)
.
-
-
Constructor Summary
Constructors Constructor Description CRAMBAIIndexer(OutputStream output, SAMFileHeader fileHeader)
Create a CRAM indexer that writes BAI to a stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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.void
processBAIEntry(BAIEntry baiEntry)
void
processContainer(Container container, ValidationStringency validationStringency)
Index a container, any of mapped, unmapped and multiple references are allowed.
-
-
-
Constructor Detail
-
CRAMBAIIndexer
public CRAMBAIIndexer(OutputStream output, SAMFileHeader fileHeader)
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 Detail
-
processContainer
public void processContainer(Container container, ValidationStringency validationStringency)
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
public final void processBAIEntry(BAIEntry baiEntry)
-
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
-
-