Quick Start¶
Python library¶
Parse an SSSOM TSV file¶
import sssom
# Parse a local file
msdf = sssom.parse_tsv("my_mappings.sssom.tsv")
# Parse from a URL
url = "https://raw.githubusercontent.com/mapping-commons/mh_mapping_initiative/master/mappings/mp_hp_eye_impc.sssom.tsv"
msdf = sssom.parse_tsv(url)
The returned MappingSetDataFrame object contains:
msdf.df-- a pandasDataFramewith the mapping rowsmsdf.converter-- acuries.Converterfor prefix handlingmsdf.metadata-- a dictionary of mapping set metadata
Write to different formats¶
# Write back to TSV
sssom.write_tsv(msdf, "output.sssom.tsv")
# Convert to other formats
sssom.write_json(msdf, "output.json")
sssom.write_owl(msdf, "output.owl")
sssom.write_rdf(msdf, "output.ttl")
Warning
The export formats (JSON, RDF) are not yet finalised. Expect changes in future releases.
Inspect mappings¶
import sssom
msdf = sssom.parse_tsv("my_mappings.sssom.tsv")
# Access the DataFrame
print(f"Number of mappings: {len(msdf.df)}")
print(msdf.df.head())
# Access metadata
print(msdf.metadata)
Compare two mapping sets¶
import sssom
msdf1 = sssom.parse_tsv("set1.sssom.tsv")
msdf2 = sssom.parse_tsv("set2.sssom.tsv")
diff = sssom.compare_dataframes(msdf1.df, msdf2.df)
print(f"Common mappings: {len(diff.common_tuples)}")
print(f"Unique to set1: {len(diff.unique_tuples1)}")
print(f"Unique to set2: {len(diff.unique_tuples2)}")
Filter redundant mappings¶
import sssom
msdf = sssom.parse_tsv("my_mappings.sssom.tsv")
filtered_df = sssom.filter_redundant_rows(msdf.df)
print(f"Before: {len(msdf.df)} rows, After: {len(filtered_df)} rows")
Command line¶
Parse and convert¶
# Parse an SSSOM file (validates and pretty-prints)
sssom parse my_mappings.sssom.tsv
# Convert TSV to OWL
sssom convert my_mappings.sssom.tsv -o output.owl -O owl
# Convert TSV to RDF (Turtle)
sssom convert my_mappings.sssom.tsv -o output.ttl -O rdf
Compare mapping sets¶
Validate¶
Merge multiple files¶
Query with SQL¶
Filter mappings¶
For the full list of CLI commands, see the CLI Reference.