|
5 | 5 | import unittest
|
6 | 6 | from typing import Any, Dict
|
7 | 7 |
|
| 8 | +import curies |
8 | 9 | import pandas as pd
|
9 | 10 | from curies import Converter
|
10 | 11 |
|
@@ -191,3 +192,69 @@ def test_write_sssom_ontoportal_json(self):
|
191 | 192 | self.mapping_count,
|
192 | 193 | f"{path} has the wrong number of mappings.",
|
193 | 194 | )
|
| 195 | + |
| 196 | + # TODO: Determine assertions that should pass |
| 197 | + # TODO: Fix failing assertions that should pass |
| 198 | + # TODO: before merging, remove pass/fail comments at end of xassertion lines |
| 199 | + def test_missing_entries(self): |
| 200 | + """Test to make sure that missing entires do not appear.""" |
| 201 | + df = pd.DataFrame( |
| 202 | + [ |
| 203 | + { |
| 204 | + "subject_id": "Orphanet:58", |
| 205 | + "subject_label": "Alexander disease", |
| 206 | + "predicate_id": "skos:exactMatch", |
| 207 | + "object_id": "icd11.foundation:2023359698", |
| 208 | + "object_label": "Alexander disease", |
| 209 | + "mapping_justification": "semapv:UnspecifiedMatching", |
| 210 | + } |
| 211 | + ] |
| 212 | + ) |
| 213 | + metadata = { |
| 214 | + "creator_id": "orcid:0000-0002-2906-7319", |
| 215 | + "curie_map": { |
| 216 | + "MONDO": "http://purl.obolibrary.org/obo/MONDO_", |
| 217 | + "Orphanet": "http://www.orpha.net/ORDO/Orphanet_", |
| 218 | + "icd11.foundation": "http://id.who.int/icd/entity/", |
| 219 | + "oboInOwl": "http://www.geneontology.org/formats/oboInOwl#", |
| 220 | + "orcid": "https://orcid.org/", |
| 221 | + "owl": "http://www.w3.org/2002/07/owl#", |
| 222 | + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", |
| 223 | + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", |
| 224 | + "semapv": "https://w3id.org/semapv/", |
| 225 | + "skos": "http://www.w3.org/2004/02/skos/core#", |
| 226 | + "sssom": "https://w3id.org/sssom/", |
| 227 | + }, |
| 228 | + "license": "http://w3id.org/sssom/license/unspecified", |
| 229 | + "mapping_provider": "https://www.orpha.net/", |
| 230 | + } |
| 231 | + |
| 232 | + # When passing Converter |
| 233 | + msdf: MappingSetDataFrame = MappingSetDataFrame( |
| 234 | + converter=curies.Converter.from_prefix_map(metadata["curie_map"]), |
| 235 | + df=df, |
| 236 | + metadata=metadata, |
| 237 | + ) |
| 238 | + self.assertIn("curie_map", msdf.metadata) # pass |
| 239 | + self.assertIn("icd11.foundation", msdf.metadata["curie_map"]) # pass |
| 240 | + self.assertIn("icd11.foundation", msdf.prefix_map) # pass |
| 241 | + tmp_file = os.path.join(test_out_dir, "test_missing_entries.sssom.tsv") |
| 242 | + with open(tmp_file, "w") as f: |
| 243 | + write_table(msdf, f) |
| 244 | + msdf2 = parse_sssom_table(tmp_file) |
| 245 | + self.assertIn("curie_map", msdf2.metadata) # fail |
| 246 | + self.assertIn("icd11.foundation", msdf2.metadata["curie_map"]) # KeyError |
| 247 | + self.assertIn("icd11.foundation", msdf2.prefix_map) # pass |
| 248 | + |
| 249 | + # When no passed Converter |
| 250 | + msdf: MappingSetDataFrame = MappingSetDataFrame(df=df, metadata=metadata) |
| 251 | + self.assertIn("curie_map", msdf.metadata) # pass |
| 252 | + self.assertIn("icd11.foundation", msdf.metadata["curie_map"]) # pass |
| 253 | + self.assertIn("icd11.foundation", msdf.prefix_map) # fail |
| 254 | + tmp_file = os.path.join(test_out_dir, "test_missing_entries.sssom.tsv") |
| 255 | + with open(tmp_file, "w") as f: |
| 256 | + write_table(msdf, f) |
| 257 | + msdf2 = parse_sssom_table(tmp_file) |
| 258 | + self.assertIn("curie_map", msdf2.metadata) # fail |
| 259 | + self.assertIn("icd11.foundation", msdf2.metadata["curie_map"]) # KeyError |
| 260 | + self.assertIn("icd11.foundation", msdf2.prefix_map) # fail |
0 commit comments