fix: honor explicit k in indel search, clamp above the pigeonhole optimal#29
Merged
Merged
Conversation
…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
self-requested a review
July 18, 2026 03:57
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.
Resolves #28.
indel_searchignored the user'skand always used the derived optimal, so an explicitly-passedkwas silently swapped and its k-mer table rebuilt. It now:kwhen it doesn't exceed the pigeonhole optimal — reusing an existing k-mer table (e.g. one built for a mismatch run) instead of rebuilding.kto the optimal with a warning, preserving complete recall (akabovemax(2, min_len // (max_indels + 1))drops belowmax_indels + 1disjoint seeds and forfeits the guarantee).kis given (unchanged).Composes with the existing constructor guard:
k > shortest query lengthis already rejected up front, soindel_searchonly clamps within the functional band.Consistency with mismatch:
_auto_kis generalized to take the edit count so the two paths share one pigeonhole formula instead of duplicating it. Indel additionally clamps a too-large explicitk(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, andk > min_lenrejected. Full suite green (52); 500/500 seeds agree with the brute-force oracle (match set unchanged).