From fee46cbad346f0a5ec964e1d5067b76d8ef3e64c Mon Sep 17 00:00:00 2001 From: Kori Kuzma Date: Thu, 11 Jul 2024 13:26:35 -0400 Subject: [PATCH] wip --- pyproject.toml | 4 +- src/therapy/query.py | 30 ++--- src/therapy/schemas.py | 7 +- tests/data/fixtures/query_fixtures.json | 145 +----------------------- tests/unit/test_query.py | 10 +- 5 files changed, 29 insertions(+), 167 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4166184c..4a22e550 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,13 +31,13 @@ dependencies = [ "uvicorn", "click", "boto3", - "ga4gh.vrs~=2.0.0a1", + # "ga4gh.vrs~=2.0.0a1", ] dynamic = ["version"] [project.optional-dependencies] etl = [ - "disease-normalizer[etl]~=0.4.0.dev0", + # "disease-normalizer[etl]~=0.4.0.dev0", "owlready2", "rdflib", "wikibaseintegrator>=0.12.0", diff --git a/src/therapy/query.py b/src/therapy/query.py index dcf4b594..aa8e43d0 100644 --- a/src/therapy/query.py +++ b/src/therapy/query.py @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TypeVar, Union from botocore.exceptions import ClientError -from ga4gh.core import core_models +from ga4gh.core import domain_models, entity_models from uvicorn.config import logger from therapy import NAMESPACE_LUIS, PREFIX_LOOKUP, SOURCES @@ -391,7 +391,7 @@ def _add_therapeutic_agent( :param MatchType match_type: type of match achieved :return: completed response object ready to return to user """ - therapeutic_agent_obj = core_models.TherapeuticAgent( + therapeutic_agent_obj = domain_models.TherapeuticAgent( id=f"normalize.therapy.{record['concept_id']}", label=record.get("label") ) @@ -400,18 +400,18 @@ def _add_therapeutic_agent( for source_id in source_ids: system, code = source_id.split(":") mappings.append( - core_models.Mapping( - coding=core_models.Coding( - code=core_models.Code(code), system=system.lower() + entity_models.ConceptMapping( + coding=entity_models.Coding( + code=entity_models.Code(code), system=system.lower() ), - relation=core_models.Relation.RELATED_MATCH, + relation=entity_models.Relation.RELATED_MATCH, ) ) if mappings: therapeutic_agent_obj.mappings = mappings if "aliases" in record: - therapeutic_agent_obj.aliases = record["aliases"] + therapeutic_agent_obj.alternativeLabels = record["aliases"] extensions = [] if any( @@ -438,16 +438,16 @@ def _add_therapeutic_agent( if indication.normalized_disease_id: system, code = indication.normalized_disease_id.split(":") mappings = [ - core_models.Mapping( - coding=core_models.Coding( - code=core_models.Code(code), system=system.lower() + entity_models.ConceptMapping( + coding=entity_models.Coding( + code=entity_models.Code(code), system=system.lower() ), - relation=core_models.Relation.RELATED_MATCH, + relation=entity_models.Relation.RELATED_MATCH, ) ] else: mappings = [] - ind_disease_obj = core_models.Disease( + ind_disease_obj = domain_models.Disease( id=indication.disease_id, label=indication.disease_label, mappings=mappings or None, @@ -455,14 +455,14 @@ def _add_therapeutic_agent( if indication.supplemental_info: ind_disease_obj.extensions = [ - core_models.Extension(name=k, value=v) + entity_models.Extension(name=k, value=v) for k, v in indication.supplemental_info.items() ] inds_list.append(ind_disease_obj.model_dump(exclude_none=True)) if inds_list: approv_value["has_indication"] = inds_list - approv = core_models.Extension( + approv = entity_models.Extension( name="regulatory_approval", value=approv_value ) extensions.append(approv) @@ -470,7 +470,7 @@ def _add_therapeutic_agent( trade_names = record.get("trade_names") if trade_names: extensions.append( - core_models.Extension(name="trade_names", value=trade_names) + entity_models.Extension(name="trade_names", value=trade_names) ) if extensions: diff --git a/src/therapy/schemas.py b/src/therapy/schemas.py index 96c45df8..c6f4cfb3 100644 --- a/src/therapy/schemas.py +++ b/src/therapy/schemas.py @@ -3,7 +3,7 @@ from enum import Enum, IntEnum from typing import Any, Dict, List, Literal, Optional, Set, Union -from ga4gh.core import core_models +from ga4gh.core import domain_models from pydantic import BaseModel, ConfigDict, StrictBool, constr from therapy.version import __version__ @@ -484,7 +484,7 @@ class NormalizationService(BaseNormalizationService): """Response containing one or more merged records and source data.""" normalized_id: Optional[str] = None - therapeutic_agent: Optional[core_models.TherapeuticAgent] = None + therapeutic_agent: Optional[domain_models.TherapeuticAgent] = None source_meta_: Optional[Dict[SourceName, SourceMeta]] = None model_config = ConfigDict( @@ -560,7 +560,7 @@ class NormalizationService(BaseNormalizationService): "relation": "relatedMatch", }, ], - "aliases": [ + "alternativeLabels": [ "CIS-DDP", "cis Platinum", "DDP", @@ -583,7 +583,6 @@ class NormalizationService(BaseNormalizationService): ], "extensions": [ { - "type": "Extension", "name": "trade_names", "value": ["Platinol", "Cisplatin"], }, diff --git a/tests/data/fixtures/query_fixtures.json b/tests/data/fixtures/query_fixtures.json index 14c48520..2bb93081 100644 --- a/tests/data/fixtures/query_fixtures.json +++ b/tests/data/fixtures/query_fixtures.json @@ -4,7 +4,7 @@ "label": "cisplatin", "description": null, "id": "normalize.therapy.rxcui:2555", - "aliases": [ + "alternativeLabels": [ "Liplacis", "cis-diamminedichloroplatinum III", "APRD00359", @@ -45,7 +45,6 @@ ], "extensions": [ { - "type": "Extension", "name": "regulatory_approval", "value": { "approval_ratings": [ @@ -62,7 +61,6 @@ "label": "Testicular cancer", "extensions": [ { - "type": "Extension", "name": "regulatory_body", "value": "FDA" } @@ -83,7 +81,6 @@ "label": "Ovarian cancer", "extensions": [ { - "type": "Extension", "name": "regulatory_body", "value": "FDA" } @@ -104,7 +101,6 @@ "label": "Bladder cancer", "extensions": [ { - "type": "Extension", "name": "regulatory_body", "value": "FDA" } @@ -125,7 +121,6 @@ "label": "Thymoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -146,7 +141,6 @@ "label": "Prostatic Neoplasms, Castration-Resistant", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -167,7 +161,6 @@ "label": "Biliary Tract Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -188,7 +181,6 @@ "label": "Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_4" } @@ -209,7 +201,6 @@ "label": "mouth neoplasm", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -230,7 +221,6 @@ "label": "Carcinoma, Squamous Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -251,7 +241,6 @@ "label": "Cholangiocarcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -272,7 +261,6 @@ "label": "Ependymoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -293,7 +281,6 @@ "label": "Esophageal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -314,7 +301,6 @@ "label": "Small Cell Lung Carcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -335,7 +321,6 @@ "label": "Kidney Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -356,7 +341,6 @@ "label": "Carcinoid Tumor", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -377,7 +361,6 @@ "label": "Neuroectodermal Tumors, Primitive", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -398,7 +381,6 @@ "label": "Fallopian Tube Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -419,7 +401,6 @@ "label": "Myelodysplastic Syndromes", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -440,7 +421,6 @@ "label": "Lymphoma, Large B-Cell, Diffuse", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -461,7 +441,6 @@ "label": "Kidney Diseases", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -482,7 +461,6 @@ "label": "Stomach Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -503,7 +481,6 @@ "label": "Urogenital Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -515,7 +492,6 @@ "label": "Urethral Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -536,7 +512,6 @@ "label": "Lymphoma, T-Cell, Peripheral", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -557,7 +532,6 @@ "label": "Neoplasms, Germ Cell and Embryonal", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -578,7 +552,6 @@ "label": "Anus Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -599,7 +572,6 @@ "label": "Thymus Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -620,7 +592,6 @@ "label": "Liver Diseases", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -641,7 +612,6 @@ "label": "Vulvar Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -662,7 +632,6 @@ "label": "Gestational Trophoblastic Disease", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -683,7 +652,6 @@ "label": "Gallbladder Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -704,7 +672,6 @@ "label": "Choroid Plexus Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -725,7 +692,6 @@ "label": "Hypopharyngeal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -746,7 +712,6 @@ "label": "Carcinoma, Renal Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -767,7 +732,6 @@ "label": "Digestive System Diseases", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -788,7 +752,6 @@ "label": "Liver Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -809,7 +772,6 @@ "label": "ovarian serous cystadenocarcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -830,7 +792,6 @@ "label": "Digestive System Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -851,7 +812,6 @@ "label": "Colorectal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -872,7 +832,6 @@ "label": "Pancreatic Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -893,7 +852,6 @@ "label": "Head and Neck Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -914,7 +872,6 @@ "label": "Rhabdomyosarcoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_0.5" } @@ -935,7 +892,6 @@ "label": "Lymphoma, AIDS-Related", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -956,7 +912,6 @@ "label": "Brain Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -977,7 +932,6 @@ "label": "Carcinoma, Pancreatic Ductal", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -998,7 +952,6 @@ "label": "Choriocarcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1019,7 +972,6 @@ "label": "Postoperative Nausea and Vomiting", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1031,7 +983,6 @@ "label": "Inflammatory Breast Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1052,7 +1003,6 @@ "label": "Carcinoma, Merkel Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -1073,7 +1023,6 @@ "label": "Testicular Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1094,7 +1043,6 @@ "label": "Adenocarcinoma of Lung", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1115,7 +1063,6 @@ "label": "Uterine Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1136,7 +1083,6 @@ "label": "Genital Neoplasms, Female", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -1157,7 +1103,6 @@ "label": "Mucositis", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1178,7 +1123,6 @@ "label": "oral cavity cancer", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1199,7 +1143,6 @@ "label": "Multiple Myeloma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1220,7 +1163,6 @@ "label": "Carcinoma, Basal Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -1241,7 +1183,6 @@ "label": "Oropharyngeal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1262,7 +1203,6 @@ "label": "Neuroblastoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1283,7 +1223,6 @@ "label": "Leukemia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1304,7 +1243,6 @@ "label": "Pharyngeal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1325,7 +1263,6 @@ "label": "Melanoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1346,7 +1283,6 @@ "label": "Adrenal Cortex Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1367,7 +1303,6 @@ "label": "Hodgkin Disease", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1388,7 +1323,6 @@ "label": "Uterine Cervical Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1409,7 +1343,6 @@ "label": "Carcinoma, Non-Small-Cell Lung", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1430,7 +1363,6 @@ "label": "Nausea", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1442,7 +1374,6 @@ "label": "Carcinoma, Small Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1463,7 +1394,6 @@ "label": "Adenocarcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1484,7 +1414,6 @@ "label": "Carcinoma, Large Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1505,7 +1434,6 @@ "label": "Endodermal Sinus Tumor", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1526,7 +1454,6 @@ "label": "Breast Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1547,7 +1474,6 @@ "label": "Pleural Effusion", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1559,7 +1485,6 @@ "label": "Central Nervous System Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1580,7 +1505,6 @@ "label": "Salivary Gland Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1601,7 +1525,6 @@ "label": "Carcinoma, Hepatocellular", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1622,7 +1545,6 @@ "label": "Mediastinal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1643,7 +1565,6 @@ "label": "Teratoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1664,7 +1585,6 @@ "label": "Peritoneal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1685,7 +1605,6 @@ "label": "Paranasal Sinus Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1706,7 +1625,6 @@ "label": "Klatskin Tumor", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -1727,7 +1645,6 @@ "label": "Seminoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1748,7 +1665,6 @@ "label": "Ovarian Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1769,7 +1685,6 @@ "label": "Lymphoma, Follicular", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1790,7 +1705,6 @@ "label": "Squamous Cell Carcinoma of Head and Neck", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1811,7 +1725,6 @@ "label": "Mesothelioma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1832,7 +1745,6 @@ "label": "Hepatoblastoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1853,7 +1765,6 @@ "label": "Carcinoma, Embryonal", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1874,7 +1785,6 @@ "label": "Lymphoma, Large-Cell, Anaplastic", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1895,7 +1805,6 @@ "label": "Anemia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1916,7 +1825,6 @@ "label": "Carcinoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1937,7 +1845,6 @@ "label": "Penile Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -1958,7 +1865,6 @@ "label": "Skin Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -1979,7 +1885,6 @@ "label": "Retinoblastoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2000,7 +1905,6 @@ "label": "Sarcoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2021,7 +1925,6 @@ "label": "Carcinoma, Islet Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2042,7 +1945,6 @@ "label": "Lymphoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2063,7 +1965,6 @@ "label": "Lymphoma, Non-Hodgkin", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2084,7 +1985,6 @@ "label": "Lung Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2105,7 +2005,6 @@ "label": "Urinary Bladder Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2126,7 +2025,6 @@ "label": "Leukemia-Lymphoma, Adult T-Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2147,7 +2045,6 @@ "label": "Medulloblastoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2168,7 +2065,6 @@ "label": "Endometrial Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2189,7 +2085,6 @@ "label": "Stomatitis", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2210,7 +2105,6 @@ "label": "Lymphoma, Mantle-Cell", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2231,7 +2125,6 @@ "label": "Xerostomia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -2243,7 +2136,6 @@ "label": "Osteosarcoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2264,7 +2156,6 @@ "label": "Sex Cord-Gonadal Stromal Tumors", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2285,7 +2176,6 @@ "label": "Nasopharyngeal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2306,7 +2196,6 @@ "label": "Glioma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2327,7 +2216,6 @@ "label": "Ganglioneuroblastoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2348,7 +2236,6 @@ "label": "Neoplasm Metastasis", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2360,7 +2247,6 @@ "label": "Granuloma, Lethal Midline", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2381,7 +2267,6 @@ "label": "Laryngeal Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2402,7 +2287,6 @@ "label": "Primary Myelofibrosis", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -2423,7 +2307,6 @@ "label": "Immunoblastic Lymphadenopathy", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2444,7 +2327,6 @@ "label": "Carcinoma, Neuroendocrine", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2465,7 +2347,6 @@ "label": "Malaria", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -2486,7 +2367,6 @@ "label": "Carcinoma, Endometrioid", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -2507,7 +2387,6 @@ "label": "Tongue Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2528,7 +2407,6 @@ "label": "Thyroid Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2549,7 +2427,6 @@ "label": "Gastrointestinal Stromal Tumors", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2570,7 +2447,6 @@ "label": "Triple Negative Breast Neoplasms", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_2" } @@ -2590,7 +2466,6 @@ } }, { - "type": "Extension", "name": "trade_names", "value": [ "Platinol", @@ -3008,7 +2883,6 @@ "label": "phenobarbital", "extensions": [ { - "type": "Extension", "name": "regulatory_approval", "value": { "approval_ratings": [ @@ -3022,7 +2896,6 @@ "label": "Dementia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3043,7 +2916,6 @@ "label": "Neutropenia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -3064,7 +2936,6 @@ "label": "Depressive Disorder", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3085,7 +2956,6 @@ "label": "Lymphoma", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_1" } @@ -3106,7 +2976,6 @@ "label": "Schizophrenia", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3127,7 +2996,6 @@ "label": "Epilepsy", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_4" } @@ -3148,7 +3016,6 @@ "label": "Status Epilepticus", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3169,7 +3036,6 @@ "label": "Neonatal Abstinence Syndrome", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3190,7 +3056,6 @@ "label": "Seizures", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3211,7 +3076,6 @@ "label": "Anxiety", "extensions": [ { - "type": "Extension", "name": "chembl_max_phase_for_ind", "value": "chembl_phase_3" } @@ -3231,7 +3095,6 @@ } }, { - "type": "Extension", "name": "trade_names", "value": [ "Luminal", @@ -3379,7 +3242,7 @@ } ], "type": "TherapeuticAgent", - "aliases": [ + "alternativeLabels": [ "PHENOBARBITAL", "Phenemal", "5-Ethyl-5-phenyl-2,4,6(1H,3H,5H)-pyrimidinetrione", @@ -3495,7 +3358,7 @@ } ], "type": "TherapeuticAgent", - "aliases": [ + "alternativeLabels": [ "Rovamycin", "Spiramycin 1", "Foromacidin A", @@ -3518,7 +3381,7 @@ "label": "Therapeutic Procedure", "description": null, "id": "normalize.therapy.ncit:C49236", - "aliases": [ + "alternativeLabels": [ "Therapeutic Interventions", "any therapy", "therapy", diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index 1dc6933b..f6c35f44 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -4,7 +4,7 @@ from pathlib import Path import pytest -from ga4gh.core import core_models +from ga4gh.core import domain_models from therapy.database.database import AbstractDatabase from therapy.query import InvalidParameterError, QueryHandler @@ -136,7 +136,7 @@ def compare_ta(response, fixture, query, match_type, warnings=None): assert response.match_type == match_type - fixture = core_models.TherapeuticAgent(**fixture.copy()) + fixture = domain_models.TherapeuticAgent(**fixture.copy()) assert response.normalized_id == fixture.id.split("normalize.therapy.")[-1] actual = response.therapeutic_agent actual_keys = actual.model_dump(exclude_none=True).keys() @@ -161,9 +161,9 @@ def compare_ta(response, fixture, query, match_type, warnings=None): assert no_matches == [], no_matches assert len(actual.mappings) == len(fixture.mappings) - assert bool(actual.aliases) == bool(fixture.aliases) - if actual.aliases: - assert set(actual.aliases) == set(fixture.aliases) + assert bool(actual.alternativeLabels) == bool(fixture.alternativeLabels) + if actual.alternativeLabels: + assert set(actual.alternativeLabels) == set(fixture.alternativeLabels) def get_extension(extensions, name): matches = [e for e in extensions if e.name == name]