Manager

class Manager(registry: None | str | Path | Mapping[str, Resource] = None, metaregistry: None | str | Path | Mapping[str, Registry] = None, collections: None | str | Path | Mapping[str, Collection] = None, contexts: None | str | Path | Mapping[str, Context] = None, mismatches: Mapping[str, Mapping[str, set[str]]] | None = None, version_mappings: Mapping[str, Mapping[str, set[str]]] | None = None, provided_by_mappings: Mapping[str, Mapping[str, set[str]]] | None = None, base_url: str | None = None)[source]

Bases: object

A manager for functionality related to a metaregistry.

Instantiate a registry manager.

Parameters:
  • registry – A custom registry. If none given, defaults to the Bioregistry.

  • metaregistry – A custom metaregistry. If none, defaults to the Bioregistry’s metaregistry.

  • collections – A custom collections dictionary. If none, defaults to the Bioregistry’s collections.

  • contexts – A custom contexts dictionary. If none, defaults to the Bioregistry’s contexts.

  • mismatches – A custom mismatches dictionary. If none, defaults to the Bioregistry’s mismatches.

  • base_url – The base URL.

Attributes Summary

converter

Get the default converter.

Methods Summary

add_collection(collection)

Add a collection.

add_resource(resource)

Add a custom resource to the manager.

add_to_collection(collection, resource)

Add a resource to the collection.

compress(-> str)

Parse a compact uniform resource identifier (CURIE) from a URI.

count_mappings([include_bioregistry])

Count the mappings for each registry.

get_appears_in(prefix)

Return a list of resources that this resource (has been annotated to) depends on.

get_bioportal_iri(prefix, identifier)

Get the Bioportal URL for the given CURIE.

get_bioregistry_iri(prefix, identifier)

Get a Bioregistry link.

get_canonical_for(prefix)

Get the prefixes for which this is annotated as canonical.

get_collection_first_party(collection[, ...])

Get a mapping from prefix to first-party or not.

get_collection_indirect_dependencies(collection)

Get all the "depends on" recursively for a collection.

get_collection_name(identifier)

Get a collection's name.

get_context(key)

Get a prescriptive context.

get_context_artifacts(key[, include_synonyms])

Get a prescriptive prefix map and pattern map.

get_converter(*[, prefix_priority, ...])

Get a converter from this manager.

get_converter_from_context(context[, ...])

Get a converter based on a context.

get_curie_pattern(prefix, *[, use_preferred])

Get the CURIE pattern for this resource.

get_default_iri(prefix, identifier)

Get the default URL for the given CURIE.

get_depends_on(prefix)

Return a list of resources that this resource (has been annotated to) depends on.

get_description(prefix, *[, use_markdown])

Get the description for the given prefix, if it's available.

get_example(prefix)

Get an example identifier, if it's available.

get_external(prefix, metaprefix)

Get the external data for the entry.

get_external_mappings(source_metaprefix, ...)

Get mappings between two external registries.

get_formatted_iri(metaprefix, prefix, identifier)

Get an IRI using the format in the metaregistry.

get_has_canonical(prefix)

Get the canonical prefix.

get_has_parts(prefix)

Get the children resources, if annotated.

get_homepage(-> str)

Get the description for the given prefix, if it's available.

get_in_collections(prefix)

Get the identifiers for collections the prefix is in.

get_indirect_dependencies(prefixes)

Get all the "depends on" recursively for a list of prefixes.

get_internal_prefix_map()

Get an internal prefix map for RDF and SSSOM dumps.

get_iri(prefix[, identifier, priority, ...])

Get the best link for the CURIE pair, if possible.

get_keyword_to_resources()

Get a dictionary from keywords to resources.

get_keywords(prefix)

Get keywords associated with a given prefix, if available.

get_logo(prefix)

Get the logo for the resource, if it's available.

get_mailing_list(prefix)

Get the mailing list for the resource, if it's available.

get_mapped_prefix(prefix, metaprefix, *[, ...])

Get the prefix mapped into another registry.

get_miriam_curie(prefix, identifier)

Get the identifiers.org CURIE for the given CURIE.

get_miriam_iri(prefix, identifier)

Get the identifiers.org URL for the given CURIE.

get_n2t_iri(prefix, identifier)

Get the name-to-thing URL for the given CURIE.

get_name(...)

Get the name for the given prefix, if it's available.

get_namespace_in_lui(-> bool | None)

Get the name for the given prefix, if it's available.

get_obo_health_url(prefix)

Get the OBO community health badge.

get_obofoundry_iri(prefix, identifier)

Get the OBO Foundry URL if possible.

get_ols_iri(prefix, identifier)

Get the OLS URL if possible.

get_part_of(prefix)

Get the parent resource, if annotated.

get_parts_collections()

Group resources' prefixes based on their part_of entries.

get_pattern(prefix)

Get the pattern for the given prefix, if it's available.

get_pattern_map(*[, prefix_priority, ...])

Get a mapping from prefixes to their regular expression patterns.

get_preferred_prefix(prefix)

Get the preferred prefix (e.g., with stylization) if it exists.

get_prefix_map(*[, uri_prefix_priority, ...])

Get a mapping from Bioregistry prefixes to their URI prefixes .

get_provided_by(prefix)

Get the resources that provide for the given prefix, or return none if the prefix can't be looked up.

get_provider_functions()

Return a mapping of provider functions.

get_providers(prefix, identifier)

Get all providers for the CURIE.

get_providers_list(prefix, identifier, *[, ...])

Get all providers for the CURIE.

get_provides_for(prefix)

Get the resource that the given prefix provides for, or return none if not a provider.

get_rdf_uri(prefix, identifier)

Get the RDF URI for the given CURIE.

get_registry(...)

Get the metaregistry entry for the given prefix.

get_registry_description(metaprefix)

Get the registry description.

get_registry_homepage(-> str)

Get the registry homepage.

get_registry_invmap(metaprefix[, ...])

Get a mapping from prefixes in another registry to Bioregistry prefixes.

get_registry_map(metaprefix, *[, ...])

Get a mapping from the Bioregistry prefixes to prefixes in another registry.

get_registry_name(-> str)

Get the registry name.

get_registry_provider_uri_format(metaprefix, ...)

Get the URL for the resource inside registry, if available.

get_registry_short_name(metaprefix)

Get the registry short name.

get_registry_short_name_to_prefix(metaprefix)

Get a mapping from short names in an external registry to their associated prefixes in the external registry.

get_registry_uri(metaprefix, prefix, identifier)

Get the URL to resolve the given prefix/identifier pair with the given resolver.

get_resource(...)

Get the Bioregistry entry for the given prefix.

get_resources_with_keyword(keyword)

Get resources with the given keyword.

get_reverse_prefix_map([include_prefixes, ...])

Get a reverse prefix map, pointing to canonical prefixes.

get_rrid_iri(prefix, identifier)

Get the RRID URL for the given CURIE.

get_scholia_iri(prefix, identifier)

Get a Scholia IRI, if possible.

get_synonyms(prefix)

Get the synonyms for a given prefix, if available.

get_uri_format(prefix[, priority])

Get the URI format string for the given prefix, if it's available.

get_uri_prefix(-> str)

Get a well-formed URI prefix, if available.

get_versions()

Get a map of prefixes to versions.

has_no_terms(prefix)

Get if the entry has been annotated to not have own terms.

is_deprecated(prefix)

Return if the given prefix corresponds to a deprecated resource.

is_novel(prefix)

Check if the prefix is novel to the Bioregistry, i.e., it has no external mappings.

is_standardizable_curie(curie)

Check if a CURIE is validatable, but not necessarily standardized.

is_standardizable_identifier(prefix, identifier)

Check if the identifier is standardizable.

is_valid_curie(curie)

Check if a CURIE is standardized and valid.

is_valid_identifier(prefix, identifier)

Check if the pre-parsed CURIE is standardized valid.

lookup_from(metaprefix, metaidentifier[, ...])

Get the bioregistry prefix from an external prefix.

make_preferred(t[, use_preferred])

Replace a reference tuple's prefix with a preferred one.

normalize_curie(-> str)

Normalize the prefix and identifier in the CURIE.

normalize_parsed_curie(...)

Normalize a prefix/identifier pair.

normalize_prefix(-> str)

Get the normalized prefix, or return None if not registered.

parse_curie(...)

Parse a CURIE and normalize its prefix and identifier.

parse_uri(-> ~curies.api.ReferenceTuple | None)

Parse a compact identifier from a URI.

rasterize()

Build a dictionary representing the fully constituted registry.

rasterized_resource(resource)

Rasterize a resource.

read_contributors([direct_only])

Get a mapping from contributor ORCID identifiers to author objects.

write_collections()

Write collections.

write_registry()

Write the registry.

Attributes Documentation

converter

Get the default converter.

Methods Documentation

add_collection(collection: Collection) None[source]

Add a collection.

add_resource(resource: Resource) None[source]

Add a custom resource to the manager.

add_to_collection(collection: str | Collection, resource: str | Resource) None[source]

Add a resource to the collection.

compress(uri: str, *, use_preferred: bool = False, strict: Literal[True] = True) str[source]
compress(uri: str, *, use_preferred: bool = False, strict: Literal[False] = False) str | None

Parse a compact uniform resource identifier (CURIE) from a URI.

Parameters:
  • uri – A valid URI

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

Returns:

A CURIE, if the URI can be parsed

URI from an OBO PURL:

>>> from bioregistry import manager
>>> manager.compress("http://purl.obolibrary.org/obo/DRON_00023232")
'dron:00023232'

URI from the OLS:

>>> manager.compress(
...     "https://www.ebi.ac.uk/ols/ontologies/ecao/terms?iri=http://purl.obolibrary.org/obo/ECAO_1"
... )  # noqa:E501
'ecao:1'

URI from native provider

>>> manager.compress("https://www.alzforum.org/mutations/1234")
'alzforum.mutation:1234'

Dog food:

>>> manager.compress("https://bioregistry.io/DRON:00023232")
'dron:00023232'

IRIs from Identifiers.org (https and http, colon and slash):

