Category

Sam/Bam Manipulation


Usage

samtools index [-bc] [-m INT] aln.bam|aln.cram [out.index]


Manual

Index coordinate-sorted BGZIP-compressed SAM, BAM or CRAM files for fast random access. Note for SAM this only works if the file has been BGZF compressed first. This index is needed when region arguments are used to limit samtools view and similar commands to particular regions of interest.

When no output filename is specified, for a CRAM file aln.cram, index file aln.cram.crai will be created; for a BAM file aln.bam, either aln.bam.bai or aln.bam.csi will be created; and for a compressed SAM file aln.sam.gz, either aln.sam.gz.bai or aln.sam.gz.csi will be created, depending on the index format selected.

The BAI index format can handle individual chromosomes up to 512 Mbp ($2^{29}$ bases) in length. If your input file might contain reads mapped to positions greater than that, you will need to use a CSI index.

Required arguments

  • FILE str: Input SAM, BAM, or CRAM file(s) to be indexed.

Options

  • out.index str: Write the output index to FILE (currently may only be used when exactly one alignment file is being indexed). Similar to specify the -o option. This works when one input file is provided.
  • -M: Index multiple input files. In this case the program interprets all filename arguments as alignment files to be indexed individually. Available in samtools 1.16 or later.
  • -b, --bai: Create a BAI index (currently the default when no format options are used).
  • -c, --csi: Create a CSI index. The minimum interval size for the index is $2^{14}$, which is the same as the fixed value used by the BAI format.
  • -m, --min-shift INT: Create a CSI index, with a minimum interval size of $2^{INT}$.
  • -M: Mentioned in the description.
  • -o, --output FILE: Write the output index to FILE (currently may only be used when exactly one alignment file is being indexed).
  • -@, --threads INT: Number of input/output compression threads to use in addition to the main thread [0].

Protocols using this tool

PROcap preprocessing (with two replicates)
File formats this tool works with
BAMCRAMSAM

Share your experience or ask a question