Conda Environment
About Conda
1. Conda is an open-source package management system and environment management system.
2. Package, dependency and environment management for any language---Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN
3. Comparison of pip and conda
Pip installs Python software packaged as wheels or source distributions, which may require compilers and libraries. Conda packages are binaries. No need for compilers.
Conda packages are not limited to Python package.
Conda can create isolated environments. Pip has no built in support for environments but rather depends on other tools like virtualenv or venv to create isolated environments.
Pip installation does not check dependencies of all packages. Conda installation will verify that all requirements of all packages installed in an environment are met. This check can be slow.
A package may not be available as a conda package https://anaconda.org but is available on PyPI and can be installed with pip https://pypi.org
4. Miniconda is a free and mini version of Anaconda.
Use Conda
1. Load miniconda3 module
Some online conda doc suggests running conda init to initialize conda environment. Please do not run this as it will add conda settings in your .bashrc file which may pollute your environment. You only want to call the conda environment when needed, not by default.
2. Managing environments
Conda allows you to create separate environments containing files, packages, and their dependencies that will not interact with other environments. When you begin using conda, you already have a default environment named base. To see available packages in the base environment
You can run the command "python -V" to see what is the python version in the base environment. You can't add your own programs into the base environment because you will not have permissions. Create your own separate environments to keep your programs isolated from each other. To see available conda environments
Create a new environment and install a package in it. We will name the environment snowflakes and install the package BioPython. Type the following:
Run python and then import Bio to confirm biopython can be imported. Then run conda deactivate to leave the snowflakes environment.
To delete an entire environment.
3. Show conda environment info
4. Exercise 1: install samtools
If you run "module avail samtools", you will find the latest module available is 1.10. Now you are going to install a newer version of samtools using conda. First create an environment named samtools
Visit https://anaconda.org and search for "samtools" which will lead you to page about installation instructions. Follow the instruction there. Run the samtools command to confirm it worked.
What if you want to install a different version of samtools? You can change the syntax to conda install -c bioconda samtools=1.1. This will downgrade your samtools from 1.12 to 1.11.
What if you want to keep both versions? HINT: create a separate conda environment named samtools-1.1.
5. Exercise 2: install umi_tools
Next you want to install a python package named umi_tools. Search for umi_tools in https://anaconda.org to get instructions.
You can download conda cheat sheet from https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html or google conda cheat sheet.
Last updated