Skip to content
Dianne Velasco edited this page Mar 1, 2019 · 6 revisions

Or how to install a program, make it a module, create a virtual environment, and use them together in a script. Using miniconda3 and SMC++ as an example. (SMC++ has disappeared from farm's miniconda3 -AKA conda3/bio3- install more than once and a reliable installation was needed.) Disclaimer: Works as intended but may not be the best method

INSTALL THE PROGRAM

First, get the Miniconda3 install file

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Install to your chosen directory

bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/Software/miniconda3

  • (flags: -b forced unattended installation; -p indicates the installation path)
  • Note: Also see the more comprehensive information about software installation on farm

CREATE A PERSONAL MODULE

Create your personal modules directory

mkdir -p $HOME/MyModules/miniconda3

  • Note: miniconda3 was not a module listed in module avail for the cluster therefore it was okay to use, however, I think you can name the module whatever you want.

Copy the module file for miniconda (i.e. conda3) to your personal modules directory

cp /share/apps/modulefiles/hpc/conda3/1.0 $HOME/MyModules/miniconda3

Modify the setenv in $HOME/MyModules/miniconda3/1.0 to the user installation

  • Original: setenv CONDA3_HOME /share/apps/conda3/miniconda3

  • Modified: setenv MINICONDA3_HOME /<full path to program here>/miniconda3

  • Note: modified CONDA3_HOME throughout 1.0 file to MINICONDA3_HOME to ensure proper functioning

Add to your available modules

module use $HOME/MyModules

  • Note: module avail will now show your personal modules under the first section listed, in my case /home/dmvelasc/MyModules
  • Note: module use $HOME/MyModules and export MODULEPATH=$HOME/MyModules:$MODULEPATH only temporarily save $HOME/MyModules in the $MODULEPATH.

CREATE A VIRTUAL ENVIRONMENT

Load your miniconda module

module load miniconda3

  • Note: Be sure to add your module to the module list with module use $HOME/MyModules before calling it

Create a virtual environments directory

mkdir $HOME/.virtualenvs

Create the desired virtual environment

virtualenv -p python3 .virtualenvs/smcpp

  • Note: the -p flag specifies the python version to use, can be even more version-specific if that version is installed

Activate the virtual environment

source $HOME/.virtualenvs/smcpp/bin/activate

Install SMC++

conda install -c terhorst -c bioconda smcpp

USE YOUR NEW MODULE AND VIRTUAL ENVIRONMENT IN A SCRIPT

You will need to include the following lines, with full paths, in your script after the header, etc.

module use /<full path>/MyModules
module load miniconda3
set +u
source <full path>/.virtualenvs/smcpp/bin/activate
set -u

Then carry on as normal in your script with bash and SMC++ commands

Helpful resources used to put this together

Clone this wiki locally