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 default to correspond to the first-party IRI and custom to refer to the custom prefix map. The default priority list is:

    1. Custom prefix map (custom) 1. First-party IRI (default) 2. Identifiers.org / MIRIAM (miriam) 3. Ontology Lookup Service (ols) 4. OBO PURL (obofoundry) 5. Name-to-Thing (n2t) 6. BioPortal (bioportal)

  • prefix_map – A custom prefix map to go with the custom key in the priority list

  • use_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/displayImage.do?defaultImage=true&imageIndex=0&chebiId=24867’