Conda has been my go-to software manager, but it was only recently brought to my attention that a well maintained project has aimed to greatly speed up and improve the conda functions. Mamba is an almost complete rewrite of conda in C++, allows for parallel downloading of data, and has faster (and better) dependency resolving. For working with larger environments I’ve noticed tasks that would take tens of minutes only takes minutes now (if not less).
Below I’ll provide a quick tutorial on working with mamba, which in theory mirrors what one would do with conda. You should have at least miniconda3 installed.
Your conda base environment is the environment where the conda software lives, and additionally any software in base gets added to your path. Generally you don’t want to install software into the base environment., however in this particular case you need to install mamba here, since it will replace conda for most tasks.
conda install -n base -c conda-forge mamba
I usually set the conda-forge and bioconda channels to allow for downloading up-to-date biology software.
conda config --add channels defaults conda config --add channels bioconda conda config --add channels conda-forge
If you ever want to update the mamba software you can now update it similar to how conda is updated.
mamba update -n base mamba
If you want to search for an available package, the command is slightly different in mamba.
mamba repoquery search samtools
You also have the ability to check which packages the one you are searching for depends on.
mamba repoquery depends -a samtools
Creating an environment
Installing an environment is similar to conda. As an example I’ll create an environment that includes common software for transcript quantification and differential gene expression.
mamba create -n rnaquant salmon r-tximport bioconductor-deseq2
The environment can now be activated and used with
conda activate rnaquant.
Once an environment is created, it’s easy to add new software. I will add FastQC to my RNA-seq quantification environment, because as a good bioinformatician I want to quality control my fastq files.
mamba install -n rnaquant fastqc
It’s also easy to update the software in an environment.
mamba update -n rnaquant --all
Undoing changes to an environment
Environments keep track of all software changes. You can look through these changes and revert back to a previous state using revisions.
First, search through the revision history of an environment.
mamba list -n rnaquant --revisions
Let’s say that updating the environment above put us at revision 2, but now we want to undo those updates and get back to the state we were in just after we installed fastqc (revision 1). You can install revisions like you can software.
mamba install -n rnaquant --revision 1
Removing an environment
You’ve done all your work for a project and now you don’t need it any more. You can safely remove the environment.
mamba env remove -n rnaquant
Remember that if you want to save an environment for use later, you can export a recipe to a yaml file.
mamba env export -n rnaquant > rnaquant_env.yaml
You can then use that yaml file to install the environment again.
mamba create --file rnaquant_env.yaml
Read more here: Source link