### Install and run Bioregistry via CLI
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/deployment.rst
Installs the Bioregistry package and starts the web server using Gunicorn.
```shell
python -m pip install --upgrade gunicorn bioregistry[web]
python -m bioregistry web \
--with-gunicorn --workers 4 \
--port 8766 \
--host "0.0.0.0" \
--base-url https://example.com
```
--------------------------------
### Install Bioregistry
Source: https://github.com/biopragmatics/bioregistry/blob/main/README.md
Install the package from PyPI or set up a local development environment.
```shell
$ pip install bioregistry
```
```shell
$ git clone https://github.com/biopragmatics/bioregistry.git
$ cd bioregistry
$ pip install --editable .
```
--------------------------------
### Get Example Identifier
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve an example identifier for a given resource prefix. This is helpful for understanding the expected format of identifiers.
```python
example = bioregistry.get_example('chebi')
print(f"Example: chebi:{example}")
```
--------------------------------
### Run Bioregistry Web Application
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Starts the Bioregistry web application using the installed CLI.
```bash
# Run the web application
bioregistry web
```
--------------------------------
### Generate Example Code Snippet
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/macros.html
A generic Jinja macro for generating Python doctest examples.
```jinja
{% macro code_example(prefix, func, text, quote=True) -%}
>>> import {{ config.METAREGISTRY_PYTHON_PACKAGE }} as br
>>> br.{{ func }}("{{ prefix }}")
{% if quote %}'{{ text }}'{% else %}{{ text }}{% endif %}
{%- endmacro -%}
```
--------------------------------
### Install Bioregistry from GitHub
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/index.rst
Installation command to pull the most recent code and data directly from the GitHub repository.
```shell
$ pip install git+https://github.com/biopragmatics/bioregistry.git
```
--------------------------------
### Run the web application
Source: https://github.com/biopragmatics/bioregistry/blob/main/README.md
Install the web extras and launch the Bioregistry web application.
```shell
$ python -m pip install bioregistry[web]
$ bioregistry web
```
--------------------------------
### Install Bioregistry in development mode
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/index.rst
Commands to clone the repository and install the package in editable mode for development purposes.
```shell
$ git clone git+https://github.com/biopragmatics/bioregistry.git
$ cd bioregistry
$ pip install -e .
```
--------------------------------
### Install Bioregistry via pip
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/index.rst
Standard installation command for the latest release from PyPI.
```shell
$ pip install bioregistry
```
--------------------------------
### Start Docker Compose Service
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/deployment.rst
Command to initialize the services defined in the docker-compose.yml file.
```shell
docker-compose up
```
--------------------------------
### Adding Example Local Unique Identifier for a Resource
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/curation.md
This JSON snippet illustrates how to include an 'example' field for a resource, providing a sample local unique identifier. This serves as a courtesy to newcomers and helps in understanding the identifier format.
```json
{
...
"jax": {
"example": "004435",
// <-- this one here
"name": "Jackson Laboratories Strain",
"url": "https://www.jax.org/strain/$1"
},
...
}
```
--------------------------------
### Install Bioregistry CLI with Web Dependencies
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Installs the Bioregistry Python package including dependencies required for running the web server.
```bash
# Install with web dependencies
pip install bioregistry[web]
```
--------------------------------
### Deploy Web Application via CLI
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/meta/access.html
Install and run the web application directly from the shell using pip or development mode.
```bash
$ pip install {{ config.METAREGISTRY_PYTHON_PACKAGE }}[web]
$ {{ config.METAREGISTRY_PYTHON_PACKAGE }} web
```
```bash
$ git clone {{ config.METAREGISTRY_REPOSITORY }}.git
$ cd {{ config.METAREGISTRY_PYTHON_PACKAGE }}
$ pip install --editable .[web]
$ {{ config.METAREGISTRY_PYTHON_PACKAGE }} web
```
--------------------------------
### Get All Resources in Registry (JSON)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves all resources registered in the Bioregistry in JSON format. No specific setup is required beyond making the HTTP GET request.
```bash
curl https://bioregistry.io/api/registry
```
--------------------------------
### Check Bioregistry Version
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Displays the currently installed version of the Bioregistry CLI.
```bash
# Check version
bioregistry --version
```
--------------------------------
### Install Bioregistry CLI with Align Extras
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Installs the Bioregistry Python package with the 'align' extra dependencies, required for updating from external registries.
```bash
# Update from external registries (requires align extras)
pip install bioregistry[align]
```
--------------------------------
### Example Bioregistry Entry (3dmet)
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/curation.md
This JSON snippet shows an example entry for '3dmet' in the bioregistry, including MIRIAM annotations, N2T mapping, and Wikidata integration. Ensure all fields are correctly populated.
```json
{
"3dmet": {
"miriam": {
"deprecated": false,
"description": "3DMET is a database collecting three-dimensional structures of natural metabolites.",
"id": "00000066",
"name": "3DMET",
"namespaceEmbeddedInLui": false,
"pattern": "^B\\d{5}$",
"prefix": "3dmet"
},
"n2t": {
"prefix": "3dmet"
},
"wikidata": {
"database": "Q23948774", // <-- this is it!!
"property": "P2796"
}
},
...
}
```
--------------------------------
### Build Bioregistry documentation locally with Docker
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/README.md
Use these commands to clone the repository and start a local Jekyll server for documentation development.
```shell
git clone https://github.com/biopragmatics/bioregistry
cd bioregistry/docs
docker run --rm --volume="$PWD:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll:latest jekyll serve
```
--------------------------------
### Run Bioregistry Web Application on Custom Host/Port
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Starts the Bioregistry web application, specifying a custom host and port.
```bash
# Run on custom host/port
bioregistry web --host 0.0.0.0 --port 8000
```
--------------------------------
### Add Upstream Repository
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/CONTRIBUTING.md
Add the upstream repository to your local clone to sync with the main branch. This is a one-time setup step.
```shell
$ git remote add biopragmatics https://github.com/biopragmatics/bioregistry.git
```
--------------------------------
### Get URI Format with Custom Priority
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Get the URI format string for a prefix with a custom priority list for resolving the URI. This ensures the desired URI format is selected.
```python
uri_format = get_uri_format('chebi', priority=['obofoundry', 'bioregistry', 'biocontext', 'miriam', 'ols'])
assert uri_format == 'http://purl.obolibrary.org/obo/CHEBI_$1'
```
--------------------------------
### Get Full Resource Entry
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve all metadata for a given resource using its prefix. This includes its name, description, pattern, and homepage.
```python
resource = bioregistry.get_resource('chebi')
print(f"Prefix: {resource.prefix}")
print(f"Name: {resource.name}")
print(f"Description: {resource.description}")
print(f"Pattern: {resource.pattern}")
print(f"Homepage: {resource.homepage}")
```
--------------------------------
### Get Specific Resource (Default Format)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves details for a specific resource (e.g., 'chebi') from the registry. The default response format is JSON.
```bash
curl https://bioregistry.io/api/registry/chebi
```
--------------------------------
### Get Specific Resource (YAML)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves details for a specific resource (e.g., 'chebi') from the registry, requesting the response in YAML format.
```bash
curl -H "Accept: application/yaml" https://bioregistry.io/api/registry/chebi
```
--------------------------------
### Define RDF Turtle Prefixes
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/validation-cli.rst
Example of a standard prefix map stanza used at the beginning of an RDF Turtle file.
```turtle
@prefix nfdicore: .
@prefix ns1: .
@prefix ns2: .
@prefix obo: .
@prefix rdfs: .
@prefix xsd: .
```
--------------------------------
### Get All Resources in Registry (YAML)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves all resources registered in the Bioregistry in YAML format. This is useful for configuration or human-readable inspection.
```bash
curl https://bioregistry.io/api/registry?format=yaml
```
--------------------------------
### Get Synonyms for a Prefix
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve a dictionary of synonyms associated with a given registry prefix. Useful for finding alternative ways to refer to a resource.
```python
synonyms = bioregistry.get_synonyms('ncbitaxon')
assert 'taxonomy' in synonyms
assert 'taxon' in synonyms
```
--------------------------------
### Get Collection as JSON-LD Context
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves a specific collection (e.g., '0000001') formatted as a JSON-LD context.
```bash
curl https://bioregistry.io/api/collection/0000001?format=context
```
--------------------------------
### Load Example Gene Ontology Annotations Data
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Load a sample Pandas DataFrame containing Gene Ontology Annotations data for demonstration purposes.
```python
import pandas as pd
import bioregistry.pandas as brpd
df = brpd.get_goa_example()
```
--------------------------------
### Get Specific Resource (Turtle)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves details for a specific resource (e.g., 'chebi') from the registry, requesting the response in Turtle (RDF) format.
```bash
curl -H "Accept: text/turtle" https://bioregistry.io/api/registry/chebi
```
--------------------------------
### Resolve Reference and Get Provider URLs
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Resolves a given reference (e.g., 'chebi:24867') and returns all associated provider URLs in JSON format.
```bash
curl https://bioregistry.io/api/reference/chebi:24867
```
--------------------------------
### Get URI Format String
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve the URI format string for a given prefix, which includes a placeholder for the identifier. This is used to construct full URIs.
```python
uri_format = get_uri_format('chebi')
assert uri_format == 'http://purl.obolibrary.org/obo/CHEBI_$1'
```
--------------------------------
### Define a Bioregistry record with providers
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/guides/providers.md
Example of a ChEBI record configuration including primary URI formats and an additional provider for image resolution.
```json
{
"chebi": {
"name": "Chemical Entities of Biological Interest",
"uri_format": "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=$1",
"rdf_uri_format": "http://purl.obolibrary.org/obo/CHEBI_$1",
"providers": [
{
"code": "chebi-img",
"description": "Image server from chebi",
"homepage": "https://www.ebi.ac.uk/chebi/",
"name": "ChEBI",
"uri_format": "https://www.ebi.ac.uk/chebi/displayImage.do?defaultImage=true&chebiId=$1"
}
]
}
}
```
--------------------------------
### Get a Named Context (Prefix Map Configuration)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve a pre-defined context configuration, which is essentially a prefix map, by its name. Useful for standard serialization formats like OBO.
```python
obo_context = get_context('obo')
if obo_context:
print(f"OBO Context: {obo_context.name}")
```
--------------------------------
### Get External Registry Mappings
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Fetch mappings of a resource prefix to identifiers in external registries like OBO Foundry and Identifiers.org.
```python
mappings = bioregistry.get_mappings('chebi')
print(f"OBO Foundry: {mappings.get('obofoundry')}")
print(f"Identifiers.org: {mappings.get('miriam')}")
```
--------------------------------
### Get Full Resource Objects for Collection Prefixes
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve the full resource objects for all prefixes within a given collection. This provides detailed metadata for each prefix in the collection.
```python
resources = get_collection_resources('0000001')
if resources:
for resource in resources[:3]:
print(f" {resource.prefix}: {resource.name}")
```
--------------------------------
### Get Specific Metadata
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Fetch individual metadata fields for a resource by its prefix. Asserts are used to verify the presence and correctness of the data.
```python
assert bioregistry.get_name('go') is not None
assert bioregistry.get_description('chebi') is not None
assert bioregistry.get_pattern('go') == '^GO:\d{7}$'
assert bioregistry.get_homepage('chebi') is not None
```
--------------------------------
### Access Resource Metadata Programmatically
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/resource.html
Retrieve specific metadata fields for a resource using the utility code_example function.
```python
{{ utils.code_example(prefix, "get_synonyms", synonyms, quote=False) }}
```
```python
{{ utils.code_example(prefix, "get_version", version) }}
```
```python
{{ utils.code_example(prefix, "get_name", name_pack.value) }}
```
```python
{{ utils.code_example(prefix, "get_license", resource_license) }}
```
```python
{{ utils.code_example(prefix, "get_homepage", homepage) }}
```
```python
{{ utils.code_example(prefix, "get_repository", repository) }}
```
```python
{{ utils.code_example(prefix, "get_obo_download", obo_download) }}
```
```python
{{ utils.code_example(prefix, "get_owl_download", owl_download) }}
```
```python
{{ utils.code_example(prefix, "get_json_download", json_download) }}
```
```python
{{ utils.code_example(prefix, "get_rdf_download", rdf_download) }}
```
--------------------------------
### Deploy Web Application via Docker
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/meta/access.html
Run the application containerized using Docker.
```bash
$ docker run -id -p 8766:8766 {{ config.METAREGISTRY_DOCKERHUB_SLUG }}:latest
```
--------------------------------
### Run Tests and Infrastructure
Source: https://github.com/biopragmatics/bioregistry/blob/main/README.md
Commands for managing the test environment and executing unit tests.
```shell
$ docker compose up
```
```shell
$ docker compose exec virtuoso isql -U dba -P dba exec='GRANT "SPARQL_SELECT_FED" TO "SPARQL";'
```
```shell
$ tox
```
--------------------------------
### Get All Collections
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves a list of all collections managed by the Bioregistry in JSON format.
```bash
curl https://bioregistry.io/api/collection
```
--------------------------------
### Get Bioregistry Inverse Map
Source: https://github.com/biopragmatics/bioregistry/blob/main/notebooks/Bioregistry Taxonomy Curation via Wikidata.ipynb
Retrieves the inverse mapping for the Wikidata registry.
```python
wikidata_to_bioregistry = bioregistry.get_registry_invmap("wikidata")
```
--------------------------------
### Render Prefix as Code
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/macros.html
Formats a prefix string as a clickable link with code styling.
```jinja
{% macro render_prefix(prefix, classes="") -%}
[`{{ prefix }}`]({{ url_for() }}
{%- endmacro -%}
```
--------------------------------
### Get All Contributor Information
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves a list of all contributors to the Bioregistry project in JSON format.
```bash
curl https://bioregistry.io/api/contributors
```
--------------------------------
### Get Specific Collection
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves details for a specific collection (e.g., '0000001') in JSON format.
```bash
curl https://bioregistry.io/api/collection/0000001
```
--------------------------------
### Build and Run Docker Image
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/source/deployment.rst
Commands to build the custom Docker image and run it in detached mode.
```shell
# Build the docker image from the same directory as the Dockerfile
docker build --tag bioregistry_custom:latest .
# Run the docker image, -d means "detach"
docker run -d -p 8766:8766 bioregistry_custom:latest
```
--------------------------------
### Get Prefixes in a Collection
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieve a list of prefixes that belong to a specific collection, identified by its ID.
```python
prefixes = get_collection_prefixes('0000001')
if prefixes:
print(f"Prefixes: {prefixes[:5]}...")
```
--------------------------------
### Get All External Registries
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves a list of all external registries (metaregistry) supported by the Bioregistry in JSON format.
```bash
curl https://bioregistry.io/api/metaregistry
```
--------------------------------
### Get CURIE string from IRI
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Use `curie_from_iri` to directly extract the canonical CURIE string from a given IRI.
```python
assert curie_from_iri('http://purl.obolibrary.org/obo/CHEBI_24867') == 'chebi:24867'
assert curie_from_iri('http://purl.bioontology.org/ontology/NCBITAXON/131567') == 'ncbitaxon:131567'
```
--------------------------------
### Get Bioregistry Version
Source: https://github.com/biopragmatics/bioregistry/blob/main/notebooks/Bioregistry Taxonomy Curation via Wikidata.ipynb
Retrieves the current version of the bioregistry library. This is useful for checking compatibility or reporting issues.
```python
bioregistry.version.get_version()
```
--------------------------------
### Render Metaprefix as Code
Source: https://github.com/biopragmatics/bioregistry/blob/main/src/bioregistry/app/templates/macros.html
Displays a metaprefix string as a link with code styling.
```jinja
{% macro render_metaprefix(metaprefix) -%}
[`{{ metaprefix }}`]({{ url_for() }}
{%- endmacro -%}
```
--------------------------------
### Generate Prefix Map Including Synonyms
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Create a prefix map that includes synonyms for registry prefixes. This expands the map to cover alternative names.
```python
prefix_map = get_prefix_map(include_synonyms=True)
assert 'taxonomy' in prefix_map
```
--------------------------------
### Align Bioregistry with External Registries
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Updates the Bioregistry by aligning it with external registry data. Requires the 'align' extras to be installed.
```bash
bioregistry align
```
--------------------------------
### Format Markdown files with Prettier
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/guides/README.md
Run this command to ensure all Markdown files in the repository adhere to the project's formatting standards.
```bash
npx prettier --prose-wrap always --check "**/*.md" --write
```
--------------------------------
### Get Specific Contributor Information
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves information for a specific contributor identified by their ORCID (e.g., '0000-0003-4423-4370') in JSON format.
```bash
curl https://bioregistry.io/api/contributor/0000-0003-4423-4370
```
--------------------------------
### Get Specific External Registry
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves details for a specific external registry (e.g., 'miriam') from the metaregistry in JSON format.
```bash
curl https://bioregistry.io/api/metaregistry/miriam
```
--------------------------------
### Get Preferred Prefix with Stylization
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Obtain the preferred, human-readable prefix for a given registry prefix. This is useful for display purposes.
```python
assert bioregistry.get_preferred_prefix('fbbt') == 'FBbt'
assert bioregistry.get_preferred_prefix('wb') == 'WormBase'
```
--------------------------------
### Retrieve resource metadata
Source: https://github.com/biopragmatics/bioregistry/blob/main/README.md
Fetch the full resource dictionary for a given prefix.
```python
import bioregistry
entry = bioregistry.get_resource('taxonomy')
# there are lots of mysteries to discover in this dictionary!
```
--------------------------------
### Run TF-IDF Analysis
Source: https://github.com/biopragmatics/bioregistry/blob/main/exports/analyses/paper_ranking/README.md
Execute the title TF-IDF analysis module directly from the command line.
```bash
python -m bioregistry.analysis.title_tfidf
```
--------------------------------
### Generate Ad-hoc JSON-LD Context (Multiple Prefixes)
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Generates an ad-hoc JSON-LD context for specified prefixes (e.g., 'go', 'doid', 'chebi') using a single query parameter.
```bash
curl "https://bioregistry.io/api/context.jsonld?prefix=go,doid,chebi"
```
--------------------------------
### Get Mappings from Bioregistry to External Registry
Source: https://context7.com/biopragmatics/bioregistry/llms.txt
Retrieves mappings from the Bioregistry to a specific external registry (e.g., 'miriam') in JSON format.
```bash
curl https://bioregistry.io/api/metaregistry/miriam/mappings.json
```
--------------------------------
### Run Unit Tests with Tox
Source: https://github.com/biopragmatics/bioregistry/blob/main/docs/curation-import-external.md
Execute unit tests for the Bioregistry using Tox with the 'py' environment. This helps verify that alignment scripts and metadata are correctly implemented.
```bash
tox -e py
```