Exports
Functions to export SSSOM MappingSets to various formats.
Export functions for writing mapping sets to various file formats.
- write_json(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write a mapping set to an SSSOM JSON file.
- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
mappings.json).
- Returns:
Path to the written file.
- write_label2prev(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write label to previous (deprecated) label mappings to a TSV file.
Only
IAO:0100001("term replaced by") rows are written; synonym rows (oboInOwl:hasExactSynonym) are excluded because they belong in thename2synonymoutput. Columns:primary_id,primary_label,previous_label,mapping_cardinality.- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
label2prev.tsv).
- Returns:
Path to the written file.
- write_label_sec2pri(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write the full previous/alias-label to current-label table to a TSV file.
Every mapping row is written (both deprecation and synonym predicates). Columns:
secondary_id,secondary_label,primary_id,primary_label,predicate_id,mapping_cardinality.- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
label_sec2pri.tsv).
- Returns:
Path to the written file.
- write_name2synonym(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write name to synonym mappings to a TSV file.
Only
oboInOwl:hasExactSynonymrows are written; deprecation rows (IAO:0100001) are excluded because they belong in thelabel2prevoutput. Columns:primary_id,name,synonym.- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
name2synonym.tsv).
- Returns:
Path to the written file.
- write_output(mapping_set: BaseMappingSet, output_format: str, output_path: Path | str) Path[source]
Write a mapping set in any registered output format.
- Parameters:
mapping_set – The mapping set to write.
output_format – Format name (must be a key in WRITERS).
output_path – Path to write to.
- Returns:
Path to the written file.
- Raises:
ValueError – If output_format is not recognized.
- write_owl(mapping_set: BaseMappingSet, output_path: Path | str, serialisation: str = 'turtle') Path[source]
Write a mapping set to an OWL/RDF file (default: Turtle).
- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
mappings_owl.ttl).serialisation – RDFLib serialisation format.
- Returns:
Path to the written file.
- write_pri_ids(mapping_set: IdMappingSet, output_path: Path | str) Path[source]
Write unique primary IDs to a text file, one per line.
- Parameters:
mapping_set – The mapping set to read primary IDs from.
output_path – Destination file path.
- Returns:
Path to the written file.
- write_pri_labels(mapping_set: LabelMappingSet, output_path: Path | str) Path[source]
Write unique
primary_id/labelpairs to a two-column TSV.- Parameters:
mapping_set – The mapping set to read primary labels from.
output_path – Destination file path.
- Returns:
Path to the written file.
- write_rdf(mapping_set: BaseMappingSet, output_path: Path | str, serialisation: str = 'turtle') Path[source]
Write a mapping set to an RDF file.
- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
mappings.ttl).serialisation – RDFLib serialisation format.
- Returns:
Path to the written file.
- write_sec2pri(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write secondary to primary ID mappings to a TSV file.
Columns:
primary_id(object_id),secondary_id(subject_id),predicate_id,mapping_cardinality.- Parameters:
mapping_set – The mapping set to write.
output_path – Destination file path (e.g.
sec2pri.tsv).
- Returns:
Path to the written file.
- write_secondary(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write unique secondary IDs (subject_id) to a text file, one per line.
- Parameters:
mapping_set – The mapping set to read secondary IDs from.
output_path – Destination file path.
- Returns:
Path to the written file.
- write_sssom(mapping_set: BaseMappingSet, output_path: Path | str) Path[source]
Write a mapping set to an SSSOM TSV file.
- Parameters:
mapping_set – The mapping set to write.
output_path – Destination
.sssom.tsvfile path.
- Returns:
Path to the written file.