OWL Interface
OwlInterface exposes OWL axioms and OWL-specific helpers directly, without
forcing everything through a graph abstraction.
Quick examples
Load a local OWL ontology using the default selector logic:
from oaklib import get_adapter
oi = get_adapter("path/to/my-ontology.owl")
Inspect common OWL axiom types:
from oaklib import get_adapter
oi = get_adapter("path/to/my-ontology.owl")
subclass_axioms = list(oi.subclass_axioms(subclass="GO:0005634"))
label_axioms = list(
oi.annotation_assertion_axioms(
subject="GO:0005634",
property="rdfs:label",
)
)
eq_axioms = list(oi.equivalence_axioms(about="GO:0031965"))
Project graph-style relationships from OWL axioms:
from oaklib import get_adapter
oi = get_adapter("path/to/my-ontology.owl")
direct = list(oi.relationships(subjects=["GO:0005634"]))
entailed = list(
oi.relationships(
subjects=["GO:0005634"],
include_entailed=True,
)
)
Reasoning
OwlInterface does not currently expose a general OWL reasoner. The
horned-owl-backed implementation can still provide a lightweight projected
closure for graph APIs when include_entailed=True is used, but that should
not be interpreted as complete OWL reasoning.
- class oaklib.interfaces.owl_interface.OwlInterface(resource: ~oaklib.resource.OntologyResource = None, strict: bool = False, _multilingual: bool = 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, 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, functional_writer: ~typing.Any = None)[source]
Presents an ontology as an OWL ontology using the py-horned-owl object model.
We leverage the FunOwl, now backed by py-horned-owl.
Currently there is one implementation, the FunOwl Adapter.
Quick examples
Load a local OWL file through the default selector logic and inspect asserted OWL axioms:
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") for axiom in oi.subclass_axioms(subclass="GO:0005634"): print(type(axiom).__name__, axiom)
Filter annotation assertions for a single subject:
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") labels = list( oi.annotation_assertion_axioms( subject="GO:0005634", property="rdfs:label", ) )
Project lightweight graph-style relationships from OWL axioms:
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") direct = list(oi.relationships(subjects=["GO:0005634"])) entailed = list( oi.relationships( subjects=["GO:0005634"], include_entailed=True, ) )
Reasoning status
OwlInterfacedoes not currently expose a pluggable OWL reasoner. For the horned-owl-backed implementation,reasoner_configurations()returns an empty list andReasonerConfigurationis not accepted by axiom filtering.Some graph-facing methods can still return a lightweight, implementation- specific closure when
include_entailed=Trueis used. Treat that as projected graph closure over supported OWL patterns, not as complete OWL reasoning or satisfiability checking.In future the SqlDatabase implementation will implement this, as well as:
owlery
robot/owlapi via py4j
- subclass_axioms(subclass: str | None = None, superclass: str | None = None, reasoner: ReasonerConfiguration | None = None) Iterable[SubClassOf][source]
Gets all SubClassOf axioms matching criterion
- Parameters:
subclass – if specified, constrains to axioms where this is the subclass
superclass – if specified, constrains to axioms where this is the superclass
reasoner
- Returns:
Example
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") for axiom in oi.subclass_axioms(subclass="GO:0005634"): print(axiom)
- equivalence_axioms(about: str | None = None, references: str | None = None, reasoner: ReasonerConfiguration | None = None) Iterable[EquivalentClasses][source]
All EquivalentClasses axioms matching criteria
- Parameters:
about
references
reasoner
- Returns:
Example
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") eq_axioms = list(oi.equivalence_axioms(about="GO:0031965"))
- annotation_assertion_axioms(subject: str | None = None, property: str | None = None, value: Any = None) Iterable[AnnotationAssertion][source]
Filters all matching annotation axioms
- Parameters:
subject
property
value
- Returns:
Example
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") labels = list( oi.annotation_assertion_axioms( subject="GO:0005634", property="rdfs:label", ) )
- disjoint_pairs(subjects: Iterable[str] | None = None) Iterable[Tuple[str, str]][source]
Gets all disjoint pairs of entities
- Parameters:
subjects
- Returns:
- is_disjoint(subject: str, object: str) bool[source]
Checks if two entities are declared or entailed disjoint.
- Parameters:
subject
object
- Returns:
- is_satisfiable(curie: str) bool[source]
Note: this may move to the validation interface
- Parameters:
curie
- Returns:
- reasoner_configurations() List[ReasonerConfiguration][source]
Lists all available reasoner configurations
- Returns:
Example
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") configs = oi.reasoner_configurations()
- axiom_is_about(axiom: OntologyID | DocIRI | OntologyAnnotation | Import | DeclareClass | DeclareObjectProperty | DeclareAnnotationProperty | DeclareDataProperty | DeclareNamedIndividual | DeclareDatatype | SubClassOf | EquivalentClasses | DisjointClasses | DisjointUnion | SubObjectPropertyOf | EquivalentObjectProperties | DisjointObjectProperties | InverseObjectProperties | ObjectPropertyDomain | ObjectPropertyRange | FunctionalObjectProperty | InverseFunctionalObjectProperty | ReflexiveObjectProperty | IrreflexiveObjectProperty | SymmetricObjectProperty | AsymmetricObjectProperty | TransitiveObjectProperty | SubDataPropertyOf | EquivalentDataProperties | DisjointDataProperties | DataPropertyDomain | DataPropertyRange | FunctionalDataProperty | DatatypeDefinition | HasKey | SameIndividual | DifferentIndividuals | ClassAssertion | ObjectPropertyAssertion | NegativeObjectPropertyAssertion | DataPropertyAssertion | NegativeDataPropertyAssertion | AnnotationAssertion | SubAnnotationPropertyOf | AnnotationPropertyDomain | AnnotationPropertyRange | Rule) Iterable[IRI][source]
Gives an axiom, yield all of the entity IRIs which this axiom is about
For example, a SubClassOf axiom is about the IRI in the subClassOf expression
We use a consistent definition of about as in the OWLAPI
- Parameters:
axiom
- Returns:
entity IRI iterator
- axiom_references(axiom: OntologyID | DocIRI | OntologyAnnotation | Import | DeclareClass | DeclareObjectProperty | DeclareAnnotationProperty | DeclareDataProperty | DeclareNamedIndividual | DeclareDatatype | SubClassOf | EquivalentClasses | DisjointClasses | DisjointUnion | SubObjectPropertyOf | EquivalentObjectProperties | DisjointObjectProperties | InverseObjectProperties | ObjectPropertyDomain | ObjectPropertyRange | FunctionalObjectProperty | InverseFunctionalObjectProperty | ReflexiveObjectProperty | IrreflexiveObjectProperty | SymmetricObjectProperty | AsymmetricObjectProperty | TransitiveObjectProperty | SubDataPropertyOf | EquivalentDataProperties | DisjointDataProperties | DataPropertyDomain | DataPropertyRange | FunctionalDataProperty | DatatypeDefinition | HasKey | SameIndividual | DifferentIndividuals | ClassAssertion | ObjectPropertyAssertion | NegativeObjectPropertyAssertion | DataPropertyAssertion | NegativeDataPropertyAssertion | AnnotationAssertion | SubAnnotationPropertyOf | AnnotationPropertyDomain | AnnotationPropertyRange | Rule) Iterable[IRI][source]
Gives an axiom, yield all of the entity IRIs which this axiom references (i.e. entities in the signature)
- Parameters:
axiom
- Returns:
entity IRI iterator
- property_characteristics(property: str) Iterable[str][source]
Gets all property characteristics for a given property
- Parameters:
property
- Returns:
Example
from oaklib import get_adapter oi = get_adapter("path/to/my-ontology.owl") characteristics = list(oi.property_characteristics("BFO:0000050"))