Patcher Interface

Warning

this interface is still highly incomplete. In future it will allow any operation from KGCL to be applied

class oaklib.interfaces.patcher_interface.PatcherInterface(resource: typing.Optional[oaklib.resource.OntologyResource] = None, strict: bool = False, multilingual: typing.Optional[bool] = None, preferred_language: str = <factory>, autosave: bool = <factory>, exclude_owl_top_and_bottom: bool = <factory>, ontology_metamodel_mapper: typing.Optional[oaklib.mappers.ontology_metadata_mapper.OntologyMetadataMapper] = None, _converter: typing.Optional[curies.api.Converter] = None, auto_relax_axioms: typing.Optional[bool] = None)[source]

Applies diffs

See KGCL

apply_patch(patch: kgcl_schema.datamodel.kgcl.Change, activity: Optional[kgcl_schema.datamodel.kgcl.Activity] = None, metadata: Optional[Mapping[str, Any]] = None, configuration: Optional[kgcl_schema.datamodel.kgcl.Configuration] = None) Optional[kgcl_schema.datamodel.kgcl.Change][source]

Applies a change description

Parameters
  • patch – TBD use KGCL

  • activity

  • metadata

  • configuration

Returns

if successful, return copy of change object with additional metadata attached

auto_add_contributor_using: str = None

If provided, then any creators of or contributors on a Change object are propagated to the entity after application of that change, using this property. If this is set then the recommended value is dct:contributor

expand_change(change: kgcl_schema.datamodel.kgcl.Change, configuration: Optional[kgcl_schema.datamodel.kgcl.Configuration] = None) List[kgcl_schema.datamodel.kgcl.Change][source]

Expand a complex change object to a list of atomic changes.

Examples:

  • An obsoletion command may also generate a label change and removal or rewiring of edges

  • A NameBecomesSynonym may generate a NewSynonym and a NodeRename

Parameters
  • change

  • configuration

Returns

expand_changes(changes: List[kgcl_schema.datamodel.kgcl.Change], configuration: Optional[kgcl_schema.datamodel.kgcl.Configuration] = None, apply=False) List[kgcl_schema.datamodel.kgcl.Change][source]

Expand a list of complex change objects to a list of atomic changes.

Parameters
  • changes

  • configuration

  • apply – if True, apply the changes

Returns

migrate_curies(curie_map: Dict[str, str]) None[source]

Rewire an ontology replacing all usages of some CURIEs

Parameters

curie_map

Returns

reverse_changes(changes: List[kgcl_schema.datamodel.kgcl.Change]) List[kgcl_schema.datamodel.kgcl.Change][source]

Creates reciprocal Undo operations for a list of changes

Parameters

changes

Returns

save()[source]

Commits all changes

Returns

undo(changes: List[kgcl_schema.datamodel.kgcl.Change], expand=False, strict=True, **kwargs) List[kgcl_schema.datamodel.kgcl.Change][source]

Undo a list of changes

Parameters
  • changes

  • kwargs

Returns