Repository: cancervariants/therapy-normalization (language: python)

Issue:
Update tests for spiramycin records



Discussion / hints:

Fix patch:
diff --git a/therapy/version.py b/therapy/version.py
index b9e242bf..b70e11a8 100644
--- a/therapy/version.py
+++ b/therapy/version.py
@@ -1,2 +1,2 @@
 """Therapy normalizer version"""
-__version__ = "0.3.2"
+__version__ = "0.3.3"
diff --git a/tox.ini b/tox.ini
index b5dcfe50..0f0ef939 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,7 +13,7 @@ deps =
     lint: flake8-quotes
     lint: flake8-import-order
     lint: flake8-annotations
-    mypy: mypy
+    mypy: mypy == 0.910
     mypy: types-PyYAML
     mypy: types-requests
 setenv =


Test patch:
diff --git a/tests/unit/data/therapies.json b/tests/unit/data/therapies.json
index a8c36e75..d9965490 100644
--- a/tests/unit/data/therapies.json
+++ b/tests/unit/data/therapies.json
@@ -1229,7 +1229,7 @@
   {
     "label_and_type": "chemidplus:8025-81-8##identity",
     "src_name": "ChemIDplus",
-    "merge_ref": "ncit:c839",
+    "merge_ref": "rxcui:9991",
     "item_type": "identity",
     "label": "Spiramycin",
     "concept_id": "chemidplus:8025-81-8",
@@ -1306,7 +1306,14 @@
     "xrefs": ["chemidplus:8025-81-8"],
     "associated_with": ["umls:C0037962", "unii:71ODY0V87H"],
     "src_name": "NCIt",
-    "merge_ref": "ncit:c839"
+    "merge_ref": "rxcui:9991",
+    "item_type": "identity"
+  },
+  {
+    "label_and_type": "chemidplus:8025-81-8##xref",
+    "concept_id": "ncit:c839",
+    "src_name": "NCIt",
+    "item_type": "xref"
   },
   {
     "label_and_type": "rp 5337##alias",
@@ -1510,25 +1517,42 @@
     ]
   },
   {
-    "label_and_type": "ncit:c839##merger",
+    "label_and_type": "rxcui:9991##merger",
     "item_type": "merger",
-    "concept_id": "ncit:C839",
-    "xrefs": ["chemidplus:8025-81-8", "wikidata:Q422265"],
-    "label": "Spiramycin",
+    "concept_id": "rxcui:9991",
+    "xrefs": [
+      "ncit:C839",
+      "drugbank:DB06145",
+      "chemidplus:8025-81-8",
+      "wikidata:Q422265"
+    ],
     "aliases": [
+      "RP 5337",
       "SPIRAMYCIN",
+      "Foromacidine A",
+      "Spiramycine",
+      "Provamycin",
+      "Foromacidin A",
       "Antibiotic 799",
+      "spiramycin I",
       "Rovamycin",
-      "Provamycin",
-      "Rovamycine",
-      "RP 5337",
+      "Spiramycin A",
+      "Spiramycin 1",
       "(4R,5S,6R,7R,9R,10R,11E,13E,16R)-10-{[(2R,5S,6R)-5-(dimethylamino)-6-methyltetrahydro-2H-pyran-2-yl]oxy}-9,16-dimethyl-5-methoxy-2-oxo-7-(2-oxoethyl)oxacyclohexadeca-11,13-dien-6-yl 3,6-dideoxy-4-O-(2,6-dideoxy-3-C-methyl-alpha-L-ribo-hexopyranosyl)-3-(dimethylamino)-alpha-D-glucopyranoside",
-      "spiramycin I"
+      "Spiramycin I",
+      "Rovamycine",
+      "Demycarosylturimycin H"
     ],
+    "label": "spiramycin",
     "associated_with": [
+      "pubchem.compound:5356392",
       "umls:C0037962",
       "unii:71ODY0V87H",
-      "pubchem.compound:5356392"
+      "inchikey:ACTOXUHEUCPTEW-KWBWCIJSSA-N",
+      "mesh:C017186",
+      "atc:J01FA02",
+      "mesh:D015572",
+      "unii:033ECH6IFG"
     ]
   },
   {
@@ -2877,5 +2901,80 @@
     "src_name": "RxNorm",
     "concept_id": "rxcui:7975",
     "item_type": "trade_name"
+  },
+  {
+    "label_and_type": "drugbank:db06145##identity",
+    "concept_id": "drugbank:DB06145",
+    "aliases": [
+      "Foromacidin A",
+      "Spiramycin A",
+      "Spiramycin 1",
+      "Spiramycin I",
+      "Foromacidine A",
+      "Demycarosylturimycin H"
+    ],
+    "associated_with": [
+      "inchikey:ACTOXUHEUCPTEW-KWBWCIJSSA-N",
+      "unii:033ECH6IFG"
+    ],
+    "label": "Spiramycin",
+    "merge_ref": "rxcui:9991",
+    "xrefs": ["chemidplus:24916-50-5"],
+    "item_type": "identity",
+    "src_name": "DrugBank"
+  },
+  {
+    "label_and_type": "chemidplus:24916-50-5##xref",
+    "concept_id": "drugbank:db06145",
+    "src_name": "DrugBank",
+    "item_type": "xref"
+  },
+  {
+    "label_and_type": "wikidata:q422265##identity",
+    "concept_id": "wikidata:Q422265",
+    "aliases": ["spiramycin I"],
+    "associated_with": ["pubchem.compound:5356392"],
+    "label": "spiramycin",
+    "merge_ref": "rxcui:9991",
+    "xrefs": ["rxcui:9991", "chembl:CHEMBL1256397", "chemidplus:8025-81-8"],
+    "item_type": "identity",
+    "src_name": "Wikidata"
+  },
+  {
+    "label_and_type": "chemidplus:8025-81-8##xref",
+    "item_type": "xref",
+    "concept_id": "wikidata:q422265",
+    "src_name": "wikidata"
+  },
+  {
+    "label_and_type": "rxcui:9991##xref",
+    "item_type": "xref",
+    "concept_id": "wikidata:q422265",
+    "src_name": "wikidata"
+  },
+  {
+    "label_and_type": "rxcui:9991##identity",
+    "concept_id": "rxcui:9991",
+    "aliases": [
+      "Spiramycine",
+      "Foromacidin A",
+      "Spiramycin A",
+      "Spiramycin 1",
+      "Spiramycin I",
+      "Foromacidine A",
+      "Demycarosylturimycin H"
+    ],
+    "associated_with": ["mesh:C017186", "atc:J01FA02", "mesh:D015572"],
+    "label": "spiramycin",
+    "merge_ref": "rxcui:9991",
+    "xrefs": ["drugbank:DB06145"],
+    "item_type": "identity",
+    "src_name": "RxNorm"
+  },
+  {
+    "label_and_type": "drugbank:db06145##xref",
+    "item_type": "xref",
+    "src_name": "RxNorm",
+    "concept_id": "rxcui:9991"
   }
 ]
diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py
index 51937401..f722147b 100644
--- a/tests/unit/test_database.py
+++ b/tests/unit/test_database.py
@@ -48,7 +48,7 @@ def test_item_type(db):  # noqa: F811
     assert "item_type" in item
     assert item["item_type"] == "trade_name"
 
-    filter_exp = Key("label_and_type").eq("ncit:c839##merger")
+    filter_exp = Key("label_and_type").eq("rxcui:9991##merger")
     item = db.therapies.query(KeyConditionExpression=filter_exp)["Items"][0]
     assert "item_type" in item
     assert item["item_type"] == "merger"
diff --git a/tests/unit/test_merge.py b/tests/unit/test_merge.py
index d1e75653..29d690c0 100644
--- a/tests/unit/test_merge.py
+++ b/tests/unit/test_merge.py
@@ -290,24 +290,41 @@ def spiramycin_merged():
     to this group.
     """
     return {
-        "label_and_type": "ncit:c839##merger",
-        "concept_id": "ncit:C839",
+        "label_and_type": "rxcui:9991##merger",
+        "concept_id": "rxcui:9991",
         "xrefs": [
+            "ncit:C839",
+            "drugbank:DB06145",
             "chemidplus:8025-81-8",
+            "wikidata:Q422265"
         ],
-        "label": "Spiramycin",
+        "label": "spiramycin",
         "aliases": [
+            "RP 5337",
             "SPIRAMYCIN",
+            "Foromacidine A",
+            "Spiramycine",
+            "Provamycin",
+            "Foromacidin A",
             "Antibiotic 799",
+            "spiramycin I",
             "Rovamycin",
-            "Provamycin",
+            "Spiramycin A",
+            "Spiramycin 1",
+            "(4R,5S,6R,7R,9R,10R,11E,13E,16R)-10-{[(2R,5S,6R)-5-(dimethylamino)-6-methyltetrahydro-2H-pyran-2-yl]oxy}-9,16-dimethyl-5-methoxy-2-oxo-7-(2-oxoethyl)oxacyclohexadeca-11,13-dien-6-yl 3,6-dideoxy-4-O-(2,6-dideoxy-3-C-methyl-alpha-L-ribo-hexopyranosyl)-3-(dimethylamino)-alpha-D-glucopyranoside",  # noqa: E501
+            "Spiramycin I",
             "Rovamycine",
-            "RP 5337",
-            "(4R,5S,6R,7R,9R,10R,11E,13E,16R)-10-{[(2R,5S,6R)-5-(dimethylamino)-6-methyltetrahydro-2H-pyran-2-yl]oxy}-9,16-dimethyl-5-methoxy-2-oxo-7-(2-oxoethyl)oxacyclohexadeca-11,13-dien-6-yl 3,6-dideoxy-4-O-(2,6-dideoxy-3-C-methyl-alpha-L-ribo-hexopyranosyl)-3-(dimethylamino)-alpha-D-glucopyranoside"  # noqa: E501
+            "Demycarosylturimycin H"
         ],
         "associated_with": [
+            "pubchem.compound:5356392",
             "umls:C0037962",
-            "unii:71ODY0V87H"
+            "unii:71ODY0V87H",
+            "inchikey:ACTOXUHEUCPTEW-KWBWCIJSSA-N",
+            "mesh:C017186",
+            "atc:J01FA02",
+            "mesh:D015572",
+            "unii:033ECH6IFG"
         ],
     }
 
@@ -379,13 +396,40 @@ def record_id_groups():
             "chembl:CHEMBL40",
             "iuphar.ligand:2804"
         },
+        "rxcui:9991": {  # Spiramycin
+            "rxcui:9991",
+            "ncit:C839",
+            "chemidplus:8025-81-8",
+            "drugbank:DB06145",
+            "wikidata:Q422265"
+        },
         "ncit:C839": {  # Spiramycin
+            "rxcui:9991",
             "ncit:C839",
             "chemidplus:8025-81-8",
+            "drugbank:DB06145",
+            "wikidata:Q422265"
         },
         "chemidplus:8025-81-8": {  # Spiramycin
+            "rxcui:9991",
+            "ncit:C839",
+            "chemidplus:8025-81-8",
+            "drugbank:DB06145",
+            "wikidata:Q422265"
+        },
+        "drugbank:DB06145": {  # Spiramycin
+            "rxcui:9991",
+            "ncit:C839",
+            "chemidplus:8025-81-8",
+            "drugbank:DB06145",
+            "wikidata:Q422265"
+        },
+        "wikidata:Q422265": {  # Spiramycin
+            "rxcui:9991",
             "ncit:C839",
             "chemidplus:8025-81-8",
+            "drugbank:DB06145",
+            "wikidata:Q422265"
         },
         "rxcui:2555": {  # Cisplatin
             "rxcui:2555",
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py
index 39788364..3e4d2eb5 100644
--- a/tests/unit/test_query.py
+++ b/tests/unit/test_query.py
@@ -287,37 +287,51 @@ def cisplatin():
 
 @pytest.fixture(scope="module")
 def spiramycin():
-    """Create fixture for spiramycin."""
+    """Create fixture for normalized spiramycin record."""
     return {
         "id": "normalize.therapy:Spiramycin",
         "type": "TherapyDescriptor",
-        "therapy_id": "ncit:C839",
-        "label": "Spiramycin",
+        "label": "spiramycin",
         "xrefs": [
+            "ncit:C839",
+            "drugbank:DB06145",
             "chemidplus:8025-81-8",
             "wikidata:Q422265"
         ],
         "alternate_labels": [
+            "RP 5337",
             "SPIRAMYCIN",
+            "Foromacidine A",
+            "Spiramycine",
+            "Provamycin",
+            "Foromacidin A",
             "Antibiotic 799",
+            "spiramycin I",
             "Rovamycin",
-            "Provamycin",
-            "Rovamycine",
-            "RP 5337",
+            "Spiramycin A",
+            "Spiramycin 1",
             "(4R,5S,6R,7R,9R,10R,11E,13E,16R)-10-{[(2R,5S,6R)-5-(dimethylamino)-6-methyltetrahydro-2H-pyran-2-yl]oxy}-9,16-dimethyl-5-methoxy-2-oxo-7-(2-oxoethyl)oxacyclohexadeca-11,13-dien-6-yl 3,6-dideoxy-4-O-(2,6-dideoxy-3-C-methyl-alpha-L-ribo-hexopyranosyl)-3-(dimethylamino)-alpha-D-glucopyranoside",  # noqa: E501
-            "spiramycin I"
+            "Spiramycin I",
+            "Rovamycine",
+            "Demycarosylturimycin H"
         ],
         "extensions": [
             {
                 "type": "Extension",
                 "name": "associated_with",
                 "value": [
+                    "pubchem.compound:5356392",
                     "umls:C0037962",
                     "unii:71ODY0V87H",
-                    "pubchem.compound:5356392"
+                    "inchikey:ACTOXUHEUCPTEW-KWBWCIJSSA-N",
+                    "mesh:C017186",
+                    "atc:J01FA02",
+                    "mesh:D015572",
+                    "unii:033ECH6IFG"
                 ]
             }
-        ]
+        ],
+        "therapy_id": "rxcui:9991"
     }
 
 
@@ -400,8 +414,6 @@ def compare_vod(response, fixture, query, match_type, response_id,
 
     assert ("xrefs" in actual.keys()) == ("xrefs" in fixture.keys())
     if "xrefs" in actual:
-        print(actual["xrefs"])
-        print(fixture["xrefs"])
         assert set(actual["xrefs"]) == set(fixture["xrefs"])
 
     assert ("alternate_labels" in actual.keys()) == ("alternate_labels" in
@@ -684,9 +696,9 @@ def test_infer_option(query_handler, merge_query_handler):
     assert response["match_type"] == MatchType.NO_MATCH
 
 
-def test_query_merged(merge_query_handler, phenobarbital, cisplatin,
-                      spiramycin, therapeutic_procedure):
-    """Test that the merged concept endpoint handles queries correctly."""
+def test_query_normalize(merge_query_handler, phenobarbital, cisplatin,
+                         spiramycin, therapeutic_procedure):
+    """Test that the normalized concept endpoint handles queries correctly."""
     # test merged id match
     query = "rxcui:2555"
     response = merge_query_handler.search_groups(query)