Conda and Mamba
The long-standing environment managers for conda-forge and Bioconda; Mamba and micromamba are faster versions of Conda
The course uses Pixi, which installs the same packages. Conda is what you meet on shared servers, in older projects and in workflow managers; lesson 05b compares the two.
Words
| Word | Meaning |
|---|---|
| channel | where packages come from: conda-forge for most software, bioconda for bioinformatics |
| environment | a folder with its own set of packages; Conda keeps them all in one place (~/miniforge3/envs/) |
environment.yml |
the packages an environment needs, often with loose versions |
| explicit spec | the exact package files of one platform, one URL per line |
Environments
| What you want | Command |
|---|---|
| A new environment with packages | conda create -n ltee -c conda-forge -c bioconda samtools |
| Use it / leave it | conda activate ltee / conda deactivate |
| Run one command in it | conda run -n ltee samtools --version |
| List your environments | conda env list |
| Delete it | conda env remove -n ltee |
Packages
| What you want | Command |
|---|---|
| Add a package | conda install -n ltee bwa |
| Remove a package | conda remove -n ltee bwa |
| Update everything | conda update -n ltee --all |
| See what is installed | conda list -n ltee |
See lesson 05b, the command table, with the Pixi command for each.
Mamba and micromamba
mamba takes the same commands as conda and solves faster (mamba create ..., mamba install ...). micromamba is one small program with no base environment; through Pixi you need not install it:
| What you want | Command |
|---|---|
| An environment in a folder, from a file | pixi exec micromamba create -y -p ./conda-env -f envs/pipeline.yml |
| Run a command in it | pixi exec micromamba run -p ./conda-env samtools --version |
| Empty micromamba’s package cache | pixi exec micromamba clean --all -y |
Run tools through run (or conda activate), not as ./conda-env/bin/TOOL: FastQC, for one, needs the environment’s Java.
Between Conda and Pixi
| What you want | Command |
|---|---|
A Pixi workspace from an environment.yml |
pixi init --import environment.yml NAME |
An environment.yml from a Pixi environment (version ranges) |
pixi workspace export conda-environment -e pipeline envs/pipeline.yml |
Exact specs from pixi.lock, one file per platform |
pixi workspace export conda-explicit-spec -e pipeline envs/explicit |
Official cheat sheets and references
- Conda cheat sheet, from the Conda project: https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html
- Mamba and micromamba documentation: https://mamba.readthedocs.io/
- Bioconda, with how to set up its channels: https://bioconda.github.io/
- NBIS, Controlling your environment with Conda: https://nbisweden.github.io/workshop-reproducible-research/pages/conda.html