Differ Interface

class oaklib.interfaces.differ_interface.DifferInterface(resource: ~oaklib.resource.OntologyResource | None = None, strict: bool = False, _multilingual: bool | None = None, autosave: bool = <factory>, exclude_owl_top_and_bottom: bool = <factory>, ontology_metamodel_mapper: ~oaklib.mappers.ontology_metadata_mapper.OntologyMetadataMapper | None = None, _converter: ~curies.api.Converter | None = None, auto_relax_axioms: bool | None = None, cache_lookups: bool = False, property_cache: ~oaklib.utilities.keyval_cache.KeyValCache = <factory>, _edge_index: ~oaklib.indexes.edge_index.EdgeIndex | None = None, _entailed_edge_index: ~oaklib.indexes.edge_index.EdgeIndex | None = None, _prefix_map: ~typing.Mapping[str, str] | None = None)[source]

Generates Change objects between one ontology and another.

This uses the KGCL datamodel, see https://w3id.org/kgcl/ for more information.

grouped_diff(*args, **kwargs) Iterator[Tuple[str, List[Change]]][source]

Yields changes grouped by type.

This wraps the diff() method and groups the changes by type.

Parameters:
  • args

  • kwargs

Returns:

diff(other_ontology: BasicOntologyInterface, configuration: DiffConfiguration | None = None, **kwargs) Iterator[Change][source]

Diffs two ontologies.

The changes that are yielded describe transitions from the current ontology to the other ontology.

Note that this is not guaranteed to diff every axiom in both ontologies. Different implementations may implement different subsets.

Example usage:

>>> from oaklib import get_adapter
>>> from linkml_runtime.dumpers import yaml_dumper
>>> path1 = "simpleobo:tests/input/go-nucleus.obo"
>>> path2 = "simpleobo:tests/input/go-nucleus-modified.obo"
>>> ont1 = get_adapter(path1)
>>> ont2 = get_adapter(path2)
>>> for change in ont1.diff(ont2):
...     print(yaml_dumper.dumps(change))

...
type: NodeRename
old_value: catalytic activity
new_value: enzyme activity
about_node: GO:0003824
...
Parameters:
  • other_ontology – Ontology to compare against

  • configuration – Configuration for the differentiation

Returns:

A sequence of changes in the form of a dictionary

diff_summary(other_ontology: BasicOntologyInterface, configuration: DiffConfiguration | None = None) Dict[str, Any][source]

Provides high level summary of differences.

The result is a two-level dictionary

  • the first level is the grouping key

  • the second level is the type of change

The value of the second level is a count of the number of changes of that type.

Parameters:
  • other_ontology

  • configuration

Returns:

compare_ontology_term_lists(other_ontology: BasicOntologyInterface) Iterator[Change][source]

Provides high level summary of differences

Parameters:

other_ontology

Returns: