Skip to content

fix: honor explicit k in indel search, clamp above the pigeonhole optimal#29

Merged
dmx2 merged 1 commit into
IEDB:masterfrom
Roman-Young:fix/indel-honor-explicit-k
Jul 18, 2026
Merged

fix: honor explicit k in indel search, clamp above the pigeonhole optimal#29
dmx2 merged 1 commit into
IEDB:masterfrom
Roman-Young:fix/indel-honor-explicit-k

Conversation

@Roman-Young

Copy link
Copy Markdown
Contributor

Resolves #28. indel_search ignored the user's k and always used the derived optimal, so an explicitly-passed k was silently swapped and its k-mer table rebuilt. It now:

  • Honors an explicit k when it doesn't exceed the pigeonhole optimal — reusing an existing k-mer table (e.g. one built for a mismatch run) instead of rebuilding.
  • Clamps a larger k to the optimal with a warning, preserving complete recall (a k above max(2, min_len // (max_indels + 1)) drops below max_indels + 1 disjoint seeds and forfeits the guarantee).
  • Derives the optimal when no k is given (unchanged).

Composes with the existing constructor guard: k > shortest query length is already rejected up front, so indel_search only clamps within the functional band.

Consistency with mismatch: _auto_k is generalized to take the edit count so the two paths share one pigeonhole formula instead of duplicating it. Indel additionally clamps a too-large explicit k (mismatch honors it as-is) — indel's completeness guarantee is a core claim, so it warns and uses the optimal rather than silently dropping recall.

Tests: 4 new cases in test_indel_search.py (in the CI matrix) — honor + table-reuse, clamp + warning, unspecified → optimal, and k > min_len rejected. Full suite green (52); 500/500 seeds agree with the brute-force oracle (match set unchanged).

…imal

indel_search ignored the user's k and always used the optimized value, so an explicit k was silently swapped and its k-mer table rebuilt. It now honors an explicit k up to the pigeonhole optimal (reusing an existing table rather than rebuilding) and clamps a larger k down to the optimal with a warning, preserving complete recall. _auto_k is generalized to take the edit count so the mismatch and indel paths share one pigeonhole formula.

Fixes IEDB#28.

@dmx2 dmx2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dmx2
dmx2 merged commit 2d0e610 into IEDB:master Jul 18, 2026
8 checks passed
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.

indel matching still optimizes for k even if k is explicitly passed

2 participants