Skip to content

Running a Refgenie Server

This tutorial walks you through setting up and running your own refgenie server. A refgenie server allows you to share genome assets with others on your network or the public internet.

There are several reasons you might want to run your own refgenie server:

  • Internal distribution: Share assets privately across your organization without uploading to public servers
  • Custom assets: Serve specialized or proprietary genome assets that aren’t available on public servers
  • Performance: Run a local server for faster asset access within your network
  • Community sharing: Distribute your resources through the familiar refgenie interface

Before starting a server, you need:

  1. Refgenie installed with server extras:

    Terminal window
    pip install refgenie[server]
  2. Built assets: You need local assets to serve. If you haven’t built any yet, see the build documentation.

  3. Archives created: Assets must be archived before they can be served.

Before serving assets, you must create archives. Archives are compressed, downloadable packages of your assets.

First, ensure you have an archive folder configured. You can set this during initialization or via environment variable:

Terminal window
# Set via environment variable
export REFGENIE_GENOME_ARCHIVE_FOLDER=~/.refgenie/archives
# Or specify during init
refgenie1 init --genome-archive-folder ~/.refgenie/archives

Create an archive for a specific asset:

Terminal window
refgenie1 archive create hg38/fasta

This creates a .tar.gz archive in your genome_archive_folder that can be served to clients.

You can archive multiple assets at once:

Terminal window
refgenie1 archive create hg38/fasta hg38/bowtie2_index mm10/fasta

You can also create archives automatically when building:

Terminal window
refgenie1 build hg38/fasta --archive

View all available archives:

Terminal window
refgenie1 archive list

Start the server with default settings (port 8000):

Terminal window
refgenie1 serve

The server will be available at http://localhost:8000.

Specify a different port:

Terminal window
refgenie1 serve --port 8080

For development, enable auto-reload to automatically restart when code changes:

Terminal window
refgenie1 serve --reload

The dashboard provides a read-only web interface for browsing your local assets:

Terminal window
refgenie1 dash

By default, this opens http://localhost:8080 in your browser. Specify a different port with:

Terminal window
refgenie1 dash --port 9000

The dashboard automatically opens in your default web browser and displays:

  • All genomes and their aliases
  • Available assets for each genome
  • Asset metadata and descriptions

The refgenie server exposes a REST API with several endpoint groups:

EndpointDescription
/ or /indexLanding page with all available genomes
/healthcheckHealth check endpoint (returns {"status": "ok"})
/summaryDatabase summary with counts of genomes, asset groups, and assets
/species/summaryStatistics grouped by species
EndpointDescription
/page/genome/{digest}Genome splash page with available assets
/page/asset/{digest}/{asset_group}Asset detail page
/archives/{digest}/downloadDownload an archive by its digest

The server implements the GA4GH Data Repository Service (DRS) specification:

EndpointDescription
/ga4gh/drs/service-infoDRS service information
/ga4gh/drs/objects/{object_id}Get DRS object metadata
/ga4gh/drs/objects/{object_id}/access/{access_id}Get access URL for download
EndpointDescription
/data_channel/List available data channels
/data_channel/index.yamlCompiled index of all data channels

Visit /docs for Swagger UI or /redoc for ReDoc-style documentation.

For production deployments, consider using PostgreSQL instead of SQLite. Create a database configuration file:

~/.refgenie/refgenie_db_config.yaml
type: postgresql
name: refgenie
host: localhost
port: 5432
user: refgenie_user
password: your_secure_password

Set the path to this config:

Terminal window
export REFGENIE_DB_CONFIG_PATH=~/.refgenie/refgenie_db_config.yaml

See the configuration documentation for more details.

Key environment variables for server configuration:

VariableDefaultDescription
REFGENIE_HOME_PATH~/.refgenieBase directory for refgenie files
REFGENIE_GENOME_FOLDER$REFGENIE_HOME_PATH/genomesDirectory for genome assets
REFGENIE_GENOME_ARCHIVE_FOLDER$REFGENIE_HOME_PATH/archivesDirectory for asset archives
REFGENIE_DB_CONFIG_PATH$REFGENIE_HOME_PATH/refgenie_db_config.yamlPath to database config
REFGENIE_LOG_LEVELINFOLogging verbosity

For serving assets from cloud storage (e.g., S3), configure a remote:

Terminal window
refgenie1 remote add --type http --prefix https://your-bucket.s3.amazonaws.com/archives --description "S3 archive storage"

When a remote is configured, the server will redirect download requests to the remote URL instead of serving files directly.

Data channels allow you to aggregate asset classes and recipes from external sources. Set the path to your data channels configuration:

Terminal window
export DATA_CHANNELS_CONFIG_PATH=/path/to/data_channels.yaml

See data channels documentation for the configuration format.

For containerized deployments, you can run the server with Docker:

Terminal window
docker run --rm -d -p 80:80 \
-v /path/to/genomes:/genomes \
-v /path/to/archives:/archives \
-e REFGENIE_GENOME_FOLDER=/genomes \
-e REFGENIE_GENOME_ARCHIVE_FOLDER=/archives \
--name refgenie-server \
refgenie/refgenie:latest refgenie1 serve --port 80

Once your server is running, clients can subscribe to it:

Terminal window
refgenie1 subscribe http://your-server-address:8000

Then pull assets normally:

Terminal window
refgenie1 pull hg38/fasta
  • Ensure the server extras are installed: pip install refgenie[server]
  • Check that the port isn’t already in use
  • Verify database configuration is correct
  • Confirm assets are archived: refgenie1 archive list
  • Check the archive folder path is correct
  • Verify database contains the assets: refgenie1 list
  • Ensure archive files exist in the archive folder
  • If using remote storage, verify the remote configuration is correct
  • Check server logs for detailed error messages