Skip to content

Commit

Permalink
update disease-normalizer version + fix indication tests
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Oct 25, 2023
1 parent 62ab943 commit 8788bb8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test =
pytest-cov

dev =
disease-normalizer ~= 0.4.0.dev0
owlready2
rdflib
wikibaseintegrator >= 0.12.0
Expand Down
8 changes: 0 additions & 8 deletions tests/data/fixtures/query_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@
"id": "mesh:D014565",
"type": "Disease",
"label": "Urogenital Neoplasms",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -1104,7 +1103,6 @@
"id": "mesh:D020250",
"type": "Disease",
"label": "Postoperative Nausea and Vomiting",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -1600,7 +1598,6 @@
"id": "mesh:D009325",
"type": "Disease",
"label": "Nausea",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -1991,7 +1988,6 @@
"id": "mesh:D009362",
"type": "Disease",
"label": "Neoplasm Metastasis",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -2214,7 +2210,6 @@
"id": "mesh:D010996",
"type": "Disease",
"label": "Pleural Effusion",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -2290,7 +2285,6 @@
"id": "mesh:D014987",
"type": "Disease",
"label": "Xerostomia",
"disease": null,
"extensions": [
{
"type": "Extension",
Expand Down Expand Up @@ -3364,7 +3358,6 @@
"Spiramycin I",
"Foromacidin A"
],
"extensions": [],
"mappings": [
{
"coding": {
Expand Down Expand Up @@ -3472,7 +3465,6 @@
"any_therapy",
"treatment"
],
"extensions": [],
"mappings": [
{
"coding": {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion therapy/etl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions therapy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8788bb8

Please sign in to comment.