TermList

class pronto.TermList

A list of Term instances.

TermList behaves exactly like a list, except it contains shortcuts to generate lists of terms’ attributes.

Example

>>> nmr = Ontology('tests/resources/nmrCV.owl')
>>> type(nmr['NMR:1000031'].children)
<class 'pronto.term.TermList'>
>>> nmr['NMR:1000031'].children.id
[u'NMR:1000122', u'NMR:1000156', u'NMR:1000157', u'NMR:1000489']
>>> nmr['NMR:1400014'].relations[Relationship('is_a')]
[<NMR:1400011: cardinal part of NMR instrument>]

Tip

It is also possible to call Term methods on a TermList to create another TermList:

>>> nmr['NMR:1000031'].rchildren(3, False).rparents(3, False).id
[u'NMR:1000031']
__contains__(term)

Check if the TermList contains a term.

The method allows to check for the presence of a Term in a TermList based on a Term object or on a term accession number.

Example

>>> from pronto import *
>>> nmr = Ontology('tests/resources/nmrCV.owl')
>>> 'NMR:1000122' in nmr['NMR:1000031'].children
True
>>> nmr['NMR:1000122'] in nmr['NMR:1000031'].children
True
__init__(elements=None)

Create a new TermList.

Parameters:elements (collections.Iterable, optional) – an Iterable that yields Term objects.
Raises:TypeError – when the given elements are not instances of Term.
append(object) → None -- append object to end
extend(iterable) → None -- extend list by appending elements from the iterable
__weakref__

list of weak references to the object (if defined)

children

~TermList – the children of all the terms in the list.

desc

list – the description of all the terms in the list.

id

list – a list of id corresponding to each term of the list.

name

list – the name of all the terms in the list.

obo

list – all the terms in the term list serialized in obo.

other

list – the “other” property of all the terms in the list.

parents

~TermList – the parents of all the terms in the list.