Phred quality and base-call error probability, with expected errors per read, version 2.0.0
ngs-phred-quality@2.0.0: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.
What this page can and cannot show
Level: Checked against a reference; SAM v1.6 scale; offsets checked against Biopython 1.88; strings up to 3,000 characters; calibrated qualities assumed. Reference kind: our own exact-arithmetic script and a hand-worked case.
Not fully recorded, and not independently reviewed. Items marked "Not recorded" are missing from this project's records for the version named. Apart from any worked example shown, the cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed these methods or checks.
Every version of this method · Every method · What the levels mean
Version 2.0.0
Level: Checked against a reference; SAM v1.6 scale; offsets checked against Biopython 1.88; strings up to 3,000 characters; calibrated qualities assumed. Reference kind: our own exact-arithmetic script and a hand-worked case. ngs-phred-quality@2.0.0
Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.
Verification statement: the SAM v1.6 Phred scale and the offsets of Cock et al. 2010, checked against Biopython 1.88's FASTQ decoders and a 60-digit script of our own; the per-read sums are the record's arithmetic; expected errors assume calibrated qualities
p = 10^(-Q/10) and Q = -10 log10 p (rounded to the closest integer, halves upward); quality strings at offset 33 or 64; per read Σp, the mean error, its quality, and the mean of the Qs.
- How results are reported: qualityRounded is the closest integer, halves upward, decided on the exact Q of the stated decimal p (p^20 against powers of ten, SGB-1): no finite decimal p gives an exact half, since 10^-0.05 is irrational, but the reported quality double can print as x.5 while qualityRounded is x or x + 1; everything else at full double precision, the per-read means in double arithmetic in input order; no -0
- Uncertainty: Arithmetic in double precision on the reported qualities; Σp is the expected error count only if they are calibrated error probabilities.
- Reference, as its record states it: Biopython 1.88's FASTQ decoders on the offsets and ranges (the outside comparison), with the SAM v1.6 Phred scale at 60 digits in a script of our own
- Level confirmed by this project's ruling of 14 November 2026
What this page can and cannot show
What was checked
148 cases in 2 files, linked by this exact version.
Run through the tool at build against our own exact-arithmetic script and a hand-worked case: 92 agree within the tolerance the file states, 56 refuse as the case expects, 0 differ, 0 were not run.
File 1, 104 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: second implementation (Python 3.13), 2026-11-14; licence BSD-3-Clause
- Tolerance as the file states it: qualities absolute 1e-9 phred; probabilities and expected errors relative 1e-12 (exact below 1e-300); statuses, codes, flags and counts exact
File 2, 44 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: CPython standard library (decimal, fractions), 3.13.18; licence PSF-2.0
- Tolerance as the file states it: qualities absolute 1e-9 phred; probabilities and expected errors relative 1e-12 (exact below 1e-300); statuses, codes, flags and counts exact
Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.
What was not checked
Whether the qualities are calibrated (binned or uncalibrated scores make Σp an estimate); the distribution of the error count; Solexa scores (their formula unread); FASTQ files themselves (strings only).
Definition or model
A closed form: the result follows from the inputs by the equations alone.
Equations
Equation 1
p = 10^(-Q/10)
Q = -10 log10 p
Q rounded = floor(Q + 1/2)
within the phred+33 range when Q rounded <= 93 (126 - 33): SAMv1 §1.2 defines Q = -10 log10 p "rounded to the closest integer" and §1.4 gives QUAL as ASCII Q + 33 in [!-~]
the inverse p = 10^(-Q/10) follows from the definition, and halves upward is the record's choice, since the source states no tie rule
| Symbol | Meaning and unit |
|---|---|
| p | base-call error probability |
| Q | Phred quality, phred |
Source: Sequence Alignment/Map Format Specification v1.6, samtools/hts-specs, SAMv1.tex, section 1.2 Terminologies and Concepts: Phred scale; 1.4 The alignment section: mandatory fields, field 11 QUAL, hts-specs master at commit 510c107b; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 5f1326a2298b. Free to read (free to read; no licence stated in the file or repository, so cited only), checked 2026-11-11. No erratum found (searched the file at commit 510c107b), 2026-11-11.
Equation 2
Q = ASCII code - offset, offset 33 (phred+33) or 64 (phred+64)
a code below the offset or above 126 is outside the encoding (Cock et al. 2010)
the rest of this item is the record's, not the source's: the kit trims whitespace from both ends of the string before any check, so a space, tab or line break at either end is dropped and never decoded (none is a quality character), whitespace inside is CHARACTER_OUTSIDE_ENCODING, and a string that is empty or all whitespace is the kit's INVALID_STRING
a quality string is at most 3,000 characters after that trim, counted as UTF-16 code units, which equal characters for any valid quality character (ASCII 33 to 126), so that the worst-case reply stays under the 2 MB reply cap (1,638,340 bytes as served at 3,000 characters, a margin of 22 %)
order of checks: the kit's checks of each argument (a quality above 93 is QUALITY_ABOVE_RANGE, checked before the whole-number test, so Q 93.5 is refused QUALITY_ABOVE_RANGE), then one of the three input forms, then the whole-number test of qualities (NOT_AN_INTEGER), then CHARACTER_OUTSIDE_ENCODING
| Symbol | Meaning and unit |
|---|---|
| offset | 33 or 64 |
Source: Cock PJA, Fields CJ, Goto N, Heuer ML, Rice PM (2010), The Sanger FASTQ file format for sequences with quality scores, and the Solexa/Illumina FASTQ variants, Nucleic Acids Research 38:1767-1771, section FASTQ variants: Sanger offset 33, Phred 0 to 93; Illumina 1.3+ offset 64, version of record, Europe PMC full-text XML (PMC2847217); read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 071f16626ba8. Free to read (CC BY-NC 2.5), checked 2026-11-11. No erratum found (searched Europe PMC commentCorrectionList for PMC2847217), 2026-11-11.
Equation 3
expected errors = Σ p_i (linearity of expectation, whatever the dependence)
mean error = Σ p_i / n
quality of the mean error = -10 log10(mean error)
mean of Q = Σ Q_i / n >= quality of the mean error (the arithmetic mean of p is at least its geometric mean, and -10 log10 is decreasing): the record's own arithmetic, not SAMv1's, which is cited for the scale only (§1.2, Phred scale)
Σp, the mean error and its quality are returned for every input form, qualities, quality strings and error probabilities alike, and the mean of the Qs for qualities and quality strings
the sums run in input order in double precision
| Symbol | Meaning and unit |
|---|---|
| n | bases in the read |
Ruling of this project: 14 November 2026, section "The CSO on six sequencing and single-cell tools under the D-0219 full check, batch 3, 14 November 2026". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.
Constants
Constants: none used.
Worked example
Worked example: one case of ngs-phred-quality@2.0.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- errorProbabilities[0] = 0.001
Steps
- Q = 30 phred, from errorProbabilities[0]; by equation 1; gives result.bases[0].quality.
The working, as the case writes it:
-10 log10(0.0010000000000000000208166817) = 30.000000000000
closest integer 30
Answer
result.bases[0].quality= 30 phred
Where these values came from: our own exact-arithmetic script and a hand-worked case; SAM v1.6 section 1.2, Terminologies and Concepts: the Phred scale of p is -10 log10 p, rounded to the closest integer; halves upward (towards larger Q) is the record's choice, since SAMv1 states no tie rule, and no finite decimal p reaches a tie.
At build the tool returned this answer within the tolerance the file states: qualities absolute 1e-9 phred; probabilities and expected errors relative 1e-12 (exact below 1e-300); statuses, codes, flags and counts exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
QUALITY_ABOVE_RANGE: a given quality is above the top of what Sanger (phred+33) FASTQ can encode Next: Check the qualities came from this read's encoding; give error probabilities instead for values beyond it.CHARACTER_OUTSIDE_ENCODING: a character of the quality string lies outside the stated encoding, often data in the other encoding Next: Check the encoding: phred+33 for Sanger and current Illumina output, phred+64 for older Illumina output.
Input ranges: qualities[*]: at most 93 phred; outside it, refused (QUALITY_ABOVE_RANGE).
Changes
2026-11-14-ngs-phred-quality@2.0.0-1
2026-11-14 · ngs-phred-quality@2.0.0 · Corrections to our methods
- What was wrong: The tool accepted quality strings of up to 10,000 characters, but its reply lists every base, and from about 3,800 characters in the worst case (the threshold depends on the characters) the reply passed the 2 MB reply limit, so an accepted input got no answer (4.87 MB at 10,000 characters). Error probabilities returned only per-base values, while the description promised expected errors for every input form.
- Affected: Quality strings longer than about 3,800 characters in the worst case (the threshold depends on the characters), and every error-probability input, in version 1.0.0 of the assistant tool ngs_phred_quality. No served number was wrong.
- What changed: In 2.0.0 a quality string is at most 3,000 characters, where the worst-case reply is 1,638,340 bytes; a longer read is split and the parts' expected errors added. Error probabilities also return the expected errors, the mean error probability and its quality. The record labels the per-read sums as its own arithmetic, states the order of checks and the value the rounding is decided on, and records Biopython 1.88's decoders as checks.
- How it was found: A second implementation in Python by a separate agent of the same model family, in the raising run's full check of 14 November 2026 (finding SEQ-F2).
- Cases added: stored reference values re-records the retired -1 at 2.0.0, with the encodings' ends checked against Biopython 1.88, the cap and one above it, and Q 93.5.
Tools that use it
Cite this version
Phred quality and base-call error probability, with expected errors per read. Drybench; ngs-phred-quality@2.0.0; https://www.drybench.com/methods/m/ngs-phred-quality/2.0.0 (accessed [date]).