本文最后更新于190 天前,其中的信息可能已经过时,如有错误请发送邮件到wuyk@163.com
samtools的安装需要已经安装了java环境,如果没有安装java环境,请移步linux下java环境的安装
java环境安装好后,我们开始安装samtools
访问samtools的官网:http://www.htslib.org/,点击download下载安装包
随后通过ftp将其上传至linux下软件安装位置
#解压samtools安装包
tar -xvf samtools-1.18.tar.bz2
#进入samtools的环境下
cd samtools-1.18.tar.bz2
./configure
#编译
make
make install
#测试是否安装成功
./samtools
samtools安装成功后,我们需要将 samtools可执行文件的路径添加到系统的环境变量中,这样就可以在任何位置直接使用samtools命令
#回到主目录下
cd
#打开编辑系统环境变量文件
vim .bashrc
# 将samtools的可执行文件的路径添加到系统的环境变量中,在合适的位置输入
export PATH=/home/wuyk/biosoft/samtools-1.18:$PATH
samtools环境配置完成后,输入source .bashrc刷新以下环境变量,就可以在任何位置直接使用samtools~
值得注意的是,如果你是一个新的服务器,在samtools在编译的过程中,往往会出现很多软件没有的情况,这个时候缺什么就装什么就行,以下是本人在编译samtools的时候遇到的问题
###############第一个报错#######################
#configure: error: curses development files not found
#The 'samtools tview' command uses the curses text user interface library.
#Building samtools with tview requires curses/ncurses/etc development files
#to be installed #on the build machine; you may need to ensure a package such
#as libncurses5-dev (on Debian or #Ubuntu Linux) or ncurses-devel (on RPM-based
#Linux distributions) is installed.
#FAILED. Either configure --without-curses or resolve this error to build
#samtools successfully.
#解决办法
#这个错误出现的原因是在构建samtools时缺少所需的curses文本用户界面库的开发文件。要解决这个错误#并成功构建samtools
sudo apt-get update
sudo apt-get install libncurses5-dev
#好了,第一个报错解决,接下来我继续输入./configure编译
###################出现了第二个报错###################
#configure: error: libbzip2 development files not found
#The CRAM format may use bzip2 compression, which is implemented in HTSlib by using #compression routines from libbzip2 <http://www.bzip.org/>.
#Building HTSlib requires libbzip2 development files to be installed on the build machine; #you may need to ensure a package such as libbz2-dev (on Debian or Ubuntu Linux) or bzip2-#devel (on RPM-based Linux distributions or Cygwin) is installed.
#Either configure with --disable-bz2 (which will make some CRAM files produced elsewhere #unreadable) or resolve this error to build HTSlib. configure: error: ./configure failed for #htslib-1.18
#这个错误是因为在构建HTSlib时缺少libbzip2的开发文件。HTSlib使用libbzip2来实现bzip2压缩,因此##需要在构建机器上安装相应的开发包。
sudo apt-get update
sudo apt-get install libbz2-dev
#好了,第二个缺少的开发包已经安装好了,继续输入./configure编译
###################第三次报错###############################
#configure: error: liblzma development files not found The CRAM format may use LZMA2 #compression, which is implemented in HTSlib by using compression routines from #liblzma<http://tukaani.org/xz/>.
#Building HTSlib requires liblzma development files to be installed on the build machine; you #may need to ensure a package such as liblzma-dev (on Debian or Ubuntu Linux), xz-devel (on #RPM-based Linux distributions or Cygwin), or xz (via Homebrew on macOS) is installed; or #build XZ Utils from source.
#Either configure with --disable-lzma (which will make some CRAM files produced elsewhere #unreadable) or resolve this error to build HTSlib.configure: error: ./configure failed for #htslib-1.18
###这个错误是因为在构建HTSlib时缺少liblzma的开发文件。HTSlib使用liblzma来实现LZMA2压缩,因此##需要在环境中安装相应的开发包。
sudo apt-get update
sudo apt-get install liblzma-dev
###安装完成后,再次输入./configure就没再报错啦~,随后输入make编译,编译完成后将samtools添加到系统的环境变量下就好啦~