From d89360ba274ee8e216ce06efc73bf45746119673 Mon Sep 17 00:00:00 2001 From: Kevin Schaper Date: Tue, 9 Jul 2024 10:23:37 -0700 Subject: [PATCH] Patches MGI curie expansions that replace the colon with a slash erroneously (#756) Needs a real fix upstream in curies/prefixmaps (probably prefixmaps?), but we need this fix to for immediate release --- backend/src/monarch_py/utils/entity_utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/monarch_py/utils/entity_utils.py b/backend/src/monarch_py/utils/entity_utils.py index 479c034e7..c140c8660 100644 --- a/backend/src/monarch_py/utils/entity_utils.py +++ b/backend/src/monarch_py/utils/entity_utils.py @@ -1,3 +1,4 @@ +import re from monarch_py.datamodels.model import ExpandedCurie from monarch_py.service.curie_service import converter @@ -6,9 +7,20 @@ ] +def expansion_patch(url: str): + """Any short term patches that we need while waiting for upstream fixes""" + + # This fixes MGI urls that take the form of + # https://identifiers.org/MGI/97486 + # rather than https://identifiers.org/MGI:97486 + pattern = r"/MGI/(\d+)$" + replacement = r"/MGI:\1" + return re.sub(pattern, replacement, url) + + def get_uri(id: str) -> str: """Returns the URI for the given CURIE.""" - return converter.expand(id) + return expansion_patch(converter.expand(id)) def get_expanded_curie(id: str) -> ExpandedCurie: