diff --git a/src/sssom/parsers.py b/src/sssom/parsers.py index 246a279b..c2348fe3 100644 --- a/src/sssom/parsers.py +++ b/src/sssom/parsers.py @@ -914,6 +914,16 @@ def _ensure_valid_mapping_from_dict(mdict: Dict[str, Any]): try: m = Mapping(**mdict) + if m.subject_type == "rdfs literal": + if m.subject_label is None: + raise ValueError("Missing subject_label") + elif m.subject_id is None: + raise ValueError("Missing subject_id") + if m.object_type == "rdfs literal": + if m.object_label is None: + raise ValueError("Missing object_label") + elif m.object_id is None: + raise ValueError("Missing object_id") except ValueError as e: logging.warning( f"One mapping in the mapping set is not well-formed, " diff --git a/tests/test_utils.py b/tests/test_utils.py index e8e518e9..a6e1c807 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,6 +7,7 @@ import yaml from curies import Converter, Record, chain from sssom_schema import Mapping as SSSOM_Mapping +from sssom_schema import slots as SSSOM_Slots from sssom.constants import ( CREATOR_ID, @@ -409,14 +410,19 @@ def test_get_dict_from_mapping(self): "match_string": "", "subject_preprocessing": "", "object_preprocessing": "", - "semantic_similarity_score": np.nan, - "semantic_similarity_measure": "", "see_also": "", "issue_tracker_item": "", "other": "", "comment": "", } + if hasattr(SSSOM_Slots, "similarity_score"): + expected_result["similarity_score"] = np.nan + expected_result["similarity_measure"] = "" + else: + expected_result["semantic_similarity_score"] = np.nan + expected_result["semantic_similarity_measure"] = "" + result_with_mapping_object = get_dict_from_mapping(mapping_obj) result_with_dict = get_dict_from_mapping(mapping_dict) self.assertEqual(result_with_mapping_object, result_with_dict)