Package htsjdk.samtools
Class BAMIndexer
java.lang.Object
htsjdk.samtools.BAMIndexer
Class for both constructing BAM index content and writing it out.
There are two usage patterns:
1) Building a bam index from an existing bam file
2) Building a bam index while building the bam file
In both cases, processAlignment is called for each alignment record and
finish() is called at the end.
-
Constructor Summary
ConstructorDescriptionBAMIndexer
(File output, SAMFileHeader fileHeader) BAMIndexer
(OutputStream output, SAMFileHeader fileHeader) Prepare to index a BAM.BAMIndexer
(OutputStream output, SAMFileHeader fileHeader, boolean fillInUninitializedValues) Prepare to index a BAM.BAMIndexer
(Path output, SAMFileHeader fileHeader) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
createAndWriteIndex
(File input, File output, boolean textOutput) Generates a BAM index file, either textual or binary, from an input BAI file.static void
createIndex
(SamReader reader, File output) Generates a BAM index file from an input BAM filestatic void
createIndex
(SamReader reader, File output, Log log) Generates a BAM index file from an input BAM filestatic void
createIndex
(SamReader reader, Path output) Generates a BAM index file from an input BAM filestatic void
createIndex
(SamReader reader, Path output, Log log) Generates a BAM index file from an input BAM filevoid
finish()
After all the alignment records have been processed, finish is called.void
Record any index information for a given BAM record.
-
Constructor Details
-
BAMIndexer
- Parameters:
output
- binary BAM Index (.bai) filefileHeader
- header for the corresponding bam file
-
BAMIndexer
- Parameters:
output
- binary BAM Index (.bai) filefileHeader
- header for the corresponding bam file
-
BAMIndexer
Prepare to index a BAM.- Parameters:
output
- Index will be written here. output will be closed when finish() method is called.fileHeader
- header for the corresponding bam file.
-
BAMIndexer
Prepare to index a BAM.- Parameters:
output
- Index will be written here. output will be closed when finish() method is called.fileHeader
- header for the corresponding bam file.fillInUninitializedValues
- if true, set uninitialized values (-1) to the last non-zero offset; if false, leave uninitialized values as -1, which is required when merging index files (seeBAMIndexMerger
)
-
-
Method Details
-
processAlignment
Record any index information for a given BAM record. If this alignment starts a new reference, write out the old reference. Requires a non-null value for rec.getFileSource().- Parameters:
rec
- The BAM record
-
finish
public void finish()After all the alignment records have been processed, finish is called. Writes any final information and closes the output file. -
createAndWriteIndex
Generates a BAM index file, either textual or binary, from an input BAI file. Only used for testing, but located here for visibility into CachingBAMFileIndex.- Parameters:
output
- BAM Index (.bai) file (or bai.txt file when text)textOutput
- Whether to create text output or binary
-
createIndex
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- Path for output index file
-
createIndex
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- File for output index file
-
createIndex
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- Path for output index file
-
createIndex
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- File for output index file
-