HPOTerm

HPOTerm instances contain all relevant information about a single HPO term. They are part of an Ontology and contain links to parental and offspring HPOTerm s.

HPOTerm

class pyhpo.term.HPOTerm[source]

Represents an HPO Term with all metadata

Note

An HPOTerm is initialized as an empty object. Attributes are added line by line from an OBO file

all_parents

Set of direct and indirect parent HPOTerms

Note

This property is read-only

Type

set of HPOTerm

children

List of direct children HPOTerms

Type

list of HPOTerm

comment

Comments from HPO Team

Example:

Multicystic kidney dysplasia is the result of
abnormal fetal renal development in which the affected kidney
is replaced by multiple cysts and has little or no residual
function. The vast majority of multicystic kidneys are unilateral.
Multicystic kidney can be diagnosed on prenatal ultrasound.
Type

str

definition

HPO Term Definition

Example:

"Multicystic dysplasia of the kidney is characterized by
multiple cysts of varying size in the kidney and the absence of a
normal pelvicaliceal system. The condition is associated with
ureteral or ureteropelvic atresia, and the affected kidney is
nonfunctional." [HPO:curators]

Warning

The string contains double-quote enclosed sections

Type

str

genes

All genes associated with the term or its children

Note

The set is recursively calcualted the first time it is requested by retrieving all children genes as well. The updated set is then cached.

It is not possibe to remove genes from the set. Any updates will only allow addition of new genes.

Warning

Updating the associated gene set causes a recalculation of the cache and the caches of all parents, so this is a quite expensive operation and should be avoided.

Type

set of pyhpo.annotations.Gene

id

HPO Term ID

Example:

'HP:0000003'
Type

str

information_content

The information content of the HPO term for:

  • gene: float

  • omim: float

  • orpha: float

  • decipher: float

Example:

{
    'gene': 0.24,
    'omim': 0.84,
    'orpha': 0.43,
    'decipher': 0.12
}
Type

dict

name

HPO Term name

Example:

'Abnormality of body height'
Type

str

omim_diseases

All OMIM diseases associated with the term or its children

Note

The set is recursively calcualted the first time it is requested by retrieving all children OMIM diseases as well. The updated set is then cached.

It is not possibe to remove OMIM diseases from the set. Any updates will only allow addition of new omim-diseases.

Warning

Updating the associated OMIM disease set causes a recalculation of the cache and the caches of all parents, so this is a quite expensive operation and should be avoided.

Type

set of pyhpo.annotations.Omim

omim_excluded_diseases

All OMIM diseases that are excluded from the term

Note

Since excluded diseased do not follow the general model of ontology inheritance, the associated annotations are not inherited from or passed on to parents or children

Type

set of pyhpo.annotations.Omim

orpha_diseases

All Orphanet diseases associated with the term or its children

Note

The set is recursively calcualted the first time it is requested by retrieving all children Orphanet diseases as well. The updated set is then cached.

It is not possibe to remove Orphanet diseases from the set. Any updates will only allow addition of new orphanet-diseases.

Warning

Updating the associated Orphanet disease set causes a recalculation of the cache and the caches of all parents, so this is a quite expensive operation and should be avoided.

Type

set of pyhpo.annotations.Orpha

decipher_diseases

All Decipher diseases associated with the term or its children

Note

The set is recursively calcualted the first time it is requested by retrieving all children Decipher diseases as well. The updated set is then cached.

It is not possibe to remove Decipher diseases from the set. Any updates will only allow addition of new decipher-diseases.

Warning

Updating the associated Decipher disease set causes a recalculation of the cache and the caches of all parents, so this is a quite expensive operation and should be avoided.

Type

set of pyhpo.annotations.Decipher

parents

List of direct parent HPOTerms

Type

list of HPOTerm

synonym

List of synonymous names

Example:

['Multicystic dysplastic kidney', 'Multicystic kidneys',
'Multicystic renal dysplasia']
Type

list of str

xref

List of xref attributes

Type

list

is_a

List of parent HPO terms

Example:

['HP:0000107 ! Renal cyst']
Type

list of str

is_obsolete

Indicates if the HPO term is obsolete and should not be used anymore.

Note

Check the replaced_by attribute which HPO term to use instead.

Type

bool

replaced_by

Specifies which HPO term to use instead if self is obsolete.

Example:

'HP:0008665'

Warning

It is not guaranteed that this attribute is present - even for obsolete terms.

Type

str (HPOTerm.id)

is_modifier

Indicates whether the HPO is a child of a mooifier term. (read only) Modifier terms are specified in HPOTerm._modifier_ids

  • Mode of inheritance - 'HP:0000005'

  • Clinical modifier - 'HP:0012823'

  • Frequency - 'HP:0040279'

  • Clinical course - 'HP:0031797'

  • Blood group - 'HP:0032223'

  • Past medical history - 'HP:0032443'

Type

bool

_index

Integer representation of ID

Example:

3
Type

int

parent_of

HPOTerm.parent_of(other: pyhpo.term.HPOTerm) → bool[source]

Checks if self is a direct or indirect parent of other.

Parameters

other (HPOTerm) – HPOTerm to check for lineage dependency

Returns

Is the HPOTerm a direct or indirect parent of another HPOTerms

Return type

bool

child_of

HPOTerm.child_of(other: pyhpo.term.HPOTerm) → bool[source]

Checks if self is a direct or indirect child of other.

Parameters

other (HPOTerm) – HPOTerm to check for lineage dependency

Returns

Is the HPOTerm a direct or indirect child of another HPOTerms

Return type

bool

parent_ids

HPOTerm.parent_ids() → List[int][source]

List of IDs of parent HPO Terms

Returns

All ids of the direct parents

Return type

list of int

common_ancestors

HPOTerm.common_ancestors(other: pyhpo.term.HPOTerm) → Set[pyhpo.term.HPOTerm][source]

Identifies all common ancestors of two HPO terms

Parameters

other (HPOTerm) – Target HPO term for path finding

Returns

Set of common ancestor HPOTerms

Return type

set

count_parents

HPOTerm.count_parents() → int[source]

Calculates total number of ancestral HPO Terms

Returns

The number of all ancestral HPO Terms

Return type

int

longest_path_to_root

HPOTerm.longest_path_to_root() → int[source]

Calculates the longest path to root

Returns

Maximum number of nodes until the root HPOTerm

Return type

int

shortest_path_to_root

HPOTerm.shortest_path_to_root() → int[source]

Calculates the shortest path to root

Returns

Minimum number of nodes until the root HPOTerm

Return type

int

shortest_path_to_parent

HPOTerm.shortest_path_to_parent(other: pyhpo.term.HPOTerm) → Tuple[Union[int, float], Optional[Tuple[pyhpo.term.HPOTerm, ]]][source]

Calculates the shortest path to another HPO Term

Parameters

other (HPOTerm) – parent HPOTerm instance

Returns

  • int – Minimum number of nodes until the specified HPOTerm

    (float(‘inf’) if other is not a parent.)

  • tuple – Tuple of all HPOTerm instances on the path

    (None if other is not a parent)

longest_path_to_bottom

HPOTerm.longest_path_to_bottom(level: int = 0) → int[source]

Calculates how far the most distant child is apart

Parameters

level (int) – Offset level to indicate for calculation Default: 0

Returns

Number of steps to most distant child

Return type

int

path_to_other

HPOTerm.path_to_other(other: pyhpo.term.HPOTerm) → Tuple[int, Tuple[pyhpo.term.HPOTerm, ], int, int][source]

Identifies the shortest connection between two HPO terms

Parameters

other (HPOTerm) – Target HPO term for path finding

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

hierarchy

HPOTerm.hierarchy() → Tuple[Tuple[pyhpo.term.HPOTerm, ], ][source]

Calculates all paths from current term to Root term and returns each path as a Tuple of HPOTerms

Note

This function is expensive. To ensure better performance, the result is cached and all subsequent calls utilize the cache. Don’t call hierarchy before the Ontology is fully built with all items.

Returns

Tuple of paths. Each path is another tuple made up of HPOTerms

Return type

tuple of tuple of HPOTerm s

similarity_score

HPOTerm.similarity_score(other: pyhpo.term.HPOTerm, kind: str = '', method: str = '') → float[source]

According to Robinson et al, American Journal of Human Genetics, (2008) and Resnik et at, Proceedings of the 14th IJCAI, (1995)

Parameters
  • kind (str, default omim) –

    Which kind of information content should be calculated.

    Available option:

    • omim (Default)

    • orpha

    • decipher

    • gene

  • method (string, default resnik) –

    The method to use to calculate the similarity.

    Available options:

    • resnik - Resnik P, Proceedings of the 14th IJCAI, (1995)

    • lin - Lin D, Proceedings of the 15th ICML, (1998)

    • jc - Jiang J, Conrath D, ROCLING X, (1997) Implementation according to R source code

    • jc2 - Jiang J, Conrath D, ROCLING X, (1997) Implementation according to paper from R hposim library Deng Y, et. al., PLoS One, (2015)

    • rel - Relevance measure - Schlicker A, et.al., BMC Bioinformatics, (2006)

    • ic - Information coefficient - Li B, et. al., arXiv, (2010)

    • graphic - Graph based Information coefficient - Deng Y, et. al., PLoS One, (2015)

    • dist - Distance between terms

Returns

The similarity score of the two terms.

Return type

float

toJSON

HPOTerm.toJSON(verbose: bool = False) → Dict[source]

Creates a JSON-like object of the HPOTerm

Parameters

verbose (bool, default False) – Include extra properties

Returns

A dictionary with the main properties of the HPOTerm

Return type

dict

Example:

>>> terms[2].toJSON()
{
    'name': 'Abnormality of body height',
    'id': 'HP:0000002',
    'int': 2
}

>>> terms[2].toJSON(verbose=True)
{
    'name': 'Abnormality of body height',
    'synonym': ['Abnormality of body height'],
    'comment': None,
    'def': '"Deviation from the norm of height with respect [...]',
    'xref': ['UMLS:C4025901'],
    'is_a': ['HP:0001507 ! Growth abnormality'],
    'id': 'HP:0000002',
    'int': 2
}

Class methods

id_from_string

static HPOTerm.id_from_string(hpo_string: str) → int[source]

Formats the HPO-type Term-ID into an integer id

Parameters

hpo_string (str) –

HPO term ID.

(e.g.: HP:000001)

Returns

Integer representation of provided HPO ID

(e.g.: 1)

Return type

int

parse_synonym

static HPOTerm.parse_synonym(synonym: str) → str[source]

Extracts the synonym from the synonym data line in the obo file format

Parameters

synonym (str) –

value part of synonym-data line of obo file

e.g: “Multicystic dysplastic kidney” EXACT []

Returns

Actual synonym title

e.g.: Multicystic dysplastic kidney

Return type

str