Package htsjdk.samtools
Class CRAMBAIIndexer
- java.lang.Object
-
- htsjdk.samtools.CRAMBAIIndexer
-
public class CRAMBAIIndexer extends Object
Class for both constructing BAM index content and writing it out. There are two usage patterns: 1) Building a bam index from an existing cram file 2) Building a bam index while building the cram file In both cases, processAlignment is called for each cram slice and finish() is called at the end.
-
-
Constructor Summary
Constructors Constructor Description CRAMBAIIndexer(File output, SAMFileHeader fileHeader)
Create a CRAM indexer that writes BAI to a file.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
processContainer(Container container, ValidationStringency validationStringency)
Index a container, any of mapped, unmapped and multiple references are allowed.void
processSingleReferenceSlice(Slice slice)
Record index information for a given CRAM slice that contains either unmapped reads or reads mapped to a single reference.
-
-
-
Constructor Detail
-
CRAMBAIIndexer
public CRAMBAIIndexer(File output, SAMFileHeader fileHeader)
Create a CRAM indexer that writes BAI to a file.- Parameters:
output
- binary BAM Index (.bai) filefileHeader
- header for the corresponding bam file
-
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.- Parameters:
container
- container to be indexed
-
processSingleReferenceSlice
public void processSingleReferenceSlice(Slice slice)
Record index information for a given CRAM slice that contains either unmapped reads or reads mapped to a single reference. If this alignment starts a new reference, write out the old reference.- Parameters:
slice
- The CRAM slice, single ref or unmapped only.- Throws:
SAMException
- if slice refers to multiple reference sequences.
-
finish
public void finish()
After all the slices have been processed, finish is called. Writes any final information and closes the output file.
-
createIndex
public static void createIndex(SeekableStream stream, File output, Log log, ValidationStringency validationStringency) throws IOException
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- Throws:
IOException
-
-