Honour an absolute number of errors (-e N) for every adapter length - #893
Open
cindykrafft wants to merge 2 commits into
Open
Honour an absolute number of errors (-e N) for every adapter length#893cindykrafft wants to merge 2 commits into
cindykrafft wants to merge 2 commits into
Conversation
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
force-pushed
the
fix/absolute-error-count
branch
from
September 3, 2026 03:30
23a3a5b to
c571a5c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #892.
With
-e N(N ≥ 1) the number of errors becomes the rateN / n, and the aligneraccepts an alignment over
Ladapter characters iferrors <= L * rate. For somenthe productn * (N / n)is slightly belowNin floating point(
49 * (1 / 49) == 0.9999999999999999), so-e 1allowed no errors for a 49 ntadapter and
-e 2only one for a 98 nt adapter; the same floor was applied inPrefixComparer, inAdapterIndexand in the k-mer heuristic.This adds a 1e-9 tolerance to every
length * rateproduct through one helper(
align.max_errors_for_length) and aDEFconstant in_align.pyx, plus testsin
test_align.pyandtest_adapters.pythat fail without the change. If youwould rather keep exact integer arithmetic (carry
Nandninto the aligner andcompare
errors * n <= L * N), I am happy to rework it.Changelog entry included under "development version".
Generated by Claude Code