Exports

Functions to export SSSOM MappingSets to various formats.

Export functions for writing mapping sets to various file formats.

write_json(mapping_set: Sec2PriMappingSet, 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_name2synonym(mapping_set: Sec2PriMappingSet, output_path: Path | str) Path[source]

Write name to synonym mappings to a TSV file.

Only rows where at least one of subject_label or object_label is set are written. Columns: subject_id, subject_label, object_label.

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: Sec2PriMappingSet, 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: Sec2PriMappingSet, 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: Sec2PriMappingSet, 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_rdf(mapping_set: Sec2PriMappingSet, 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: Sec2PriMappingSet, output_path: Path | str) Path[source]

Write secondary to primary ID mappings to a TSV file.

Columns: subject_id, object_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: Sec2PriMappingSet, 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: Sec2PriMappingSet, 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.tsv file path.

Returns:

Path to the written file.

write_symbol2prev(mapping_set: Sec2PriMappingSet, output_path: Path | str) Path[source]

Write symbol to previous symbol mappings to a TSV file.

Only rows where at least one of subject_label or object_label is set are written. Columns: subject_id, subject_label, object_label, mapping_cardinality.

Parameters:
  • mapping_set – The mapping set to write.

  • output_path – Destination file path (e.g. symbol2prev.tsv).

Returns:

Path to the written file.