Term

class pronto.Term

A term in an ontology.

Example

>>> ms = Ontology('tests/resources/psi-ms.obo')
>>> type(ms['MS:1000015'])
<class 'pronto.term.Term'>
__init__(id, name='', desc='', relations=None, synonyms=None, other=None)

Create a new Term.

Parameters:
  • id (str) – the Term id (e.g. “MS:1000031”)
  • name (str) – the name of the Term in human language
  • desc (str) – a description of the Term
  • relations (dict, optional) – a dictionary containing the other terms the Term is in a relationship with.
  • other (dict, optional) – other information about the term
  • synonyms (set, optional) – a list containing pronto.synonym.Synonym objects relating to the term.

Example

>>> new_term = Term('TR:001', 'new term', 'a new term')
>>> linked_term = Term('TR:002', 'other new', 'another term',
...                    { Relationship('is_a'): 'TR:001'})
__repr__()

Return repr(self).

_empty_cache()

Empty the cache of the Term’s memoized functions.

rchildren(level=-1, intermediate=True)

Create a recursive list of children.

Parameters:
  • level (int) – The depth level to continue fetching children from (default is -1, to get children to the utter depths)
  • intermediate (bool) – Also include the intermediate children (default is True)
Returns:

The recursive children of the Term following the parameters

Return type:

pronto.TermList

rparents(level=-1, intermediate=True)

Create a recursive list of children.

Note that the :param:`intermediate` can be used to include every parents to the returned list, not only the most nested ones.

Parameters:
  • level (int) – The depth level to continue fetching parents from (default is -1, to get parents to the utter depths)
  • intermediate (bool) – Also include the intermediate parents (default is True)
Returns:

The recursive children of the Term following the parameters

Return type:

pronto.TermList

__deref__

dict – the Term as a dict without circular references.

__weakref__

list of weak references to the object (if defined)

children

~TermList – The direct children of the Term.

obo

str – the Term serialized in an Obo [Term] stanza.

parents

~TermList – The direct parents of the Term.