ubuntu 安装 samtools

ubuntu 安装 samtools

samtool具体是什么,就不介绍了(哈哈,因为我也不知道)

安装包来自github,地址:https://github.com/samtools/samtools

看了它的README,安装samtools需要先安装一些必要的库和htslib这个工具包

System Requirements
===================

Samtools requires the zlib library <http://zlib.net>, the bzip2
library <http://bzip.org/>, liblzma <http://tukaani.org/xz/> and (optionally)
a curses or GNU ncurses library <http://www.gnu.org/software/ncurses/>.
The bzip2 and liblzma dependencies can be removed if full CRAM support
is not needed - see HTSlib's INSTALL file for details.


接下来,开始安装

在usr目录下面新建了个文件work

cd /usr

mkdir work

然后进入work目录

cd work

下载这两个工具包,samtools和htslib

git clone https://github.com/samtools/samtools.git

git clone https://github.com/samtools/htslib.git

然后进入htslib工具包目录下(先安装这个)

cd htslib

依次执行

autoheader     # If using configure, generate the header template...
autoconf       # ...and configure script (or use autoreconf to do both)
./configure    # Optional, needed for choosing optional functionality
make
make install

在configure(产生警告缺少库)或者make(产生错误,没有bzlib.h)之后

cram/cram_io.c:57:19: fatal error: bzlib.h: No such file or directory
 #include <bzlib.h>
                   ^
compilation terminated.
make: *** [cram/cram_io.o] Error 1
那就安装这个库文件

apt-get install libbz2-dev

安装完之后继续make,出现另外一个错误,没有lzma.h

gcc -g -Wall -O2 -I.  -c -o cram/cram_io.o cram/cram_io.c
cram/cram_io.c:60:18: fatal error: lzma.h: No such file or directory
 #include <lzma.h>
                  ^
compilation terminated.
make: *** [cram/cram_io.o] Error 1

安装这个库文件

apt-get install liblzma-dev

然后就make

make install

不会再有其他问题了。

接着,返回到上级目录,进入到samtools,开始安装这个工具包 

autoconf -Wno-syntax  # Generate the configure script, if needed
./configure           # Optional, needed for choosing optional functionality
make
make install

如果在上面的make后提示

bam_tview_curses.c:41:20: fatal error: curses.h: No such file or directory

#include <curses.h>

请安装这个库文件

sudo apt-get install libncurses-dev

安装完之后,继续make make install


最后,测试他们提供的例子

进入example目录

To try samtools, you may run the following commands.

Index the reference FASTA.
    samtools faidx ex1.fa

Convert the (headerless) SAM file to BAM.  Note if we had used
"samtools view -h" above to create the ex1.sam.gz then we could omit the
"-t ex1.fa.fai" option here.
    samtools view -S -b -t ex1.fa.fai -o ex1.bam ex1.sam.gz

Build an index for the BAM file:
    samtools index ex1.bam

View a portion of the BAM file:
    samtools view ex1.bam seq2:450-550

发表评论

电子邮件地址不会被公开。 必填项已用*标注