Repository navigation
fix: derive omitted RLE sequence when translating to HGVS - #705
Open
chenyangsu wants to merge 1 commit into
Open
chenyangsu wants to merge 1 commit into
chenyangsu wants to merge 1 commit into
Conversation
arieleven
reviewed
Dec 6, 2026
arieleven
left a comment
There was a problem hiding this comment.
Thanks, this fixes a real round-trip gap: with the default rle_seq_limit, translate_from(..., fmt="hgvs") drops state.sequence for long repeats, and translate_to(..., "hgvs") then failed on .root. Deriving the alt from the reference with denormalize_reference_length_expression matches what _to_spdi already does, and the updated test_rle_seq_limit dup case now round-trips.
A few thoughts:
_to_spdialways re-derives the alt for RLEs and logs a warning if a providedsequencedisagrees, while here the derived alt is only used whensequenceis missing. Either is reasonable, but making the two translators behave the same (or noting why they differ) would avoid surprises later.- The test covers an expansion (dup). A contraction case, such as an RLE whose
lengthis shorter than the reference span, would exercise the deletion path through the same code. - Minor: when
start == end,refisNone. That shouldn't happen for a normalized RLE, but a clear error there would be easier to debug than aTypeErrorfrom slicingNone.
This branch has not been deployed
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.
translate_to(allele, "hgvs")raisesAttributeError: 'NoneType' object has no attribute 'root'for a ReferenceLengthExpression allele whosesequencewas left out byrle_seq_limit(the case in #344).test_rle_seq_limitcurrently expects this error._to_spdialready rebuilds the sequence withdenormalize_reference_length_expression.HgvsTools._to_sequence_variantnow does the same whensequenceis missing. Alleles that carry a sequence are unchanged. Happy to raise a clearer error instead if you prefer.Testing:
test_rle_seq_limitnow expects["NC_000013.11:g.32331043_32331094dup"]for the allele without a sequence. It fails on main and passes with the change. Full suite: 224 passed.