Package htsjdk.samtools
Class BAMIndexer
- java.lang.Object
-
- htsjdk.samtools.BAMIndexer
-
public class BAMIndexer 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 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
Constructors Constructor Description BAMIndexer(File output, SAMFileHeader fileHeader)
BAMIndexer(OutputStream output, SAMFileHeader fileHeader)
Prepare to index a BAM.BAMIndexer(Path output, SAMFileHeader fileHeader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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
processAlignment(SAMRecord rec)
Record any index information for a given BAM record.
-
-
-
Constructor Detail
-
BAMIndexer
public BAMIndexer(Path output, SAMFileHeader fileHeader)
- Parameters:
output
- binary BAM Index (.bai) filefileHeader
- header for the corresponding bam file
-
BAMIndexer
public BAMIndexer(File output, SAMFileHeader fileHeader)
- Parameters:
output
- binary BAM Index (.bai) filefileHeader
- header for the corresponding bam file
-
BAMIndexer
public BAMIndexer(OutputStream output, SAMFileHeader fileHeader)
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.
-
-
Method Detail
-
processAlignment
public void processAlignment(SAMRecord rec)
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
public static void createAndWriteIndex(File input, File output, boolean textOutput)
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
public static void createIndex(SamReader reader, Path output)
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- Path for output index file
-
createIndex
public static void createIndex(SamReader reader, File output)
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- File for output index file
-
createIndex
public static void createIndex(SamReader reader, Path output, Log log)
Generates a BAM index file from an input BAM file- Parameters:
reader
- SamReader for input BAM fileoutput
- Path for output index file
-
-