Skip to content

fix(mapper): p.? for an inversion past the transcript - #336

Merged
tedil merged 2 commits into
mainfrom
fix/stop-codon-changes
Oct 27, 2026
Merged

tedil merged 2 commits into
mainfrom
fix/stop-codon-changes

Conversation

@tedil

@tedil tedil commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

An inversion that ends after the last base of the transcript sequence was cut at that end, so c_to_p built its protein from other bases than the inverted ones. These bases are unknown, so it now gives p.?, as for the other edits that end there. E.g. APOA1 c.305_*5561inv gave p.(Glu102_Gln267delins...CysTer). biocommons/hgvs cuts the inversion as hgvs-rs did, so DIFFERENCES.md lists it.

New tests also pin the descriptions of in-frame changes of the stop codon, which stay as they are, as in biocommons/hgvs and Mutalyzer. A longer protein whose change starts at the stop codon is an extension, and one whose change starts in front of it is a delins, e.g. p.(Lys9delinsAsnGlnAla), not a frameshift, as the reading frame stays. A stop codon in place of the old one keeps the residue change, and one in front of it gives a nonsense variant.

Details

On a transcript that ends at c.*14, biocommons/hgvs 1.5.7 rejects c.26_*20del as out of bounds, but cuts c.26_*20inv and gives p.(Lys9_Ter10delinsArgGlyProLeuSerLeuXaa), the same as for c.26_*14inv. hgvs-rs 4.0.0 gave the same. Now c.26_*20inv gives p.?, and c.26_*14inv, whose bases are all known, keeps its description. HGVS gives p.? for a deletion of the last exons of DMD because "it is not known what sequences ... are added to the transcript".

For the ClinVar variant NC_000011.10:g.116830247_116836307inv, Mutalyzer gives NM_000039.3:c.305_*5561inv and no protein ("Variant affects one or more splice sites"). VariantValidator describes it on the genome only.

The pinned descriptions agree with Mutalyzer on ClinVar variants, e.g. NM_001005242.3(PKP2):c.2511_2513delinsATT gives p.(Asp837delinsGluLeuGlyLys).

A known gap stays: if the inserted sequence of a delins brings a stop codon in front of the old one, HGVS describes a "deletion-insertion of this sequence, not ... a deletion-insertion removing the entire C-terminal amino acid sequence". hgvs-rs, biocommons/hgvs and Mutalyzer give the latter, e.g. NM_023067.4(FOXL2):c.673_*315inv (376 to 264 amino acids) gives p.(Ala225_Leu376delins...ArgArgThr).

On a ClinVar subset, mehari 0.48.0 with this branch changes only this APOA1 inversion, on 29 transcripts and in both modes: p. becomes p.?, and with the unknown protein mehari drops stop_gained, stop_lost and protein_altering_variant, keeping the 3' UTR term.

fix(mapper): p.? for an inversion past the transcript

test(mapper): pin p. of in-frame stop codon changes

Summary by CodeRabbit

  • Bug Fixes

    • Protein-level results for inversions extending beyond the transcript now report p.? when the sequence beyond the transcript is unknown, rather than implying a specific outcome.
  • Documentation

    • Clarified how deletions and inversions extending beyond the transcript are represented when strict bounds are not enforced.

tedil added 2 commits October 26, 2026 22:38
An inversion that ends after the last base of the transcript was cut at
the end of the transcript, so its protein came from bases other than
the inverted ones. These bases are unknown, so c_to_p now gives p.?, as
for the other edits that end there.
As in biocommons/hgvs and Mutalyzer, p. compares the proteins. A longer
protein whose change starts at the stop codon is an extension, one whose
change starts in front of it a delins, not a frameshift, as the reading
frame stays. A stop codon in place of the old one keeps the residue
change, and one in front of it gives a nonsense variant.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ba6f4930-a329-49f7-a56e-0623fb1e39d8
Commits

Reviewing files that changed from the base of the PR and between e079943 and 9caf972.

Files selected for processing: 3
  • DIFFERENCES.md
  • src/mapper/altseq.rs
  • src/mapper/variant.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The inversion mapper now marks variants extending beyond the transcript as ambiguous. New tests cover stop-codon changes and inversion boundary cases. The documentation now describes the p.? outcome for inversions beyond the transcript.

Changes: Transcript-end inversion handling

Layer / File(s) Summary
Inversion ambiguity and protein consequence tests
src/mapper/altseq.rs, src/mapper/variant.rs, DIFFERENCES.md
incorporate_inv marks inversions extending beyond the transcript as ambiguous. Tests cover protein consequences for in-frame stop-codon changes and inversions beyond or ending at the transcript boundary. The documentation describes the p.? outcome when replacement bases are unknown.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • varfish-org/hgvs-rs#320: Changes AltSeqBuilder bounds handling and inversion setup errors, which is directly related to transcript-end inversion handling.

Suggested reviewers: hoeze

Merge Risk: Minimal · up to 9caf9

The change returns an unknown protein consequence when an inversion requires unavailable transcript bases, while preserving exact-boundary behavior. No actionable merge-blocking risk was identified; normal test validation remains necessary.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: returning p.? for inversions that extend past the transcript.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.34%. Comparing base (e079943) to head (9caf972).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #336      +/-   ##
==========================================
+ Coverage   91.30%   91.34%   +0.04%     
==========================================
  Files          20       20              
  Lines       13904    13975      +71     
==========================================
+ Hits        12695    12766      +71     
  Misses       1209     1209              
Files with missing lines Coverage Δ
src/mapper/altseq.rs 95.65% <100.00%> (ø)
src/mapper/variant.rs 92.58% <100.00%> (+0.20%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tedil
tedil merged commit a45da36 into main Oct 27, 2026
9 checks passed
@tedil
tedil deleted the fix/stop-codon-changes branch October 27, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant