From d77d05b5ab714b2eca627ae814d0c9bba183b75c Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Thu, 26 Dec 2024 12:01:14 -0500 Subject: [PATCH] cleanup --- src/gene/query.py | 7 ++++--- src/gene/schemas.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gene/query.py b/src/gene/query.py index e467151..10c74ad 100644 --- a/src/gene/query.py +++ b/src/gene/query.py @@ -21,6 +21,7 @@ from gene.database import AbstractDatabase, DatabaseReadException from gene.schemas import ( NAMESPACE_TO_SYSTEM_URI, + SYSTEM_URI_TO_NAMESPACE, BaseGene, BaseNormalizationService, Gene, @@ -347,9 +348,9 @@ def _add_merged_meta(self, response: NormalizeService) -> NormalizeService: sources = [] for m in gene.mappings or []: - for ns, system in NAMESPACE_TO_SYSTEM_URI.items(): - if system == m.coding.system and ns.value in PREFIX_LOOKUP: - sources.append(PREFIX_LOOKUP[ns.value]) + ns = SYSTEM_URI_TO_NAMESPACE.get(m.coding.system) + if ns in PREFIX_LOOKUP: + sources.append(PREFIX_LOOKUP[ns]) for src in sources: if src not in sources_meta: diff --git a/src/gene/schemas.py b/src/gene/schemas.py index cabe619..d8b15d6 100644 --- a/src/gene/schemas.py +++ b/src/gene/schemas.py @@ -195,6 +195,11 @@ class NamespacePrefix(Enum): NamespacePrefix.IUPHAR: "https://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId=", } +# URI to source +SYSTEM_URI_TO_NAMESPACE = { + system_uri: ns.value for ns, system_uri in NAMESPACE_TO_SYSTEM_URI.items() +} + class DataLicenseAttributes(BaseModel): """Define constraints for data license attributes."""