get_iri
- get_iri(prefix: str, identifier: str | None = None, *, priority: Sequence[str] | None = None, prefix_map: Mapping[str, str] | None = None, use_bioregistry_io: bool = True, provider: str | None = None) str | None[source]
Get the best link for the CURIE, if possible.
- Parameters:
prefix – The prefix in the CURIE
identifier – The identifier in the CURIE. If identifier is given as None, then this function will assume that the first argument (
prefix) is actually a full CURIE.priority –
A user-defined priority list. In addition to the metaprefixes in the Bioregistry corresponding to resources that are resolvers/lookup services, you can also use
defaultto correspond to the first-party IRI andcustomto refer to the custom prefix map. The default priority list is:Custom prefix map (
custom)First-party IRI (
default)Identifiers.org / MIRIAM (
miriam)Ontology Lookup Service (
ols)OBO PURL (
obofoundry)Name-to-Thing (
n2t)BioPortal (
bioportal)
prefix_map – A custom prefix map to go with the
customkey in the priority listuse_bioregistry_io – Should the bioregistry resolution IRI be used? Defaults to true.
provider – The provider code to use for a custom provider
- Returns:
The best possible IRI that can be generated based on the priority list.
A pre-parse CURIE can be given as the first two arguments
>>> get_iri("chebi", "24867") 'http://purl.obolibrary.org/obo/CHEBI_24867'
A CURIE can be given directly as a single argument
>>> get_iri("chebi:24867") 'http://purl.obolibrary.org/obo/CHEBI_24867'
A priority list can be given
>>> priority = ["miriam", "default", "bioregistry"] >>> get_iri("chebi:24867", priority=priority) 'https://identifiers.org/CHEBI:24867'
A custom prefix map can be supplied
>>> prefix_map = {"chebi": "https://example.org/chebi/"} >>> get_iri("chebi:24867", prefix_map=prefix_map) 'https://example.org/chebi/24867'
A custom prefix map can be supplied in combination with a priority list
>>> prefix_map = {"lipidmaps": "https://example.org/lipidmaps/"} >>> priority = ["obofoundry", "custom", "default", "bioregistry"] >>> get_iri("chebi:24867", prefix_map=prefix_map, priority=priority) 'http://purl.obolibrary.org/obo/CHEBI_24867' >>> get_iri("lipidmaps:1234", prefix_map=prefix_map, priority=priority) 'https://example.org/lipidmaps/1234'
A custom provider is given, which makes the Bioregistry very extensible
>>> get_iri("chebi:24867", provider="chebi-img") 'https://www.ebi.ac.uk/chebi/backend/api/public/compound/24867/structure/?width=300&height=300'