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: