File formats

Descriptions of common bioinformatics file formats such as FASTA and BAM.

BAM is the binary compressed form of SAM. It stores aligned sequencing reads with CIGAR strings, mapping quality, and optional tags. Indexed BAM (.bai) enables random access by genomic region.

Structure

A BAM file begins with a binary header (including @SQ reference dictionary), then alignment records. Companion BAI/CSI indexes support region queries. CRAM is a related reference-compressed format.

Example

samtools view -h sample.bam | head
@HD	VN:1.6	SO:coordinate
@SQ	SN:chr1	LN:248956422
READ1	99	chr1	1000	60	10M	=	1100	150	ACGTACGTAC	FFFFFFFFFF

Common tools

SAMtools, Picard, GATK, and IGV read and write BAM/CRAM; indexing with samtools index is standard after coordinate sorting.