keep_predicates
- keep_predicates(triples: Iterable[TripleType], predicates: Reference | Collection[Reference], *, progress: bool = False) Iterable[TripleType][source]
Keep triples whose predicate appear in the given references.
- Parameters:
triples – An iterable of triples
predicates – A collection of references
progress – Should a progress bar be shown?
- Returns:
A sub-iterable of triples whose predicate appear in the given references.
>>> from curies import Reference, Triple >>> from curies.vocabulary import exact_match, subclass_of >>> c1, c2, c3 = "DOID:0050577", "mesh:C562966", "DOID:225" >>> r1, r2, r3 = (Reference.from_curie(c) for c in (c1, c2, c3)) >>> m1 = Triple.from_curies(c1, exact_match.curie, c2) >>> m2 = Triple.from_curies(c2, exact_match.curie, c3) >>> m3 = Triple.from_curies(c1, subclass_of.curie, c3) >>> assert list(keep_predicates([m1, m2, m3], exact_match)) == [m1, m2]