11Part 6: Working With OWL
2- =====================
2+ ========================
33
4- OAK comes bundled with the `funowl <https://github.com/hsolbrig/funowl/ >`_ library
4+ OAK exposes an experimental ``funowl `` adapter for local OWL files.
5+ The selector name is historical; the adapter is now backed by
6+ `py-horned-owl <https://github.com/ontology-tools/py-horned-owl >`_.
7+ Plain local ``.owl ``, ``.ofn ``, ``.omn ``, and ``.owx `` paths default to this
8+ adapter; explicit schemes such as ``sqlite:foo.owl `` still override that
9+ default.
510
611
712OWL Datamodel
@@ -12,7 +17,102 @@ See :ref:`funowl`
1217OwlInterface
1318------------
1419
15- TODO
20+ ``OwlInterface `` is the low-level OAK view for working with OWL axioms and OWL-
21+ specific structures directly.
22+
23+ Loading a local OWL file
24+ ^^^^^^^^^^^^^^^^^^^^^^^^
25+
26+ For local files, plain ``.owl ``, ``.ofn ``, ``.omn ``, and ``.owx `` paths now
27+ default to the horned-owl-backed OWL adapter:
28+
29+ .. code-block :: python
30+
31+ from oaklib import get_adapter
32+
33+ oi = get_adapter(" path/to/my-ontology.owl" )
34+ print (type (oi).__name__ )
35+
36+ If you want a different backend, be explicit in the selector:
37+
38+ .. code-block :: python
39+
40+ sqlite_oi = get_adapter(" sqlite:path/to/my-ontology.owl" )
41+ sparql_oi = get_adapter(" sparql:path/to/my-ontology.owl" )
42+
43+ Inspecting asserted OWL axioms
44+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45+
46+ You can iterate over raw axioms, or use helpers for common axiom types:
47+
48+ .. code-block :: python
49+
50+ from oaklib import get_adapter
51+
52+ oi = get_adapter(" path/to/my-ontology.owl" )
53+
54+ for axiom in oi.subclass_axioms(subclass = " GO:0005634" ):
55+ print (type (axiom).__name__ , axiom)
56+
57+ labels = list (
58+ oi.annotation_assertion_axioms(
59+ subject = " GO:0005634" ,
60+ property = " rdfs:label" ,
61+ )
62+ )
63+
64+ eq_axioms = list (oi.equivalence_axioms(about = " GO:0031965" ))
65+
66+ If you need the underlying horned-owl ontology object, use:
67+
68+ .. code-block :: python
69+
70+ ontology = oi.owl_ontology()
71+ print (type (ontology).__name__ )
72+
73+ Projected graph operations
74+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
75+
76+ The horned-owl adapter also projects a graph view from supported OWL patterns,
77+ so graph-oriented APIs can often be used alongside axiom APIs:
78+
79+ .. code-block :: python
80+
81+ from oaklib import get_adapter
82+
83+ oi = get_adapter(" path/to/my-ontology.owl" )
84+
85+ direct = list (oi.relationships(subjects = [" GO:0005634" ]))
86+ entailed = list (
87+ oi.relationships(
88+ subjects = [" GO:0005634" ],
89+ include_entailed = True ,
90+ )
91+ )
92+ ancestors = list (oi.ancestors(" GO:0005634" , predicates = [" rdfs:subClassOf" ]))
93+
94+ Logical definitions are exposed in OBO Graph form:
95+
96+ .. code-block :: python
97+
98+ ldefs = list (oi.logical_definitions(subjects = [" GO:0031965" ]))
99+ for ldef in ldefs:
100+ print (ldef.definedClassId, ldef.genusIds, ldef.restrictions)
101+
102+ Reasoning status
103+ ^^^^^^^^^^^^^^^^
104+
105+ ``OwlInterface `` does not currently provide a pluggable OWL reasoner. In the
106+ current horned-owl-backed implementation:
107+
108+ - ``reasoner_configurations() `` returns an empty list
109+ - axiom filtering does not accept a ``ReasonerConfiguration ``
110+ - ``include_entailed=True `` on graph methods gives a lightweight projected
111+ closure over supported OWL patterns, not full OWL reasoning
112+
113+ For precomputed closure and broader graph-style querying, the recommended
114+ production path remains the :ref: `sql_implementation `. For external OWL
115+ reasoners, see the ROBOT plugin below.
16116
17117ROBOT Plugin
18118------------
0 commit comments