Skip to content

Instantly share code, notes, and snippets.

@sritchie73
Last active November 21, 2017 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie73/d880a15ec1fe30ab259e73f7f61de263 to your computer and use it in GitHub Desktop.
Save sritchie73/d880a15ec1fe30ab259e73f7f61de263 to your computer and use it in GitHub Desktop.
Script that will install HUMAnN2 and its dependencies on a linux machine
#!/bin/bash
# This script will install HUMAnN2 and its dependencies on a linux machine with BASH as the default terminal.
# Several pieces of software require user input during the installation process.
# In all cases the default option should be entered.
setwd $HOME
# Directories to store locally installed software
if [ ! -d "$HOME/usr/local/" ]; then
mkdir -p $HOME/usr/local/
fi
if [ ! -d "$HOME/usr/local/src" ]; then
mkdir -p $HOME/usr/local/src
fi
if [ ! -d "$HOME/usr/local/bin" ]; then
mkdir -p $HOME/usr/local/bin
fi
# Add to PATH - handling case where user has no bashrc file yet
if [ ! -f $HOME/.bashrc ]; then
touch $HOME/.bashrc
fi
if [ ! -f $HOME/.bash_profile ]; then
echo "source $HOME/.bashrc" > $HOME/.bash_profile
fi
if [ $(echo $PATH | grep "$HOME/usr/local/bin:") ]; then
# Do nothing
echo ""
else
echo 'export PATH=$HOME/usr/local/bin:$PATH' >> .bashrc
fi
# Install miniconda - required for bioconda package manager, also installs python 2.7
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -P $HOME/usr/local/src
bash $HOME/usr/local/src/Miniconda2-latest-Linux-x86_64.sh .
################################################################
### Previous command requires user input! Stop copying here! ###
################################################################
source $HOME/.bashrc
# Add bioconda package manager
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda
# Install bowtie2
conda install bowtie2
# Make sure pip is in the path too
echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc
################################################################
### Previous command requires user input! Stop copying here! ###
################################################################
# Install diamond - must use v0.8.22 regardless of what HUMAnN2 dependency list says
wget https://github.com/bbuchfink/diamond/releases/download/v0.8.22/diamond-linux64.tar.gz \
-O $HOME/usr/local/src/diamond-v0.8.22.tar.gz
mkdir $HOME/usr/local/src/diamond-v0.8.22
tar -xzf $HOME/usr/local/src/diamond-v0.8.22.tar.gz -C $HOME/usr/local/src/diamond-v0.8.22
ln -s $HOME/usr/local/src/diamond-v0.8.22/diamond $HOME/usr/local/bin/diamond
# Install dependencies for MetaPhlAn2
conda install numpy
pip install --user biom-format
################################################################
### Previous command requires user input! Stop copying here! ###
################################################################
# Install MetaPhlAn2
wget https://www.dropbox.com/s/ztqr8qgbo727zpn/metaphlan2.zip?dl=0 -O $HOME/usr/local/src/metaphlan2.zip
mkdir $HOME/metaphlan2
unzip $HOME/usr/local/src/metaphlan2.zip
echo "export PATH=$HOME/metaphlan2:$PATH" >> .bashrc # software must be installed to $HOME/metaphlan2 to work
source $HOME/.bashrc
# Install glpk-4.6 (dependency for MinPath)
wget http://ftp.gnu.org/gnu/glpk/glpk-4.60.tar.gz -P $HOME/usr/local/src/
tar -xzf $HOME/usr/local/src/glpk-4.60.tar.gz -C $HOME
mv $HOME/glpk-4.60 $HOME/glpk-4.6
cd $HOME/glpk-4.6
./configure --prefix=$HOME/usr/local
make install
cd $HOME
# Install MinPath
wget "http://omics.informatics.indiana.edu/mg/get.php?justdoit=yes&software=minpath1.2.tar.gz" \
-O $HOME/usr/local/src/minpath1.2.tar.gz
mkdir $HOME/usr/local/src/MinPath1.2
tar -xzf $HOME/usr/local/src/minpath1.2.tar.gz -C $HOME/usr/local/src/
ln -s $HOME/usr/local/src/MinPath/MinPath1.2.py $HOME/usr/local/bin/MinPath1.2.py
# Install HUMAnN2
pip install --user humann2
# Test install
mkdir humann2_test
cd humann2_test
wget https://bitbucket.org/biobakery/biobakery/raw/tip/demos/biobakery_demos/data/humann2/input/demo.fastq
humann2_databases --download chocophlan DEMO humann2_database_downloads
humann2_databases --download uniref DEMO_diamond humann2_database_downloads
humann2 --input demo.fastq --output demo_fastq
cd $HOME
rm -rf humann2_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment