Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make variant region at boundary configurable
Browse files Browse the repository at this point in the history
b0d0nne11 committed Jan 21, 2025
1 parent ac8ffa4 commit 6081fa7
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/hgvs/_data/defaults.ini
Original file line number Diff line number Diff line change
@@ -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
9 changes: 5 additions & 4 deletions src/hgvs/utils/altseqbuilder.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 12 additions & 2 deletions tests/issues/test_655.py
Original file line number Diff line number Diff line change
@@ -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"]):

0 comments on commit 6081fa7

Please sign in to comment.