FASTA vs FASTQ, GenBank, and GFF vs GTF

Four plain text formats, and what each one quietly leaves out

17 min

Line drawing of a row of base cells with a quality bar above each cell at only three heights, and below it an exon and intron gene model tied to the cells by dashed lines, with the three stop codon cells filled teal and a dashed outline starting three cells later.

What is the difference between FASTA and FASTQ?

A FASTA file stores sequences, each under one header line that starts with >. A FASTQ file stores sequencing reads, and for every base it adds a quality score: the sequencer's estimate of how likely that base call is to be wrong.[1][2] Assemblies, genes, proteins and reference genomes travel as FASTA. Raw reads come off the instrument as FASTQ.

The quality line is not as self-describing as it looks. A read we sampled from a NovaSeq 6000 run of sake yeast has a quality line made almost entirely of the letter F.[5] In the Phred+33 encoding that both runs sampled here use, F means Q37, about one wrong call in 5,000. In the Phred+64 encoding that older Illumina pipelines used, the same F means Q6, one wrong call in four.[2] Nothing in the file says which encoding it uses.

That pattern repeats across the formats in this article. FASTQ adds per-base confidence to FASTA. GenBank wraps a sequence in its annotation, with every gene and coding sequence given as coordinates in the same record. GFF3 and GTF hold annotation in a separate table that points at a sequence held elsewhere, usually a FASTA genome. Which one you need depends on what the next program reads, and each format drops something the others keep.

FASTQ to FASTA converterDrop the quality lines when a tool only takes sequences, in the browser.Open tool

What a FASTQ record holds

Each FASTQ record has four lines: a header starting with @, the sequence, a separator line starting with +, and a quality string exactly as long as the sequence.[2] This is the first read of the NovaSeq run, unedited:

Text
@DRR256905.1 A00609:58:H2GVHDSXY:2:1101:5927:1016/1
GAACAAACTCGTTATTGGCCATAGGTTCAGCCGGAAAGCTTGTTGAATGATGATATATTGGACCATCATACTGATACGAGGAATCGGCACGCAGTTTATACGCTTTCTCTTTTTCTTTATCCGGCGAGGAACTCGTACTATTGGGGGTAG
+
FFFFFF::FFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFFF:FFFFFFFF,:FFFFFFFFF

Each character is one Phred score, Q=−10log⁡10PQ = -10 \log_{10} P, where PP is the probability that the base is wrong.[3] Subtract 33 from the character's ASCII code to get Q: F is 70, so Q37, and : is 58, so Q25, about one error in 316. Cock and colleagues documented the three encodings in use by 2010: Sanger (Phred+33), Solexa (a different score with an offset of 64) and Illumina 1.3 and later (Phred+64).[2]

You can usually tell the encoding from the characters, and the NovaSeq file shows how. It contains #, ASCII 35, which under Phred+64 would be Q−29, an impossible score, so the file must be Phred+33. A file whose lowest character is @ or above is ambiguous. FastQC and most trimmers guess from the character range, and a wrong guess shifts every score by 31.

The @ character causes a second problem. It is a legal quality value (Q31 in Phred+33), so a quality line can begin with it, and a script that treats every line starting with @ as a header will split records in the wrong place. In 10,000 MiSeq reads of a yeast strain, 267 quality lines started with @.[6] Parse FASTQ four lines at a time, never by searching for @.

Binned quality scores hold less than they show

A quality string looks like a precise measurement per base. On current Illumina instruments it is a choice between three values. Illumina says the NovaSeq 6000, NextSeq 1000 and 2000 and iSeq "all use a three-bin Q-score table", with bins such as 3 to 17, 18 to 29 and 30 or above, which shrinks FASTQ and BAM files by as much as 50%.[4] Older instruments such as the MiSeq wrote scores at whole-number resolution.

We counted every quality value in the first 10,000 reads of the two yeast runs. The NovaSeq reads used four values in 1.5 million bases: Q37 for 94.1%, Q25 for 4.0%, Q11 for 2.0%, and Q2 for exactly two bases, both of them N calls. The MiSeq reads used 28 distinct values.

Figure 1. Quality values in 10,000 reads from a MiSeq run and a NovaSeq 6000 run. Share of all bases at each Phred score, on a logarithmic axis so the rare values stay visible. Both runs are whole-genome sequencing of Saccharomyces cerevisiae (ENA DRR049502 and DRR256905, read 1, the first 10,000 reads). Our count. Reuse under CC BY 4.0.

Binning changes what the file costs and what it can say. Compressed with gzip, the NovaSeq quality lines took about 0.65 bits per base and the MiSeq quality lines 1.73 bits, close to the 2.46 bits the MiSeq bases themselves took.

So a gzipped NovaSeq FASTQ was only 1.30 times the size of the same reads as FASTA, against 1.65 times for MiSeq; uncompressed, both were 1.7 to 1.8 times larger. Binning does not make the reads less accurate, and Illumina reports minimal difference in variant calls.[4] It does mean a Q37 is a label for "30 or better", not a measurement of 37.

Converting FASTQ to FASTA throws the scores away, and nothing can recover them. Converting the other way, as FASTA to FASTQ does for tools that only accept FASTQ, writes placeholder scores, and a read mapper will trust them as if the sequencer had measured them. How much the real scores are worth on each instrument is covered in DNA sequencing accuracy.

FASTA vs GenBank

A FASTA record is a header and a sequence, and nothing else is defined. The header is free text after >, so the name, accession and description in it follow whatever convention the source used.[1] Making a FASTA file by hand is easy for exactly that reason.

A GenBank flat file is a whole database record. It opens with a LOCUS line giving the length, molecule type and topology, then fields such as DEFINITION, ACCESSION, SOURCE and the references, then a FEATURES table, and only then the sequence after ORIGIN, in numbered lines of 60 bases, ending with //.[7] The feature table is the point: every gene, mRNA and coding sequence is listed with a location and qualifiers such as /gene, /product and /translation.

Locations follow the INSDC feature table rules. 53260..54377 is a 1-based, inclusive range; join() strings ranges together into one feature, such as a coding sequence split by an intron; complement() puts the feature on the reverse strand; and < or > marks an end that lies beyond the known boundary.[8] A CDS location includes the stop codon.[8]

We downloaded the yeast actin gene, ACT1, both ways from the RefSeq record for chromosome VI, as the region 53,260 to 54,696.[9] The GenBank file was 10,194 bytes, the FASTA file 1,548 bytes, for the same 1,437 bases. Most of the difference is the CDS entry, with 17 experimental evidence qualifiers and the 375-residue translation.

The FASTA file loses more than metadata. ACT1 sits on the reverse strand, so the region FASTA begins TTAGAAACAC: the reverse complement of the gene's last codons, starting with its TAA stop codon read backwards. Nothing in the file says the gene runs the other way, where its 309-base intron is, or that its first 10 coding bases sit at the far end of the file, past the intron. The GenBank record says complement(join(1..1118,1428..1437)).

Figure 2. Extracting the actin protein from the ACT1 GenBank record. The ACT1 region of RefSeq NC_001138.5 uploaded to GenBank to FASTA with Translated proteins selected. The converter reads the /translation qualifier of the CDS, so the output is the 375-residue protein deposited with the record, and the header keeps the location that FASTA itself cannot carry.

So the direction of conversion matters. GenBank to FASTA is lossy but easy: GenBank to FASTA writes the full sequence, each coding sequence spliced and reverse-complemented from its join and complement locations, or each protein. FASTA to GenBank is not a conversion at all, because the annotation has to come from somewhere. For a genome, it usually comes from a GFF3 or GTF file.

GFF vs GTF

