URI Helpers

CURIE / URI helpers - expansion & compaction.

uri_to_curie(uri: str) tuple[str, str, str][source]

Convert a URI to (curie, prefix, namespace) via bioregistry.

Falls back to splitting on # or / when bioregistry is unavailable or the URI is unknown.

make_expander(context: dict[str, str], br_map: dict[str, str] | None = None) Callable[[str], str][source]

Return a cached CURIE -> URI expander function.

The returned closure looks up context first, then br_map. Already-expanded URIs are returned unchanged. Results are cached for the lifetime of the closure.

expand_curie(curie: str, context: dict[str, str]) str[source]

Expand a CURIE using the JSON-LD @context, returning a URI.

If curie is already a full URI it is returned unchanged.

expand_curie_bioregistry(value: str) str[source]

Expand a CURIE to a full URI using bioregistry only.

If value is already a full URI it is returned unchanged. If the prefix is unknown the original string is returned.