keep_object_prefixes
- keep_object_prefixes(triples: Iterable[TripleType], prefixes: str | Iterable[str], *, progress: bool = False) Iterable[TripleType][source]
Keep triples whose objects’ prefixes are in the given prefixes.
- Parameters:
triples – An iterable of triples
prefixes – A set of prefixes to use for filtering the triples
progress – Should a progress bar be shown?
- Returns:
A sub-iterable of triples whose objects’ prefixes are in the given prefixes
>>> from curies import Triple >>> from curies.vocabulary import exact_match >>> c1, c2, c3 = "DOID:0050577", "mesh:C562966", "umls:C4551571" >>> m1 = Triple.from_curies(c1, exact_match.curie, c2) >>> m2 = Triple.from_curies(c2, exact_match.curie, c3) >>> m3 = Triple.from_curies(c1, exact_match.curie, c3) >>> assert list(keep_object_prefixes([m1, m2, m3], {"umls"})) == [m2, m3]