GFF3 and GTF both describe features as rows of nine tab-separated columns: sequence name, source, feature type, start, end, score, strand, phase and attributes.[10][11] Both use 1-based, inclusive coordinates, like GenBank.[10][11] Neither contains the sequence itself (GFF3 allows an optional ##FASTA section at the end, which the Ensembl files do not use).[10] The first eight columns of an Ensembl GTF and GFF3 line for the same exon are identical.

The difference is in column 9 and in what the rows are allowed to mean. These are the first CDS rows for ACT1 in Ensembl release 116, which publishes both formats for the same yeast annotation:[12]

Text
GFF3: VI  sgd  CDS  53260  54377  .  -  2  ID=CDS:YFL039C;Parent=transcript:YFL039C_mRNA;protein_id=YFL039C
GTF:  VI  sgd  CDS  53263  54377  .  -  2  gene_id "YFL039C"; transcript_id "YFL039C_mRNA"; exon_number "2"; gene_name "ACT1"; ...

GFF3 writes attributes as tag=value pairs and links features into a tree with ID and Parent: CDS and exons point to an mRNA, the mRNA points to a gene, and one exon may list several parent transcripts.[10] Types come from the Sequence Ontology, so Ensembl's yeast GFF3 separates gene from ncRNA_gene, tRNA, snoRNA and transposable_element_gene.

GTF writes key "value"; pairs and requires every row to carry a gene_id and a transcript_id, so grouping is flat: a row belongs to whatever gene and transcript its IDs name.[11] Ensembl's GTF calls every locus a gene and moves the type into a gene_biotype attribute.

The coordinates differ too. The GTF2.2 specification is explicit: "Unlike Genbank annotation, the stop codon is not included in the CDS for the terminal exon," and it gets its own stop_codon row.[11] GFF3 says the opposite, that the start and stop codons are included in the CDS.[10] So the two ACT1 rows above end at 53,263 and 53,260.

This is not an ACT1 quirk. We summed CDS lengths per transcript in both Ensembl yeast files: for all 6,600 protein-coding transcripts, the GFF3 coding sequence is exactly 3 bases longer than the GTF one, and the GTF carries 6,600 stop_codon rows to make up the difference. Translate GTF CDS rows and you get proteins without a stop; count codons from GFF3 and the last one is a stop. Table 1 lists the other differences.

PropertyGFF3GTF
Column 9 syntaxID=gene:YFL039C;Name=ACT1gene_id "YFL039C"; gene_name "ACT1";
How features are groupedID and Parent tree, several parents allowedFlat, by gene_id and transcript_id on every row
Feature typesSequence Ontology terms (ncRNA_gene, tRNA, mRNA)gene, transcript, exon, CDS and codon rows in Ensembl's file, with the type in gene_biotype
Stop codonInside the CDSOutside the CDS, as a stop_codon row
Feature rows in the yeast file28,695, plus 7,167 directive and comment lines41,879
Size of the yeast file5.9 MB10.5 MB, as every row repeats the gene and transcript attributes
Table 1. GFF3 and GTF compared on the same Ensembl annotation. Format rules from the GFF3 1.26 and GTF2.2 specifications; file figures are our counts on the Ensembl release 116 files for Saccharomyces cerevisiae R64-1-1, uncompressed.[10][11][12]

Most RNA-seq software was written for GTF, and that is where the formats bite in practice. STAR builds transcripts from exon rows using the transcript_id attribute by default, and its manual says GFF3 needs --sjdbGTFtagExonParentTranscript Parent.[13]

None of the 7,507 exon rows in the Ensembl yeast GFF3 carries a transcript_id. The RNA-seq workflow from FASTQ to counts uses a GTF for that reason, and quantifiers such as Salmon take a transcriptome FASTA built from it.

The sequence names in column 1 must also match the FASTA genome exactly. The STAR manual warns that Ensembl names chromosomes 1, 2 and so on while UCSC uses chr1, chr2, so an Ensembl GTF and a UCSC genome "cannot be mixed together" unless one is renamed.[13] A mismatch need not stop the run; it can instead produce a count table in which no read lands on any gene.

One yeast gene in four formats

ACT1 makes a good test because it has everything that trips up conversions: it is on the reverse strand, it has an intron, and its first exon holds only 10 coding bases. Figure 3 follows its coding sequence through the four formats.

Figure 3. The coding sequence of yeast ACT1 as GenBank, GFF3, GTF and FASTA record it. Coordinates are on chromosome VI of the R64 assembly, from RefSeq NC_001138.5 and the Ensembl release 116 GFF3 and GTF files. Exon, intron and codon widths are not to scale; the stop and start codons are drawn wide so the 3 bases where GTF disagrees with the other two formats stay visible.

The four records agree on where ACT1 is and disagree on how to say it. GenBank gives the coding sequence as one location, complement(join(53260..54377,54687..54696)), and includes the stop codon. GFF3 gives the same span as two CDS rows with a shared parent. GTF gives two CDS rows that stop 3 bases short, plus start_codon and stop_codon rows.

The coding-sequence FASTA from RefSeq has 1,128 bases, starting ATG and ending TAA, already spliced and reverse-complemented; it has no coordinates at all.[9]

Two of those differences cause real errors. Take the region FASTA and translate it in the forward frame, and you translate the wrong strand straight through the intron. Compute a coding length from GTF and compare it with one from GenBank or GFF3, and every gene is 3 bases, one codon, short. Neither mistake raises an error. Each one gives a plausible answer that is wrong for every gene in the genome.

Which format should you use?

The choice is made by the next program, not by preference. Table 2 pairs the usual tasks with the format that program expects, what that format cannot tell you, and the check that catches the problem early.

TaskFormatWhat it cannot tell youCheck first
Trim, map or assemble sequencing readsFASTQThe quality encoding, and on binned instruments any score finer than three levelsLowest quality character: below @ means Phred+33
Search, align or fold a sequenceFASTAStrand, coordinates, features and qualityThat the header carries an accession you can trace
Work with one annotated sequence, such as a plasmid or a viral genomeGenBankNothing about the sequence, but feature locations are relative to the record, not the chromosome, when you download a regionWhether coordinates start at 1 or at the chromosome position
Count RNA-seq reads per gene or build an aligner indexGTFThe stop codon inside the CDS, and ontology types for non-coding genesChromosome names match the genome FASTA, same release
Load a genome annotation into a browser or an annotation pipelineGFF3Nothing a GTF holds, but many RNA-seq tools need extra options to read itWhich attribute links exons to transcripts (Parent)
Table 2. Choosing a sequence or annotation format. The format each task usually expects, what the format leaves out, and a check to run before the analysis.

The habit that prevents most of these problems is to keep the annotation and the sequence from the same release and the same source, and to check one gene by hand before running the whole genome. Pick a gene on the reverse strand with an intron, find it in every file, and confirm that its coordinates, strand and coding length agree. If they do not, the file you just converted is the one to look at.

The GenBank row is the one people miss. The region download of ACT1 renumbers the record, so the gene that sits at 53,260 to 54,696 on chromosome VI appears at 1 to 1,437, while the same region in GFF3 keeps chromosome coordinates. Mixing the two puts every feature 53,259 bases off.

Sequence file tools on ProteinIQ

Conversion usually runs in one direction, from the richer format to the leaner one, and these tools cover each step in the browser:

  • FASTQ to FASTA: drop quality lines when a tool only takes sequences
  • FASTA to FASTQ: add placeholder quality scores for tools that only accept FASTQ
  • GenBank to FASTA: write the full sequence, each coding sequence or each protein from a GenBank record
  • GenBank feature extractor: pull out individual genes, CDS or other features with their locations
  • FASTA converter: turn GenBank, EMBL, FASTQ or alignment files into FASTA
  • Reverse complement: flip a region FASTA onto the strand a reverse-strand gene is read from
GenBank to FASTA ConverterSpliced and reverse-complemented from join and complement locations, or as proteins.Open tool

Frequently asked questions

What is the main difference between FASTA and FASTQ?

FASTQ stores a quality score for every base and FASTA does not. A FASTQ record takes four lines (header starting with @, sequence, + line, quality string), while a FASTA record is a > header and the sequence.[2] Sequencers write FASTQ; references, genes and proteins are kept as FASTA.

How do I know if a FASTQ file is Phred+33 or Phred+64?

Look at the lowest quality character in the file. Any character below @ (ASCII 64), such as # or 5, can only be valid in Phred+33, the Sanger encoding.[2] If every character is @ or higher the file is ambiguous, and you should check the instrument and pipeline version in the run metadata.

Can I convert FASTA to FASTQ?

Only by inventing quality scores. A FASTA file has no per-base quality, so a converter writes the same placeholder score for every base, and downstream tools will treat it as measured. Use it when a tool insists on FASTQ input, not to recover lost information.

Is GenBank the same as FASTA?

No. A GenBank flat file is a full record with a FEATURES table giving the location and translation of every annotated gene and coding sequence, followed by the sequence after ORIGIN.[7] FASTA keeps only a header line and the sequence. For the 1,437-base yeast ACT1 region, the GenBank file was 10,194 bytes and the FASTA 1,548 bytes.

What is the difference between GFF and GTF?

Both are nine-column, tab-separated annotation tables with 1-based coordinates. GFF3 writes attributes as tag=value and links features with ID and Parent; GTF writes key "value"; and requires gene_id and transcript_id on every row.[10][11] GTF also leaves the stop codon out of the CDS, so in the Ensembl yeast files every one of 6,600 coding sequences is 3 bases shorter in GTF than in GFF3.

Should I use GTF or GFF3 for RNA-seq?

GTF, unless your tool documents GFF3 support. Aligners and quantifiers such as STAR link exons to transcripts through transcript_id by default, and STAR needs --sjdbGTFtagExonParentTranscript Parent to read GFF3.[13] Take the GTF from the same release and source as the genome FASTA so the chromosome names match.