Skip to content

Instantly share code, notes, and snippets.

@dceoy
Last active March 13, 2019 22:00
Show Gist options
  • Save dceoy/7f01f536df504a67e9c160d017e67ea0 to your computer and use it in GitHub Desktop.
Save dceoy/7f01f536df504a67e9c160d017e67ea0 to your computer and use it in GitHub Desktop.
[Shell] Install BWA, Samtools, Bcftools, and Bedtools
#!/usr/bin/env bash
#
# Usage: ./install_bio_stack.sh <dest dir path>
set -uex
PREFIX_DIR=$(realpath "${1}")
BIN_DIR="${PREFIX_DIR}/bin"
SRC_DIR="${PREFIX_DIR}/src"
mkdir -p "${SRC_DIR}" "${BIN_DIR}"
function clone-or-pull {
for r in "${@}"; do
dest="${SRC_DIR}/${r##*/}"
if [[ -d "${dest}" ]]; then
cd "${dest}" && git pull
else
git clone "https://github.com/${r}.git" "${dest}"
fi
done
}
clone-or-pull \
lh3/bwa \
samtools/htslib \
samtools/samtools \
samtools/bcftools \
arq5x/bedtools2
cd "${SRC_DIR}/bwa" \
&& make \
&& cd "${BIN_DIR}" \
&& find ../src/bwa -maxdepth 1 -type f -executable \
-exec cp -f {} "${BIN_DIR}" \;
cd "${SRC_DIR}/htslib" \
&& autoheader \
&& autoconf \
&& ./configure --prefix="${PREFIX_DIR}" \
&& make \
&& make install
cd "${SRC_DIR}/samtools" \
&& autoheader \
&& autoconf \
&& ./configure --prefix="${PREFIX_DIR}" \
&& make \
&& make install
cd "${SRC_DIR}/bcftools" \
&& autoheader \
&& autoconf \
&& ./configure --prefix="${PREFIX_DIR}" \
&& make \
&& make install
cd "${SRC_DIR}/bedtools2" \
&& make \
&& cp -f "${SRC_DIR}/bedtools2/bin/"* "${BIN_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment