Assembly contiguity (N50, L50, NG50, auN) from contig or scaffold lengths
genome_assembly_contiguity
Works out N50, L50, auN and other Nx and Lx from contig or scaffold lengths, and NGx against a genome size.
- Runs
- On the server
- Level
- Checked against a reference: exact integer arithmetic in a script of our own, with hand-worked cases; seqkit 2.14.0 (N50, L50, Nx) and GenomeTools 1.6.5 (NG50, NG80) independent; QUAST 5.2.0's N50 module a transcription check
What it is
Returns Nx, Lx, NGx, LGx and auN (N50, L50 and NG50 among them) from a list of contig or scaffold lengths. Use when summarising the contiguity of a genome assembly from its contig or scaffold lengths, against its own total or a stated genome size. Not for sequencing depth from a read count: use `ngs_coverage_depth`. Not for GC content: use `seq_gc_content`. sequenceKind and lengthFilter are required; no minimum length is applied unless stated (QUAST applies 500 bp by default). At most 10,000 lengths.
Field: Sequencing and genomics.
What it does
You give
lengths(required): Sequence lengths in whole bp, one per contig or scaffold, in any order.sequenceKind(required): What the lengths are: contigs, scaffolds (runs of N inside a scaffold count in its length), or unknown. Required and echoed; it labels the figures and changes no arithmetic.lengthFilter(required): none keeps every length; at-least drops lengths below minimumLength before every figure. Required: no minimum is assumed.minimumLength: With at-least, required: the smallest length kept (inclusive), whole bp. Must be at least 1 bp and at most 10000000000 bp. Optional.levels: Levels returned beside 50, which is always returned; each once. Optional.genomeSize: Genome size for NGx and LGx; never taken as the assembly total. Whole bp. Must be above 0 bp and at most 1000000000000 bp. Optional.
and 1 more, listed below
No request is recorded for this tool.
Limits
- Research arithmetic for planning sequencing libraries and runs and for genomic coordinate bookkeeping; it does arithmetic on the inputs it receives, and does not measure the library, the instrument or the data.
- Contiguity statistics describe the lengths supplied, after the stated minimum length; they say nothing about whether the sequences are correctly assembled and are not a quality verdict.
- Lengths are taken as given, so a scaffold's length includes its gap bases.
- NG and LG use the genome size you state, usually an estimate, and are withheld when the sequences total less than that share of it.
- L is the smallest number of sequences reaching the share; the count of sequences at least the N length is given beside it and differs when lengths tie.
- QUAST drops sequences under 500 bp by default, so its figures differ from an unfiltered set.
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.
It will not answer when
- no length is at least the stated minimum length, so no figure exists.
- a level is sent twice, or 50 is sent although N50 is always returned.
Every input, with its units7 inputs
lengths(required): Sequence lengths in whole bp, one per contig or scaffold, in any order.sequenceKind(required): What the lengths are: contigs, scaffolds (runs of N inside a scaffold count in its length), or unknown. Required and echoed; it labels the figures and changes no arithmetic.lengthFilter(required): none keeps every length; at-least drops lengths below minimumLength before every figure. Required: no minimum is assumed.minimumLength: With at-least, required: the smallest length kept (inclusive), whole bp. Must be at least 1 bp and at most 10000000000 bp. Optional.levels: Levels returned beside 50, which is always returned; each once. Optional.genomeSize: Genome size for NGx and LGx; never taken as the assembly total. Whole bp. Must be above 0 bp and at most 1000000000000 bp. Optional.genomeSizeSource: With genomeSize, required: reference-length or estimate. Echoed. Optional.
Every refusal, with its code2 refusals
| Code | When |
|---|---|
NO_SEQUENCES_KEPT | no length is at least the stated minimum length, so no figure exists. |
DUPLICATE_LEVEL | a level is sent twice, or 50 is sent although N50 is always returned. |
The calculation
The method's equations, constants and worked example.
Equation 1
T = sum of the lengths kept
a length is kept when no minimum is stated or when it is at least the stated minimum m (inclusive)
sequencesKept = the number kept
sequencesExcluded and basesExcluded = the number and summed length of those dropped (0 with no filter)
longestSequenceLength and shortestSequenceLength are of the lengths kept
lengths are whole bp of at least 1, in any order
sequenceKind (contigs, scaffolds or unknown) is echoed and changes no figure
| Symbol | Meaning |
|---|---|
T | total length of the sequences kept, bp |
m | the stated minimum length, bp |
Source 1.
Equation 2
sort the kept lengths longest first, L(1) >= L(2) >= ...
C_k = L(1) + ... + L(k)
Lx = the smallest k with 100 C_k >= x T, compared in integers
countAtOrAboveNx = the number of kept lengths >= Nx, which exceeds Lx exactly when lengths tie at Nx
equal to the largest kept length l whose lengths >= l total at least x percent of T
| Symbol | Meaning |
|---|---|
x | the level, a whole number from 1 to 100, % |
C_k | sum of the k longest kept lengths, bp |
Source 1.
Equation 3
NGx and LGx: the same rule with the stated genome size G in place of T, 100 C_k >= x G
withheld when 100 T < x G, since then no k reaches it
| Symbol | Meaning |
|---|---|
G | the stated genome size, never the assembly total, bp |
Source 1.
Equation 4
auN = sum of L_i^2 / T over the kept lengths, computed as an exact integer quotient and rounded once to the nearest double
| Symbol | Meaning |
|---|---|
L_i | a kept length, bp |
Source 2.
Equation 5
Lx is the smallest count (QUAST's 'minimal number of contigs that cover' sentence), the count at least Nx is returned beside it
x is a whole number from 1 to 100 (0 has no finite Nx)
N50 and L50 are always returned as the first entry of levels, then each requested x in the order sent
auNG is not in 1.0.0
| Symbol | Meaning |
|---|---|
Lx | the smallest number of sequences reaching x percent |
Source not recorded.
Conventions
- lengthFilter = none: every length sent is kept
- lengthFilter = at-least: lengths shorter than the stated minimum length are dropped before every figure; a length equal to it is kept
A definition, not a model: the equation states what the quantity means. A different convention gives a different number.
Worked example
Worked example: one case of genome-assembly-contiguity@1.0.1, 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
- lengths.values[0] = 80
- lengths.values[1] = 70
- lengths.values[2] = 50
- lengths.values[3] = 40
- lengths.values[4] = 30
- lengths.values[5] = 20
- lengths.values[6] = 10
- lengths.unit = bp
- sequenceKind = contigs
- lengthFilter = none
- levels[0] = 90 %
Steps
- T = 300 bp, from lengths; by equation 1; gives result.totalLength.
- n50 = 70 bp, from lengths; by equation 2; gives result.levels[0].nx.
- l50 = 2, from lengths; by equation 2; gives result.levels[0].lx.
- n90 = 30 bp, from lengths, levels; by equation 2; gives result.levels[1].nx.
- l90 = 5, from lengths, levels; by equation 2; gives result.levels[1].lx.
- auN = 56 bp, from lengths; by equation 4; gives result.auN.
The working, as the case writes it:
x = 50: smallest k with 100 C_k >= 50 x 300 is 2 (C_2 = 150), N50 = 70, lengths >= N50: 2
x = 90: smallest k with 100 C_k >= 90 x 300 is 5 (C_5 = 270), N90 = 30, lengths >= N90: 5
auN = sum L^2 / T = 16800 / 300 = 56 = 56.0
Answer
result.totalLength = 300 bp
result.levels[0].nx = 70 bp
result.levels[0].lx = 2
result.levels[1].nx = 30 bp
result.levels[1].lx = 5
result.auN = 56 bp
Where these values came from: our own exact-arithmetic script and a hand-worked case; Worked by hand by Drybench on 11 November 2026 (Drybench ruling, 11 November 2026, cases). This is not an independent check.
At build the tool returned this answer within the tolerance the file states: every figure exact: lengths, counts and levels as integers; auN equal to the correctly rounded double of the exact fraction; texts, statuses, codes and withheld rules exact.
Sources
QUAST 5.3.0 manual, section 3.1.1 (Metrics description: Summary report)
Used for: Assembly contiguity: Nx, Lx, NGx, LGx and auN from sequence lengths. At: section 3.1.1 Summary report: N50, NG50, Nx and NGx, L50 (Lx, LG50, LGx), auN, --min-contig.
Read in full, 11 November 2026Li H (2020), auN: a new metric to measure assembly contiguity, blog post of 8 April 2020
Used for: Assembly contiguity: Nx, Lx, NGx, LGx and auN from sequence lengths. At: section the formula auN = sum_i L_i^2 / sum_j L_j.
Read in full, 11 November 2026
How it is checked
- Level
Checked against a reference.
- Checked against
Our own exact-arithmetic script and a hand-worked case.
- Cases
No case set is linked to this version.
- Not checked
QUAST's N50 code is from the project whose manual is the source, so it checks transcription only (Nx, Lx, NGx, LGx); seqkit is the independent check for N50, L50 and Nx and GenomeTools for NG50 and NG80, at levels 50 and 80 only, and both count L at a tie as the lengths at least N, so the tool's minimal Lx and LGx at a tie have QUAST's code alone, and its LGx at levels other than 50 and 80 no independent program; seqkit on lists above 5 × 10^7 bp; QUAST's whole pipeline (only its N50 module was run); Earl et al. 2011, Assemblathon 1 (not read: the publisher's page loops through logins and no full text was served); auNG; decimal levels; splitting scaffolds at gap runs.
What this project's records still lack1 thing
- The source's location for each equation for genome-assembly-contiguity@1.0.1.
Changes to its methods0 changes
No change is logged for these method versions.