diff --git a/Pipfile b/Pipfile index 7caf0c24..719b6e11 100644 --- a/Pipfile +++ b/Pipfile @@ -13,7 +13,7 @@ boto3 = "*" [dev-packages] thera-py = {editable = true, path = "."} -disease-normalizer = {editable = true, path = "cancervariants/disease-normalization"} +disease-normalizer = "~=0.4.0.dev0" owlready2 = "*" rdflib = "*" wikibaseintegrator = ">=0.12.0" diff --git a/setup.cfg b/setup.cfg index fe877501..9df5a98a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,6 +32,7 @@ test = pytest-cov dev = + disease-normalizer ~= 0.4.0.dev0 owlready2 rdflib wikibaseintegrator >= 0.12.0 diff --git a/tests/data/fixtures/query_fixtures.json b/tests/data/fixtures/query_fixtures.json index 2c14b6b6..764809c5 100644 --- a/tests/data/fixtures/query_fixtures.json +++ b/tests/data/fixtures/query_fixtures.json @@ -356,7 +356,6 @@ "id": "mesh:D014565", "type": "Disease", "label": "Urogenital Neoplasms", - "disease": null, "extensions": [ { "type": "Extension", @@ -1104,7 +1103,6 @@ "id": "mesh:D020250", "type": "Disease", "label": "Postoperative Nausea and Vomiting", - "disease": null, "extensions": [ { "type": "Extension", @@ -1600,7 +1598,6 @@ "id": "mesh:D009325", "type": "Disease", "label": "Nausea", - "disease": null, "extensions": [ { "type": "Extension", @@ -1991,7 +1988,6 @@ "id": "mesh:D009362", "type": "Disease", "label": "Neoplasm Metastasis", - "disease": null, "extensions": [ { "type": "Extension", @@ -2214,7 +2210,6 @@ "id": "mesh:D010996", "type": "Disease", "label": "Pleural Effusion", - "disease": null, "extensions": [ { "type": "Extension", @@ -2290,7 +2285,6 @@ "id": "mesh:D014987", "type": "Disease", "label": "Xerostomia", - "disease": null, "extensions": [ { "type": "Extension", @@ -3364,7 +3358,6 @@ "Spiramycin I", "Foromacidin A" ], - "extensions": [], "mappings": [ { "coding": { @@ -3472,7 +3465,6 @@ "any_therapy", "treatment" ], - "extensions": [], "mappings": [ { "coding": { diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index f4f7d82f..3a7e4557 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -180,9 +180,9 @@ def get_extension(extensions, name): assert set(ratings_actual) == set(ratings_fixture) assert set(approv_actual.value.get("approval_year", [])) == \ set(approv_fixture.value.get("approval_year", [])) - approv_inds = [json.dumps(ind) for ind + approv_inds = [json.dumps(ind, sort_keys=True) for ind in approv_actual.value.get("has_indication", [])] - fixture_inds = [json.dumps(ind) for ind + fixture_inds = [json.dumps(ind, sort_keys=True) for ind in approv_fixture.value.get("has_indication", [])] assert set(approv_inds) == set(fixture_inds) diff --git a/therapy/etl/base.py b/therapy/etl/base.py index 16c143c2..2f5a52a3 100644 --- a/therapy/etl/base.py +++ b/therapy/etl/base.py @@ -328,7 +328,7 @@ def _normalize_disease(self, query: str) -> Optional[str]: """ response = self.disease_normalizer.normalize(query) if response.match_type > 0: - return response.disease.id + return response.normalized_id else: logger.warning(f"Failed to normalize disease term: {query}") return None diff --git a/therapy/query.py b/therapy/query.py index ff296a06..82ea2966 100644 --- a/therapy/query.py +++ b/therapy/query.py @@ -500,12 +500,11 @@ def _add_therapeutic_agent( ) extensions.append(approv) - for field, name in (("trade_names", "trade_names"), - ("associated_with", "associated_with")): - values = record.get(field) - - if values: - extensions.append(core_models.Extension(name=name, value=values)) + trade_names = record.get("trade_names") + if trade_names: + extensions.append( + core_models.Extension(name="trade_names", value=trade_names) + ) if extensions: therapeutic_agent_obj.extensions = extensions