>>> manager.compress("https://identifiers.org/aop.relationships:5")
'aop.relationships:5'
>>> manager.compress("http://identifiers.org/aop.relationships:5")
'aop.relationships:5'
>>> manager.compress("https://identifiers.org/aop.relationships/5")
'aop.relationships:5'
>>> manager.compress("http://identifiers.org/aop.relationships/5")
'aop.relationships:5'

URI from N2T

>>> manager.compress("https://n2t.net/aop.relationships:5")
'aop.relationships:5'

URI from an OBO PURL (with preferred prefix)

>>> manager.compress("http://purl.obolibrary.org/obo/DRON_00023232", use_preferred=True)
'DRON:00023232'
count_mappings(include_bioregistry: bool = True) Counter[str][source]

Count the mappings for each registry.

get_appears_in(prefix: str) list[str] | None[source]

Return a list of resources that this resource (has been annotated to) depends on.

This is complementary to get_depends_on().

Parameters:

prefix – The prefix to look up

Returns:

The list of resources this prefix has been annotated to appear in. This list could be incomplete, since curation of these fields can easily get out of sync with curation of the resource itself. However, false positives should be pretty rare.

get_bioportal_iri(prefix: str, identifier: str) str | None[source]

Get the Bioportal URL for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A link to the Bioportal page

>>> from bioregistry import manager
>>> manager.get_bioportal_iri("chebi", "24431")
'https://bioportal.bioontology.org/ontologies/CHEBI/?p=classes&conceptid=http://purl.obolibrary.org/obo/CHEBI_24431'
get_bioregistry_iri(prefix: str, identifier: str) str | None[source]

Get a Bioregistry link.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A link to the Bioregistry resolver

get_canonical_for(prefix: str) list[str] | None[source]

Get the prefixes for which this is annotated as canonical.

get_collection_first_party(collection: str | Collection, skip_org_rors: set[str] | None = None) dict[str, bool][source]

Get a mapping from prefix to first-party or not.

A prefix is first party if:

  1. One of the maintainers of the collection is also a contact or contact extra

  2. One of the organizations of the collection is also an organization of the record

get_collection_indirect_dependencies(collection: str | Collection) list[Resource][source]

Get all the “depends on” recursively for a collection.

get_collection_name(identifier: str) str[source]

Get a collection’s name.

get_context(key: str) Context | None[source]

Get a prescriptive context.

Parameters:

key – The identifier for the prescriptive context, e.g., obo.

Returns:

A prescriptive context object, if available

get_context_artifacts(key: str, include_synonyms: bool | None = None) tuple[Mapping[str, str], Mapping[str, str]][source]

Get a prescriptive prefix map and pattern map.

get_converter(*, prefix_priority: Sequence[str] | None = None, uri_prefix_priority: Sequence[str] | None = None, include_prefixes: bool = False, strict: bool = False, remapping: Mapping[str, str] | None = None, rewiring: Mapping[str, str] | None = None, blacklist: Collection[str] | None = None, enforce_w3c: bool = False) Converter[source]

Get a converter from this manager.

Parameters:
  • prefix_priority – The order of metaprefixes OR “preferred” for choosing a primary prefix OR “default” for Bioregistry prefixes

  • uri_prefix_priority – The order of metaprefixes for choosing the primary URI prefix OR “default” for Bioregistry prefixes

  • include_prefixes – Should prefixes be included with colon delimiters? Setting this to true makes an “omni”-reverse prefix map that can be used to parse both URIs and CURIEs

  • strict – If true, errors on URI prefix collisions. If false, sends logging and skips them.

  • remapping – A mapping from bioregistry prefixes to preferred prefixes.

  • rewiring – A mapping from bioregistry prefixes to new URI prefixes.

  • blacklist – A collection of prefixes to skip

  • enforce_w3c – Should non-W3C-compliant prefix synoynms be removed?

Returns:

A list of records for curies.Converter

get_converter_from_context(context: str | Context, strict: bool = False, include_prefixes: bool = False) Converter[source]

Get a converter based on a context.

get_curie_pattern(prefix: str, *, use_preferred: bool = False) str | None[source]

Get the CURIE pattern for this resource.

Parameters:
  • prefix – The prefix to look up

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

Returns:

The regular expression pattern to match CURIEs against

>>> from bioregistry import manager
>>> manager.get_curie_pattern("go")
'^go:\\d{7}$'
>>> manager.get_curie_pattern("go", use_preferred=True)
'^GO:\\d{7}$'
>>> manager.get_curie_pattern("kegg.compound")
'^kegg\\.compound:C\\d+$'
>>> manager.get_curie_pattern("KEGG.COMPOUND")
'^kegg\\.compound:C\\d+$'
get_default_iri(prefix: str, identifier: str) str | None[source]

Get the default URL for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A IRI string corresponding to the default provider, if available.

>>> from bioregistry import manager
>>> manager.get_default_iri("chebi", "24867")
'http://purl.obolibrary.org/obo/CHEBI_24867'
get_depends_on(prefix: str) list[str] | None[source]

Return a list of resources that this resource (has been annotated to) depends on.

This is complementary to get_appears_in().

Parameters:

prefix – The prefix to look up

Returns:

The list of resources this prefix has been annotated to depend on. This list could be incomplete, since curation of these fields can easily get out of sync with curation of the resource itself. However, false positives should be pretty rare.

>>> from bioregistry import manager
>>> assert "bfo" in manager.get_depends_on("foodon")
get_description(prefix: str, *, use_markdown: bool = False) str | None[source]

Get the description for the given prefix, if it’s available.

get_example(prefix: str) str | None[source]

Get an example identifier, if it’s available.

get_external(prefix: str, metaprefix: str) Mapping[str, Any][source]

Get the external data for the entry.

get_external_mappings(source_metaprefix: str, target_metaprefix: str) MappingsDiff[source]

Get mappings between two external registries.

get_formatted_iri(metaprefix: str, prefix: str, identifier: str) str | None[source]

Get an IRI using the format in the metaregistry.

Parameters:
  • metaprefix – The metaprefix of the registry in the metaregistry

  • prefix – A bioregistry prefix (will be mapped to the external one automatically)

  • identifier – The identifier for the entity

Returns:

An IRI generated from the resolver_url format string of the registry, if it exists.

>>> from bioregistry import manager
>>> manager.get_formatted_iri("miriam", "hgnc", "16793")
'https://identifiers.org/hgnc:16793'
>>> manager.get_formatted_iri("n2t", "hgnc", "16793")
'https://n2t.net/hgnc:16793'
>>> manager.get_formatted_iri("obofoundry", "fbbt", "00007294")
'http://purl.obolibrary.org/obo/FBbt_00007294'
get_has_canonical(prefix: str) str | None[source]

Get the canonical prefix.

get_has_parts(prefix: str) list[str] | None[source]

Get the children resources, if annotated.

get_homepage(prefix: str, *, strict: Literal[True] = True) str[source]
get_homepage(prefix: str, *, strict: Literal[False] = False) str | None

Get the description for the given prefix, if it’s available.

get_in_collections(prefix: str) list[str] | None[source]

Get the identifiers for collections the prefix is in.

get_indirect_dependencies(prefixes: list[str]) list[Resource][source]

Get all the “depends on” recursively for a list of prefixes.

get_internal_prefix_map() Mapping[str, str][source]

Get an internal prefix map for RDF and SSSOM dumps.

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 pair, 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)

    2. First-party IRI (default)

    3. Identifiers.org / MIRIAM (miriam)

    4. Ontology Lookup Service (ols)

    5. OBO PURL (obofoundry)

    6. Name-to-Thing (n2t)

    7. 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

>>> from bioregistry import manager
>>> manager.get_iri("chebi", "24867")
'http://purl.obolibrary.org/obo/CHEBI_24867'

A CURIE can be given directly as a single argument

>>> manager.get_iri("chebi:24867")
'http://purl.obolibrary.org/obo/CHEBI_24867'

A priority list can be given

>>> priority = ["miriam", "default", "bioregistry"]
>>> manager.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/"}
>>> manager.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"]
>>> manager.get_iri("chebi:24867", prefix_map=prefix_map, priority=priority)
'http://purl.obolibrary.org/obo/CHEBI_24867'
>>> manager.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

>>> manager.get_iri("chebi:24867", provider="chebi-img")
'https://www.ebi.ac.uk/chebi/backend/api/public/compound/24867/structure/?width=300&height=300'
get_keyword_to_resources() dict[str, list[Resource]][source]

Get a dictionary from keywords to resources.

get_keywords(prefix: str) list[str] | None[source]

Get keywords associated with a given prefix, if available.

Get the logo for the resource, if it’s available.

get_mailing_list(prefix: str) str | None[source]

Get the mailing list for the resource, if it’s available.

get_mapped_prefix(prefix: str, metaprefix: str, *, use_obo_preferred: bool = False) str | None[source]

Get the prefix mapped into another registry.

get_miriam_curie(prefix: str, identifier: str) str | None[source]

Get the identifiers.org CURIE for the given CURIE.

get_miriam_iri(prefix: str, identifier: str) str | None[source]

Get the identifiers.org URL for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A IRI string corresponding to the Identifiers.org, if the prefix exists and is mapped to MIRIAM.

get_n2t_iri(prefix: str, identifier: str) str | None[source]

Get the name-to-thing URL for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A IRI string corresponding to the N2T resolve, if the prefix exists and is mapped to N2T.

>>> from bioregistry import manager
>>> manager.get_n2t_iri("chebi", "24867")
'https://n2t.net/chebi:24867'
get_name(prefix: str, *, provenance: Literal[False] = False, strict: Literal[True] = False) str[source]
get_name(prefix: str, *, provenance: Literal[True] = True, strict: Literal[True] = False) MetaresourceAnnotatedValue[str]
get_name(prefix: str, *, provenance: Literal[False] = False, strict: Literal[False] = False) str | None
get_name(prefix: str, *, provenance: Literal[True] = True, strict: Literal[False] = False) MetaresourceAnnotatedValue[str] | None

Get the name for the given prefix, if it’s available.

get_namespace_in_lui(prefix: str, *, provenance: Literal[False] = False) bool | None[source]
get_namespace_in_lui(prefix: str, *, provenance: Literal[True] = False) None | MetaresourceAnnotatedValue[bool]

Get the name for the given prefix, if it’s available.

get_obo_health_url(prefix: str) str | None[source]

Get the OBO community health badge.

get_obofoundry_iri(prefix: str, identifier: str) str | None[source]

Get the OBO Foundry URL if possible.

Parameters:
  • prefix – The prefix

  • identifier – The identifier

Returns:

The OBO Foundry URL if the prefix can be mapped to an OBO Foundry entry

>>> from bioregistry import manager
>>> manager.get_obofoundry_iri("chebi", "24431")
'http://purl.obolibrary.org/obo/CHEBI_24431'

For entries where there’s a preferred prefix, it is respected.

>>> manager.get_obofoundry_iri("fbbt", "00007294")
'http://purl.obolibrary.org/obo/FBbt_00007294'
get_ols_iri(prefix: str, identifier: str) str | None[source]

Get the OLS URL if possible.

get_part_of(prefix: str) str | None[source]

Get the parent resource, if annotated.

get_parts_collections() Mapping[str, list[str]][source]

Group resources’ prefixes based on their part_of entries.

Returns:

A dictionary with keys that appear as the values of Resource.part_of and whose values are lists of prefixes for resources that have the key as a value in its part_of field.

Warning

Many of the keys in this dictionary are valid Bioregistry prefixes, but this is not necessary. For example, ctd is one key that appears that explicitly has no prefix, since it corresponds to a resource and not a vocabulary.

get_pattern(prefix: str) str | None[source]

Get the pattern for the given prefix, if it’s available.

get_pattern_map(*, prefix_priority: Sequence[str] | None = None, include_synonyms: bool = False, remapping: Mapping[str, str] | None = None, blacklist: Collection[str] | None = None) Mapping[str, str][source]

Get a mapping from prefixes to their regular expression patterns.

Parameters:
  • prefix_priority – The order of metaprefixes OR “preferred” for choosing a primary prefix OR “default” for Bioregistry prefixes

  • include_synonyms – Should synonyms of each prefix also be included as additional prefixes, but with the same URI prefix?

  • remapping – A mapping from prefixes to preferred prefixes.

  • blacklist – Prefixes to skip

Returns:

A mapping from prefixes to regular expression pattern strings.

get_preferred_prefix(prefix: str) str | None[source]

Get the preferred prefix (e.g., with stylization) if it exists.

get_prefix_map(*, uri_prefix_priority: Sequence[str] | None = None, prefix_priority: Sequence[str] | None = None, include_synonyms: bool = False, remapping: Mapping[str, str] | None = None, rewiring: Mapping[str, str] | None = None, blacklist: Collection[str] | None = None) Mapping[str, str][source]

Get a mapping from Bioregistry prefixes to their URI prefixes .

Parameters:
  • prefix_priority – The order of metaprefixes OR “preferred” for choosing a primary prefix OR “default” for Bioregistry prefixes

  • uri_prefix_priority – The order of metaprefixes for choosing the primary URI prefix OR “default” for Bioregistry prefixes

  • include_synonyms – Should synonyms of each prefix also be included as additional prefixes, but with the same URI prefix?

  • remapping – A mapping from Bioregistry prefixes to preferred prefixes.

  • rewiring – A mapping from Bioregistry prefixes to URI prefixes.

  • blacklist – Prefixes to skip

Returns:

A mapping from prefixes to URI prefixes.

get_provided_by(prefix: str) list[str] | None[source]

Get the resources that provide for the given prefix, or return none if the prefix can’t be looked up.

get_provider_functions() Mapping[str, Callable[[str, str], str | None]][source]

Return a mapping of provider functions.

get_providers(prefix: str, identifier: str) dict[str, str][source]

Get all providers for the CURIE.

Parameters:
  • prefix – the prefix in the CURIE

  • identifier – the identifier in the CURIE

Returns:

A dictionary of IRIs associated with the CURIE

>>> from bioregistry import manager
>>> assert "chebi-img" in manager.get_providers("chebi", "24867")
get_providers_list(prefix: str, identifier: str, *, filter_known_inactive: bool = False) Sequence[tuple[str, str]][source]

Get all providers for the CURIE.

get_provides_for(prefix: str) str | None[source]

Get the resource that the given prefix provides for, or return none if not a provider.

get_rdf_uri(prefix: str, identifier: str) str | None[source]

Get the RDF URI for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A IRI string corresponding to the canonical RDF provider, if available.

>>> from bioregistry import manager
>>> manager.get_rdf_uri("edam", "data_1153")
'http://edamontology.org/data_1153'
get_registry(metaprefix: str, *, strict: Literal[False]) Registry | None[source]
get_registry(metaprefix: str, *, strict: Literal[True]) Registry
get_registry(metaprefix: str) Registry | None

Get the metaregistry entry for the given prefix.

get_registry_description(metaprefix: str) str | None[source]

Get the registry description.

get_registry_homepage(metaprefix: str, *, strict: Literal[True] = True) str[source]
get_registry_homepage(metaprefix: str, *, strict: Literal[False] = False) str | None

