1 新建install.sh,内容如下
#!/bin/bash
set -e
if [ ! $1 ] || [ "$1"x == "-h"x ] || [ "$1"x == "--help"x ];then
echo -e "
\033[32mone-click install samtools, bcftools and htslib\033[0m
usage: \033[1m`basename $0` version [prefix]\033[0m
version the version to install, eg. 1.9
prefix the path to install, default: `dirname $(pwd)`/v\$version
contact: suqingdong@novogene.com"
exit
fi
VERSION=$1
if [ $2 ];then
INSTALL_DIR=$2
else
SOURCE_DIR=`pwd`
INSTALL_DIR=`dirname $SOURCE_DIR`/v${VERSION}
fi
for name in samtools bcftools htslib;do
if [ ! -f $name-$VERSION.tar.bz2 ];then
wget -c https://github.com/samtools/$name/releases/download/$VERSION/$name-$VERSION.tar.bz2
fi
done
tar -xf htslib-${VERSION}.tar.bz2
cd htslib-${VERSION}
./configure --prefix=${INSTALL_DIR} --disable-lzma
make && make install
cd ..
tar -xf bcftools-${VERSION}.tar.bz2
cd bcftools-${VERSION}
./configure --prefix=${INSTALL_DIR} --disable-lzma \
--with-htslib=${INSTALL_DIR}
make && make install
cd ..
tar -xf samtools-${VERSION}.tar.bz2
cd samtools-${VERSION}
./configure --prefix=${INSTALL_DIR} --disable-lzma \
--with-htslib=${INSTALL_DIR}
make && make install
echo "
export PATH=${INSTALL_DIR}/bin:\$PATH
export LD_LIBRARY_PATH=${INSTALL_DIR}/lib:\$LD_LIBRARY_PATH
" > ${INSTALL_DIR}/source_this
chmod 755 ${INSTALL_DIR}/source_this
cd ..
rm -rf *-${VERSION}*
echo -e '\033[1;32minstall done !\033[0m'
2 在软件安装目录执行以下命令
sh install.sh 1.9
3 使用时,source一下source_this文件即可