Skip to content

Commit 7f18cfd

Browse files
committed
Fix ins/dups where splice region is preserved
1 parent dd6b998 commit 7f18cfd

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

src/hgvs/assemblymapper.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,27 @@ def n_to_c(self, var_n):
171171
return self._maybe_normalize(var_out)
172172

173173
def c_to_p(self, var_c):
174-
var_out = super(AssemblyMapper, self).c_to_p(var_c)
174+
var_out = super(AssemblyMapper, self)._c_to_p(var_c)
175+
176+
if (
177+
var_c.posedit.edit.type in ['ins', 'dup']
178+
and var_c.type in "cnr"
179+
and var_c.posedit.pos is not None
180+
and (var_c.posedit.pos.start.offset != 0 or var_c.posedit.pos.end.offset != 0)
181+
and var_out.posedit is None
182+
):
183+
if self._fetch_AlignmentMapper(tx_ac=var_c.ac).strand == 1:
184+
normalizer = hgvs.normalizer.Normalizer(
185+
self._norm.hdp, alt_aln_method=self.alt_aln_method, validate=False, shuffle_direction=5
186+
)
187+
else:
188+
normalizer = hgvs.normalizer.Normalizer(
189+
self._norm.hdp, alt_aln_method=self.alt_aln_method, validate=False, shuffle_direction=3
190+
)
191+
var_g = normalizer.normalize(self.c_to_g(var_c))
192+
var_c = self.g_to_c(var_g, var_c.ac)
193+
var_out = super(AssemblyMapper, self)._c_to_p(var_c)
194+
175195
return self._maybe_normalize(var_out)
176196

177197
def relevant_transcripts(self, var_g):

src/hgvs/variantmapper.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,21 @@ def c_to_p(self, var_c, pro_ac=None):
429429
430430
"""
431431

432+
var_p = self._c_to_p(var_c, pro_ac=None)
433+
434+
if (
435+
var_c.posedit.edit.type in ['ins', 'dup']
436+
and var_c.type in "cnr"
437+
and var_c.posedit.pos is not None
438+
and (var_c.posedit.pos.start.offset != 0 or var_c.posedit.pos.end.offset != 0)
439+
and var_p.posedit is None
440+
):
441+
raise HGVSUnsupportedOperationError('c_to_p not supported on VariantMapper for this var_c, try AssemblyMapper')
442+
443+
return var_p
444+
445+
446+
def _c_to_p(self, var_c, pro_ac=None):
432447
if not (var_c.type == "c"):
433448
raise HGVSInvalidVariantError("Expected a cDNA (c.) variant; got " + str(var_c))
434449
if self._validator:

tests/data/cache-py3.hdp

23 KB
Binary file not shown.

tests/data/gcp/real.tsv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ ID00056 NC_000010.10:g.89693009delG NM_000314.4:c.492+1delG NP_000305.3:p.?
5858
ID00057 NC_000010.10:g.89711873A>C NM_000314.4:c.493-2A>C NP_000305.3:p.?
5959
ID00058 NC_000010.10:g.89717676G>A NM_000314.4:c.701G>A NP_000305.3:p.(Arg234Gln)
6060
ID00059 NC_000010.10:g.89717777G>A NM_000314.4:c.801+1G>A NP_000305.3:p.?
61-
ID00060 NC_000010.10:g.89720648dupT NM_000314.4:c.802-3dupT NP_000305.3:p.?
6261
ID00061 NC_000005.9:g.131705667G>T NM_003060.3:c.3G>T NP_003051.1:p.Met1?
6362
ID00062 NC_000005.9:g.131706014G>A NM_003060.3:c.350G>A NP_003051.1:p.(Trp117*)

tests/support/mock_input_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def get_tx_seq(self, ac):
5555
def get_seq(self, ac, start_i=None, end_i=None):
5656
return self.get_tx_seq(ac)[start_i:end_i]
5757

58+
def get_pro_ac_for_tx_ac(self, ac):
59+
return 'MOCK'
60+
5861
#
5962
# internal methods
6063
#

tests/test_hgvs_assemblymapper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ def test_c_to_p_with_stop_gain(self):
201201
self.assertEqual(str(var_p), hgvs_p)
202202

203203

204+
def test_map_of_ins_splice_region_preserved(self):
205+
hgvs_c = "NM_004119.2:c.1837+21_1837+22insCGAGAGAATATGAATATGATCTCAAATGGGAGTTTCCAAGAGAAAATTTAGAGTTTGGTAAGAATGGAATGTGCCAAA"
206+
hgvs_p = "NP_004110.2:p.(Lys614_Val615insAsnGlyMetCysGlnThrArgGluTyrGluTyrAspLeuLysTrpGluPheProArgGluAsnLeuGluPheGlyLys)"
207+
208+
var_c = self.hp.parse_hgvs_variant(hgvs_c)
209+
var_p = self.am.c_to_p(var_c)
210+
211+
self.assertEqual(str(var_p), hgvs_p)
212+
213+
204214
class Test_RefReplacement(unittest.TestCase):
205215
test_cases = [
206216
# These casese attempt to test reference update in four dimensions:

0 commit comments

Comments
 (0)