mowl.projection
In this module we provide different methods for projecting an ontology into a graph: The methods we provide are:
Ontology Projection
- class mowl.projection.base.ProjectionModel[source]
Bases:
object
Abstract class for Ontology projection into a graph
- Parameters
ontology (
org.semanticweb.owlapi.model.OWLOntology
) – The ontology to be processed.
- project(ontology)[source]
Performs the ontology parsing.
- Returns
A list of triples where each triple is of the form \((head, relation, tail)\)
- Return type
List of
mowl.projection.edge.Edge
All the methods will return a list of edges corresponding to the Edge class:
Edge
- class mowl.projection.edge.Edge(src, rel, dst, weight=1.0)[source]
Bases:
object
Class representing a graph edge.
- static getEntitiesAndRelations(edges)[source]
Deprecated since version 0.1.0: Use get_entities_and_relations instead
- static as_pykeen(edges, create_inverse_triples=True, entity_to_id=None, relation_to_id=None)[source]
This method transform a set of edges into an object of the type
pykeen.triples.triples_factory.TriplesFactory
. This method is intended to be used for PyKEEN methods.- Parameters
- Return type
New in version 0.1.0: This method is available to transform graph edges obtained from ontologies into PyKEEN triples.
Subclass Hierarchy
- class mowl.projection.taxonomy.model.TaxonomyProjector(bidirectional_taxonomy: bool = False)[source]
Bases:
ProjectionModel
This class will project the ontology considering only the axioms of the form \(A \sqsubseteq B\) where A and B are ontology classes.
- Parameters
ontology – The ontology to be processed.
bidirectional_taxonomy – If true then per each SubClass edge one SuperClass edge will be generated.
- project(ontology)[source]
Performs the ontology parsing.
- Returns
A list of triples where each triple is of the form \((head, relation, tail)\)
- Return type
List of
mowl.projection.edge.Edge
Subclass Hierarchy With Relations
- class mowl.projection.taxonomy_rels.model.TaxonomyWithRelationsProjector(taxonomy=False, bidirectional_taxonomy: bool = False, relations=None)[source]
Bases:
ProjectionModel
This class will project the ontology considering the following axioms:
\(A \sqsubseteq B\) will generate the triple \(\langle A, subClassOf, B \rangle\)
\(A \sqsubseteq \exists R. B\) will generate the triple \(\left\langle A, R, B \right\rangle\)
- Parameters
ontology – The ontology to be processed.
bidirectional_taxonomy – If true then per each SubClass edge one SuperClass edge will be generated.
- project(ontology)[source]
Performs the ontology parsing.
- Returns
A list of triples where each triple is of the form \((head, relation, tail)\)
- Return type
List of
mowl.projection.edge.Edge
DL2Vec Graph
The DL2Vec graph follows the rules described in the paper Predicting candidate genes from phenotypes, functions, and anatomical site of expression (2020). The parsing rules are shown in the table below:
Condition 1 |
Condition 2 |
Triple(s) |
---|---|---|
\(A \sqsubseteq Q R_{0} \ldots Q R_{m} D\) |
\(D := B_{1} \sqcup \ldots \sqcup B_{n} | B_{1} \sqcap \ldots \sqcap B_{n}\) |
\(\left\langle A, (R_{0}...R_{m}), B_i \right\rangle\) for \(i \in 1 \ldots n\) |
\(A \equiv Q R_{0} \ldots Q R_{m} D\) |
||
\(A \sqsubseteq B\) |
\(\left\langle A, SubClassOf, B \right\rangle\) |
|
\(A \equiv B\) |
\(\left\langle A, EquivalentTo, B \right\rangle\) |
- class mowl.projection.dl2vec.model.DL2VecProjector(bidirectional_taxonomy: bool = False)[source]
Bases:
ProjectionModel
- Parameters
ontology (
org.semanticweb.owlapi.model.OWLOntology
) – The ontology to be processed.bidirectional_taxonomy (bool) – If true then per each SubClass edge one SuperClass edge will be generated.
- project(ontology, with_individuals=False, verbose=False)[source]
Generates the projection of the ontology.
- Parameters
ontology (
org.semanticweb.owlapi.model.OWLOntology
) – The ontology to be processed.with_individuals (bool, optional) – If true then assertion axioms with named individuals will be included in the projection. Default is False.
verbose (bool, optional) – If true then the warnings will be printed to the standard output. Default is False.
- Return type
OWL2Vec* Graph
The OWL2Vec* graph follows the rules described in the paper OWL2Vec*: embedding of OWL ontologies (2021). The parsing rules are shown in the table below:
Axiom of condition 1 |
Axiom or triple(s) of condition 2 |
Projected triple(s) |
---|---|---|
\(A \sqsubseteq \square r . D\) |
\(D \equiv B\left|B_{1} \sqcup \ldots \sqcup B_{n}\right| B_{1} \sqcap \ldots \sqcap B_{n}\) |
\(\langle A, r, B\rangle\) |
or |
||
\(\square r . D \sqsubseteq A\) |
||
\(\exists r . \top \sqsubseteq A\) (domain) |
\(\top \sqsubseteq \forall r . B\) (range) |
\(\langle A, r, B_{i}\rangle\) for \(i \in 1, \ldots, n\) |
\(A \sqsubseteq \exists r .\{b\}\) |
\(B(b)\) |
|
\(r \sqsubseteq r^{\prime}\) |
\(\left\langle A, r^{\prime}, B\right\rangle\) has been projected |
|
\(r^{\prime} \equiv r^{-}\) |
\(\left\langle B, r^{\prime}, A\right\rangle\) has been projected |
|
\(s_{1} \circ \ldots \circ s_{n} \sqsubseteq r\) |
\(\langle A, s_1, C_1\rangle \ldots \langle C_n, s_n, B\rangle\) have been projected |
|
\(B \sqsubseteq A\) |
\(-\) |
\(\langle B, r d f s: s u b C l a s s O f, A\rangle\) |
\(\left\langle A, rdfs:subClassOf^{-}, B\right\rangle\) |
||
\(A(a)\) |
\(-\) |
\(\langle a, r d f: t y p e, A\rangle\) |
\(\left\langle A, r d f: t y p e^{-}, a\right\rangle\) |
||
\(r(a, b)\) |
\(-\) |
\(\langle a, r, b\rangle\) |
- class mowl.projection.owl2vec_star.model.OWL2VecStarProjector(bidirectional_taxonomy=False, only_taxonomy=False, include_literals=False)[source]
Bases:
ProjectionModel
- Parameters
ontology (
org.semanticweb.owlapi.model.OWLOntology
) – The ontology to be processed.bidirectional_taxonomy (bool) – If true then per each SubClass edge one SuperClass edge will be generated. Default is False.
include_literals (bool) – If true the graph will also include triples involving data property assertions and annotations. Default is False.
only_taxonomy (bool) – If true, the projection will only include subClass edges
- project(ontology)[source]
Performs the ontology parsing.
- Returns
A list of triples where each triple is of the form \((head, relation, tail)\)
- Return type
List of
mowl.projection.edge.Edge