Skip to content

Commit

Permalink
Allow mapping to continue when intronic variants are found
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbesfeld committed Oct 23, 2024
1 parent 5193625 commit 2e317b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dcd_mapping/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def get_sequence(
# -------------------------------- VRS-Python -------------------------------- #


def translate_hgvs_to_vrs(hgvs: str) -> Allele:
def translate_hgvs_to_vrs(hgvs: str) -> Allele | None:
"""Convert HGVS variation description to VRS object.
:param hgvs: MAVE-HGVS variation string
Expand All @@ -500,7 +500,11 @@ def translate_hgvs_to_vrs(hgvs: str) -> Allele:
hgvs = hgvs.replace(":c.", ":g.")

tr = TranslatorBuilder(get_seqrepo())
allele: Allele = tr.translate_from(hgvs, "hgvs", do_normalize=False)
try:
allele: Allele = tr.translate_from(hgvs, "hgvs", do_normalize=False)
except ValueError as warn:
_logger.warning(warn)
return None

if (
not isinstance(allele.location, SequenceLocation)
Expand Down
2 changes: 2 additions & 0 deletions src/dcd_mapping/vrs_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ def _get_variation(
for hgvs_string in hgvs_strings:
# Generate VRS Allele structure. Set VA digests and SL digests to None
allele = translate_hgvs_to_vrs(hgvs_string)
if allele is None:
break
allele.id = None
allele.digest = None
allele.location.id = None
Expand Down

0 comments on commit 2e317b6

Please sign in to comment.