Scripts
Standalone utility scripts for one-off data preparation tasks. These are not part of the deployed
application and require the optional scripts dependency group:
poetry install --with scripts
create_cell_ontology_resource.py
Generates the Cell Type Ontology resource JSON consumed by the CAS API from a CL OWL file.
The output JSON contains five precomputed fields:
ancestors_dictionary— maps each CL term to its ordered list of ancestorscell_ontology_term_id_to_cell_type— maps each CL term to its human-readable labelchildren_dictionary— maps each CL term to its direct childrenshortest_path_lengths_from_cell_root— BFS distance fromCL:0000000to each termlongest_path_lengths_from_cell_root— longest DAG path fromCL:0000000to each term
Usage
python scripts/create_cell_ontology_resource.py \
--owl-url https://github.com/obophenotype/cell-ontology/releases/download/v2025-07-30/cl.owl \
--output gs://your-bucket/path/to/cell_ontology_resource.json
Arguments
- --owl-url
URL or local filesystem path to the CL OWL file. Accepts any URL supported by
owlready2.
- --output
Destination file path for the resulting JSON. Accepts local paths or GCS URIs (
gs://bucket/path/resource.json) viasmart-open.
Output
The script writes a single JSON file. The resource must then be uploaded to the
OntologicalColumn record in the database (via the Admin interface) and the GCS path stored
in OntologicalColumn.ontology_resource_name so the API can look it up by name.