Get the registry homepage.

get_registry_invmap(metaprefix: str, use_obo_preferred: bool = False) dict[str, str][source]

Get a mapping from prefixes in another registry to Bioregistry prefixes.

Parameters:
  • metaprefix – Which external registry should be used?

  • use_obo_preferred – Should OBO preferred prefixes be used?

Returns:

A mapping of external prefixes to bioregistry prefies

>>> from bioregistry import manager
>>> obofoundry_to_bioregistry = manager.get_registry_invmap(
...     "obofoundry", use_obo_preferred=False
... )
>>> obofoundry_to_bioregistry["go"]
'go'
>>> obofoundry_to_bioregistry["geo"]
'geogeo'
>>> manager.get_registry_invmap("obofoundry", use_obo_preferred=True)["GO"]
'go'
get_registry_map(metaprefix: str, *, use_obo_preferred: bool = False) dict[str, str][source]

Get a mapping from the Bioregistry prefixes to prefixes in another registry.

get_registry_name(metaprefix: str, *, strict: Literal[True] = True) str[source]
get_registry_name(metaprefix: str, *, strict: Literal[False] = False) str | None

Get the registry name.

get_registry_provider_uri_format(metaprefix: str, prefix: str) str | None[source]

Get the URL for the resource inside registry, if available.

get_registry_short_name(metaprefix: str) str | None[source]

Get the registry short name.

get_registry_short_name_to_prefix(metaprefix: str) dict[str, str][source]

Get a mapping from short names in an external registry to their associated prefixes in the external registry.

Parameters:

metaprefix – A metaprefix (e.g., integbio)

Returns:

A mapping

Note

A given record in an external registry could have multiple short names, so there might be duplicate values in this dictionary

get_registry_uri(metaprefix: str, prefix: str, identifier: str) str | None[source]

Get the URL to resolve the given prefix/identifier pair with the given resolver.

Parameters:
  • metaprefix – The metaprefix for an external registry

  • prefix – The Bioregistry prefix

  • identifier – The local unique identifier for a concept in the semantic space denoted by the prefix

Returns:

The external registry’s URI (either for resolving or lookup) of the entity denoted by the prefix/identifier pair.

>>> from bioregistry import manager
>>> manager.get_registry_uri("rrid", "antibodyregistry", "493771")
'https://scicrunch.org/resolver/RRID:AB_493771'

GO is not in RRID so this should return None

>>> manager.get_registry_uri("rrid", "GO", "493771")
get_resource(prefix: str, *, strict: Literal[True] = False) Resource[source]
get_resource(prefix: str, *, strict: Literal[False] = False) Resource | None

Get the Bioregistry entry for the given prefix.

Parameters:
  • prefix – The prefix to look up, which is normalized with normalize_prefix() before lookup in the Bioregistry

  • strict – If true, requires the prefix to be valid or raise an exveption

Returns:

The Bioregistry entry dictionary, which includes several keys cross-referencing other registries when available.

get_resources_with_keyword(keyword: str) list[Resource][source]

Get resources with the given keyword.

get_reverse_prefix_map(include_prefixes: bool = False, strict: bool = False) Mapping[str, str][source]

Get a reverse prefix map, pointing to canonical prefixes.

get_rrid_iri(prefix: str, identifier: str) str | None[source]

Get the RRID URL for the given CURIE.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A IRI string corresponding to the RRID resolver, if the prefix exists and is mapped to RRID.

>>> from bioregistry import manager
>>> manager.get_rrid_iri("antibodyregistry", "493771")
'https://scicrunch.org/resolver/RRID:AB_493771'
get_scholia_iri(prefix: str, identifier: str) str | None[source]

Get a Scholia IRI, if possible.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

Returns:

A link to the Scholia page

>>> from bioregistry import manager
>>> manager.get_scholia_iri("pubmed", "1234")
'https://scholia.toolforge.org/pubmed/1234'
>>> manager.get_scholia_iri("pdb", "1234")
None
get_synonyms(prefix: str) set[str] | None[source]

Get the synonyms for a given prefix, if available.

get_uri_format(prefix: str, priority: Sequence[str] | None = None) str | None[source]

Get the URI format string for the given prefix, if it’s available.

get_uri_prefix(prefix: str, *, priority: Sequence[str] | None = None, strict: Literal[True] = False) str[source]
get_uri_prefix(prefix: str, *, priority: Sequence[str] | None = None, strict: Literal[False] = False) str | None

Get a well-formed URI prefix, if available.

get_versions() Mapping[str, str][source]

Get a map of prefixes to versions.

has_no_terms(prefix: str) bool[source]

Get if the entry has been annotated to not have own terms.

is_deprecated(prefix: str) bool[source]

Return if the given prefix corresponds to a deprecated resource.

is_novel(prefix: str) bool | None[source]

Check if the prefix is novel to the Bioregistry, i.e., it has no external mappings.

is_standardizable_curie(curie: str) bool[source]

Check if a CURIE is validatable, but not necessarily standardized.

Parameters:

curie – A compact URI

Returns:

If the CURIE can be standardized (e.g., prefix normalize and identifier normalized) then validated.

