Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: projection issue for stop retained insertion (#707) #708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/hgvs/utils/altseq_to_hgvsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def build_hgvsp(self):
# get size diff from diff in ref/alt lengths
start = self._alt_data.variant_start_aa - 1
delta = len(self._alt_seq) - len(self._ref_seq)
while self._ref_seq[start] == self._alt_seq[start]:
start_max = min(len(self._ref_seq), len(self._alt_seq))
while start < start_max and self._ref_seq[start] == self._alt_seq[start]:
start += 1
offset = start + abs(delta)

Expand Down Expand Up @@ -190,10 +191,15 @@ def _convert_to_sequence_variants(self, variant, acc):
self._is_ambiguous = True # side-effect

if insertion and insertion.find("*") == 0: # stop codon at variant position
aa_start = aa_end = AAPosition(base=start, aa=deletion[0])
ref = ""
alt = "*"
is_sub = True
alt = "*"
if start == len(self._alt_seq) and not deletion:
# insertion of stop codon at end of sequence, a special case of "stop_retained"
aa_start = aa_end = AAPosition(base=start, aa="*")
ref = "*"
else:
aa_start = aa_end = AAPosition(base=start, aa=deletion[0])
ref = ""

elif start == len(self._ref_seq): # extension
if self._alt_seq[-1] == "*":
Expand Down
Binary file modified tests/data/cache-py3.hdp
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/test_hgvs_variantmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def setUpClass(cls):
cls.vm = hgvs.variantmapper.VariantMapper(cls.hdp)
cls.hp = hgvs.parser.Parser()

def test_map_stop_retained(self):
hgvs_c = "NM_001253909.2:c.416_417insGTG"
var_c = self.hp.parse_hgvs_variant(hgvs_c)
var_p = self.vm.c_to_p(var_c)

assert str(var_p) == "NP_001240838.1:p.(Ter140Ter)"

def test_gcrp_invalid_input_type(self):
hgvs_g = "NC_000007.13:g.36561662C>T"
hgvs_c = "NM_001637.3:c.1582G>A"
Expand Down