Site icon Ampersand Tutorials

Bioinformatics File Formats Explained: FASTA, BAM, GFF, and VCF

Quick answer: Every bioinformatics pipeline is a chain of file formats: sequencing machines emit FASTQ reads, aligners produce SAM/BAM alignments, annotations live in GFF3, and variant callers write VCF. Each format exists because it answers one specific question at one stage of the pipeline. Learn which format answers which question, and every tool manual you read afterward starts to make sense.

A companion to the two FASTA and FASTQ format guides already on this blog. This article is the wider map: what each format in a modern project stores, when it appears, and what reads it.

One job, one format

Biology produces many kinds of claim, and no single file can hold them all. Each major format is organized around exactly one claim type:

This division is the real organizing principle of the field, and it explains awkward-sounding facts such as why a BAM file keeps the reference packed inside CRAM, or why a VCF header is enormous. When a file confuses you, ask first: which single claim is this format built to store?

FASTA and FASTQ: the sequence layer

FormatStoresTypical sizeRead with
FASTAOne or more sequences plus headers0.1 to 4 GBEverything; genome browsers, BLAST
FASTQPer-base sequences plus Phred-scaled quality scores10 to 200+ GBFASTQ processing tools, QC packages

These two formats are covered in depth in their own guides on this blog; what matters in the wider map is that everything upstream of the aligner is FASTQ and everything else is downstream of it. A FASTQ record is four lines: header, sequence, a separator, and a quality string of equal length. The quality line encodes base-call confidence as printable characters, so quality scores, not just read lengths, are one less thing the aligner must guess.

SAM and BAM: the alignment layer

SAM (Sequence Alignment/Map) is a huge tab-separated text file: a header section, then one line per alignment record. BAM is exactly that file, binary-compressed and, crucially, sorted and indexed for random access. Practical facts that solve most beginner problems:

The core toolkit is samtools:

samtools view -b -o aligned.bam aligned.sam     # convert SAM to BAM
samtools sort -o aligned.sorted.bam aligned.bam
samtools index aligned.sorted.bam
samtools view -c aligned.sorted.bam chr11       # count reads on one chromosome
samtools flagstat aligned.sorted.bam            # the one-line alignment health check

flagstat is the quickest sanity check for any alignment: it prints how many reads mapped, how many are properly paired, and how many are duplicates or singletons.

VCF: variant calls with provenance

VCF (Variant Call Format) stores the positions where a sample differs from the reference, and it is the format through which most population genetics, clinical screening, and association studies actually flow. The fixed columns — CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO — describe the variant itself; the FORM and FORMAT columns then describe, per sample, what evidence supports it. Three habits worth forming early:

The tool trio for the variant layer is bcftools (query, filter, merge, compare) plus bgzip and tabix for compression and indexing.

GFF and GTF: annotation coordinates

GFF3 and GTF are the annotation counterparts to the sequence files: one line per feature (gene, transcript, exon, repeat) with its coordinates and attributes. This is the layer your genome browser displays and what the genome annotation tools produce, as covered in the genome annotation guide. The bioinformatics detail that saves hours later: GFF3 and GTF use inclusive, one-based coordinates (position 1 is the first base), while almost every programmatic API and the BED format use zero-based, half-open intervals. A glide across the boundary is how real analyses end up shifted by exactly one base.

For a browser-track of regions rather than gene models, BED is the lightweight cousin: chromosome, start, end, optional columns, usually zero-based.

The format map of a real project

StageFormat inFormat outKey tools
Raw sequencingimages and base callsFASTQbcl2fastq-type converters
QC trim and filterFASTQFASTQfastp-style preprocessors
Alignment to referenceFASTQSAM/BAM/CRAMBWA, Bowtie, minimap2
Post-processing alignmentsBAMBAM + indexsamtools suite
Variant discoveryBAM + referenceVCFbcftools, GATK-class callers
Annotation and featuresgenome FASTA + BAMGFF3, bedGraphannotation pipelines
Variants in contextVCF + annotationannotated VCF, tablesbcftools annotate

Read this table top to bottom and you are reading the storyline of a project: sequences become alignments, alignments become variants, variants meet annotation. Every job on a bioinformatics job board assumes you can move a dataset across these format boundaries without hand-wringing.

Common failure modes

Key takeaways

Challenge

Take any public dataset associated with a published study, walk one sample through the table above, and name the file format present at every stage. If your dataset has no explicit VCF or GFF, note which stage your lab substitutes instead. Tight scope on one dataset makes the format landscape less abstract and gives you something concrete to discuss in an interview.

Related: The BAM to VCF half of the format chain has a pipeline of its own — see our variant calling guide.

Need help reading real datasets in a course or research project? Ampersand Academy offers one-to-one mentoring in bioinformatics and data analysis — part of Mahadhi, a development and digital marketing company.

FAQ

What is the difference between SAM and BAM?

SAM is the text form, one line per alignment record; BAM is the same information binary-compressed and, in practice, sorted and indexed for random access. Tools accept both, but BAM is what you work with day to day.

Why does VCF seem more complicated than the other formats?

A VCF describes not only the variant but also how evidence varies per sample. The fixed columns describe the position and change, while FORMAT columns carry per-sample genotype and depth information, which is where studies stitch samples together.

What does the FASTQ fourth line mean?

It is the quality string: one printable character per sequencing base, encoding a confidence level after the Phred scheme. High quality means the base call is more likely correct, so trimming and filtering choices derive from this line.

What is the difference between GFF3 and GTF?

Both record feature coordinates, one line per feature. GFF3 is the broader, hierarchical standard with explicit ID and Parent attributes, while GTF is the simpler form commonly exchanged with certain alignment and expression tools. Conversions are routine but not always lossless.

Do I need a bgzipped and tabix-indexed VCF?

For anything above toy size, yes. The compression plus region index means downstream tools can stream only the chromosomes or intervals you ask for, which is the practical difference between a run that finishes and one that loads the entire file each query.

Where do the off-by-one bugs come from in file formats?

GFF3 and GTF are one-based with inclusive ranges, while BED and most programmatic APIs use zero-based, half-open intervals. Mixing the two conventions without converting is the classic silent shift of exactly one base.

What does CRAM trade away compared with BAM?

CRAM compresses further, partly by referring to a reference sequence, so opening one genuinely requires the matching reference file. The trade is smaller archives versus a dependency on keeping the reference accessible.

Exit mobile version