Skip to content

Commit e6dbd1e

Browse files
authored
Merge pull request #708 from holtgrewe/fix-hgvs-projection-ins-stop-retained
fix: projection issue for stop retained insertion (#707)
2 parents 83f297d + b05b2d2 commit e6dbd1e

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/hgvs/utils/altseq_to_hgvsp.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def build_hgvsp(self):
9797
# get size diff from diff in ref/alt lengths
9898
start = self._alt_data.variant_start_aa - 1
9999
delta = len(self._alt_seq) - len(self._ref_seq)
100-
while self._ref_seq[start] == self._alt_seq[start]:
100+
start_max = min(len(self._ref_seq), len(self._alt_seq))
101+
while start < start_max and self._ref_seq[start] == self._alt_seq[start]:
101102
start += 1
102103
offset = start + abs(delta)
103104

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

192193
if insertion and insertion.find("*") == 0: # stop codon at variant position
193-
aa_start = aa_end = AAPosition(base=start, aa=deletion[0])
194-
ref = ""
195-
alt = "*"
196194
is_sub = True
195+
alt = "*"
196+
if start == len(self._alt_seq) and not deletion:
197+
# insertion of stop codon at end of sequence, a special case of "stop_retained"
198+
aa_start = aa_end = AAPosition(base=start, aa="*")
199+
ref = "*"
200+
else:
201+
aa_start = aa_end = AAPosition(base=start, aa=deletion[0])
202+
ref = ""
197203

198204
elif start == len(self._ref_seq): # extension
199205
if self._alt_seq[-1] == "*":

tests/data/cache-py3.hdp

1.37 KB
Binary file not shown.

tests/test_hgvs_variantmapper.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def setUpClass(cls):
3737
cls.vm = hgvs.variantmapper.VariantMapper(cls.hdp)
3838
cls.hp = hgvs.parser.Parser()
3939

40+
def test_map_stop_retained(self):
41+
hgvs_c = "NM_001253909.2:c.416_417insGTG"
42+
var_c = self.hp.parse_hgvs_variant(hgvs_c)
43+
var_p = self.vm.c_to_p(var_c)
44+
45+
assert str(var_p) == "NP_001240838.1:p.(Ter140Ter)"
46+
4047
def test_gcrp_invalid_input_type(self):
4148
hgvs_g = "NC_000007.13:g.36561662C>T"
4249
hgvs_c = "NM_001637.3:c.1582G>A"

0 commit comments

Comments
 (0)