Skip to content

Commit

Permalink
park stached semra compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matentzn committed Nov 9, 2024
1 parent 40b97ac commit 53d1345
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_semra_compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Test for merging MappingSetDataFrames."""

import unittest

from sssom_schema import Mapping

from sssom.context import get_converter
from sssom.parsers import parse_sssom_table
from sssom.util import MappingSetDataFrame
from sssom.writers import write_table


class TestSemraCompatibility(unittest.TestCase):
"""A test case for making sure the model works as intended."""

def test_basic_inference(self):
"""Test if instantiating Mapping() fails when required elements are missing."""
mdict_missing = dict(
subject_id="ID:123"
) # This is missing object_id, predicate_id, mapping_justification

import io

import pandas as pd
from semra.api import infer_chains, infer_reversible
from semra.io import from_sssom_df, get_sssom_df

data = [
["UBERON:1", "skos:exactMatch", "FBbt:9"],
["UBERON:1", "skos:exactMatch", "WBbt:6"],
]

df = pd.DataFrame(data=data, columns=["subject_id", "predicate_id", "object_id"])

mappings = from_sssom_df(df, mapping_set_name="test")
mappings = infer_reversible(mappings, progress=False)
mappings = infer_chains(mappings, progress=False)

df = get_sssom_df(mappings)
print(df)
msdf = MappingSetDataFrame(df=df, converter=get_converter())
print(msdf.df)
msdf.standardize_references()
msdf.clean_prefix_map()
with open("testout.sssom.tsv", "w", encoding="utf-8") as file:
write_table(msdf=msdf, file=file)

0 comments on commit 53d1345

Please sign in to comment.