Skip to content

Commit

Permalink
Merge pull request #708 from holtgrewe/fix-hgvs-projection-ins-stop-r…
Browse files Browse the repository at this point in the history
…etained

fix: projection issue for stop retained insertion (#707)
  • Loading branch information
reece authored Sep 2, 2024
2 parents 83f297d + b05b2d2 commit e6dbd1e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
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

0 comments on commit e6dbd1e

Please sign in to comment.