- FASTA and FASTQ are two of the most widely used file formats in bioinformatics for storing nucleotide and protein sequence information. They are fundamental to DNA sequencing, RNA sequencing, genome assembly, sequence alignment, comparative genomics, transcriptomics, and many other biological analyses. Both formats represent biological sequences as text, but they differ in the information they contain. FASTA stores sequence data together with a descriptive header, whereas FASTQ stores sequence data along with a quality score for every nucleotide or base call. Understanding their structures, differences, applications, and methods of handling is essential for working with biological sequence data.
- FASTA is a simple text-based format used to represent DNA, RNA, and protein sequences. It was developed for sequence data exchange and is supported by almost all major bioinformatics tools. A FASTA file contains one or more sequence records. Each record begins with a header line starting with the greater-than symbol (>), followed by an identifier and optional descriptive information. The biological sequence appears on the subsequent lines. A sequence may be written on one line or divided across multiple lines for readability. The next header indicates the beginning of another record.
- A basic FASTA record is shown below:
>sequence_001 Example DNA sequence
ATGCGTACGTAGCTAGCTAG
GCTAGCTAGCTAGCTAGCTA
- In this example, sequence_001 is the sequence identifier, while the remaining text in the header provides a description. The lines below the header contain the nucleotide sequence. FASTA files can contain multiple records, allowing researchers to store collections of genes, transcripts, proteins, or genomic sequences in a single file.
- A FASTA file containing multiple sequences may look like this:
>gene_001 Gene A nucleotide sequence
ATGCGTACGTAGCTAGCTAG
>gene_002 Gene B nucleotide sequence
ATGCCCGGTTAGCTAGCTAA
>protein_001 Example protein sequence
MKWVTFISLLFLFSSAYS
- FASTA supports different types of biological sequences. DNA sequences generally use the nucleotide symbols A, C, G, and T, while RNA sequences use A, C, G, and U. Protein sequences use the standard one-letter amino acid codes. Ambiguous nucleotide symbols may also be used when the exact base is unknown or when multiple possibilities are represented. For example, N represents any nucleotide, while R represents A or G and Y represents C or T. Other ambiguity codes describe additional combinations of nucleotides. These symbols are important when representing incomplete, uncertain, or degenerate sequence information.
- FASTA headers are important because they identify individual sequences and may contain useful metadata. A header can include a sequence accession, gene name, organism, chromosome, protein description, or other information. However, header conventions differ between databases and software tools. Some programs interpret only the first word after the > symbol as the sequence identifier, while others retain the entire header. Researchers should therefore use consistent and unique identifiers and avoid unnecessary spaces or ambiguous naming conventions when preparing FASTA files for computational analysis.
- FASTA is commonly used for storing reference genomes, assembled contigs, chromosomes, transcripts, coding sequences, and protein sequences. It is also used as input for sequence alignment programs such as BLAST, nucleotide and protein alignment tools, genome assembly software, and gene prediction systems. Researchers frequently use FASTA files to compare sequences, identify homologous genes, detect conserved regions, and investigate evolutionary relationships.
- Although FASTA is widely used, it has limitations. It stores sequence information but does not normally include a per-base sequencing quality score. It also does not provide a universal mechanism for storing detailed experimental metadata, sample information, or complex biological annotations. Such information is usually stored separately or represented in other formats, such as GenBank, GFF3, or structured metadata files. FASTA should therefore be considered a sequence representation format rather than a complete record of an experiment.
- FASTQ is another text-based sequence format, but it contains additional information about the quality of sequencing data. It is primarily used to store raw sequencing reads produced by high-throughput sequencing technologies. Each FASTQ record includes a sequence identifier, the nucleotide sequence, a separator line, and a quality string. The quality string represents the confidence associated with each base call and allows researchers to evaluate the reliability of sequencing reads.
A standard four-line FASTQ record has the following structure:
@read_001
ATGCGTACGTAGCTAG
+
IIIIIIIIIIIIIIII
- The first line begins with the at symbol (@) and contains the read identifier and optional descriptive information. The second line contains the nucleotide sequence. The third line begins with a plus symbol (+) and separates the sequence from its quality scores. The fourth line contains encoded quality characters, with one quality character corresponding to each nucleotide in the sequence. In some files, the separator line may repeat the sequence identifier, although this is not required.
- The quality information in FASTQ is generally represented using Phred quality scores. A Phred score expresses the estimated probability that a base call is incorrect. The higher the score, the lower the estimated probability of an error. The relationship is:
[
Q = -10\log_{10}(P)
]
- where (Q) is the Phred quality score and (P) is the estimated probability that the base call is incorrect.
- For example, a Phred score of 20 corresponds to an estimated error probability of 1 in 100, while a score of 30 corresponds to approximately 1 in 1,000. A score of 40 corresponds to approximately 1 in 10,000. These values describe estimated base-calling error probabilities, not guarantees that an individual base is correct.
- FASTQ quality scores are stored as ASCII characters rather than as ordinary numerical values. In the widely used Phred+33 encoding, the numerical Phred score is converted into an ASCII character by adding 33 to the score. For example, a Phred score of 30 is represented by the ASCII character ?. The character I corresponds to a Phred score of 40 under Phred+33 encoding. Historical FASTQ datasets may use other quality encodings, so researchers should verify the encoding before interpreting quality characters. Modern sequencing workflows commonly use Phred+33.
- FASTQ is especially important in next-generation sequencing (NGS) workflows. Sequencing instruments generate millions or billions of reads, and each read is stored with its corresponding quality information. These reads are typically examined before downstream analysis. Quality-control tools evaluate base quality, read length, GC content, adapter contamination, sequence duplication, and other characteristics. Low-quality bases and unwanted adapter sequences may be removed or filtered before alignment, genome assembly, transcript quantification, or variant detection.
- FASTQ files are frequently generated in paired-end sequencing experiments. In paired-end sequencing, both ends of a DNA fragment are sequenced, producing two related reads. These reads are commonly stored in separate files, often named with conventions such as sample_R1.fastq.gz and sample_R2.fastq.gz. The first file contains one read from each fragment, and the second contains its corresponding mate. The read identifiers are used to associate the pairs. Preserving the correct relationship between paired reads is essential for accurate alignment, assembly, and downstream analysis. Some workflows use interleaved FASTQ files, in which the two mates are stored consecutively in the same file.
- A simplified paired-end example is shown below:
@read_001/1
ATGCGTACGTAGCTAG
+
IIIIIIIIIIIIIIII
@read_001/2
CTAGCTAGCTAGGTCA
+
IIIIIIIIIIIIIIII
- The /1 and /2 suffixes are illustrative conventions indicating the first and second reads of a pair. Actual read identifiers vary according to sequencing platform and software. Some identifiers contain additional instrument, lane, tile, and cluster information. Researchers should follow the naming conventions used by their sequencing provider and analysis software rather than assuming that all FASTQ files use identical headers.
- FASTA and FASTQ differ in their information content and typical applications. FASTA stores sequence identifiers and biological sequences, making it suitable for reference sequences, assembled genomes, transcripts, and proteins. FASTQ stores sequencing reads together with per-base quality scores, making it suitable for raw sequencing data and quality assessment. FASTQ can be converted to FASTA by removing the quality information, but this conversion loses the original base-quality scores. Converting FASTA to FASTQ cannot recover genuine sequencing quality information because FASTA does not contain those scores.
- The following example demonstrates the conversion of a FASTQ file into FASTA using Biopython. The conversion retains the sequence identifiers and sequences but discards the quality scores.
from Bio import SeqIO
SeqIO.convert(
“reads.fastq”,
“fastq”,
“reads.fasta”,
“fasta”
)
print(“FASTQ converted to FASTA.”)
- Biopython is a widely used Python library for working with biological sequence data. Its SeqIO module supports reading, writing, and converting common formats, including FASTA and FASTQ. The following example reads a FASTA file and displays the identifier, description, and sequence length of each record.
from Bio import SeqIO
for record in SeqIO.parse(“sequences.fasta”, “fasta”):
print(“ID:”, record.id)
print(“Description:”, record.description)
print(“Length:”, len(record.seq))
- The following example reads a FASTQ file and calculates the average Phred quality score for each read. It assumes the file uses the standard Phred+33 encoding, as expected by Biopython’s fastq format parser.
from Bio import SeqIO
for record in SeqIO.parse(“reads.fastq”, “fastq”):
qualities = record.letter_annotations[“phred_quality”]
if qualities:
average_quality = sum(qualities) / len(qualities)
print(record.id, average_quality)
- Researchers can also use command-line tools to inspect and process FASTA and FASTQ files. Commands such as head, tail, grep, and wc can help examine text-based files, although specialized tools are preferable for complex sequence operations. The following commands illustrate basic file inspection and compression handling in Linux.
# Display the first FASTA records
head -n 20 sequences.fasta
# Display the first FASTQ records
head -n 8 reads.fastq
# Count FASTA header lines
grep -c “^>” sequences.fasta
# Count FASTQ records in a standard four-line FASTQ file
awk ‘END {print NR/4}’ reads.fastq
# Display the first records of a gzipped FASTQ file
zcat reads.fastq.gz | head -n 8
- The FASTQ record-count command assumes a standard four-line FASTQ representation without wrapped sequence or quality lines. Some FASTQ parsers support multiline records, so dedicated software should be used when the file structure is uncertain. For large sequencing datasets, tools such as seqkit, fastp, and Bioawk provide more specialized functionality for sequence inspection, filtering, conversion, and processing.
- FASTA and FASTQ files are often compressed because sequencing datasets can require substantial storage space. Gzip compression is commonly used, producing filenames such as genome.fasta.gz and sample.fastq.gz. Compression reduces storage requirements and transfer times. Many bioinformatics tools can read gzip-compressed files directly, while others require decompression. Researchers should check the input requirements of the software before processing compressed files. Compression should not be confused with file format: a .fastq.gz file contains FASTQ data compressed using gzip.
- Quality control is an essential part of FASTQ handling. Sequencing reads may contain low-quality bases, adapter contamination, ambiguous nucleotides, unusual GC content, or duplicated sequences. These problems can affect read alignment, genome assembly, transcript quantification, and variant detection. Tools such as FastQC provide quality reports, while fastp and Cutadapt can perform filtering and adapter trimming. Quality filtering should be selected according to the sequencing technology, experimental design, and downstream analytical requirements. Excessive trimming can remove useful biological information, while insufficient filtering can allow poor-quality reads to affect the analysis.
- FASTA files also require validation before analysis. Researchers should check that each record has a valid header, that sequence identifiers are unique where required, and that the sequence contains appropriate characters for its biological type. DNA and RNA files may contain ambiguity codes, while protein files use amino acid symbols. Unexpected characters, empty records, duplicated identifiers, or accidental inclusion of non-sequence text can cause software errors. The expected sequence type and permitted alphabet should be verified before processing.
- FASTQ validation requires additional checks because sequence and quality information must remain synchronized. Each record must contain the expected structure, and the number of quality characters must equal the number of sequence bases. The quality encoding should be known, and paired-end files should contain corresponding reads in the correct order. Trimming and filtering software should preserve valid FASTQ structure when writing output files. Any conversion or manipulation should be followed by appropriate validation.
- FASTA and FASTQ are frequently used together in bioinformatics workflows. FASTA files commonly provide reference genomes or protein sequences, while FASTQ files provide raw sequencing reads. In a typical genome sequencing workflow, FASTQ reads are first subjected to quality control and preprocessing. They are then aligned to a reference genome stored in FASTA format or used in a de novo genome assembly. The resulting alignment files may be stored in SAM, BAM, or CRAM format, and genetic variants may be represented in VCF format. In RNA sequencing, FASTQ reads may be aligned or pseudo-aligned against a reference genome or transcriptome, followed by gene or transcript quantification.
- The following example illustrates a simplified sequencing workflow:
Raw sequencing reads
|
v
FASTQ files
|
v
Quality control and adapter trimming
|
v
Filtered FASTQ files
|
v
Alignment to reference FASTA
|
v
SAM / BAM / CRAM files
|
v
Variant calling or expression analysis
|
v
VCF files or expression matrices
- In addition to sequence content, FASTA and FASTQ records should be managed with appropriate metadata. Researchers should record the organism, sample identifier, tissue or cell type, sequencing platform, library preparation method, read configuration, retrieval or sequencing date, and relevant experimental details. Reference FASTA files should be associated with their genome assembly and version. FASTQ datasets should retain information about sample identity, sequencing run, lane, and paired-end relationships where applicable. Such information helps prevent sample mix-ups and supports reproducible analysis.
- Data provenance and file integrity are also important when handling FASTA and FASTQ files. Researchers should preserve original sequencing files and avoid overwriting raw data during preprocessing. File names, sample identifiers, database accessions, retrieval dates, reference versions, software versions, and processing parameters should be documented. Checksums such as SHA-256 can be used to verify that files have not changed unexpectedly during transfer or storage.
- FASTA and FASTQ are fundamental to biological data exchange and are supported by a wide range of bioinformatics databases and software systems. Sequence repositories such as GenBank, the European Nucleotide Archive (ENA), and the DNA Data Bank of Japan (DDBJ) provide nucleotide sequence resources in FASTA and other formats. Sequencing archives such as the NCBI Sequence Read Archive (SRA) and ENA provide raw sequencing data and associated metadata, with FASTQ commonly used for analysis-ready read files. Protein databases such as UniProt also provide protein sequences in FASTA format.
- FASTA and FASTQ are closely related to other biological data formats. GenBank and EMBL provide sequence records with detailed annotations, while GFF3 and GTF describe genomic features. SAM, BAM, and CRAM represent sequence alignments, and VCF represents genetic variants. Understanding the relationships between these formats allows researchers to move efficiently from raw sequencing data to genome annotation, variant analysis, transcriptomics, and other downstream applications.
- FASTA and FASTQ are therefore essential formats in modern bioinformatics. FASTA provides a simple and widely supported representation of biological sequences, while FASTQ combines sequencing reads with per-base quality information. Their use in genome sequencing, RNA sequencing, sequence alignment, assembly, and comparative analysis makes them central to many biological research workflows. Understanding their structure, quality encoding, paired-end conventions, compression, validation, and computational handling enables researchers to manage sequence data accurately and perform reliable, reproducible analyses.