- GFF3 (General Feature Format version 3) and GTF (Gene Transfer Format) are widely used text-based formats for representing genomic features and their annotations. They describe the locations and biological characteristics of genes, transcripts, exons, coding sequences, untranslated regions, regulatory elements, and other functional regions within a genome. These formats are essential in genome annotation, gene expression analysis, comparative genomics, variant interpretation, transcriptome studies, and many other bioinformatics applications. Although GFF3 and GTF have similar tabular structures, they differ in their attribute conventions, feature relationships, and common applications.
- Genome annotation involves identifying and describing biologically meaningful features within a genome sequence. A genome annotation file connects these features to their precise genomic coordinates and provides information about their biological relationships. For example, a gene may contain several transcripts, each transcript may consist of multiple exons, and some exons may contain coding sequences. GFF3 and GTF represent these relationships so that bioinformatics software can identify which genomic regions belong to particular genes and transcripts.
- Both formats are generally tab-delimited text files in which each feature is represented by one line containing nine columns. The columns are sequence identifier, source, feature type, start, end, score, strand, phase, and attributes. The sequence identifier identifies the chromosome, scaffold, contig, or other reference sequence on which the feature is located. The source indicates the database, software, or method responsible for the annotation. The feature type describes the biological element, such as gene, transcript, exon, CDS, start codon, or stop codon. The start and end columns define the genomic coordinates of the feature. The score column contains an optional numerical score, while the strand column indicates whether the feature is located on the forward or reverse strand. The phase column is used for coding sequences to indicate the reading-frame offset. The attributes column contains additional information, such as gene identifiers, transcript identifiers, gene names, and relationships between features.
- A simplified GFF3 record has the following structure:
##gff-version 3
chr1 Ensembl gene 1000 5000 . + . ID=gene1;Name=ExampleGene
chr1 Ensembl mRNA 1000 5000 . + . ID=transcript1;Parent=gene1
chr1 Ensembl exon 1000 1500 . + . ID=exon1;Parent=transcript1
chr1 Ensembl exon 2500 3000 . + . ID=exon2;Parent=transcript1
chr1 Ensembl CDS 1200 1500 . + 0 ID=cds1;Parent=transcript1
- The first line identifies the file as GFF3. The following records describe a gene, an mRNA transcript, two exons, and a coding sequence. The ID attribute provides a unique identifier for a feature, while the Parent attribute establishes its relationship to another feature. In this example, the transcript is a child of the gene, and the exons and coding sequence are associated with the transcript. The example is illustrative and does not represent a complete biological annotation.
- GFF3 uses a structured attribute system in which attributes are generally represented as key-value pairs separated by semicolons. The equals sign separates each key from its value, and multiple values may be represented using comma-separated lists where permitted. Important attributes include ID, Name, Parent, Alias, Target, Note, Dbxref, and Ontology_term. The ID attribute identifies a feature, while Parent indicates the feature or features that contain or logically relate to it. This parent-child structure is particularly useful for representing complex genomic annotations, including genes with multiple transcripts and transcripts with multiple exons. GFF3 also supports directives such as ##gff-version 3, sequence-region declarations, and embedded sequence sections.
- GTF, also known as GTF2 or GTF version 2 in many applications, is another widely used format for genomic annotation. It has the same basic nine-column structure as GFF3, but its attribute syntax is different. Instead of the GFF3 convention of key=value, GTF generally uses attributes in the form key “value”;. Two especially important attributes are gene_id and transcript_id. These identifiers connect exons, coding sequences, and other transcript-associated features to their corresponding genes and transcripts.
- A simplified GTF record looks like this:
chr1 Ensembl gene 1000 5000 . + . gene_id “gene1”; gene_name “ExampleGene”;
chr1 Ensembl transcript 1000 5000 . + . gene_id “gene1”; transcript_id “transcript1”;
chr1 Ensembl exon 1000 1500 . + . gene_id “gene1”; transcript_id “transcript1”; exon_number “1”;
chr1 Ensembl exon 2500 3000 . + . gene_id “gene1”; transcript_id “transcript1”; exon_number “2”;
chr1 Ensembl CDS 1200 1500 . + 0 gene_id “gene1”; transcript_id “transcript1”;
- In this example, gene_id identifies the gene, while transcript_id identifies the transcript associated with each feature. The exon_number attribute indicates the position of an exon within a transcript. GTF annotations commonly contain features such as gene, transcript, exon, CDS, start codon, stop codon, and untranslated regions. The precise feature types and attributes available depend on the annotation provider and the GTF specification or conventions followed by the generating software.
- One important distinction between GFF3 and GTF is how they represent relationships between genomic features. GFF3 explicitly supports parent-child relationships through ID and Parent attributes. This makes it suitable for describing complex feature hierarchies and annotations involving multiple levels of biological organization. GTF commonly represents gene and transcript relationships through repeated gene_id and transcript_id attributes on individual records. This approach is convenient for transcript-centric analysis and is widely supported by RNA-sequencing tools. However, GTF does not provide the same general-purpose hierarchical relationship mechanism as GFF3.
- The coordinate system used by both standard GFF3 and GTF is one-based and inclusive. This means that the first base of a reference sequence is position 1, and both the start and end coordinates are included in the feature. For example, a feature extending from position 100 to position 200 contains 101 nucleotides. This differs from BED format, which normally uses zero-based, half-open coordinates. When converting between GFF3 or GTF and BED, the start coordinate must be adjusted appropriately to avoid off-by-one errors. The end coordinate remains the same during a basic conversion from one-based inclusive coordinates to zero-based half-open coordinates.
- The strand column indicates the orientation of a feature. A plus sign (+) represents the forward strand, while a minus sign (-) represents the reverse strand. A period (.) indicates that strand information is not specified or is not applicable. Strand information is particularly important when interpreting gene orientation, transcript structure, exon order, and transcriptional direction. For genes on the reverse strand, genomic coordinate order and biological transcript order are opposite: the exon with the highest genomic coordinates may be the first exon in the transcript.
- The phase column is especially important for coding sequence features. It specifies how many bases should be skipped at the beginning of a CDS feature to reach the first base of the next complete codon, using the coding direction of the feature. Valid values are 0, 1, and 2. A phase of 0 means that the first base of the feature is the first base of a codon; a phase of 1 means that one base precedes the next complete codon; and a phase of 2 means that two bases precede it. For features on the reverse strand, phase is interpreted relative to the coding direction rather than simply reading from the lower genomic coordinate to the higher one. The phase is not the same as the reading frame in every context, and it should be interpreted together with the transcript’s complete CDS structure.
- A gene may have multiple transcript isoforms generated through alternative splicing. These isoforms can differ in exon composition, untranslated regions, and coding sequences. GFF3 and GTF can represent these differences by assigning separate transcript identifiers and associating each transcript with its corresponding exons and CDS features. For example, one gene may produce three transcripts with different exon combinations. This information is essential for transcript-level expression quantification, alternative splicing analysis, coding sequence reconstruction, and functional interpretation of genomic variants.
- GFF3 and GTF files are commonly produced by genome annotation pipelines and major biological databases. Ensembl and Ensembl Genomes provide genome annotation files in GTF and GFF3 formats for many organisms. NCBI distributes genome annotation in GFF3 and other formats, including GTF for some resources and releases. RefSeq annotations are widely used as reference gene models, while specialized resources such as GENCODE provide detailed human and mouse gene annotations, commonly distributed in GTF and GFF3. Annotation files from different providers may differ in transcript selection, gene naming, feature representation, completeness, and evidence standards. Therefore, the source and release of an annotation file should always be recorded.
- GFF3 is frequently used in genome annotation pipelines, comparative genomics, genome browsers, and tools that process hierarchical genomic features. GTF is especially common in RNA-sequencing workflows. Tools such as HISAT2, STAR, StringTie, featureCounts, and HTSeq use GTF or related annotation representations for tasks such as splice-junction guidance, transcript assembly, and gene or transcript-level read counting. Exact format requirements vary between software versions and analysis modes. For example, a read-counting tool may require exon features and a particular gene identifier attribute, whereas a genome browser may require explicit transcript and exon relationships.
- In Python, GFF3 and GTF files can be examined using standard text-processing libraries or specialized bioinformatics packages. Biopython provides useful sequence and annotation functionality, although its SeqIO module is not a general-purpose parser for every GFF3 or GTF file. Libraries such as gffutils can create databases from GFF and GTF annotations and support queries for genes, transcripts, exons, and other features. The following example reads a GFF3 file using gffutils and retrieves gene features.
pip install gffutils
import gffutils
db = gffutils.create_db(
“annotation.gff3”,
dbfn=”annotation.db”,
force=True,
keep_order=True,
merge_strategy=”merge”,
sort_attribute_values=True
)
for gene in db.features_of_type(“gene”):
print(
gene.id,
gene.seqid,
gene.start,
gene.end,
gene.strand
)
- The following example retrieves all exon features associated with a particular transcript. The transcript identifier must match an identifier present in the annotation database.
import gffutils
db = gffutils.FeatureDB(“annotation.db”)
transcript_id = “transcript1”
for exon in db.children(
transcript_id,
featuretype=”exon”,
order_by=”start”
):
print(exon.seqid, exon.start, exon.end, exon.strand)
- For GTF files, the pandas library can be used to read the tab-delimited structure. Because GTF contains comment lines and attribute fields with spaces and quotation marks, it is important to parse the ninth column as a complete string rather than treating it as an ordinary collection of independent columns.
import pandas as pd
columns = [
“seqid”,
“source”,
“feature”,
“start”,
“end”,
“score”,
“strand”,
“phase”,
“attributes”
]
gtf = pd.read_csv(
“annotation.gtf”,
sep=”\t”,
comment=”#”,
header=None,
names=columns,
dtype={“seqid”: str, “phase”: str}
)
print(gtf.head())
A simple extraction of gene identifiers from a common GTF attribute string can be performed using regular expressions.
import re
import pandas as pd
gtf[“gene_id”] = gtf[“attributes”].str.extract(
r’gene_id “([^”]+)”‘
)
gtf[“transcript_id”] = gtf[“attributes”].str.extract(
r’transcript_id “([^”]+)”‘
)
print(gtf[[“feature”, “gene_id”, “transcript_id”]].head())
- This approach is useful for basic inspection and filtering, but it should not replace a format-aware parser when the annotation contains complex attributes, unusual feature types, or relationships that must be preserved. Attribute conventions can vary between providers, so parsing expressions should be checked against the actual file.
- In R, packages such as rtracklayer and GenomicFeatures from Bioconductor provide tools for importing and working with genomic annotations. The rtracklayer package can import GFF3 and GTF files into GRanges objects, which represent genomic intervals together with their associated metadata.
if (!requireNamespace(“BiocManager”, quietly = TRUE)) {
install.packages(“BiocManager”)
}
BiocManager::install(“rtracklayer”)
library(rtracklayer)
annotation <- import(“annotation.gff3”)
head(annotation)
The same package can import a GTF file:
library(rtracklayer)
gtf_annotation <- import(“annotation.gtf”)
head(gtf_annotation)
- The GenomicFeatures package can be used to construct transcript databases from annotation files. Such databases support queries about genes, transcripts, exons, coding sequences, and genomic relationships.
BiocManager::install(“GenomicFeatures”)
library(GenomicFeatures)
txdb <- makeTxDbFromGFF(
“annotation.gtf”,
format = “gtf”
)
transcripts(txdb)
exons(txdb)
genes(txdb)
- Command-line tools are also useful for inspecting, filtering, and validating annotation files. Standard utilities such as grep, awk, cut, and sort can be used for quick checks, while specialized tools such as AGAT, gffread, and GenomeTools provide more advanced annotation processing and conversion functions. For example, gffread can inspect and convert common GFF/GTF annotations and extract transcript or coding sequences when supplied with an appropriate reference genome.
# Display the first annotation records
head -n 20 annotation.gff3
# Count the number of exon records
awk -F ‘\t’ ‘$3 == “exon” {count++} END {print count}’ annotation.gff3
# Display gene records
awk -F ‘\t’ ‘$3 == “gene”‘ annotation.gff3
# Display GTF transcript records
awk -F ‘\t’ ‘$3 == “transcript”‘ annotation.gtf
# Convert or process an annotation with gffread
gffread annotation.gff3 -T -o converted_annotation.gtf
# Extract transcript sequences using a reference genome
gffread annotation.gtf \
-g reference_genome.fa \
-w transcripts.fa
# Extract coding sequences
gffread annotation.gtf \
-g reference_genome.fa \
-x coding_sequences.fa
- The conversion between GFF3 and GTF should be performed carefully because the two formats do not represent all information in exactly the same way. GFF3 may contain explicit parent-child relationships, multiple parents, feature identifiers, and attributes that cannot always be represented directly in a conventional GTF file. Conversion software may simplify, transform, or omit some attributes. Similarly, converting GTF to GFF3 may require the software to reconstruct hierarchical feature relationships from gene and transcript identifiers. The output should therefore be checked to confirm that gene models, transcript structures, feature coordinates, and important metadata have been preserved.
- Annotation validation is an important step before downstream analysis. Files should be checked for the correct number of columns, valid coordinate values, recognized strand symbols, valid CDS phase values, and appropriate feature relationships. In GFF3, feature identifiers should be unique where required, and parent references should point to valid features. In GTF, gene and transcript identifiers should be consistent across associated records. Exons belonging to a transcript should have appropriate genomic positions, and coding sequence features should be consistent with the transcript’s orientation and reading frame. Specialized validation tools can identify structural errors that may not be obvious from visual inspection.
- A further important consideration is the relationship between an annotation file and its reference genome. The chromosome names, sequence identifiers, coordinate system, and assembly version must match the reference sequence used in the analysis. For example, an annotation generated for one human genome assembly should not be applied directly to a different assembly without an appropriate coordinate conversion or remapping procedure. Chromosome naming conventions may also differ, such as chr1 versus 1. Such differences can cause software to fail to match reads or variants to the correct genomic features.
- GFF3 and GTF annotations are central to RNA sequencing and gene expression analysis. In RNA-seq workflows, reads are aligned to a reference genome, and annotation files help identify genes, transcripts, and exons associated with aligned reads. Tools such as featureCounts and HTSeq use gene and transcript identifiers to summarize read counts. Transcript quantification methods such as Salmon and Kallisto commonly use transcript sequences and transcript-to-gene mapping information, which can be derived from annotation files. The quality and completeness of the annotation directly influence the interpretation of gene expression, alternative splicing, and transcript abundance.
- These formats are also important in variant annotation and functional genomics. Genomic variants can be compared with annotated gene structures to determine whether they occur within exons, introns, untranslated regions, splice sites, or intergenic regions. The transcript model helps determine whether a variant affects a particular coding sequence or transcript isoform. However, GFF3 and GTF primarily describe genomic features; they do not independently provide a complete clinical interpretation of genetic variants. Additional resources and evidence are needed for determining pathogenicity, functional effects, and clinical significance.
- The choice between GFF3 and GTF depends on the purpose of the analysis and the requirements of the software being used. GFF3 is particularly useful when detailed hierarchical relationships and flexible feature attributes are important. GTF is widely used for transcript-oriented workflows, especially RNA-seq analysis and gene expression quantification. Both formats are valuable, and many bioinformatics workflows use them together. Researchers should select the format supported by their tools, preserve the original annotation, and document any conversions.
- For reproducible bioinformatics research, it is essential to record the annotation provider, genome assembly, database release, file retrieval date, and any modifications made to the annotation. Compressed annotation files should be retained with their original filenames and, where possible, checksums should be calculated to verify file integrity. The exact software versions and conversion commands should also be documented. Annotation files may change between releases as new transcripts are identified, gene models are corrected, and biological evidence is updated. Consequently, two analyses using different annotation releases may produce different gene counts, transcript structures, or variant consequences even when they use the same sequencing data.
- Overall, GFF3 and GTF provide standardized ways of describing genomic features and their relationships. They connect genome sequences to gene structures, transcript isoforms, exons, coding regions, and other functional elements. Understanding their nine-column organization, coordinate conventions, attribute syntax, strand information, CDS phase, and hierarchical relationships is essential for accurate genome annotation and downstream bioinformatics analysis. Their correct use supports reproducible research, reliable gene expression studies, comparative genomics, variant interpretation, and large-scale genomic data integration.