Nature Method:Bioconda解决生物软件安装的烦恼

2019-10-14 16:25:39 浏览数 (1)

其它之前很多人都用过Conda,特别是生信科学家近两年都在用Bioconda,那叫一个妙不可言、根本停不下来。这里我郑重通知大家,Bioconda于今年6月2号正式发表于Nature Methods(IF=26.9)。吃水不忘挖井人,用过的写文章记得引用它。

Bioconda是生物软件库,可以利用Conda快速安装绝大多数生物学软件,让生物学家从复杂的版本和依赖关系中解脱出来,专心数据分析。

Bioconda主页:https://bioconda.github.io/

想查询要使用的软件及指定版本是否己被Bioconda收录,可访问 https://bioconda.github.io/recipes.html#recipes 查询:

上图看到查询qiime,发现目前bioconda已经有8744个软件及版本收录,qiime有1.9.1和1.8.0,大多数在Linux和OSX都可以使用。安装时可以指定版本,如不指定则安装最新版本。

查询到的软件名,可以点击进入

有详细的安装和升级说明,而且还有Docker镜像,即使你安装不成功,也可以使用Docker方式来使用软件。这一点非常重要,因为conda也会存在依赖关系无法解决的情况,或安装完仍存在问题。但Docker是不存在外部依赖问题的,成功率更高。

想使用Bioconda,你需要先安装Conda。

软件管理器conda

Conda是目前最方便的软件管理器,可以一键安装大多数生物学软件,让你从痛苦的依赖关系和包安装中解脱出来。常用的发行版有Anaconda,和miniconda两种。从字面上看就知道一个非常大,一个很小。这里推荐你空间大的选anaconda,想快速安装的选miniconda。

而且每个版本都有Python2和Python3的版本,这里我们选择python2的版本,对目前大多数软件兼容更好。

本教程演示使用的测试平台为Ubuntu 16.04,~/bin默认为自己的环境变量目录

代码语言:javascript复制
# 创建并进入测试目录中的软件目录,请按个人习惯修改
mkdir -p ~/test/soft && cd ~/test/soft

下面Anaconda和Miniconda任选其一即可,这里推荐Miniconda更小巧

选择一、Anaconda安装 603Mb

代码语言:javascript复制
# https://www.anaconda.com 下载Linux python2.7 5.1
wget -c  https://repo.anaconda.com/archive/Anaconda2-5.2.0-Linux-x86_64.sh &
bash Anaconda2-5.2.0-Linux-x86_64.sh
# 安装过程同下面minicona

选择二、Miniconda安装 38Mb

代码语言:javascript复制
# 可选miniconda https://conda.io/miniconda.html
wget -c https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh
# Miniconda2 4.5.4

按提示Enter回车、输入yes同意许可协议、默认安装目录为~/miniconda2回车即可;安装结束后提示添加环境变量,一般选no,否则可能会破坏你之前安装的软件依赖关系。如果你是新用户,没什么软件可破坏的,请选yes添加以后使用更方便

如上面选择no,以后想使用conda,还要执行下面一句话临时添加conda为环境变量

代码语言:javascript复制
export PATH=~/miniconda2/bin:$PATH

Codna配置

主要是添加bioconda频道,方便生物软件安装。添加清华的一系列镜像,加速下载,提高成功率。默认仓库不仅速度极慢,而且经常中断,国内镜像下载速度可达国外几百倍。

代码语言:javascript复制
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda
# 添加清华镜像加速下载
site=https://mirrors.tuna.tsinghua.edu.cn/anaconda
conda config --add channels ${site}/pkgs/free/
conda config --add channels ${site}/pkgs/main/
conda config --add channels ${site}/cloud/conda-forge/
conda config --add channels ${site}/pkgs/r/
conda config --add channels ${site}/cloud/bioconda/
conda config --add channels ${site}/cloud/msys2/
conda config --add channels ${site}/cloud/menpo/
conda config --add channels ${site}/cloud/pytorch/

Conda安装软件

代码语言:javascript复制
conda install bowtie2

显示如下信息:

代码语言:javascript复制
Solving environment: done## Package Plan ## environment location: /mnt/bai/yongxin/miniconda2 added / updated specs:
   - bowtie2The following packages will be downloaded:   package                    |            build
   ---------------------------|-----------------
   bowtie2-2.3.4.2            |   py27h2d50403_0        13.6 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   certifi-2018.8.24          |           py27_1         139 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   perl-5.26.2                |       h470a237_0        15.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   ca-certificates-2018.8.24  |       ha4d7672_0         136 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   openssl-1.0.2o             |       h470a237_1         3.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   conda-4.5.11               |           py27_0         634 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   ------------------------------------------------------------
                                          Total:        33.8 MBThe following NEW packages will be INSTALLED:   bowtie2:         2.3.4.2-py27h2d50403_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda  
   perl:            5.26.2-h470a237_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeThe following packages will be UPDATED:   ca-certificates: 2018.03.07-0                                                                           --> 2018.8.24-ha4d7672_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   certifi:         2018.4.16-py27_0                                                                       --> 2018.8.24-py27_1     https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   conda:           4.5.4-py27_0                                                                           --> 4.5.11-py27_0        https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   openssl:         1.0.2o-h20670df_0                                                                      --> 1.0.2o-h470a237_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forgeProceed ([y]/n)?

主要是该软件的依赖关系,及依赖关系下载地点,输入y回车,等着安装完成即可。

对于依赖上百个软件和包的流程,一键安装成功,那叫一个字“爽”!轻松节约你原来几天的时间。

