monarch-initiative / monarch-mapping-commons

Building a fully exectuable workflow for boomer
Creative Commons Zero v1.0 Universal
4 stars 3 forks source link

Add mondo cross mappings into mapping commons #41

Open matentzn opened 12 months ago

matentzn commented 12 months ago

Right now, Mondo mappings are MONDO ids to external. We would like to add external-external mappings to the Monarch mapping commons. Here is some code using semra that can roughly achieve this but may need tweaks.

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"],
]

# replace the following with mondo mappings
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)
msdf = MappingSetDataFrame(df=df, converter=get_converter())
msdf.standardize_references()
msdf.clean_prefix_map()