Skip to content

Honour an absolute number of errors (-e N) for every adapter length - #893

Open
cindykrafft wants to merge 2 commits into
marcelm:mainfrom
cindykrafft:fix/absolute-error-count
Open

Honour an absolute number of errors (-e N) for every adapter length#893
cindykrafft wants to merge 2 commits into
marcelm:mainfrom
cindykrafft:fix/absolute-error-count

Conversation

@cindykrafft

Copy link
Copy Markdown

Fixes #892.

With -e N (N ≥ 1) the number of errors becomes the rate N / n, and the aligner
accepts an alignment over L adapter characters if errors <= L * rate. For some
n the product n * (N / n) is slightly below N in floating point
(49 * (1 / 49) == 0.9999999999999999), so -e 1 allowed no errors for a 49 nt
adapter and -e 2 only one for a 98 nt adapter; the same floor was applied in
PrefixComparer, in AdapterIndex and in the k-mer heuristic.

This adds a 1e-9 tolerance to every length * rate product through one helper
(align.max_errors_for_length) and a DEF constant in _align.pyx, plus tests
in test_align.py and test_adapters.py that fail without the change. If you
would rather keep exact integer arithmetic (carry N and n into the aligner and
compare errors * n <= L * N), I am happy to rework it.

Changelog entry included under "development version".


Generated by Claude Code

Cindy Krafft and others added 2 commits September 3, 2026 01:13
With -e N (N >= 1), the number of errors is converted to the rate N/n for an
adapter of length n, and an alignment covering L adapter characters is
accepted if errors <= L * rate. For some n, the floating-point product
n * (N / n) is slightly smaller than N (49 * (1 / 49) == 0.9999999999999999),
so a full-length match was found only with N - 1 errors: -e 1 allowed no
errors for a 49 nt adapter and -e 2 only one for a 98 nt adapter. The same
truncation happened in PrefixComparer (--no-indels), when building the
adapter index and in the k-mer heuristic.

Add a tolerance of 1e-9 to every length * error_rate product: a
max_errors_for_length() helper in align.py for the Python code and a DEF
constant in _align.pyx.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
@cindykrafft
cindykrafft force-pushed the fix/absolute-error-count branch from 23a3a5b to c571a5c Compare September 3, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Absolute number of errors (-e N) is one too small for some adapter lengths (e.g. -e 1 allows 0 errors for a 49 nt adapter)

1 participant