Installing Conda, Setting Up Environments, and Installing Packages - statonlab/UTIA_Computational_Resource GitHub Wiki

Conda is an open source package and environment management. Within a conda environment you will be able to install any packages - and their dependencies - and run them. If you find a package that is unavailable in Spack but available in Conda, you can load a Conda environment and install the package.

1. Installing Conda

There are multiple methods to install Conda; the simplest is to install the latest version of Miniconda. Miniconda is a simplified version of Anaconda containing only what is needed to run Conda. This can be set up in your home directory (~).

Fresh installation of miniconda3 to scratch directory

If you're comfortable re-installing miniconda3 from scratch into your scratch directory, here is a way:

First, make sure your SCRATCHDIR variable is set to the new isaac24 location

# add to your ~/.bashrc
export SCRATCHDIR="/lustre/isaac24/scratch/<you username goes here>"

If you have any previous conda init lines in your ~/.bashrc, remove them. They look like the following:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/lustre/isaac24/scratch/rkuster/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/lustre/isaac24/scratch/rkuster/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/lustre/isaac24/scratch/rkuster/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/lustre/isaac24/scratch/rkuster/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Now install miniconda fresh.

mkdir -p $SCRATCHDIR/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $SCRATCHDIR/miniconda3/miniconda.sh
bash $SCRATCHDIR/miniconda3/miniconda.sh -b -u -p $SCRATCHDIR/miniconda3
rm $SCRATCHDIR/miniconda3/miniconda.sh
source $SCRATCHDIR/miniconda3/bin/activate
conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge
$SCRATCHDIR/miniconda3/bin/conda init
source .bashrc

If you want base when you log in, run the following:

conda config --set auto_activate_base true
source .bashrc

Complete the offered prompts, setting everything to default. Once installation is complete, close and reopen your window to confirm installation. If you are able to get a list of installed packages by running conda list, Conda has been installed correctly.

2. Creating a Conda Environment

Making a conda environment from scratch is fairly simple:

conda create --name <env_name>
conda activate <env_name>

I recommend making the name something you will be able to remember easily. If you aren't attempting to install packages that will conflict with each other, I also recommend creating one, centralized environment so that you know where most everything is located.

However, you may also need to load a saved environment associated with an existing package, such as aTRAM. This environment is created using the following commands:

cd /pickett_centaur/software/aTRAM
conda env create -f environment.yml
conda activate aTRAM

3. Installing new packages

If you plan on running python for any bioinformatics pipelines, Biopython is essential. To install Biopython for use, activate your personal environment and run this command:

conda install -c conda-forge biopython

As long as your environment is active, you will be able to run biopython.

The -c option specifies the channel from which we installed biopython, which will not be the same for every package you load. I recommend searching for your package + conda and getting the command from their documentation.

⚠️ **GitHub.com Fallback** ⚠️