Exploring the Ontology with EMMOntoPy#
This notebook shows how to use EMMOntoPy, a Python interface for OWL ontologies based on EMMO, to retrieve structured information from the domain-battery
ontology.
EMMOntoPy makes it simple to:
Retrieve ontology classes and properties by label
Access rich metadata (like
elucidation
,IEVReference
)Integrate semantic battery data into other tools or pipelines
Let’s explore the BatteryCell
class from the battery ontology.
[82]:
from ontopy import get_ontology
# Loading from web
battinfo = get_ontology('https://w3id.org/emmo/domain/battery/inferred').load()
Access a Class from the Ontology#
We start by retrieving the BatteryCell
class from the ontology. Each class has a globally unique identifier (IRI) and carries metadata that helps us understand its role in the ontology.
[ ]:
battery = battinfo.BatteryCell
# Print its IRI (unique identifier in the ontology)
print("IRI:", battery.iri)
IRI: https://w3id.org/emmo/domain/battery#battery_68ed592a_7924_45d0_a108_94d6275d57f0
View Properties Associated with the Class#
We can retrieve the object and data properties that are defined for this class using .get_class_properties()
. These properties describe the relationships and attributes a BatteryCell
can have.
[84]:
# Retrieve all properties (object & data) where BatteryCell is in the domain
print("Class Properties:")
for p in battery.get_class_properties():
print(f" - {p}")
Class Properties:
- core.altLabel
- emmo.IEVReference
- emmo.elucidation
- core.prefLabel
View Annotations Like Elucidation and Standards References#
Ontology classes often carry rich semantic annotations such as elucidation
(a human-readable explanation) or IEVReference
(a standards reference, e.g. from IEC). These are useful for interoperability and traceability.
[85]:
# Print annotation properties
print("Elucidation:", battery.elucidation)
print("IEV Reference:", battery.IEVReference)
Elucidation: [locstr('basic functional unit, consisting of an assembly of electrodes, electrolyte, container, terminals and usually separators, that is a source of electric energy obtained by direct conversion of chemical energy.', 'en')]
IEV Reference: ['https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=482-01-01']
Explore the Class Hierarchy#
The .is_a
attribute shows the direct superclass(es) of the class, while .mro()
(method resolution order) lists the full inheritance chain from the most specific to the most general.
[86]:
# Show the direct superclass(es)
print("Immediate superclasses (is_a):", battery.is_a)
# Show the method resolution order (full class inheritance chain)
print("Full inheritance chain (MRO):")
for cls in battery.mro():
print(f" - {cls}")
Immediate superclasses (is_a): [battery.Battery, electrochemistry.ElectrochemicalDevice]
Full inheritance chain (MRO):
- battery.BatteryCell
- battery.Battery
- electrochemistry.ElectrochemicalDevice
- emmo.Device
- emmo.ManufacturedProduct
- emmo.Product
- emmo.Maximal
- emmo.Fundamental
- emmo.Structural
- electrochemistry.ElectrochemicalCell
- emmo.HolisticArrangement
- emmo.HolisticSystem
- emmo.Whole
- emmo.QualifiedWhole
- emmo.Holistic
- emmo.Object
- emmo.Persistence
- emmo.Perspective
- emmo.CausalStructure
- emmo.Fusion
- emmo.Item
- emmo.EMMO
- owl.Thing
- <class 'object'>
Summary#
EMMOntoPy allows you to access structured ontology knowledge in Python with minimal effort:
Use
.iri
,.is_a
, and.elucidation
for metadataUse
.get_class_properties()
to integrate ontology structure with simulation tools, ELNs, or data pipelines
Next steps:
Build instances of
BatteryCell
using JSON-LD or RDFAnnotate test data using ontology terms
Query the ontology with SPARQL or integrate into a digital twin