Linux Software Installation – Exercises 1
Part 1. Setup Conda
1.1 Login to the BioHPC machine and download the installer
Login (ssh) to the machine that you are assigned for this workshop (assigned machines: https://biohpc.cornell.edu/ww/machines.aspx?i=128). Prepare the working directory, and download the latest version of Miniconda/python3 installer into the working directory.
xxxxxxxxxx
mkdir /workdir/$USER
cd /workdir/$USER
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
1.2 Run the installer
xxxxxxxxxx
sh Miniconda3-latest-Linux-x86_64.sh
The “chmod u+x” command makes the file executable.
During the installation, you will be asked for multiple questions:
“Do you accept the license terms?”: Type "yes" and press “ENTER” key;
“Miniconda3 will now be installed into this location … ”: The default answer is "/home/$USER/miniconda3". You can either press "Enter" key to accept default or enter a different installation location. If your lab has a hosted BioHPC server, we strongly encourage you to enter "/workdir/xxxxx/miniconda3" (xxxxx is your userID) to install in local directory. This would make software installation/loading more than 10x faster.
“Do you wish to update your shell profile to automatically initialize conda?” : Press ENTER to accept the default “no”;
1.3 Miniconda is ready.
Part 2. Install and run a simple software in Conda
2.1 Activate Conda
If you installed Conda in your home directory
xsource ~/miniconda3/bin/activate
If you installed Conda in /workdir/$USER directory
xsource /workdir/$USER/miniconda3/bin/activate
2.2 Install and run bwa in Conda
xconda install bwa
bwa
While you are at this step, you might want to use “which” command to check which copy of “bwa” you are running.
xxxxxxxxxx
which bwa
Part 3. Work with Conda environment
3.1 Create a virtual environment and give it a name “pysam”, install pysam the virtual environment
xxxxxxxxxx
conda create -c bioconda -n pysam pysam
The command “conda create -n aligners” would create an environment called “pysam” (you can use any names), and install the pysam package into it.
3.2 Start the pysam environment, and run python
xxxxxxxxxx
conda activate pysam
which python
python -V
which pip
“which python” “which pip”would tell you which python and pip you are using .
3.3 Install other python modules in this environment
xxxxxxxxxx
pip install numpy
The “pip” command would install numpy in the environment.
3.4 End the environment
xxxxxxxxxx
conda deactivate
3.5. Now you installed pysam and numpy in miniconda3 in the home directory. Next time you need to use it in a new session, run these commands
xxxxxxxxxx
source $HOME/miniconda3/bin/activate
conda activate pysam
# after the work is done
conda deactivate
Part 4. Create a Python3.12 environment in Miniconda3
xxxxxxxxxx
conda create -n myNewPipeline python=3.12
conda activate myNewPipeline
which python
python -V ##use capital V
conda deactivate
Note in the first command there is no package name. This step would create an empty python 3.12 environment, within which you can use pip to install other python modules.