- FASTQ quality encoding is a system used to represent the confidence of nucleotide base calls in sequencing data. It is an essential part of the FASTQ file format, which stores biological sequence reads together with quality information for every nucleotide. Each base in a sequencing read is associated with a numerical quality score, commonly expressed as a Phred quality score. Instead of storing these scores as ordinary numbers, FASTQ represents them using ASCII characters. This encoding makes the files compact and allows sequence and quality information to be stored together in a simple text-based format. Correct interpretation of FASTQ quality encoding is important for sequencing quality control, read preprocessing, sequence alignment, genome assembly, and variant analysis.
- A FASTQ record normally consists of four lines. The first line begins with the @ symbol and contains the read identifier, the second line contains the nucleotide sequence, the third line begins with a + symbol, and the fourth line contains the quality characters. Each quality character corresponds to the nucleotide at the same position in the sequence. Therefore, the number of quality characters should equal the number of nucleotides in the read.
- A simplified FASTQ record is shown below:
@READ_001
ATGCTAGCTAGCTACGATCG
+
IIIIIIIIIIIIIIIIIIII
- In this example, the nucleotide sequence contains 20 bases, and the quality line contains 20 characters. Each I represents an encoded quality score. The numerical value represented by a character depends on the FASTQ quality-encoding system used by the dataset. Consequently, the character cannot be interpreted correctly without knowing or identifying the encoding offset.
- FASTQ quality encoding is based on the Phred quality score, which expresses the estimated probability that a nucleotide has been called incorrectly. The Phred score is calculated using the following equation:
[
Q = -10\log_{10}(P)
]
- Here, (Q) represents the Phred quality score and (P) represents the estimated probability of an incorrect base call. A higher score indicates a lower estimated probability of error. For example, Q10 corresponds to an estimated error probability of 10%, Q20 to 1%, Q30 to 0.1%, and Q40 to 0.01%. These are estimated probabilities rather than guarantees of accuracy.
- To store Phred scores as characters, FASTQ uses ASCII encoding. ASCII assigns numerical codes to characters, including letters, digits, and symbols. A quality score is converted into an ASCII character by adding a defined offset to its numerical value. The two most important offsets encountered in FASTQ datasets are 33 and 64. These are commonly referred to as Phred+33 and Phred+64 encoding.
- In Phred+33 encoding, the ASCII code of the quality character is obtained by adding 33 to the numerical Phred score. To recover the original score, 33 is subtracted from the ASCII code of the character. For example, the character I has an ASCII code of 73. Subtracting 33 gives a Phred score of 40. Therefore, I represents Q40 in Phred+33 encoding.
- The conversion is expressed as:
Phred score = ASCII code of quality character – 33
- The reverse conversion is:
ASCII code of quality character = Phred score + 33
- Phred+33 is commonly used in modern FASTQ datasets and is the standard encoding associated with current Illumina FASTQ output and many other sequencing workflows. It is also known historically as Sanger-style quality encoding. The same general offset is used by modern sequencing pipelines that produce conventional Phred quality scores in FASTQ format.
- In Phred+64 encoding, the ASCII code of the quality character is obtained by adding 64 to the numerical Phred score. To recover the original score, 64 is subtracted from the ASCII code. For example, a character with ASCII code 73 represents Q9 under Phred+64 encoding, whereas it represents Q40 under Phred+33 encoding. This illustrates why the correct encoding offset must be known before interpreting quality characters.
- The conversion is expressed as:
Phred score = ASCII code of quality character – 64
- The reverse conversion is:
ASCII code of quality character = Phred score + 64
- Phred+64 encoding was used in some historical Illumina FASTQ datasets. In particular, older Illumina software versions used different quality-encoding conventions before the transition to Phred+33. Phred+64 should therefore be considered when analysing archived sequencing data, especially when the original sequencing platform and software version are known to have used this convention. It should not be assumed that every historical FASTQ file uses Phred+64.
- The two encoding systems can represent the same numerical Phred score using different ASCII characters. For example, Q20 is represented by the character 5 in Phred+33 encoding because its ASCII code is 53, while it is represented by the character T in Phred+64 encoding because its ASCII code is 84. Similarly, Q30 is represented by ? in Phred+33 and ^ in Phred+64. These examples demonstrate that the quality character alone does not uniquely identify the numerical score unless the encoding convention is known.
| Phred score | Phred+33 character | Phred+64 character |
| Q10 | + | J |
| Q20 | 5 | T |
| Q30 | ? | ^ |
| Q40 | I | h |
- An important historical distinction is the difference between Phred quality scores and Solexa quality scores. Early Solexa/Illumina systems used a quality scale based on log odds rather than the Phred definition. The Solexa quality score is calculated as:
[
Q_{\text{Solexa}} = -10\log_{10}\left(\frac{P}{1-P}\right)
]
- Here, (P) is the probability of an incorrect base call. Unlike the Phred scale, the Solexa scale can include negative quality values because it uses the log odds of error rather than the error probability alone. Historical Solexa FASTQ files commonly used an ASCII offset of 64, but this should not be confused with every Phred+64 dataset. The offset identifies the character encoding, while the mathematical definition identifies the quality-score scale.
- Solexa quality scores can be converted into Phred quality scores using the relationship:
[
Q_{\text{Phred}} = 10\log_{10}\left(1+10^{Q_{\text{Solexa}}/10}\right)
]
- This conversion is important when historical Solexa data are processed using software that expects Phred quality scores. Modern workflows generally use Phred scores, so older Solexa-encoded datasets may require conversion before analysis. Researchers should distinguish between the ASCII offset and the quality-score definition when handling historical sequencing files.
- FASTQ quality encoding can be summarized by considering two separate questions. The first is how a numerical quality score is defined, such as Phred or Solexa. The second is how that score is represented as an ASCII character, such as by adding 33 or 64. These concepts are related but not identical. A dataset may use an ASCII offset of 64 while encoding either Phred or historical Solexa scores, depending on the sequencing system and software version. Confusing these conventions can lead to incorrect quality values and unreliable downstream analysis.
- Correct identification of FASTQ quality encoding is particularly important when working with sequencing datasets from different platforms, laboratories, and historical periods. A file generated by modern sequencing software will commonly use Phred+33, but older datasets may use Phred+64 or Solexa+64. The encoding should ideally be identified from sequencing metadata, the instrument documentation, or the software that generated the FASTQ file. If this information is unavailable, the distribution of ASCII characters can provide clues, but character ranges alone may not always distinguish encoding systems reliably because their possible ranges can overlap.
- Several bioinformatics tools can assist with FASTQ quality inspection. FastQC provides reports containing per-base sequence quality, per-sequence quality, sequence length distribution, nucleotide composition, and other quality-control measurements. Its reports can help identify unusual quality-character distributions, although they should not be treated as definitive proof of the encoding convention. MultiQC can combine FastQC reports from multiple samples into a single summary. Other tools, including fastp and SeqKit, can inspect or process FASTQ files, but the user should verify that the selected software correctly recognizes the quality encoding of the input data.
- The following Python example demonstrates how to convert a quality character into a Phred score using Phred+33 encoding:
quality_character = “I”
phred_score = ord(quality_character) – 33
print(“Quality character:”, quality_character)
print(“Phred score:”, phred_score)
The output is:
Quality character: I
Phred score: 40
The same calculation can be performed for Phred+64 encoding by changing the offset:
quality_character = “I”
phred_score = ord(quality_character) – 64
print(“Quality character:”, quality_character)
print(“Phred score:”, phred_score)
- This produces a score of 9. The example demonstrates why an incorrect offset can produce a substantially different interpretation of the same character.
- The following Python example uses Biopython to read a FASTQ file and retrieve numerical Phred quality scores:
from Bio import SeqIO
fastq_file = “sample.fastq”
for record in SeqIO.parse(fastq_file, “fastq”):
qualities = record.letter_annotations[“phred_quality”]
print(“Read:”, record.id)
print(“Sequence:”, record.seq)
print(“Quality scores:”, qualities)
- Biopython’s fastq parser is intended for standard Phred+33 FASTQ data. Historical files using other conventions should be converted appropriately before being processed with a parser that expects Phred+33. Biopython also provides parsers for certain historical FASTQ variants, but the selected parser must match the actual input encoding.
- Quality encoding is directly connected to sequencing quality control and preprocessing. Software that reads FASTQ files uses the encoded quality values to calculate quality distributions, identify low-confidence bases, and determine whether trimming or filtering is necessary. If the encoding is interpreted incorrectly, a high-quality base may be treated as low quality, or a low-quality base may be treated as reliable. This can affect adapter trimming, quality filtering, read alignment, genome assembly, and variant detection.
- For example, consider a quality character with ASCII code 73. Under Phred+33, it represents Q40, corresponding to an estimated error probability of 0.01%. Under Phred+64, it represents Q9, corresponding to an estimated error probability of approximately 12.6%. The difference is substantial and could change the outcome of quality filtering. Therefore, the quality encoding should be verified before applying quality thresholds or interpreting sequencing quality reports.
- FASTQ quality encoding is also important when converting between file formats. When FASTQ data are converted into SAM or BAM alignment files, base-quality information is stored in the alignment record. SAM and BAM use the conventional Phred+33 representation for their quality strings. Conversion software must therefore interpret the original FASTQ encoding correctly and produce the appropriate quality representation. Incorrect conversion can introduce errors that affect alignment evaluation and variant calling.
- For reproducible bioinformatics research, the original FASTQ files should be preserved and the quality-encoding convention should be documented. Researchers should record the sequencing platform, instrument or software version where available, basecalling software, quality-score system, and any conversion or preprocessing operations. The versions and parameters of tools used for quality inspection and processing should also be recorded. Checksums can be used to verify that raw and processed files have not been unintentionally altered.
- FASTQ quality encoding is a fundamental component of sequencing data representation. Phred+33 is widely used in modern sequencing workflows, while Phred+64 and Solexa+64 are important historical conventions that may still be encountered in archived datasets. Understanding the relationship between ASCII characters, numerical quality scores, and estimated base-call error probabilities allows researchers to interpret sequencing quality correctly. Accurate encoding identification and conversion help prevent errors during quality control, preprocessing, alignment, genome assembly, and other downstream bioinformatics analyses.