Standard CURIE

>>> from bioregistry import manager
>>> manager.is_standardizable_curie("go:0000001")
True

Not a standard CURIE (i.e., no colon)

>>> manager.is_standardizable_curie("0000001")
False
>>> manager.is_standardizable_curie("GO_0000001")
False
>>> manager.is_standardizable_curie("PTM-0001")
False

Non-standardized prefix

>>> manager.is_standardizable_curie("GO:0000001")
True

Incorrect identifier

>>> manager.is_standardizable_curie("go:0001")
False

Banana scenario

>>> manager.is_standardizable_curie("go:GO:0000001")
True

Unknown prefix

>>> manager.is_standardizable_curie("xxx:yyy")
False
is_standardizable_identifier(prefix: str, identifier: str) bool[source]

Check if the identifier is standardizable.

Parameters:
  • prefix – The prefix from a compact URI

  • identifier – The local unique identifer from a compact URI

Returns:

If the CURIE can be standardized (e.g., prefix normalize and identifier normalized) then validated.

Standard CURIE

>>> from bioregistry import manager
>>> manager.is_standardizable_identifier("go", "0000001")
True

Non-standardized prefix

>>> manager.is_standardizable_identifier("GO", "0000001")
True

Incorrect identifier

>>> manager.is_standardizable_identifier("go", "0001")
False

Banana scenario

>>> manager.is_standardizable_identifier("go", "GO:0000001")
True

Unknown prefix

>>> manager.is_standardizable_identifier("xxx", "yyy")
False
is_valid_curie(curie: str) bool[source]

Check if a CURIE is standardized and valid.

Parameters:

curie – A compact URI of the form <prefix>:<local unique identifier>.

Returns:

If the CURIE is standardized in both syntax and semantics. This means that it uses the Bioregistry canonical prefix, does not have a redundant prefix, and if available, matches the Bioregistry’s regular expression pattern for identifiers.

Standard CURIE

>>> from bioregistry import manager
>>> manager.is_valid_curie("go:0000001")
True

Not a standard CURIE (i.e., no colon)

>>> manager.is_valid_curie("0000001")
False
>>> manager.is_valid_curie("GO_0000001")
False
>>> manager.is_valid_curie("PTM-0001")
False

Non-standardized prefix

>>> manager.is_valid_curie("GO:0000001")
False

Incorrect identifier

>>> manager.is_valid_curie("go:0001")
False

Banana scenario

>>> manager.is_valid_curie("go:GO:0000001")
False

Unknown prefix

>>> manager.is_valid_curie("xxx:yyy")
False
is_valid_identifier(prefix: str, identifier: str) bool[source]

Check if the pre-parsed CURIE is standardized valid.

Parameters:
  • prefix – The prefix from a compact URI

  • identifier – The local unique identifer from a compact URI

Returns:

If the CURIE is standardized in both syntax and semantics. This means that it uses the Bioregistry canonical prefix, does not have a redundant prefix, and if available, matches the Bioregistry’s regular expression pattern for identifiers.

Standard CURIE

>>> from bioregistry import manager
>>> manager.is_valid_identifier("go", "0000001")
True

Non-standardized prefix

>>> manager.is_valid_identifier("GO", "0000001")
False

Incorrect identifier

>>> manager.is_valid_identifier("go", "0001")
False

Banana scenario

>>> manager.is_valid_identifier("go", "GO:0000001")
False

Unknown prefix

>>> manager.is_valid_identifier("xxx", "yyy")
False
lookup_from(metaprefix: str, metaidentifier: str, use_obo_preferred: bool = False) str | None[source]

Get the bioregistry prefix from an external prefix.

Parameters:
  • metaprefix – The key for the external registry

  • metaidentifier – The prefix in the external registry

Returns:

The bioregistry prefix (if it can be mapped)

>>> from bioregistry import manager
>>> manager.lookup_from("obofoundry", "go")
'go'
>>> manager.lookup_from("obofoundry", "GO")
None
>>> manager.lookup_from("obofoundry", "GO", use_obo_preferred=True)
'go'
make_preferred(t: ReferenceTuple, use_preferred: bool = False) ReferenceTuple[source]

Replace a reference tuple’s prefix with a preferred one.

normalize_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, strict: Literal[True] = True) str[source]
normalize_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, strict: Literal[False] = False) str | None

Normalize the prefix and identifier in the CURIE.

normalize_parsed_curie(prefix: str, identifier: str, *, use_preferred: bool = False, on_failure_return_type: FailureReturnType = FailureReturnType.pair, strict: Literal[True] = True) ReferenceTuple[source]
normalize_parsed_curie(prefix: str, identifier: str, *, use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.single], strict: Literal[False] = False) ReferenceTuple | None
normalize_parsed_curie(prefix: str, identifier: str, *, use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.pair], strict: Literal[False] = False) ReferenceTuple | tuple[None, None]

Normalize a prefix/identifier pair.

Parameters:
  • prefix – The prefix in the CURIE

  • identifier – The identifier in the CURIE

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

  • on_failure_return_type – whether to return a single None or a pair of None’s

  • strict – If true, raises an error if the prefix can’t be standardized

