Genomics File Formats Reference
Once reads leave the FASTA/FASTQ stage, downstream analysis flows through a handful of tab-delimited formats. SAM/BAM hold read alignments, VCF holds variant calls, and BED and GFF3/GTF describe genomic intervals and annotations. This reference lists their columns, the SAM FLAG bits, and the coordinate system each one uses.
Coordinate systems — the #1 gotcha
The single most common source of off-by-one errors is mixing coordinate conventions. BED is 0-based and half-open — [start, end), where the start counts from 0 and the end is exclusive. Every other format here is 1-based and fully closed: positions count from 1 and both ends are included.
| Format | Base | Interval |
|---|---|---|
| BED | 0-based | Half-open [start, end) |
| SAM / BAM | 1-based | Fully closed |
| VCF | 1-based | Fully closed |
| GFF3 / GTF | 1-based | Fully closed |
SAM / BAM
SAM (Sequence Alignment/Map) is a tab-delimited text format of read alignments against a reference; BAM is its compressed binary form. Each alignment line has 11 mandatory fields. POS is 1-based.
| Col | Field | Meaning |
|---|---|---|
| 1 | QNAME | Read name |
| 2 | FLAG | Bitwise flags |
| 3 | RNAME | Reference name |
| 4 | POS | 1-based leftmost position |
| 5 | MAPQ | Mapping quality |
| 6 | CIGAR | Alignment (M/I/D/S/…) |
| 7 | RNEXT | Mate reference |
| 8 | PNEXT | Mate position |
| 9 | TLEN | Template length |
| 10 | SEQ | Read sequence |
| 11 | QUAL | Phred quality (ASCII, like FASTQ) |
SAM FLAG bits
The FLAG field is the sum of the set bits below — for example 99 = 1 + 2 + 32 + 64 (paired, proper pair, mate reverse strand, first in pair).
| Hex | Decimal | Meaning |
|---|---|---|
| 0x1 | 1 | Read paired |
| 0x2 | 2 | Read mapped in proper pair |
| 0x4 | 4 | Read unmapped |
| 0x8 | 8 | Mate unmapped |
| 0x10 | 16 | Read reverse strand |
| 0x20 | 32 | Mate reverse strand |
| 0x40 | 64 | First in pair |
| 0x80 | 128 | Second in pair |
| 0x100 | 256 | Secondary alignment |
| 0x200 | 512 | Fails QC |
| 0x400 | 1024 | PCR/optical duplicate |
| 0x800 | 2048 | Supplementary alignment |
VCF
VCF (Variant Call Format) stores variant calls. A file begins with ## meta header lines, then a single #CHROM column-header line, then one record per variant. POS is 1-based.
| Col | Field | Meaning |
|---|---|---|
| 1 | CHROM | Chromosome / reference name |
| 2 | POS | 1-based position of the variant |
| 3 | ID | Variant identifier (e.g. rsID, or .) |
| 4 | REF | Reference allele |
| 5 | ALT | Alternate allele(s) |
| 6 | QUAL | Phred-scaled variant quality |
| 7 | FILTER | PASS or filters the variant failed |
| 8 | INFO | Semicolon-separated annotations |
| 9 | FORMAT | Genotype field keys (then one column per sample) |
The first eight columns are fixed; FORMAT and one column per sample appear only when genotypes are recorded.
##fileformat=VCFv4.3
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample1
chr1 1000 . A G 60 PASS DP=42 GT 0/1BED
BED is a simple interval format. It is 0-based, half-open. Only the first three columns are required (BED3); BED6 adds name, score and strand, and BED12 adds the block columns that describe exon structure.
| Col | Field | Meaning |
|---|---|---|
| 1 | chrom | Chromosome / reference name |
| 2 | chromStart | Start (0-based) |
| 3 | chromEnd | End (exclusive) |
| 4 | name | Feature name |
| 5 | score | Score (0–1000) |
| 6 | strand | Strand (+/-) |
| 7 | thickStart | Start of thick drawing |
| 8 | thickEnd | End of thick drawing |
| 9 | itemRgb | Display color (R,G,B) |
| 10 | blockCount | Number of blocks (exons) |
| 11 | blockSizes | Comma-separated block sizes |
| 12 | blockStarts | Comma-separated block starts |
BED3 = columns 1–3 · BED6 = columns 1–6 · BED12 = all 12 columns.
GFF3 / GTF
GFF3 and GTF are 9-column, tab-delimited annotation formats. Both are 1-based and closed. GTF, an extension of GFF2, shares the first eight columns with GFF3 but differs in column 9, the attributes.
| Col | Field | Meaning |
|---|---|---|
| 1 | seqid | Sequence / chromosome name |
| 2 | source | Program or database that made the feature |
| 3 | type | Feature type (gene, mRNA, CDS, exon…) |
| 4 | start | Start (1-based) |
| 5 | end | End (inclusive) |
| 6 | score | Score (or .) |
| 7 | strand | Strand (+/-/.) |
| 8 | phase | Reading frame for CDS (0/1/2) |
| 9 | attributes | Key/value attributes (differs GFF3 vs GTF) |
The difference is entirely in column 9. GFF3 uses key=value;key=value pairs (with ID= and Parent= to link features):
chr1 ensembl gene 1000 2000 . + . ID=gene1;Name=EXMPGTF uses key "value"; pairs (notably gene_id and transcript_id):
chr1 ensembl CDS 1000 2000 . + 0 gene_id "gene1"; transcript_id "tx1";Frequently asked questions
What is the difference between SAM and BAM?
They hold the same data — read alignments against a reference. SAM is tab-delimited plain text you can read directly; BAM is its compressed binary equivalent, smaller and faster for tools to process. Both use 1-based positions and the same 11 mandatory fields.
What does a SAM FLAG value mean and how do I decode it?
The FLAG (column 2) is the sum of set bit values, so a single integer encodes several true/false properties. For example 99 = 1 + 2 + 32 + 64, meaning the read is paired, mapped in a proper pair, has its mate on the reverse strand and is the first in the pair. Decode it by subtracting the largest powers of two, or by checking each bit against the FLAG-bit table above.
Is BED 0-based or 1-based?
BED is 0-based and half-open: chromStart counts from 0 and chromEnd is exclusive, so the interval is [start, end). A BED line of chr1 0 100 covers the first 100 bases. SAM, VCF, GFF3 and GTF are all 1-based and fully closed, which is the most common off-by-one trap when converting between formats.
What is the difference between GFF3 and GTF?
Both are 9-column, tab-delimited, 1-based annotation formats and share the first eight columns. They differ only in column 9, the attributes. GFF3 uses key=value pairs separated by semicolons (ID=…;Parent=…), while GTF, an extension of GFF2, uses key "value" pairs (gene_id "…"; transcript_id "…";).
What does a VCF file store?
VCF (Variant Call Format) stores genetic variants — SNPs, insertions, deletions and more — relative to a reference. It begins with ## meta header lines, then a #CHROM header line, then one record per variant with fixed columns (CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO) and optional FORMAT plus one genotype column per sample. Positions are 1-based.
See also
Sources
- 1Sequence Alignment/Map Format Specification (version b5341fb, 12 Aug 2025)The SAM/BAM Format Specification Working Group (samtools/hts-specs) · 2025The entire SAM_FIELDS table (all 11 mandatory fields, columns 1-11, QNAME through QUAL, in exactly the page's order) and the entire SAM_FLAGS table (all 12 rows, 0x1/1 through 0x800/2048, with the spec's wording mapping one-to-one onto the page's plain-English meanings: 0x4 'segment unmapped', 0x10 'SEQ being reverse complemented', 0x100 'secondary alignment', 0x200 'not passing filters, such as platform/vendor quality controls', 0x400 'PCR or optical duplicate', 0x800 'supplementary alignment'). Also backs the COORDS row 'SAM / BAM — 1-based — fully closed', the 'POS is 1-based' claims in the SAM section, and FAQ item 1's '11 mandatory fields'. The FLAG-as-sum-of-bits rule and the 99 = 1+2+32+64 worked example follow directly from the bit table. Verified by extracting the PDF text locally. The peer-reviewed companion paper is Li H et al., 'The Sequence Alignment/Map format and SAMtools', Bioinformatics 2009;25(16):2078-9, doi:10.1093/bioinformatics/btp352, PMID 19505943 — cite the spec for the tables, the paper for the format's provenance.
- 2The Variant Call Format Specification, VCFv4.3 and BCFv2.2 (version c101c79, 5 Nov 2025)samtools/hts-specs · 2025The whole VCF_COLUMNS table and the VCF section prose. Section 1.6.1: "There are 8 fixed fields per record" — CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, matching the page's columns 1-8 including 'QUAL — Phred-scaled variant quality' (spec: "Phred-scaled quality score for the assertion made in ALT. i.e. -10log10 prob(call in ALT is wrong)") and 'FILTER — PASS or filters the variant failed'. Section 1.5 backs column 9: "If genotype data is present in the file, these are followed by a FORMAT column header, then an arbitrary number of sample IDs", which is exactly the page's 'the first eight columns are fixed; FORMAT and one column per sample appear only when genotypes are recorded'. POS 1-based is verbatim: "The reference position, with the 1st base having position 1" — backing the COORDS row, the section prose and FAQ item 5. Also backs the '##' meta lines / single '#CHROM' header line structure and the VCF_EXAMPLE's '##fileformat=VCFv4.3' line. Verified by extracting the PDF text locally.
- 3Frequently Asked Questions: Data File Formats (BED, section format1; GTF, section format4)UCSC Genome Browser, Genomics Institute, University of California Santa CruzTWO distinct things on the page. (a) BED: the entire BED_COLUMNS table, all 12 fields in the page's exact order and naming (chrom, chromStart, chromEnd, name, score, strand, thickStart, thickEnd, itemRgb, blockCount, blockSizes, blockStarts), the score range 'A score between 0 and 1000', the 'three required fields and nine additional optional fields' that backs the BED3/BED6/BED12 footnote, and the coordinate claims: "The first base in a chromosome is numbered 0" and "The chromEnd base is not included in the display of the feature. For example, the first 100 bases of chromosome 1 are defined as chrom=1, chromStart=0, chromEnd=100, and span the bases numbered 0-99" — which backs the COORDS BED row, the 'BED is 0-based and half-open' prose, and FAQ item 3's 'chr1 0 100 covers the first 100 bases' example verbatim. (b) GTF: the GTF_EXAMPLE and the GTF half of the GFF3/GTF section — that GTF shares the first eight fields with GFF, and the attribute syntax with its two mandatory attributes: "gene_id value - A globally unique identifier for the genomic source of the sequence" and "transcript_id value - A globally unique identifier for the predicted transcript", with "Attributes must end in a semi-colon, and be separated from any following attribute by exactly one space." Its GFF section also states "The first base is numbered 1" and end is "inclusive", backing the COORDS GFF3/GTF row.
- 4Generic Feature Format Version 3 (GFF3) specificationThe Sequence OntologyThe GFF_COLUMNS table using GFF3's own field names — seqid, source, type, start, end, score, strand, phase, attributes, in the page's exact order — and the GFF3_EXAMPLE. Backs column 8 'phase — Reading frame for CDS (0/1/2)': "The phase is one of the integers 0, 1, or 2, indicating the number of bases forward from the start of the current CDS feature the next codon begins." Backs the COORDS GFF3/GTF row and the '1-based and closed' prose: "The start and end coordinates of the feature are given in positive 1-based integer coordinates, relative to the landmark given in column one." Backs FAQ item 4's description of column 9 as tag=value pairs separated by semicolons, and the ID= / Parent= linkage shown in GFF3_EXAMPLE.
Related tools and references
Tools
Nearby reference tables
Quick reference for FASTA, FASTQ, GenBank and related formats.
Phred score meaning, error probabilities and ASCII encodings.
Reference table of common cloning and protein expression vectors with backbone size, origin of replication, copy number, selection marker, promoter and fusion tags.