conda可以轻松安装众多宏基因组领域软件

代码语言:javascript复制
# 宏基因组质控流程
conda install kneaddata
# humann2有参物种功能定量流程
conda install humann2
# grahplan树图
conda install graphlan
conda install export2graphlan

指定虚拟环境、python版本和软件版本安装

有时为了之前安装的软件依赖关系不被影响,或默认安装时无法满足依赖关系时,就需要新建虚拟环境,并指定版本来安装。以kneaddata为例,这是一个质控、去宿主和流程依赖很多。如果你原来是Python3,则需要虚拟环境中安装Python2.7才能运行成功。

代码语言:javascript复制
conda create -n kneaddata kneaddata=0.6.1 python=2.7

显示安装的指定版本和依赖关系,这个不少吧,共31个软件和包,这要是之前自己装,可能3天都不一定搞得定。

代码语言:javascript复制
## Package Plan ## environment location: /mnt/bai/yongxin/miniconda2/envs/kneaddata added / updated specs:
   - kneaddata=0.6.1
   - python=2.7The following packages will be downloaded:   package                    |            build
   ---------------------------|-----------------
   python-2.7.15              |       h9fef7bc_0        13.9 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   boost-1.59.0               |           py27_0        12.7 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo
   krb5-1.14.6                |                0         4.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   blast-2.5.0                |       h3727419_3       137.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   openssl-1.0.2p             |       h470a237_0         3.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   bmtagger-3.101             |       h470a237_4           7 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   bmtool-3.101               |       hfc679d8_2          64 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   bmfilter-3.101             |       hfc679d8_2          83 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   kneaddata-0.6.1            |             py_2         406 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   readline-7.0               |       haf1bffa_1         381 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   trimmomatic-0.36           |                3         132 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   wheel-0.31.1               |           py27_1          61 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   bzip2-1.0.6                |       h470a237_2         310 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   ncurses-6.1                |       hfc679d8_1         1.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   extract_fullseq-3.101      |                3           8 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   sqlite-3.24.0              |       h2f33b56_0         1.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   srprism-2.4.24             |       h96824bc_3         457 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   pip-18.0                   |           py27_1         1.7 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   libgcc-7.2.0               |       h69d50b8_2         304 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   zlib-1.2.11                |       h470a237_3          93 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   setuptools-40.2.0          |           py27_0         585 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   trf-4.09                   |                1          47 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   libstdcxx-ng-7.2.0         |       hdf63c60_3         2.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   xz-5.2.4                   |       h470a237_1         328 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   samtools-1.7               |                1         1.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   libgcc-ng-7.2.0            |       hdf63c60_3         6.1 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   libssh2-1.8.0              |       h5b517e9_2         240 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   curl-7.61.0                |       h93b3f91_1         860 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   tk-8.6.8                   |                0         3.1 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
   fastqc-0.11.5              |                1         9.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   java-jdk-8.0.92            |                1       122.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
   ------------------------------------------------------------
                                          Total:       325.3 MB

安装完成后提示如何打开、关闭新的环境

代码语言:javascript复制
# 激活工作环境To activate this environment, use:
source activate kneaddata# 关闭环境To deactivate an active environment, use:
source deactivate

查看己安装软件的版本和依赖关系

代码语言:javascript复制
conda list -n kneaddata

显示软件安装位置、依赖关系、版本和下载地址如下:

代码语言:javascript复制
# packages in environment at /mnt/bai/yongxin/miniconda2/envs/kneaddata:
#
# Name                    Version                   Build  Channel
blast                     2.5.0                h3727419_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
bmfilter                  3.101                hfc679d8_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
bmtagger                  3.101                h470a237_4    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
bmtool                    3.101                hfc679d8_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
boost                     1.59.0                   py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo
bowtie2                   2.3.4.2          py27h2d50403_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
bzip2                     1.0.6                h470a237_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ca-certificates           2018.8.24            ha4d7672_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
certifi                   2018.8.24                py27_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
curl                      7.61.0               h93b3f91_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
extract_fullseq           3.101                         3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
fastqc                    0.11.5                        1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
java-jdk                  8.0.92                        1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
kneaddata                 0.6.1                      py_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
krb5                      1.14.6                        0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgcc                    7.2.0                h69d50b8_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgcc-ng                 7.2.0                hdf63c60_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libssh2                   1.8.0                h5b517e9_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libstdcxx-ng              7.2.0                hdf63c60_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ncurses                   6.1                  hfc679d8_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
openssl                   1.0.2p               h470a237_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
perl                      5.26.2               h470a237_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pip                       18.0                     py27_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python                    2.7.15               h9fef7bc_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
readline                  7.0                  haf1bffa_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
samtools                  1.7                           1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
setuptools                40.2.0                   py27_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
sqlite                    3.24.0               h2f33b56_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
srprism                   2.4.24               h96824bc_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
tk                        8.6.8                         0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
trf                       4.09                          1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
trimmomatic               0.36                          3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
wheel                     0.31.1                   py27_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xz                        5.2.4                h470a237_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
zlib                      1.2.11               h470a237_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

Reference

Grüning, B., et al. (2018). “Bioconda: sustainable and comprehensive software distribution for the life sciences.” Nature Methods 15(7): 475-476. https://doi.org/10.1038/s41592-018-0046-7

生信软件的好帮手-bioconda https://mp.weixin.qq.com/s/nK1Kkf9lfZStoX25Y7SzHQ

生信分析平台搭建(七):bioconda https://mp.weixin.qq.com/s/ng8oNU81UQ6FtBqkyMGV5A

0 人点赞