Fix reverse-strand annotation translation for genes embedded in larger nodes - #208
Open
bobvh wants to merge 2 commits into
Open
Fix reverse-strand annotation translation for genes embedded in larger nodes#208bobvh wants to merge 2 commits into
bobvh wants to merge 2 commits into
Conversation
extract_from_entry only walks left to right: it enters at the annotation's left coordinate, walks to PATH_END, and lets translate_from reverse-complement and flip the result. For a reverse-strand CDS that does not end at the contig's right edge (the common single-contig case, e.g. pUC19 bla), the flip started translation from the contig's right end, rev-comping trailing context onto the front of the protein and halting at the first stop codon, collapsing a 286-residue gene to a few unrelated residues. Add extract_to_anchor, the reverse-strand mirror: it anchors at the annotation's right coordinate, walks left toward PATH_START, and trims the anchor node's right edge. translate_from then flips the subgraph so translation begins at the anchor and runs to its own stop codon, symmetric to the forward path. translate_annotation selects the extractor by strand; translate_from_path and forward strand are unchanged. Rework reverse_strand_annotation_translation_handles_variant to anchor at the gene's right (prefix) node and add reverse_strand_trailing_context_is_not_translated, covering a reverse CDS with trailing same-node context. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MPTVMiok2j48CqzSGR9CXd
bobvh
force-pushed
the
fix-reverse-strand-translation
branch
from
July 7, 2026 07:18
1f20b7c to
1af0030
Compare
Member
|
This is fine, but an alternate solution would be to get the graph in memory, then reverse it (including the sequences referred to by nodes), and then you could run the same code for the forward strand on the reversed graph. That may be a bit more involved, but I feel like it could be a useful general solution to handling reverse strand things. If you need to get this merged urgently, I can approve, but I'm curious how well reversing the graph would work |
Member
Author
|
Hmm. We do have the graph in memory already, so it wouldn't complicate things too much to load it as rev comp instead. We'd need to be real sure that we don't introduce off by one errors at the region parsing stage, but that's testable. I'll keep this open for now. |
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.
There was a bug in translating a gene to protein when the gene annotation is on the reverse strand and does not run all the way to the end of a node (i.e. having its reversed start codon start at the rightmost end of the node). This fixes that by properly making the reverse workflow the mirror image of the forward process.