Bioinformatics File Formats Explained: FASTA, FASTQ, SAM/BAM, VCF
A practical field guide to the four file formats you'll touch in almost every sequencing pipeline.
Every stage of a sequencing pipeline hands off to the next stage through one of a handful of standard file formats. Knowing them by sight saves a lot of confusion.
FASTA - sequences, no quality
The simplest format: a > header line followed by the sequence itself. Used for reference genomes,
gene sequences, and protein sequences.
>chr1 example reference fragment
ACGTACGTTGCATGCATGCATGCATGCATGCATGCATGC
GGCATGCATGCATGCATGCATGCATGCATGCATGCATGC
FASTQ - raw reads, with quality scores
The direct output of a sequencer. Each read is four lines: an identifier, the sequence, a +
separator, and a quality string (one character per base, encoding confidence via the Phred scale).
@READ_001 length=36
ACGTACGTTGCATGCATGCATGCATGCATGCATGCA
+
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
Each quality character maps to a Phred score - roughly, a ! is very low confidence and I is high
confidence. A Phred score of 30 means a 1-in-1000 chance that base call is wrong; this is the "Q30"
threshold labs commonly report as a quality bar.
SAM / BAM - reads aligned to a reference
Once reads are aligned to a reference genome (with a tool like BWA or Bowtie2), the result is a SAM (Sequence Alignment/Map) file - a tab-delimited text format recording, for every read, where it mapped, how well, and any mismatches. BAM is the same information in a compressed binary form - what you'll actually work with, since SAM files get enormous. CRAM compresses further still by referencing the genome instead of storing every base.
READ_001 0 chr17 41196312 60 36M * 0 0 ACGTACGT... IIIIIIII...
Key columns: read name, alignment flag, chromosome, position, mapping quality, and the CIGAR string
(36M = 36 bases matched/mismatched with no insertions or deletions).
VCF - the variants themselves
A Variant Call Format file is the end product of variant calling - one line per position where a sample differs from the reference.
#CHROM POS ID REF ALT QUAL FILTER INFO
chr17 41276045 . G A 99 PASS DP=45;AF=0.5
REF/ALT show the reference and observed base(s), QUAL is the confidence of the call, and INFO
carries extra annotation - read depth (DP), allele frequency (AF), and often much more once a tool
like VEP or ANNOVAR has run.
The typical hand-off chain
FASTQ (raw reads)
-> align -> SAM/BAM (reads on a reference)
-> call -> VCF (variants)
-> annotate -> annotated VCF (variants + predicted effect)
Further reading
- SAM/BAM/VCF format specifications - the canonical, versioned specs
- Rosalind - FASTA format
- FastQC - the standard tool for inspecting FASTQ quality