samtools index
samtools index is a command-line utility used to
create index files for BAM and CRAM alignment files. These
indexes enable rapid random access to specific genomic regions
without reading the entire alignment file, making downstream
analyses and visualization significantly faster.
The input alignment file should typically be coordinate-sorted before indexing.
.bam.bai) for standard BAM files.
.csi) for very large BAM files requiring
extended indexing support.
.cram.crai) for CRAM files.
# Index a BAM file
samtools index sample.bam
# Specify output index file
samtools index -o sample.bai sample.bam
# Create CSI index
samtools index -c sample.bam
# Index a CRAM file
samtools index sample.cram
sample.bam
sample.bam.bai
After indexing, the generated index file allows tools to jump directly to genomic regions instead of scanning the entire file.
Official Samtools Documentation: Samtools Index Manual
If you use samtools index in your work,
please cite:
Li, H., Handsaker, B., Wysoker, A., Fennell, T., Ruan, J., Homer, N., et al. (2009). The Sequence Alignment/Map (SAM) format and SAMtools. Bioinformatics, 25(16), 2078–2079. DOI: 10.1093/bioinformatics/btp352