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.
-
__le__
(other)¶ Return self<=value.
-
__lt__
(other)¶ Return self<value.
-
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.
-
discard
(term: pronto.term.Term) → None[source]¶ Remove an element. Do not raise an exception if absent.
-
subclasses
(distance: Optional[int] = None, with_self: bool = True) → pronto.logic.lineage.SubclassesIterator[source]¶ Get an iterator over the subclasses of all terms in the set.
-
superclasses
(distance: Optional[int] = None, with_self: bool = True) → pronto.logic.lineage.SubclassesIterator[source]¶ Get an iterator over the superclasses of all terms in the set.
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')
-