diff --git a/src/pyobo/reader.py b/src/pyobo/reader.py index dc32c49d..a7fabc58 100644 --- a/src/pyobo/reader.py +++ b/src/pyobo/reader.py @@ -293,12 +293,12 @@ def iterate_graph_synonym_typedefs( for s in graph.graph.get("synonymtypedef", []): sid, name = s.split(" ", 1) name = name.strip().strip('"') - if ":" not in sid: # assume it's ad-hoc - reference = Reference(prefix=ontology_prefix, identifier=sid, name=name) - else: # assume it's a curie + if ":" in sid: # assume it's a curie reference = Reference.from_curie( sid, name=name, strict=strict, ontology_prefix=ontology_prefix ) + else: + reference = default_reference(ontology_prefix, sid, name=name) if reference is None: if strict: diff --git a/src/pyobo/struct/reference.py b/src/pyobo/struct/reference.py index 0d82ee73..2eb104db 100644 --- a/src/pyobo/struct/reference.py +++ b/src/pyobo/struct/reference.py @@ -93,38 +93,12 @@ def from_curie( # type:ignore[override] prefix, identifier = normalize_curie( curie, strict=strict, ontology_prefix=ontology_prefix, node=node ) - return cls._materialize(prefix=prefix, identifier=identifier, name=name, auto=auto) - - @classmethod - def from_iri( - cls, - iri: str, - name: str | None = None, - *, - auto: bool = False, - ) -> Reference | None: - """Get a reference from an IRI using the Bioregistry. - - :param iri: The IRI to parse - :param name: The name associated with the CURIE - :param auto: Automatically look up name - """ - prefix, identifier = bioregistry.parse_iri(iri) - return cls._materialize(prefix=prefix, identifier=identifier, name=name, auto=auto) - - @classmethod - def _materialize( - cls, - prefix: str | None, - identifier: str | None, - name: str | None = None, - *, - auto: bool = False, - ) -> Reference | None: if prefix is None or identifier is None: return None if name is None and auto: - return cls.auto(prefix=prefix, identifier=identifier) + from ..api import get_name + + name = get_name(prefix, identifier) return cls.model_validate({"prefix": prefix, "identifier": identifier, "name": name}) @property