直接编译AUGUSTUS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
make[2]: Entering directory `$HOME/software/augustus-3.3.1/auxprogs/bam2hints'
make[2]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
g++ -Wall -O2    -c bam2hints.cc -o bam2hints.o -I/usr/include/bamtools
bam2hints.cc:16:10: fatal error: api/BamReader.h: No such file or directory
 #include <api/BamReader.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [bam2hints.o] Error 1
make[2]: Leaving directory `$HOME/software/augustus-3.3.1/auxprogs/bam2hints'
make[1]: *** [all] Error 2
make[1]: Leaving directory `$HOME/software/augustus-3.3.1/auxprogs'
make: *** [all] Error 2

直接编译AUGUSTUS会在编译bam2hints时出错。因此,我们需要安装bamtools

安装bamtools

一键解决方案

1
sudo apt-get install bamtools libbamtools-dev

但是,我们没有root权限,只能手动编译。

普通用户安装bamtools需要指定安装目录

1
2
3
4
5
6
7
8
wget https://github.com/pezmaster31/bamtools/archive/v2.4.1.tar.gz -O bamtools-2.4.1.tar.gz
tar zxf bamtools-2.4.1.tar.gz
cd bamtools-2.4.1
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/your/path/to/bamtools ..
make
make install

我目前的服务器环境比较复杂。CentOS 6.9,其默认的GCC版本是4.4.7,在编译很多软件时版本过低。目前将其升级到了7.3.0,但未保留原本的4.4.7环境。因此,在编译bamtools过程中有些挑剔软件版本

对于≤2.4.0版本的bamtools,编译时都会出现如下报错。≥2.4.2版本的bamtools则要求cmake版本高于3.0,而本机的cmake版本是2.8.12.2。因此,在尽量少折腾的原则下,我们选择2.4.1版本。

编译bamtools-2.4.1

安装完成后,运行bamtools程序,提示缺少libbamtools.so.2.4.1

1
2
$ ~/opt/bamtools-2.4.1/bin/bamtools
$HOME/opt/bamtools-2.4.1/bin/bamtools: error while                                                 loading shared libraries: libbamtools.so.2.4.1: cannot open shared                                                 object file: No such file or directory

find ~/opt -name libbamtools.so.2.4.1搜寻该文件。然后将libbamtools.so.2.4.1软链接到~/opt/bamtools-2.4.1/lib/目录下,即可正常启动bamtools

修改bam2hints 与filterBam的Makefile,使其与手动编译的bamtools配合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
First, go to the “./auxprogs/bam2hints” directory and make the following changes for the Makefile:

Add:
BAMTOOLS = $HOME/opt/bamtools-2.4.1

Replace:
INCLUDES = /usr/include/bamtools
By:
INCLUDES = $(BAMTOOLS)/include

Replace:
LIBS = -lbamtools -lz
By:
LIBS = $(BAMTOOLS)/lib/bamtools/libbamtools.a -lz

Then, go to the “augustus-3.2.3/auxprogs/filterBam/src” directory and make the following changes for the Makefile:
Replace:

BAMTOOLS = /usr/include/bamtools
By:
BAMTOOLS = $HOME/opt/bamtools-2.4.1

Replace:
INCLUDES = -I$(BAMTOOLS) -Iheaders -I./bamtools
By:
INCLUDES = -I$(BAMTOOLS)/include -Iheaders -I./bamtools

Replace:
LIBS = -lbamtools -lz
By:
LIBS = $(BAMTOOLS)/lib64/libbamtools.a -lz

编译bam2wig

编译好bamtools后,应当向系统目录拷贝一些库文件,但限于我们没有root权限,只能修改Makefile,手动指向这些库文件。

编译bam2wig依赖bcftools, htslib, samtools, tabix四款软件

从其github站点,或官网下载,解压后直接编译。其中,tabix已经并入了htslib

1
2
3
./configure --prefix=/where/to/install
make
make install

修改bam2wig的Makefile,使其与上述软件配合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# SAMTOOLS=$(TOOLDIR)/samtools/
SAMTOOLS=$HOME/software/samtools-1.9

#HTSLIB=$(TOOLDIR)/htslib/
HTSLIB=$HOME/software/htslib-1.9

# BCFTOOLS=$(TOOLDIR)/bcftools/
BCFTOOLS=$HOME/software/bcftools-1.9

# TABIX=$(TOOLDIR)/tabix/
TABIX=$HOME/software/htslib-1.9

注意,此处的路径$HOME/software/其实是解压后的软件包编译的路径,并不是软件最终安装的路径。否则,会出现如下报错。

1
2
3
4
5
6
7
make[2]: Entering directory `$HOME/software/augustus-3.3.1/auxprogs/bam2wig'
make[2]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
gcc -Wall -O2 -I$HOME/opt/samtools-1.8/ -I. -I$HOME/opt/htslib-1.9/ -I$HOME/opt/bcftools-1.9/ -I$HOME/opt/htslib-1.9/ -c bam2wig.c -o bam2wig.o
bam2wig.c:18:10: fatal error: sam.h: No such file or directory
 #include "sam.h"
          ^~~~~~~
compilation terminated.

编译bam2wig过程中报错

1
2
3
hfile_s3.c:(.text+0x8d7): undefined reference to `EVP_sha1'
hfile_s3.c:(.text+0x8fd): undefined reference to `HMAC'
collect2: error: ld returned 1 exit status

解决方案

1
2
hfile_libcurl.c:(.text+0x12aa): undefined reference to `curl_global_cleanup'
collect2: error: ld returned 1 exit status

解决方案

因此,我们还需修改bam2wig路径中的Makefile,向其中的LIBS项末尾添加-lcrypto -lcurl两个字段补充缺少的库文件。

再次编译AUGUSTUS

1
2
3
4
5
6
7
##清除之前未成功编译的中间文件,回复初始状态
make clean
##多线程编译缩短时间
make -j 8
echo 'PATH=$PATH:~/opt/augustus/bin:~/opt/augustus/scripts' >> ~/.bashrc
##可选步骤,手动设置配置文件夹的路径。如未设置,默认会搜寻可执行文件相对路径../config中的文件。
echo 'AUGUSTUS_CONFIG_PATH=/my_path_to_AUGUSTUS/augustus/config/' >> ~/.bashrc

总结

经过上述步骤,在普通用户权限下解决好bam2hintsbam2wig的依赖,并修改其Makefile其实适应手动安装的配置环境,从而完成普通用户的AUGUSTUS安装。

参考来源

https://github.com/Gaius-Augustus/Augustus

https://genehub.wordpress.com/2018/05/16/augustus-3-3%E7%9A%84%E5%AE%89%E8%A3%85/

https://iamphioxus.org/2017/05/08/installing-augustus-with-manual-bamtools-installation/