Micromamba package manager
The problem and its solution
A typical bioinformatics workflow involves dozens of different tools, sometimes each requiring a broad range of libraries and other dependencies. Installing all of them is a tedious task sometimes, an impossible task when different packages require different versions of the same tool.
There are two main solutions to the problem: one is to rely on containers (which resolve the problem of conflicting packages, but does not necessarily simplify the installation of the packages) or package managers.
Micromamba: a modern solution
Micromamba is a package manager that was developed to simplify the installation of Python tools and the creation of isolated environments (to allow, for example, the insulation of conflicting packages).
Micromamba quickly became a fantastic solution to the problem providing:
- a package manager that runs in the user space (not requiring
sudoprivilege) - an easy way to add new packages to the repository (in fact, repositories)
Installing conda
The latest version is available from the offical website.
In MacOS you might have “brew” installed, thus you can install micromamba with:
1
brew install micromamba
Otherwise, the installation is automated by a script (works for both Linux and MacOs):
1
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
Repositories
Conda allows to install packages from a default channel (mainly containing python modules), but also supports third party channels. There are three channels that can be of particular interest in (bio)data science:
-
biocondacontains bioinformatics programs (and bioinformatics R libraries) -
conda-forgecontains updated versions of commonly used command-line utilities
For example, to check if samtools is available in bioonda, and which versions:
1
micromamba search -c bioconda samtools
use the Bioconda website instead to search quickly
To install it you can either accept the last compatible version:
1
micromamba search -c bioconda samtools
or specify the version you require:
1
micromamba search -c bioconda samtools=1.10
To install a package, simply replace search with install.
If you also add -y you will not be prompted and will try to install directly.
1
micromamba install -y -c bioconda vsearch
We can add some channels to a configuration file so that conda always checks them
when searching. This will make some searches slower so I generally only add conda-forge,
but adding also bioconda can be appropriate. Avoid adding r: it’s massive and
rarely used in bioinformatics (most biological R packages are available in bioconda).
To add some channels in your configuration file, create (or edit) the ~/.mambarc file as
follows:
1
2
3
4
channels:
- conda-forge
- bioconda
channel_alias: https://repo.prefix.dev/
Creating and using environments
Conda simplifies installing package, but a problem remains: conflicting versions. You may want to use samtools 1.10, for example, but another tool installed an older version because it’s not yet ready to support a more recent one.
Conda allows to create environments, that are isolated rooms where you can install packages independently from other rooms.
Create a new environment
We need to choose a unique name for our new environment, in this example myenv1 (usually it’s the name of a tool (like qiime2-2020.1) or a task (like denovo):
1
micromamba create -n myenv1
You can create a new environment and simultaneously install some packages, for example
1
micromamba create -n mapping --yes "samtools>=1.9" minimap2 bwa=0.7
- the
-yor--yesswitch will automatically accept the suggested packages and proceed with installation
Activate the environment
To use an environment we need first to activate it:
1
micromamba activate myenv1
When the environment is active, you will no longer be able to access the packages you installed in the base environment, and if you install a package now it will belong to the active environment.
1
micromamba install -c bioconda vsearch=2.17
When running “install” check that you are in the correct environment
Deactivate the environment
To return to the previous environment:
1
micromamba deactivate
List your environments
To get a list of the environments in your system:
1
micromamba env list
Delete an environment
To be used with care:
1
micromamba remove -n ENVIRONMENT_NAME --all
See also: