Skip to content

CLI Tutorial

This tutorial walks you through common refgenie operations, from installation to managing reference genome assets. By the end, you will be able to download, build, and retrieve paths to reference genome resources using the command line.

  • Python 3.9 or higher
  • pip package manager
  • Internet connection (for downloading remote assets)

Download the latest wheel from GitHub releases and install:

Terminal window
pip install refgenie1-*.whl

Verify the installation:

Terminal window
refgenie1 --version

Before using refgenie, initialize the configuration and database:

Terminal window
refgenie1 init

This creates a configuration directory at ~/.refgenie/ with:

  • A SQLite database for tracking assets
  • A genomes/ folder for storing downloaded assets
  • A database configuration file

View the current refgenie configuration:

Terminal window
refgenie1 config get

Expected output:

Refgenie configuration
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ genome_folder ┃ version ┃ genome_archive_folder ┃ servers ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ /home/user/.refgenie/genomes │ 1 │ /home/user/.refgenie/archives │ [] │
└─────────────────────────────────────┴─────────┴──────────────────────────────────────┴─────────┘
Environment-based configuration
log_level: LogLevel.INFO
genome_folder: /home/user/.refgenie/genomes
genome_archive_folder: /home/user/.refgenie/archives
database_config_path: /home/user/.refgenie/refgenie_db_config.yaml

To download pre-built assets, subscribe to a remote refgenie server:

Terminal window
refgenie1 subscribe http://refgenomes.databio.org

This adds the public refgenie server to your configuration. You can subscribe to multiple servers.

To unsubscribe from a server:

Terminal window
refgenie1 unsubscribe -s http://refgenomes.databio.org

Browse what assets are available on subscribed servers:

Terminal window
refgenie1 listr

Expected output:

Refgenie assets. Source: http://refgenomes.databio.org
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Genome digest ┃ Asset group ┃ Asset ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4 │ fasta │ default │
│ 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4 │ bowtie2_index │ default │
│ 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4 │ bwa_index │ default │
│ ... │ ... │ ... │
└──────────────────────────────────────────────────┴─────────────────────────┴─────────┘

Download a pre-built asset from the server:

Terminal window
refgenie1 pull hg38/fasta

This downloads the human reference genome (hg38) FASTA file and related indexes. Refgenie automatically:

  1. Resolves the hg38 alias to its unique genome digest
  2. Downloads the asset archive
  3. Extracts and organizes the files
  4. Registers the asset in the local database

Expected output:

INFO Setting 'hg38' identity with server: http://refgenomes.databio.org
INFO Determined digest for hg38: 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4
INFO Set genome alias: hg38
hg38/fasta:default ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% • 833.4/833.4 MB

View assets you have downloaded or built locally:

Terminal window
refgenie1 list

Expected output:

Local refgenie assets
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Genome ┃ Asset ┃ Tag ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ hg38 │ fasta │ default │
└──────────────────────────────────────────────────┴───────────────┴──────────┘

Retrieve the local path to a downloaded asset using seek:

Terminal window
refgenie1 seek hg38/fasta

Expected output:

/home/user/.refgenie/genomes/alias/hg38/fasta/default

This returns the absolute path to the asset folder, making your scripts portable across different computing environments.

Some assets contain multiple files. The fasta asset, for example, includes a FASTA file, an index (.fai), and chromosome sizes. Access specific files with seek keys:

Terminal window
# Get the FASTA file path
refgenie1 seek hg38/fasta
# Get the FASTA index (.fai) path
refgenie1 seek hg38/fasta.fai
# Get the chromosome sizes file path
refgenie1 seek hg38/fasta.chrom_sizes

Get paths to assets on remote servers without downloading them:

Terminal window
refgenie1 seekr hg38/fasta

This is useful for cloud workflows where you want to stream data directly from S3 or other remote storage.

Refgenie uses sequence-derived digests to uniquely identify genomes. Aliases like hg38 or mm10 are human-friendly names that map to these digests.

Terminal window
refgenie1 alias get

If you know the genome digest, you can set an alias manually:

Terminal window
refgenie1 alias set --aliases hg38 --digest 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4

You can also set multiple aliases for the same genome:

Terminal window
refgenie1 alias set --aliases GRCh38 human_reference --digest 2230c535660fb4774114bfa966a62f823fdb6d21acf138d4
Terminal window
refgenie1 alias remove --aliases my_old_alias

For genomes or assets not available on remote servers, you can build them locally. Here is a brief example of building a FASTA asset:

Terminal window
refgenie1 build my_genome/fasta --files fasta=/path/to/my_genome.fa.gz --genome-description "My custom genome"

Once you have a FASTA asset, you can build derived assets like indexes:

Terminal window
refgenie1 build my_genome/bowtie2_index
CommandDescription
refgenie1 initInitialize configuration
refgenie1 config getView current configuration
refgenie1 subscribe URLAdd a remote server
refgenie1 unsubscribe -s URLRemove a remote server
refgenie1 listrList remote assets
refgenie1 listr -g GENOMEList remote assets for a genome
refgenie1 pull GENOME/ASSETDownload an asset
refgenie1 listList local assets
refgenie1 seek GENOME/ASSETGet local asset path
refgenie1 seekr GENOME/ASSETGet remote asset path
refgenie1 alias getView genome aliases
refgenie1 alias set -a ALIAS -d DIGESTSet a genome alias
refgenie1 build GENOME/ASSETBuild an asset
  • Configuration - Advanced configuration options, PostgreSQL setup
  • Build - Building custom assets and using Docker
  • Data Channels - Adding custom asset types and recipes
  • Seek - More on retrieving asset paths
  • Pull - More on downloading assets