EDAM Ontology Python Package
The edam-ontology library provides versioned, Python-packaged data for the EDAM ontology (http://edamontology.org/). It offers convenient access to the ontology as an `owlready2` World object, enabling programmatic querying and navigation. The current version is 1.25.3, with releases typically tied to new EDAM ontology versions and Python compatibility updates.
Common errors
-
ModuleNotFoundError: No module named 'edam_ontology'
cause The `edam-ontology` package is not installed or the current Python environment does not have access to it.fixEnsure the package is installed using `pip install edam-ontology` or activate the correct Python virtual environment where it is installed. -
ImportError: cannot import name 'EDAM' from 'edam_ontology'
cause This usually indicates an older version of `edam-ontology` that does not expose the `EDAM` object directly, or a corrupted installation.fixUpgrade to the latest version of the library using `pip install --upgrade edam-ontology`. If the problem persists, try a clean reinstall: `pip uninstall edam-ontology && pip install edam-ontology`. -
TypeError: 'owlready2.entity.ThingClass' object is not callable
cause You are trying to call an EDAM class directly, expecting it to be a function or a constructor, instead of treating it as an `owlready2` class object.fixWhen accessing EDAM entities like `EDAM.data` or `EDAM.tool`, these are `owlready2` class objects. Use their properties (e.g., `EDAM.data.label.first()`) or `owlready2` methods to query them, rather than attempting to call them like `EDAM.data()`.
Warnings
- breaking Version 1.25.3 dropped support for Python 3.5-3.8. The library now requires Python 3.9 or newer.
- gotcha The `EDAM` object is an `owlready2.World` instance. Effective use of the ontology requires familiarity with `owlready2`'s API for querying, navigating, and manipulating OWL ontologies.
- gotcha Loading the full EDAM ontology into memory (via `edam_ontology.EDAM`) can consume significant RAM (several hundred MBs), especially in resource-constrained environments.
Install
-
pip install edam-ontology
Imports
- EDAM
from edam_ontology import EDAM
- EDAM_ONTOLOGY_VERSION
from edam_ontology import EDAM_ONTOLOGY_VERSION
Quickstart
from edam_ontology import EDAM, EDAM_ONTOLOGY_VERSION
print(f"EDAM Ontology version: {EDAM_ONTOLOGY_VERSION}")
# EDAM is an OWLReady2 World object that can be queried.
# For example, count all individuals (entities) in the ontology:
num_entities = len(EDAM.individuals())
print(f"Number of EDAM entities: {num_entities}")
# Accessing a specific class (e.g., 'data'):
data_class = EDAM.data
if data_class:
print(f"Found EDAM class: {data_class.label.first()}")
else:
print("EDAM.data class not found.")