|
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,65 @@ 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 assertion lines |
| 199 | + def test_missing_entries(self): |
| 200 | + """Test to make sure that missing entires do not appear""" |
| 201 | + df = pd.DataFrame([{ |
| 202 | + 'subject_id': 'Orphanet:58', |
| 203 | + 'subject_label': 'Alexander disease', |
| 204 | + 'predicate_id': 'skos:exactMatch', |
| 205 | + 'object_id': 'icd11.foundation:2023359698', |
| 206 | + 'object_label': 'Alexander disease', |
| 207 | + 'mapping_justification': 'semapv:UnspecifiedMatching' |
| 208 | + }]) |
| 209 | + metadata = { |
| 210 | + 'creator_id': 'orcid:0000-0002-2906-7319', |
| 211 | + 'curie_map': { |
| 212 | + 'MONDO': 'http://purl.obolibrary.org/obo/MONDO_', |
| 213 | + 'Orphanet': 'http://www.orpha.net/ORDO/Orphanet_', |
| 214 | + 'icd11.foundation': 'http://id.who.int/icd/entity/', |
| 215 | + 'oboInOwl': 'http://www.geneontology.org/formats/oboInOwl#', |
| 216 | + 'orcid': 'https://orcid.org/', |
| 217 | + 'owl': 'http://www.w3.org/2002/07/owl#', |
| 218 | + 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', |
| 219 | + 'rdfs': 'http://www.w3.org/2000/01/rdf-schema#', |
| 220 | + 'semapv': 'https://w3id.org/semapv/', |
| 221 | + 'skos': 'http://www.w3.org/2004/02/skos/core#', |
| 222 | + 'sssom': 'https://w3id.org/sssom/' |
| 223 | + }, |
| 224 | + 'license': 'http://w3id.org/sssom/license/unspecified', |
| 225 | + 'mapping_provider': 'https://www.orpha.net/' |
| 226 | + } |
| 227 | + |
| 228 | + # When passing Converter |
| 229 | + msdf: MappingSetDataFrame = MappingSetDataFrame( |
| 230 | + converter=curies.Converter.from_prefix_map(metadata['curie_map']), |
| 231 | + df=df, |
| 232 | + metadata=metadata |
| 233 | + ) |
| 234 | + self.assertIn('curie_map', msdf.metadata) # pass |
| 235 | + self.assertIn('icd11.foundation', msdf.metadata['curie_map']) # pass |
| 236 | + self.assertIn('icd11.foundation', msdf.prefix_map) # pass |
| 237 | + tmp_file = os.path.join(test_out_dir, "test_missing_entries.sssom.tsv") |
| 238 | + with open(tmp_file, 'w') as f: |
| 239 | + write_table(msdf, f) |
| 240 | + msdf2 = parse_sssom_table(tmp_file) |
| 241 | + self.assertIn('curie_map', msdf2.metadata) # fail |
| 242 | + self.assertIn('icd11.foundation', msdf2.metadata['curie_map']) # KeyError |
| 243 | + self.assertIn('icd11.foundation', msdf2.prefix_map) # pass |
| 244 | + |
| 245 | + # When no passed Converter |
| 246 | + msdf: MappingSetDataFrame = MappingSetDataFrame(df=df, metadata=metadata) |
| 247 | + self.assertIn('curie_map', msdf.metadata) # pass |
| 248 | + self.assertIn('icd11.foundation', msdf.metadata['curie_map']) # pass |
| 249 | + self.assertIn('icd11.foundation', msdf.prefix_map) # fail |
| 250 | + tmp_file = os.path.join(test_out_dir, "test_missing_entries.sssom.tsv") |
| 251 | + with open(tmp_file, 'w') as f: |
| 252 | + write_table(msdf, f) |
| 253 | + msdf2 = parse_sssom_table(tmp_file) |
| 254 | + self.assertIn('curie_map', msdf2.metadata) # fail |
| 255 | + self.assertIn('icd11.foundation', msdf2.metadata['curie_map']) # KeyError |
| 256 | + self.assertIn('icd11.foundation', msdf2.prefix_map) # fail |
0 commit comments