Created
December 18, 2015 22:43
-
-
Save mojaveazure/afac905c0329a1ed8550 to your computer and use it in GitHub Desktop.
Install SAMTools without needing root privileges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script downloads and installs SAMTools | |
# The current version of SAMTools is v1.3 | |
set -e | |
set -o pipefail | |
# What versions of SAMTools are we downloading? | |
SAMTOOLS_VERSION="1.3" | |
# Check for the TAR utility and Wget | |
if ! `command -v tar > /dev/null 2> /dev/null`; then echo "Failed to find the TAR utility, exiting..."; exit 1; fi | |
if ! `command -v wget > /dev/null 2> /dev/null`; then echo "Failed to find Wget, exiting..."; exit 1; fi | |
# Usage message | |
function Usage() { | |
echo -e "\ | |
`basename $0`: software_directory | |
where: software_directory is the directory to\n\ | |
download and install SAMTools to \n\ | |
\n\ | |
This script downloads and installs SAMTools: \n\ | |
The current version of SAMTools is ${SAMTOOLS_VERSION} \n\ | |
\n\ | |
Any previous installations of SAMTools in software_directory will be removed \n\ | |
" >&2 | |
exit 1 | |
} | |
# Export the usage message | |
export -f Usage | |
# Do we have our argument? | |
if [[ "$#" -ne 1 ]]; then Usage; fi # If not, run Usage | |
# Where do we download our files? | |
SOFT_DIR=$1 | |
# Change to the software directory | |
cd "${SOFT_DIR}" | |
# Remove any previous SAMTools installation | |
echo "Removing previous any SAMTools installations..." >&2 | |
rm -rf samtools* | |
# Download SAMTools | |
echo "Downloading SAMTools..." >&2 | |
wget https://github.com/samtools/samtools/releases/download/1.3/samtools-1.3.tar.bz2 | |
# Extract the tarballs | |
tar -xjf samtools* | |
# Change to the SAMTools directory | |
echo "Installing SAMTools..." >&2 | |
cd samtools* | |
./configure --prefix=$( pwd ) # Configure, set the install directory to be in this directory | |
make # Make SAMTools | |
make install # Install SAMTools | |
make clean # Clean up excess files | |
cd bin # Change into the 'bin' directory | |
echo export PATH=$( pwd ):'$PATH' >> "${HOME}"/.bash_profile # Add a PATH addition for SAMTools to our bash_profile | |
# Change back to the software directory | |
cd "${SOFT_DIR}" | |
# Clean up the tarballs | |
echo "Cleaning up leftover files..." >&2 | |
rm samtools*.tar.bz2 | |
# Final ending message | |
echo "Run source ~/.bash_profile to finish the installation process" >&2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment