Fix ORF prediction crash on soft-masked (lowercase) genome FASTA (2.0.4) - #40
Merged
Conversation
Genome FASTA files commonly soft-mask repeats with lowercase bases. Gene.get_sequence() doesn't normalize case, so lowercase bases flowed into kozak_score's PWM lookup (indexed only by uppercase ACGTN), crashing with an uncaught KeyError (#26). Also fixes a silent sibling bug: start/stop codon regex matching ("ATG" vs "atg") would silently miss ORFs entirely in soft-masked regions rather than crash. Fixed at the single point tr_seq is obtained in add_orfs(), not in get_sequence() itself, since that's also used by the public write_fasta export where case is meaningful to preserve.
Covers the lowercase-FASTA ORF prediction fix (#26).
Two styles coexist -- self-contained fixtures vs. the pickle-based pipeline chain -- prompted by real debugging time lost to stale cross-run pickle state earlier today.
b06579c's commit message described this fix but only staged the test files -- the source change itself was never committed.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Summary
Closes #26:
add_orf_prediction/Gene.add_orfs()crashed with an uncaughtKeyErrorwhen the genome FASTA has soft-masked (lowercase) sequence.Root cause:
Gene.get_sequence()doesn't normalize case, so lowercase bases flowed intokozak_score()'s PWM lookup, which is indexed only by uppercaseACGTN. Also fixes a silent sibling bug: start/stop codon matching uses a case-sensitive regex against"ATG"/"TAA"/etc., so ORFs entirely within soft-masked regions were previously missed with no warning at all, not just crashed.Fixed at the single point
tr_seqis obtained insideadd_orfs(), not inget_sequence()itself -- that function is also used by the publicwrite_fastaexport, where preserving original case is meaningful to users (e.g. visualizing repeat-masked regions). Checked the other twoget_sequence(protein=True)callers indomains.py; they rely on the same upstreamadd_orfs()fix and don't need separate changes.Also includes a short
tests/README.mddocumenting the two test styles in this repo (self-contained fixtures vs. the pickle-based pipeline chain), prompted by real debugging time lost to stale cross-run pickle state while working on this fix.Bumps version to 2.0.4.
Test plan
pytestsuite passes (15 passed), including the new regression testflake8/blackcleanpython -m build+twine check dist/*pass at 2.0.4