From 2e317b69e5c5457770688f455982db510a5b4fc3 Mon Sep 17 00:00:00 2001 From: Jeremy Arbesfeld Date: Wed, 23 Oct 2024 10:22:07 -0400 Subject: [PATCH] Allow mapping to continue when intronic variants are found --- src/dcd_mapping/lookup.py | 8 ++++++-- src/dcd_mapping/vrs_map.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dcd_mapping/lookup.py b/src/dcd_mapping/lookup.py index 540ae0e..4905f25 100644 --- a/src/dcd_mapping/lookup.py +++ b/src/dcd_mapping/lookup.py @@ -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 @@ -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) diff --git a/src/dcd_mapping/vrs_map.py b/src/dcd_mapping/vrs_map.py index 645df6b..5b9d884 100644 --- a/src/dcd_mapping/vrs_map.py +++ b/src/dcd_mapping/vrs_map.py @@ -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