Getting started

Installation

hpo3 is provided as binary wheels for most platforms on PyPI, so in most cases you can just run

pip install hpo3

(For macOS, only Python 3.10 and 3.11 are supported, for both x64 and arm at the moment.)

Initializing the Ontology

hpo3 ships with a prebuilt HPO Ontology by default, so you can start right away.

from pyhpo import Ontology
Ontology()

# iterating all HPO terms
for term in Ontology:
    print(term.name)

# get a single term based on their HPO ID
term = Ontology[118]

# or by using the full Term ID
term = Ontology.get_hpo_object("HP:0000118")

Updating the Ontology

While I try to keep the HPO ontology version updated, it might become outdated at some point. You can always check the used version:

from pyhpo import Ontology
Ontology()
Ontology.version()
# => '2023-04-05'

If you require a newer version of the ontology, you can download the following files from JAX directly and load them manually:

Alternatively you can use phenotype_to_genes.txt (from https://hpo.jax.org/app/data/annotations), that way the HPOTerms are transitively linked to genes. See https://github.com/anergictcell/hpo/issues/44 for details.

from pyhpo import Ontology
Ontology("/path/to/folder/with/ontology/")