diff --git a/src/pyobo/sources/geonames/utils.py b/src/pyobo/sources/geonames/utils.py index b3b9183c..633bf3fd 100644 --- a/src/pyobo/sources/geonames/utils.py +++ b/src/pyobo/sources/geonames/utils.py @@ -8,8 +8,7 @@ from tqdm import tqdm from pyobo import Reference, Term, TypeDef, default_reference -from pyobo.struct.struct import CHARLIE_TERM, HUMAN_TERM -from pyobo.struct.vocabulary import has_contributor +from pyobo.struct.struct import CHARLIE_TERM, HUMAN_TERM, PYOBO_INJECTED from pyobo.utils.path import ensure_df PREFIX = "geonames" @@ -108,8 +107,8 @@ def get_feature_terms( yield ( Term(reference=cat) .append_parent(FEATURE_TERM) - .annotate_object(has_contributor, CHARLIE_TERM) - .append_comment("injected by PyOBO source") + .append_contributor(CHARLIE_TERM) + .append_comment(PYOBO_INJECTED) ) if features is None: features = get_features(force=force) diff --git a/src/pyobo/sources/ncbi/ncbi_gc.py b/src/pyobo/sources/ncbi/ncbi_gc.py index 9649dc1e..555a56bb 100644 --- a/src/pyobo/sources/ncbi/ncbi_gc.py +++ b/src/pyobo/sources/ncbi/ncbi_gc.py @@ -6,7 +6,7 @@ from collections.abc import Iterable from pyobo import default_reference -from pyobo.struct import CHARLIE_TERM, HUMAN_TERM, Obo, Reference, Term, TypeDef +from pyobo.struct import CHARLIE_TERM, HUMAN_TERM, PYOBO_INJECTED, Obo, Reference, Term, TypeDef from pyobo.struct.typedef import comment, has_contributor, see_also, term_replaced_by from pyobo.utils.path import ensure_path @@ -29,7 +29,7 @@ definition="Connects a taxonomy term to a genetic code translation table", domain=NCBITAXON_ROOT, range=GC_ROOT, -).annotate_object(has_contributor, CHARLIE_TERM) +).append_contributor(CHARLIE_TERM) NUCLEAR_GENETIC_CODE = default_reference( prefix=PREFIX, identifier="nuclear-genetic-code", name="nuclear genetic code translation table" @@ -120,15 +120,15 @@ def get_terms() -> Iterable[Term]: definition="A table for translating codons into amino acids. This can change for " "different taxa, or be different in different organelles that include genetic information.", ) - .annotate_object(has_contributor, CHARLIE_TERM) - .append_comment("injected by PyOBO") + .append_contributor(CHARLIE_TERM) + .append_comment(PYOBO_INJECTED) ) for reference in CATEGORY_TO_TABLES: term = Term(reference=reference) term.append_parent(GC_ROOT) - term.annotate_object(has_contributor, CHARLIE_TERM) - term.append_comment("injected by PyOBO") + term.append_contributor(CHARLIE_TERM) + term.append_comment(PYOBO_INJECTED) if substructure := CATEGORY_TO_CELLULAR_COMPONENT.get(reference): term.append_see_also(substructure) yield term diff --git a/src/pyobo/sources/nlm/utils.py b/src/pyobo/sources/nlm/utils.py index e4bd3b69..77ed71bc 100644 --- a/src/pyobo/sources/nlm/utils.py +++ b/src/pyobo/sources/nlm/utils.py @@ -6,8 +6,8 @@ from tqdm import tqdm from pyobo import Reference, Term, TypeDef, default_reference, ensure_path -from pyobo.struct.struct import CHARLIE_TERM -from pyobo.struct.typedef import has_contributor, has_end_date, has_start_date +from pyobo.struct.struct import CHARLIE_TERM, PYOBO_INJECTED +from pyobo.struct.typedef import has_end_date, has_start_date from pyobo.utils.path import ensure_df PREFIX_CATALOG = "nlm" @@ -29,16 +29,16 @@ .append_exact_match(Reference(prefix="MI", identifier="0885")) .append_exact_match(Reference(prefix="bibo", identifier="Journal")) .append_exact_match(Reference(prefix="uniprot.core", identifier="Journal")) - .annotate_object(has_contributor, CHARLIE_TERM) - .append_comment("injected by PyOBO source") + .append_contributor(CHARLIE_TERM) + .append_comment(PYOBO_INJECTED) ) PUBLISHER_TERM = ( Term(reference=default_reference(PREFIX_CATALOG, "publisher", name="publisher")) .append_exact_match(Reference(prefix="biolink", identifier="publisher")) .append_exact_match(Reference(prefix="schema", identifier="publisher")) .append_exact_match(Reference(prefix="uniprot.core", identifier="publisher")) - .annotate_object(has_contributor, CHARLIE_TERM) - .append_comment("injected by PyOBO source") + .append_contributor(CHARLIE_TERM) + .append_comment(PYOBO_INJECTED) ) diff --git a/src/pyobo/sources/signor/signor_complexes.py b/src/pyobo/sources/signor/signor_complexes.py index d52ec0ee..17d2ce0a 100644 --- a/src/pyobo/sources/signor/signor_complexes.py +++ b/src/pyobo/sources/signor/signor_complexes.py @@ -7,7 +7,7 @@ from pyobo import Obo, Reference, Term, default_reference from pyobo.sources.signor.download import DownloadKey, get_signor_df from pyobo.struct import CHARLIE_TERM, HUMAN_TERM, PYOBO_INJECTED -from pyobo.struct.typedef import exact_match, has_component, has_contributor, has_member +from pyobo.struct.typedef import exact_match, has_component, has_member __all__ = [ "SignorGetter", @@ -17,22 +17,22 @@ PROTEIN_FAMILY = ( Term(reference=default_reference(PREFIX, "protein-family")) - .annotate_object(has_contributor, CHARLIE_TERM) + .append_contributor(CHARLIE_TERM) .append_comment(PYOBO_INJECTED) ) PROTEIN_COMPLEX = ( Term(reference=default_reference(PREFIX, "protein-complex")) - .annotate_object(has_contributor, CHARLIE_TERM) + .append_contributor(CHARLIE_TERM) .append_comment(PYOBO_INJECTED) ) PHENOTYPE = ( Term(reference=default_reference(PREFIX, "phenotype")) - .annotate_object(has_contributor, CHARLIE_TERM) + .append_contributor(CHARLIE_TERM) .append_comment(PYOBO_INJECTED) ) STIMULUS = ( Term(reference=default_reference(PREFIX, "stimulus")) - .annotate_object(has_contributor, CHARLIE_TERM) + .append_contributor(CHARLIE_TERM) .append_comment(PYOBO_INJECTED) ) ROOT_TERMS = (PROTEIN_FAMILY, PROTEIN_COMPLEX, PHENOTYPE, STIMULUS) diff --git a/src/pyobo/struct/struct_utils.py b/src/pyobo/struct/struct_utils.py index 20ec250e..008d6da4 100644 --- a/src/pyobo/struct/struct_utils.py +++ b/src/pyobo/struct/struct_utils.py @@ -387,6 +387,10 @@ def annotate_object( self._extend_annotations(typedef, value, annotations) return self + def append_contributor(self, reference: ReferenceHint) -> Self: + """Append contributor.""" + return self.annotate_object(v.has_contributor, reference) + def get_see_also(self) -> list[Reference]: """Get all see also objects.""" return self.get_property_objects(v.see_also)