exclude_prefixes_both
- exclude_prefixes_both(triples: Iterable[TripleType], prefixes: str | Iterable[str], *, progress: bool = False) Iterable[TripleType][source]
Exclude triples whose subjects’ and 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 subjects’ and objects’ prefixes are not 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(exclude_prefixes_both([m1, m2, m3], {"umls"})) == [m1] >>> assert list(exclude_prefixes_both([m1, m2, m3], {"DOID"})) == [m2] >>> assert list(exclude_prefixes_both([m1, m2, m3], {"mesh"})) == [m3]