Returns:

A normalized prefix/identifier pair, conforming to Bioregistry standards. This means no redundant prefixes or bananas, all lowercase.

Raises:

PrefixStandardizationError – If strict is set to true and the prefix could not be standardized

normalize_prefix(prefix: str, *, use_preferred: bool = False, strict: Literal[True] = True) str[source]
normalize_prefix(prefix: str, *, use_preferred: bool = False, strict: Literal[False] = False) str | None

Get the normalized prefix, or return None if not registered.

Parameters:
  • prefix – The prefix to normalize, which could come from Bioregistry, OBO Foundry, OLS, or any of the curated synonyms in the Bioregistry

  • strict – If true and the prefix could not be looked up, raises an error

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

Returns:

The canonical Bioregistry prefix, it could be looked up. This will usually take precedence: MIRIAM, OBO Foundry / OLS, Custom except in a few cases, such as NCBITaxon.

Raises:

PrefixStandardizationError – If strict is set to true and the prefix could not be standardized

parse_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, on_failure_return_type: FailureReturnType = FailureReturnType.pair, strict: Literal[True] = True) ReferenceTuple[source]
parse_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.single] = FailureReturnType.single, strict: Literal[False] = False) ReferenceTuple | None
parse_curie(curie: str, *, sep: str = ':', use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.pair] = FailureReturnType.pair, strict: Literal[False] = False) ReferenceTuple | tuple[None, None]

Parse a CURIE and normalize its prefix and identifier.

parse_uri(uri: str, *, use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.single]) ReferenceTuple | None[source]
parse_uri(uri: str, *, use_preferred: bool = False, on_failure_return_type: Literal[FailureReturnType.pair] = FailureReturnType.pair) ReferenceTuple | tuple[None, None]

Parse a compact identifier from a URI.

Parameters:
  • uri – A valid URI

  • use_preferred – If set to true, uses the “preferred prefix”, if available, instead of the canonicalized Bioregistry prefix.

  • on_failure_return_type – whether to return a single None or a pair of None’s

Returns:

A pair of prefix/identifier, if can be parsed

IRI from an OBO PURL:

>>> from bioregistry import manager
>>> manager.parse_uri("http://purl.obolibrary.org/obo/DRON_00023232")
ReferenceTuple(prefix='dron', identifier='00023232')

IRI from the OLS:

>>> manager.parse_uri(
...     "https://www.ebi.ac.uk/ols/ontologies/ecao/terms?iri=http://purl.obolibrary.org/obo/ECAO_0107180"
... )  # noqa:E501
ReferenceTuple(prefix='ecao', identifier='0107180')

IRI from native provider

>>> manager.parse_uri("https://www.alzforum.org/mutations/1234")
ReferenceTuple(prefix='alzforum.mutation', identifier='1234')

Dog food:

>>> manager.parse_uri("https://bioregistry.io/DRON:00023232")
ReferenceTuple(prefix='dron', identifier='00023232')

IRIs from Identifiers.org (https and http, colon and slash):

>>> manager.parse_uri("https://identifiers.org/aop.relationships:5")
ReferenceTuple(prefix='aop.relationships', identifier='5')
>>> manager.parse_uri("http://identifiers.org/aop.relationships:5")
ReferenceTuple(prefix='aop.relationships', identifier='5')
>>> manager.parse_uri("https://identifiers.org/aop.relationships/5")
ReferenceTuple(prefix='aop.relationships', identifier='5')
>>> manager.parse_uri("http://identifiers.org/aop.relationships/5")
ReferenceTuple(prefix='aop.relationships', identifier='5')

IRI from N2T

>>> manager.parse_uri("https://n2t.net/aop.relationships:5")
ReferenceTuple(prefix='aop.relationships', identifier='5')

Handle either HTTP or HTTPS:

>>> manager.parse_uri("http://braininfo.rprc.washington.edu/centraldirectory.aspx?ID=268")
ReferenceTuple(prefix='neuronames', identifier='268')
>>> manager.parse_uri("https://braininfo.rprc.washington.edu/centraldirectory.aspx?ID=268")
ReferenceTuple(prefix='neuronames', identifier='268')

If you provide your own prefix map, you should pre-process the prefix map with:

>>> from curies import Converter, chain
>>> prefix_map = {"chebi": "https://example.org/chebi:"}
>>> converter = chain([Converter.from_prefix_map(prefix_map), manager.converter])
>>> converter.parse_uri("https://example.org/chebi:1234")
ReferenceTuple(prefix='chebi', identifier='1234')

Corner cases:

>>> manager.parse_uri("https://omim.org/MIM:PS214100")
ReferenceTuple(prefix='omim.ps', identifier='214100')
rasterize() dict[str, Mapping[str, Any]][source]

Build a dictionary representing the fully constituted registry.

rasterized_resource(resource: Resource) Resource[source]

Rasterize a resource.

read_contributors(direct_only: bool = False) Mapping[str, Attributable][source]

Get a mapping from contributor ORCID identifiers to author objects.

write_collections() None[source]

Write collections.

write_registry() None[source]

Write the registry.