Repository navigation
fix: cap k at 16, the longest k-mer the index can store, instead of panicking - #38
Open
Roman-Young wants to merge 1 commit into
Open
Roman-Young wants to merge 1 commit into
Roman-Young wants to merge 1 commit into
Conversation
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.
Any search whose k came out above 16 panicked in the preprocessor:
The chunked preprocessor (baab435) packs each k-mer into a
u128, one byte per residue, so 16 is the longest k-mer an index can hold, andto_be_bytes()[16 - k..]underflows at k=17. Since auto-k replaced the fixed default of 5 (31cbba3), exact search picks k = the shortest query's length, so default settings reach that limit for any batch whose shortest query is 17 residues or longer. Reproduced on master:counts_only)best_match(starts at the shortest query's length)k=17, orPreprocessor.preprocess(17)This PR:
MAX_INDEX_K = 16inpreprocessor.py, next to the index it describes._auto_k(exact, mismatch, counts), the indel group k, andbest_match's starting k. A smaller k only adds seeds, so complete recall is unchanged: with k ≤ L // (edits + 1), every query still splits into edits + 1 disjoint seeds.k > 16inMatcherandPreprocessor.preprocesswith aValueErrorinstead of a panic.pepmatch-match -k.Nothing changes for k ≤ 16. For
best_match, the first pass on long queries now runs at k=16 withmin_len // 16 - 1mismatches instead of at k=L with 0. The per-query filter still keeps the fewest-mismatch hit, so each query's best match is the same.Tests: new
test_k_limit.py(with a CI matrix row):k=17andpreprocess(17)raiseValueErrorindel2_brute_forceoracle (1 to 2 indels)27 of the 31 new tests fail on master. Full suite green: 267 passed, 2 skipped.