# Index collisions and minimum Hamming distance in a pool

`ngs_index_collisions` · Runs: On the server · Level: Checked against a reference: rapidfuzz 3.14.6 Hamming distances

Finds the minimum Hamming distance of each index read and any colliding pairs in a pool.

Research and education software; not medical advice, and not for diagnosis or treatment decisions. It computes from the inputs it receives. It does not check the person's data, design or sample.

[Catalogue](https://www.drybench.com/mcp/catalogue) / [Genomics](https://www.drybench.com/mcp/catalogue/genomics)

[Ask your assistant](https://www.drybench.com/mcp/connect)

```cite
Index collisions and minimum Hamming distance in a pool (ngs_index_collisions), Drybench MCP server 1.0.0; ngs-index-collisions@1.0.1 (Checked against a reference); https://www.drybench.com/mcp/tools/ngs-index-collisions
```

## What it is

Returns each index read's minimum Hamming distance and colliding pairs against d >= 2n + 1 at your tolerance. Use when checking a sample sheet's indexes before a run; it meets or fails the distance condition and does not predict demultiplexing. Not for aligning sequences: use \`seq\_align\`. Mismatch tolerances are required, never assumed; refuses duplicate index pairs, unequal lengths and tolerances above 2.

Field: [Sequencing and genomics](https://www.drybench.com/mcp/catalogue/genomics).

## What it does

**You give**

- `indexes` (required): The samples in the pool.
- `index1MismatchTolerance` (required): Mismatches allowed in index 1 when demultiplexing (0 to 2). Must be at least 0.
- `index2MismatchTolerance`: Mismatches allowed in index 2 (0 to 2); required when index 2 is given. Must be at least 0. Optional.

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.
- Hamming distance only, on the sequences given: no insertions or deletions, index hopping, phasing or colour balance; meets or fails the distance condition d ≥ 2n + 1 for each index read at the stated tolerance, never a prediction of demultiplexing; orientation must be consistent across entries.
- 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**

- two samples carry the same index combination.
- the sequences of one index read differ in length, where Hamming distance is undefined.
- a mismatch tolerance is above the vendor's maximum.
- index 2 is given for some samples and not others.

### Every input, with its units

3 inputs

- `indexes` (required): The samples in the pool.
- `index1MismatchTolerance` (required): Mismatches allowed in index 1 when demultiplexing (0 to 2). Must be at least 0.
- `index2MismatchTolerance`: Mismatches allowed in index 2 (0 to 2); required when index 2 is given. Must be at least 0. Optional.

### Every refusal, with its code

4 refusals

| Code | When |
| --- | --- |
| `DUPLICATE_INDEX_COMBINATION` | two samples carry the same index combination. |
| `INDEX_LENGTHS_DIFFER` | the sequences of one index read differ in length, where Hamming distance is undefined. |
| `TOLERANCE_ABOVE_RANGE` | a mismatch tolerance is above the vendor's maximum. |
| `INDEX2_ON_SOME_ONLY` | index 2 is given for some samples and not others. |

## The calculation

The method's equations, constants and worked example.

### [Index collisions and minimum Hamming distance per index read](https://www.drybench.com/methods/m/ngs-index-collisions/1.0.1)

`ngs-index-collisions@1.0.1`

**Equation 1**

```text
d(a, b) = number of positions where a and b differ (equal lengths): Hamming distance, the standard definition
Knowledge Article #2326 is cited for this mismatch count, which it describes as the distance between bases without naming it Hamming
```

| Symbol | Meaning |
| --- | --- |
| `a, b` | two distinct index sequences of one read |

Source 1.

**Equation 2**

```text
meets if d_min >= 2n + 1, the condition BCL Convert states for index-hopping counts
its use as a general collision screen, the argument that the sets of sequences within n mismatches of each index are disjoint exactly when every pair is at least 2n + 1 apart, and the largest tolerance meeting it, floor((d_min - 1)/2), are Drybench's derivations
a collision is a pair of distinct sequences with d < 2n + 1, listed with the alphabetically earlier sequence as A
each index read on its own
```

| Symbol | Meaning |
| --- | --- |
| `n` | mismatch tolerance stated by the caller |
| `d_min` | minimum pairwise distance |

Source 2.

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 ngs-index-collisions\@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**

- indexes\[0\].name = S1
- indexes\[0\].index1 = AAGGTTCC
- indexes\[1\].name = S2
- indexes\[1\].index1 = TTCCAAGG
- indexes\[2\].name = S3
- indexes\[2\].index1 = GCGCATAT
- indexes\[3\].name = S4
- indexes\[3\].index1 = AAGGTTCA
- index1MismatchTolerance = 1

**Steps**

1. dmin = 1, from indexes\[0\].index1, indexes\[3\].index1; by equation 1; gives result.index1.minimumDistance.
2. req = 3, from index1MismatchTolerance; by equation 2; gives result.index1.requiredDistance.

The working, as the case writes it:

```text
per index read: distinct sequences, every pair's Hamming distance, the minimum, and floor((dmin - 1)/2)
```

**Answer**

- result.index1.minimumDistance = 1
- result.index1.requiredDistance = 3

Where these values came from: an outside program, rapidfuzz 3.14.6; rapidfuzz 3.14.6 Hamming.distance on every pair of distinct sequences in each index read; the rule d >= 2n + 1 (radius-n balls disjoint; the condition BCL Convert documents).

At build the tool returned this answer within the tolerance the file states: exact: distances, counts, flags, sequences, names, withheld rules, statuses and codes.

Who worked this case: not recorded.

## Sources

1. Illumina Knowledge Article #2326, How to troubleshoot barcode collision error when running bcl2fastq2 Used for: Index collisions and minimum Hamming distance per index read. At: section barcode collision: the mismatch count between indexes, described as the distance between bases, and the mismatch setting. **Read in full, 11 November 2026**
2. Illumina BCL Convert documentation, Metrics Output Used for: Index collisions and minimum Hamming distance per index read. At: section Index Hopping Counts: each pair of entries within each index at least 2n+1 apart. **Read in full, 11 November 2026**

Read by AI-assisted sessions. No person has checked these readings.

## How it is checked

**Level:** Checked against a reference.

**Checked against:** An outside program, rapidfuzz, 3.14.6; our own exact-arithmetic script and a hand-worked case.

**Cases:** No case set is linked to this version.

**Not checked:** Insertions and deletions, index hopping, phasing and colour balance (gated); the vendor software's own behaviour; orientation (assumed consistent across entries).

No independent scientist has yet reviewed this.

### Changes to its methods

0 changes

No change is logged for these method versions.
