diff --git a/src/hgvs/_data/defaults.ini b/src/hgvs/_data/defaults.ini index 7e1ecd2d..657313b4 100644 --- a/src/hgvs/_data/defaults.ini +++ b/src/hgvs/_data/defaults.ini @@ -6,6 +6,7 @@ inferred_p_is_uncertain = True normalize = True prevalidation_level = EXTRINSIC replace_reference = True +ref_at_boundary_is_intronic = True # strict_bounds: require transcript variants to be within transcript sequence bounds strict_bounds = True diff --git a/src/hgvs/utils/altseqbuilder.py b/src/hgvs/utils/altseqbuilder.py index c316b086..cd70e2df 100644 --- a/src/hgvs/utils/altseqbuilder.py +++ b/src/hgvs/utils/altseqbuilder.py @@ -9,6 +9,7 @@ import logging import math +from hgvs import global_config from hgvs.exceptions import HGVSError from bioutils.sequences import reverse_complement, translate_cds @@ -198,16 +199,16 @@ def _get_variant_region(self): result = self.WHOLE_GENE elif self._var_c.posedit.edit.type == "ins" and self._var_c.posedit.pos.start.offset == -1 and self._var_c.posedit.pos.end.offset == 0: # ins at intron-exon boundary - result = self.EXON + result = self.INTRON if global_config.mapping.ref_at_boundary_is_intronic else self.EXON elif self._var_c.posedit.edit.type == "ins" and self._var_c.posedit.pos.start.offset == 0 and self._var_c.posedit.pos.end.offset == 1: # ins at exon-intron boundary - result = self.EXON + result = self.INTRON if global_config.mapping.ref_at_boundary_is_intronic else self.EXON elif self._var_c.posedit.edit.type == "dup" and self._var_c.posedit.pos.end.offset == -1: # dup at intron-exon boundary - result = self.EXON + result = self.INTRON if global_config.mapping.ref_at_boundary_is_intronic else self.EXON elif self._var_c.posedit.edit.type == "dup" and self._var_c.posedit.pos.start.offset == 1: # dup at exon-intron boundary - result = self.EXON + result = self.INTRON if global_config.mapping.ref_at_boundary_is_intronic else self.EXON elif self._var_c.posedit.pos.start.offset != 0 or self._var_c.posedit.pos.end.offset != 0: # leave out anything else intronic for now result = self.INTRON diff --git a/tests/issues/test_655.py b/tests/issues/test_655.py index d09bc3f0..fb77ab7f 100644 --- a/tests/issues/test_655.py +++ b/tests/issues/test_655.py @@ -124,8 +124,18 @@ def mock_vm(mock_hdp): return hgvs.variantmapper.VariantMapper(mock_hdp, prevalidation_level="INTRINSIC") +@pytest.fixture() +def ref_at_boundary_is_exonic(): + original = hgvs.global_config.mapping.ref_at_boundary_is_intronic + hgvs.global_config.mapping.ref_at_boundary_is_intronic = False + try: + yield + finally: + hgvs.global_config.mapping.ref_at_boundary_is_intronic = original + + @pytest.mark.parametrize("case", sanity_cases) -def test_sanity_c_to_p(case, hp, mock_vm): +def test_sanity_c_to_p(case, hp, mock_vm, ref_at_boundary_is_exonic): var_c = hp.parse(case["var_c"]) if "exc" in case: with pytest.raises(case["exc"]): @@ -135,7 +145,7 @@ def test_sanity_c_to_p(case, hp, mock_vm): @pytest.mark.parametrize("case", real_cases) -def test_real_c_to_p(case, hp, vm, am37): +def test_real_c_to_p(case, hp, vm, am37, ref_at_boundary_is_exonic): var_c = hp.parse(case["var_c"]) if "exc" in case: with pytest.raises(case["exc"]):