Ontology

The Ontology contains all HPOTerm s and thus reflects the full ontology including links and information about inheritance

Note

Starting with pyhpo 4.0, the Ontology will link genes non-transitive to HPO terms. This means it will be the same behavior as the hpo3 library. See https://github.com/anergictcell/hpo/issues/44 and https://github.com/anergictcell/pyhpo/issues/26 for details about this.

Ontology class

class pyhpo.ontology.OntologyClass[source]

A linked and indexed list of interconnected HPOTerm s.

genes

Set of all genes associated with the HPOTerms

Type:

set

omim_diseases

Set of all OMIM-diseases associated with the HPOTerms

Type:

set

omim_excluded_diseases

Set of all excluded OMIM-diseases associated with the HPOTerms

Type:

set

get_hpo_object

OntologyClass.get_hpo_object(query)[source]

Matches a single HPO term based on its name, synonym or id

Parameters:

query (str or int) –

  • str HPO term Scoliosis

  • str synonym Curved spine

  • str HPO-ID HP:0002650

  • int HPO term id 2650

Returns:

A single matching HPO term instance

Return type:

HPOTerm

Raises:
  • RuntimeError – No HPO term is found for the provided query

  • TypeError – The provided query is an unsupported type and can’t be properly converted

  • ValueError – The provided HPO ID cannot be converted to the correct integer representation

Example

# Search by ID (int)
>>> ontology.get_hpo_object(3)
HP:0000003 | Multicystic kidney dysplasia

# Search by HPO-ID (string)
>>> ontology.get_hpo_object('HP:0000003')
HP:0000003 | Multicystic kidney dysplasia

# Search by term (string)
>>> ontology.get_hpo_object('Multicystic kidney dysplasia')
HP:0000003 | Multicystic kidney dysplasia

# Search by synonym (string)
>>> ontology.get_hpo_object('Multicystic renal dysplasia')
HP:0000003 | Multicystic kidney dysplasia

match

OntologyClass.match(query)[source]

Matches a single HPO term based on its name

Parameters:

query (str) – HPO term to match e.g: Abnormality of the nervous system

Returns:

A single matching HPO term instance

Return type:

HPOTerm

path

OntologyClass.path(query1, query2)[source]

Returns the shortest connection between two HPO terms

Parameters:
  • query1 (str or int) – HPO term 1, synonym or HPO-ID (HP:00001) to match HPO term id (Integer based) e.g: Abnormality of the nervous system

  • query2 (str or int) – HPO term 2, synonym or HPO-ID (HP:00001) to match HPO term id (Integer based) e.g: Abnormality of the nervous system

Return type:

Tuple[int, Tuple[HPOTerm, ...], int, int]

Returns:

  • int – Length of path

  • tuple – Tuple of HPOTerms in the path

  • int – Number of steps from term-1 to the common parent

  • int – Number of steps from term-2 to the common parent

synonym_match

OntologyClass.synonym_match(query)[source]

Searches for actual and synonym term matches If a match is found in any term, that one is returned If no actual match is found, the first match with synonyms is considered

Parameters:

query (str) – Term to search for

Returns:

A single HPO term instance

Return type:

HPOTerm

to_dataframe