TermSet¶
- class pronto.TermSet[source]¶
A specialized mutable set to store
Term
instances.- __eq__(other)¶
Return self==value.
- __ge__(other)¶
Return self>=value.
- __gt__(other)¶
Return self>value.
- __hash__ = None¶
- __le__(other)¶
Return self<=value.
- __lt__(other)¶
Return self<value.
- __repr__()¶
Return repr(self).
- classmethod _from_iterable(it)¶
Construct an instance of the class from any iterable input.
Must override this method if the class constructor signature does not accept an iterable for an input.
- _hash()¶
Compute the hash value of a set.
Note that we don’t define __hash__: not all sets are hashable. But if you define a hashable set type, its __hash__ should call this function.
This must be compatible __eq__.
All sets ought to compare equal if they contain the same elements, regardless of how they are implemented, and regardless of the order of the elements; so there’s not much freedom for __eq__ or __hash__. We match the algorithm used by the built-in frozenset type.
- isdisjoint(other)¶
Return True if two sets have a null intersection.
- pop() _E ¶
Return the popped value. Raise KeyError if empty.
- remove(entity: _E)¶
Remove an element. If not a member, raise a KeyError.
- subclasses(distance: int | None = None, with_self: bool = True) SubclassesIterator [source]¶
Get an iterator over the subclasses of all terms in the set.
Caution
Contrary to
pronto.Term.subclasses
, this method does not return a handler that lets you edit the subclasses directly. Adding a new subclass to all the members of the set must be done explicitly.
- superclasses(distance: int | None = None, with_self: bool = True) SuperclassesIterator [source]¶
Get an iterator over the superclasses of all terms in the set.
Caution
Contrary to
pronto.Term.superclasses
, this method does not return a handler that lets you edit the superclasses directly. Adding a new superclass to all the members of the set must be done explicitly.Example
>>> ms = pronto.Ontology("ms.obo") >>> s = pronto.TermSet({ms['MS:1000122'], ms['MS:1000124']}) >>> s.superclasses(with_self=False).to_set().ids frozenset({'MS:1000031'}) >>> ms["MS:1000031"] Term('MS:1000031', name='instrument model')