使用Bioconda辅助生物信息学软件安装


2018-01-30

Andrew Perry,
Monash Bioinformatics Platform

王诗翔(译)

依照:https://github.com/XSLiuLab/bioconda-tutorial/blob/master/Bioconda_Installation.ipynb

否认声明:当我在谈论这件事的时候,我不会假装自己是一个Conda或Bioconda的专家。

这是我基于Simon Gladman, Saskia Hiltemann and Eric Rasche提供的一个工作坊"Packaging your bioinformatics tool with Bioconda and Galaxy"进行的。

为什么使用Conda?

  • 管理独立的环境,包括依赖。不需要sudo
  • 大型组织为channels的预编译的生态系统(如conda-forge、bioconda)
  • 语言不限(不仅仅是Python!)
  • 用不同的系统创建一个新的包都非常简单直接(一个食谱recipe包含一个短的build.shmeta.yml)。
  • 整合了Python的virtualenvpip
  • 以Continuum Analytics公司为背景的开源工具(BSD)。一些默认channel中的包不是开源的。

(@ο@) 哇~ 'environment'

Conda开源设置一些UNIX shell环境变量,主要是PATH,它决定了当你键入它程序名字时运行的程序版本。

键入:

env

你将看到你的环境变量。

为什么使用Bioconda?

  • 大型可获取生信软件生态系统,约250位贡献者。

  • Conda环境促进可重复性 - 一个environment.yml文件可以记录工具版本(+构建号),它可以在其他地方稳定地重装。

  • 它是支持_Galaxy_工具安装方法,已经存在的包会进行维护并有新的软件加入。

  • 质量控制 - 很好的文档指南(http://bioconda.github.io/guidelines.html),自动化测试、包构建(TravisCI / CircleCI)以及核心团队的合并审查。

    • 有趣的事实: Bioconda食谱不盲目地信任工具上的版本号,它们使用源包的md5和sha256检验和。
  • Docker容器支持(Biocontainers项目)。

可以在这个博客bioArxiv看到更多卖点。

让我们从Bioconda安装Minicaonda和一些工具

Miniconda在你的家目录下和自己的Conda环境中安装conda包管理器(Miniconda是'Anaconda'的迷你版本)。

Miniconda可以通过以下链接查阅: https://conda.io/miniconda.html

In [1]:
# 下载Minoconda

cd ~
# macOS系统
curl -O https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh

# 或者在Linux系统上
# curl -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 34.3M  100 34.3M    0     0  15.1M      0  0:00:02  0:00:02 --:--:-- 15.1M
In [2]:
# 查看安装帮助
sh ./Miniconda3-latest-MacOSX-x86_64.sh --help
usage: ./Miniconda3-latest-MacOSX-x86_64.sh [options]

Installs Miniconda3 4.3.31

-b           run install in batch mode (without manual intervention),
             it is expected the license terms are agreed upon
-f           no error if install prefix already exists
-h           print this help message and exit
-p PREFIX    install prefix, defaults to /Users/perry/miniconda3, must not contain spaces.
-s           skip running pre/post-link/install scripts
-u           update an existing installation
-t           run package tests after installation (may install conda-build)


In [3]:
# 开始安装
sh ./Miniconda3-latest-MacOSX-x86_64.sh
# sh ./Miniconda3-latest-MacOSX-x86_64.sh -b
Welcome to Miniconda3 4.3.31

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 

查看许可证(一直按 ENTER 键)然后键入'yes'。

安装器会将下面一行加入~/.bash_profile-s选项可以禁止,Linux系统一般是加入~/.bashrc)。

In [7]:
export PATH="$HOME/miniconda3/bin:$PATH"
In [8]:
# 查看conda使用说明
conda --help
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    info         Display information about current conda install.
    help         Displays a list of available conda commands and their help
                 strings.
    list         List linked packages in a conda environment.
    search       Search for packages and display their information. The input
                 is a Python regular expression. To perform a search with a
                 search string that starts with a -, separate the search from
                 the options with --, like 'conda search -- -h'. A * in the
                 results means that package is installed in the current
                 environment. A . means that package is not installed but is
                 cached in the pkgs directory.
    create       Create a new conda environment from a list of specified
                 packages.
    install      Installs a list of packages into a specified conda
                 environment.
    update       Updates conda packages to the latest compatible version. This
                 command accepts a list of package names and updates them to
                 the latest versions that are compatible with all other
                 packages in the environment. Conda attempts to install the
                 newest versions of the requested packages. To accomplish
                 this, it may update some packages that are already installed,
                 or install additional packages. To prevent existing packages
                 from updating, use the --no-update-deps option. This may
                 force conda to install older versions of the requested
                 packages, and it does not prevent additional dependency
                 packages from being installed. If you wish to skip dependency
                 checking altogether, use the '--force' option. This may
                 result in an environment with incompatible packages, so this
                 option must be used with great caution.
    upgrade      Alias for conda update. See conda update --help.
    remove       Remove a list of packages from a specified conda environment.
    uninstall    Alias for conda remove. See conda remove --help.
    config       Modify configuration values in .condarc. This is modeled
                 after the git config command. Writes to the user .condarc
                 file (/Users/perry/.condarc) by default.
    clean        Remove unused packages and caches.
    package      Low-level conda package utility. (EXPERIMENTAL)

optional arguments:
  -h, --help     Show this help message and exit.
  -V, --version  Show the conda version number and exit.

other commands, such as "conda build", are available when additional conda
packages (e.g. conda-build) are installed

In [9]:
# 启用 bioconda 'channel' 和其他一些
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda

# 国内可以添加清华镜像
conda config --add channels defaults
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes

# 更多请查看 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
Warning: 'defaults' already in 'channels' list, moving to the top
Warning: 'conda-forge' already in 'channels' list, moving to the top
Warning: 'bioconda' already in 'channels' list, moving to the top
In [11]:
# 这是conda的配置文件,可以通过config命令修改
# 底部的channel优先
cat ~/.condarc
channels:
  - bioconda
  - conda-forge
  - defaults
In [14]:
# 安装一些conda包
conda install -y seqtk
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /Users/perry/miniconda3:

The following NEW packages will be INSTALLED:

    seqtk:     1.2-0            bioconda

The following packages will be UPDATED:

    conda:     4.3.31-py36_0             --> 4.3.33-py36_0 conda-forge

The following packages will be SUPERSEDED by a higher-priority channel:

    conda-env: 2.6.0-h36134e3_0          --> 2.6.0-0       conda-forge

conda-env-2.6. 100% |################################| Time: 0:00:00 395.33 kB/s
seqtk-1.2-0.ta 100% |################################| Time: 0:00:00  63.60 kB/s
conda-4.3.33-p 100% |################################| Time: 0:00:01 279.73 kB/s
In [16]:
# samtools版本0.1.15构建号0
conda install -y samtools=0.1.15=0

# conda install kallisto
# conda install salmon=0.9.1 sailfish
Fetching package metadata ...............
Solving package specifications: .

# All requested packages already installed.
# packages in environment at /Users/perry/miniconda3:
#
samtools                  0.1.15                        0    bioconda
In [17]:
# 看下包都被装在哪里了
ls ~/miniconda3/bin
total 5792
drwxr-xr-x  75 perry  staff   2.3K 31 Jan 12:49 .
drwxr-xr-x  13 perry  staff   416B 31 Jan 12:48 ..
-rwxr-xr-x   2 perry  staff   216B 27 Oct 02:51 .python.app-post-link.sh
-rwxr-xr-x   2 perry  staff    39B 27 Oct 02:51 .python.app-pre-unlink.sh
lrwxr-xr-x   1 perry  staff     8B 31 Jan 12:49 2to3 -> 2to3-3.6
-rwxrwxr-x   1 perry  staff   111B 31 Jan 12:49 2to3-3.6
-rwxrwxr-x   2 perry  staff   3.7K 25 Jan 01:56 activate
-rwxr-xr-x   1 perry  staff   5.0K 31 Jan 12:09 c_rehash
lrwxr-xr-x   1 perry  staff     3B 31 Jan 12:48 captoinfo -> tic
-rwxr-xr-x   1 perry  staff   243B 31 Jan 12:10 chardetect
-rwxrwxr-x   2 perry  staff    13K  3 Dec  2016 clear
-rwxrwxr-x   1 perry  staff   132B 31 Jan 12:48 conda
-rwxrwxr-x   1 perry  staff   150B 31 Jan 12:48 conda-env
-rwxrwxr-x   2 perry  staff   3.0K 25 Jan 01:56 deactivate
-rwxr-xr-x   1 perry  staff   252B 31 Jan 12:10 easy_install
-rwxr-xr-x   1 perry  staff   469B 31 Jan 12:10 easy_install-3.6
lrwxr-xr-x   1 perry  staff     7B 31 Jan 12:49 idle3 -> idle3.6
-rwxrwxr-x   1 perry  staff   109B 31 Jan 12:49 idle3.6
-rwxrwxr-x   2 perry  staff    71K  3 Dec  2016 infocmp
lrwxr-xr-x   1 perry  staff     3B 31 Jan 12:48 infotocap -> tic
lrwxr-xr-x   1 perry  staff     2B 31 Jan 12:09 lzcat -> xz
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzcmp -> xzdiff
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzdiff -> xzdiff
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzegrep -> xzgrep
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzfgrep -> xzgrep
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzgrep -> xzgrep
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzless -> xzless
lrwxr-xr-x   1 perry  staff     2B 31 Jan 12:09 lzma -> xz
-rwxr-xr-x   2 perry  staff    14K  8 Nov 09:17 lzmadec
-rwxr-xr-x   2 perry  staff    13K  8 Nov 09:17 lzmainfo
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 lzmore -> xzmore
-rwxrwxr-x   1 perry  staff   5.2K 31 Jan 12:48 ncurses5-config
-rwxrwxr-x   1 perry  staff   5.2K 31 Jan 12:48 ncursesw5-config
-rwxr-xr-x   2 perry  staff   560K  8 Dec 03:05 openssl
-rwxr-xr-x   1 perry  staff   224B 31 Jan 12:10 pip
lrwxr-xr-x   1 perry  staff     8B 31 Jan 12:49 pydoc -> pydoc3.6
lrwxr-xr-x   1 perry  staff     8B 31 Jan 12:49 pydoc3 -> pydoc3.6
-rwxrwxr-x   1 perry  staff    94B 31 Jan 12:49 pydoc3.6
lrwxr-xr-x   1 perry  staff     9B 31 Jan 12:49 python -> python3.6
-rwxr-xr-x   1 perry  staff   133B 31 Jan 12:10 python.app
lrwxr-xr-x   1 perry  staff     9B 31 Jan 12:49 python3 -> python3.6
lrwxr-xr-x   1 perry  staff    17B 31 Jan 12:49 python3-config -> python3.6m-config
-rwxrwxr-x   1 perry  staff    13K 31 Jan 12:49 python3.6
lrwxr-xr-x   1 perry  staff    17B 31 Jan 12:49 python3.6-config -> python3.6m-config
-rwxrwxr-x   1 perry  staff    13K 31 Jan 12:49 python3.6m
-rwxrwxr-x   1 perry  staff   2.0K 31 Jan 12:49 python3.6m-config
-rwxr-xr-x   1 perry  staff   133B 31 Jan 12:10 pythonw
lrwxr-xr-x   1 perry  staff    10B 31 Jan 12:49 pyvenv -> pyvenv-3.6
-rwxrwxr-x   1 perry  staff   451B 31 Jan 12:49 pyvenv-3.6
lrwxr-xr-x   1 perry  staff     4B 31 Jan 12:48 reset -> tset
-rwxrwxr-x   2 perry  staff   391K  7 Oct 04:36 samtools
-rwxr-xr-x   2 perry  staff    59K  8 Jun  2016 seqtk
-rwxr-xr-x   2 perry  staff   1.3M  9 Jun  2016 sqlite3
-rwxrwxr-x   2 perry  staff    18K  3 Dec  2016 tabs
lrwxr-xr-x   1 perry  staff     8B 31 Jan 12:49 tclsh -> tclsh8.5
-rwxrwxr-x   2 perry  staff    12K 27 Jul  2017 tclsh8.5
-rwxrwxr-x   2 perry  staff    80K  3 Dec  2016 tic
-rwxrwxr-x   2 perry  staff    19K  3 Dec  2016 toe
-rwxrwxr-x   2 perry  staff    23K  3 Dec  2016 tput
-rwxrwxr-x   2 perry  staff    28K  3 Dec  2016 tset
lrwxr-xr-x   1 perry  staff     2B 31 Jan 12:09 unlzma -> xz
lrwxr-xr-x   1 perry  staff     2B 31 Jan 12:09 unxz -> xz
-rwxr-xr-x   1 perry  staff   231B 31 Jan 12:10 wheel
lrwxr-xr-x   1 perry  staff     7B 31 Jan 12:49 wish -> wish8.5
-rwxrwxr-x   2 perry  staff    21K 27 Jul  2017 wish8.5
-rwxr-xr-x   2 perry  staff    73K  8 Nov 09:17 xz
lrwxr-xr-x   1 perry  staff     2B 31 Jan 12:09 xzcat -> xz
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 xzcmp -> xzdiff
-rwxr-xr-x   2 perry  staff    14K  8 Nov 09:17 xzdec
-rwxr-xr-x   2 perry  staff   6.5K  8 Nov 09:17 xzdiff
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 xzegrep -> xzgrep
lrwxr-xr-x   1 perry  staff     6B 31 Jan 12:09 xzfgrep -> xzgrep
-rwxr-xr-x   2 perry  staff   5.5K  8 Nov 09:17 xzgrep
-rwxr-xr-x   2 perry  staff   1.8K  8 Nov 09:17 xzless
-rwxr-xr-x   2 perry  staff   2.1K  8 Nov 09:17 xzmore

使用环境

让我们创建和切换到一个新的环境,安装一些包,记录我们安装了什么,然后退出环境。

https://conda.io/docs/user-guide/tasks/manage-environments.html

In [2]:
# 创建一个新的Conda环境
conda create -y --name new_env
Fetching package metadata ...............
Solving package specifications: 
Package plan for installation in environment /Users/perry/miniconda3/envs/new_env:

#
# To activate this environment, use:
# > source activate new_env
#
# To deactivate an active environment, use:
# > source deactivate
#

In [3]:
# 显式地启用环境
source activate new_env
(new_env) 

In [4]:
# 安装一些包
conda install -y samtools=0.1.14
(new_env) Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /Users/perry/miniconda3/envs/new_env:

The following NEW packages will be INSTALLED:

    ncurses:  5.9-10   conda-forge
    samtools: 0.1.14-0 bioconda   
    zlib:     1.2.8-3  conda-forge

(new_env) 

In [5]:
# 默认,环境位于 ~/miniconda3/envs
# 看一下
ls ~/miniconda3/envs/new_env/bin
which samtools
(new_env) (new_env) total 1336
drwxr-xr-x  18 perry  staff   576B  1 Feb 15:30 .
drwxr-xr-x   7 perry  staff   224B  1 Feb 15:30 ..
lrwxr-xr-x   1 perry  staff    36B  1 Feb 15:30 activate -> /Users/perry/miniconda3/bin/activate
lrwxr-xr-x   1 perry  staff     3B  1 Feb 15:30 captoinfo -> tic
-rwxrwxr-x   3 perry  staff    13K  3 Dec  2016 clear
lrwxr-xr-x   1 perry  staff    33B  1 Feb 15:30 conda -> /Users/perry/miniconda3/bin/conda
lrwxr-xr-x   1 perry  staff    38B  1 Feb 15:30 deactivate -> /Users/perry/miniconda3/bin/deactivate
-rwxrwxr-x   3 perry  staff    71K  3 Dec  2016 infocmp
lrwxr-xr-x   1 perry  staff     3B  1 Feb 15:30 infotocap -> tic
-rwxrwxr-x   1 perry  staff   5.2K  1 Feb 15:30 ncurses5-config
-rwxrwxr-x   1 perry  staff   5.2K  1 Feb 15:30 ncursesw5-config
lrwxr-xr-x   1 perry  staff     4B  1 Feb 15:30 reset -> tset
-rwxrwxr-x   3 perry  staff   381K  7 Oct 04:39 samtools
-rwxrwxr-x   3 perry  staff    18K  3 Dec  2016 tabs
-rwxrwxr-x   3 perry  staff    80K  3 Dec  2016 tic
-rwxrwxr-x   3 perry  staff    19K  3 Dec  2016 toe
-rwxrwxr-x   3 perry  staff    23K  3 Dec  2016 tput
-rwxrwxr-x   3 perry  staff    28K  3 Dec  2016 tset
(new_env) /Users/perry/miniconda3/envs/new_env/bin/samtools
(new_env) 

In [6]:
# 你可以将当前的环境导出为一个environment.yml文件
# 这有点像Python中的requirements.txt文件
# 保留你分析项目的environment.yml
conda env export >environment.yml

cat environment.yml
(new_env) (new_env) (new_env) (new_env) (new_env) name: new_env
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- samtools=0.1.14=0
- ncurses=5.9=10
- zlib=1.2.8=3
prefix: /Users/perry/miniconda3/envs/new_env

(new_env) 

In [7]:
# 另外,如果你想要通过channel + version + build + md5检验和锁定准确的包版本
# 注意这里有平台特异性,但更好地保证了可重复性
conda list --show-channel-urls --md5 --explicit >package-list.txt

cat package-list.txt
(new_env) (new_env) (new_env) (new_env) # This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/osx-64/ncurses-5.9-10.tar.bz2#f303ad9e588c5f06b9b02077b57d88d5
https://conda.anaconda.org/bioconda/osx-64/samtools-0.1.14-0.tar.bz2#d2d79f5cab9c1c420887875623d26ea9
https://conda.anaconda.org/conda-forge/osx-64/zlib-1.2.8-3.tar.bz2#03b6fcc7a5e1a471e74049665e1c06b0
(new_env) 

In [ ]:
# 你可以使用这些文件创建包含这些包的新环境
# 命令如下:

# conda create --name reproduced_env --file environment.yml
# conda create --name locked_reproduced_env --file package-list.txt
In [9]:
# 离开环境
source deactivate
(new_env) (new_env) (new_env) (new_env) (new_env) 

brew / linuxbrew怎么样?

  • macOS系统的brewlinuxbrew基本上都是分离的项目。

  • 据传brew/linuxbrew生信软件的安装质量不好,经常崩溃。

homebrew-science已经弃用了

https://github.com/Homebrew/homebrew-science/issues/6365

apt, yum 等怎么样?

  • 目标是系统级别的包 - 通常不能处理无权限的安装或者包版本的共存。

  • 官方发行(Debian, Ubuntu, Centos)软件库很少能跟上生信软件的更新。非官方仓库有时候填补了空白(如Debian Med)。

  • 创建包实在太复杂了。

modules, LMOD等怎么样?

  • 很适合使用环境变量(即 PATH)来管理共存版本。

  • LMOD环境可以“附加”(许多“modules”可以同时导入,不像conda环境)。

  • LMOD不是一个包管理器(处理不了下载/编译/安装)。

pip和virtualenv怎么样?

  • 这两个都和Python一起的,对Python包和包生态非常好。
  • 对非Python包不友好(二进制包和依赖)。

bio-ansible怎么样?

  • bio-ansible因为是我们写的,所以非常棒。
  • 不那么棒的地方是为了安装新的工具我们必须编写任务。
    • 但是!bio-ansible 也支持安装conda包为LMOD模块(我们可以轻松地从Bioconda添加任何东西)。
  • 支持无权限软件在家目录中安装、系统包和配置。
  • 通过LMOD模块支持版本共存。
  • 学习成本高。

我发现Conda没有处理好的一些事情

  • 没有官方支持'stacking'环境和ala LMOD。
  • 构建包的食谱指明依赖名但没有依赖来自的channel名。
  • 没有从源安装的方法(例如conda install https://github.com/me/my_recipe)、预编译二进制文件?

创建(Bio)conda包

让我们看一下_seqtk_的Bionconda食谱

https://github.com/bioconda/bioconda-recipes/tree/master/recipes/seqtk

build.sh

#!/bin/bash

export C_INCLUDE_PATH=${PREFIX}/include
export LIBRARY_PATH=${PREFIX}/lib

make all
mkdir -p $PREFIX/bin
cp -f seqtk $PREFIX/bin/

PREFIX是conda构建环境中的安装路径(在配置文件中你可能会使用configure --prefix=$PREFIX

meta.yaml

package:
  name: seqtk
  version: 1.2

source:
  fn: v1.2.tar.gz
  url: https://github.com/lh3/seqtk/archive/v1.2.tar.gz
  md5: 255ffe05bf2f073dc57abcff97f11a37

build:
  number: 0

requirements:
  build:
    - gcc   # [not osx]
    - llvm  # [osx]
    - zlib
  run:
    - zlib


about:
  home: https://github.com/lh3/seqtk
  license: MIT License
  summary: Seqtk is a fast and lightweight tool for processing sequences in the FASTA or FASTQ format

test:
  commands:
    - seqtk seq

构建一个食谱(普通conda方式)

In [25]:
cd ~
mkdir -p recipes/seqtk

# 创建你的build.sh和meta.yml
# 另见`conda skeleton`,它可以帮助生成特定包类型的模板

# vi recipes/seqtk/build.sh
# vi recipes/seqtk/meta.yaml
In [28]:
# 我们需要conda-build包构建包
conda install -y conda-build
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /Users/perry/miniconda3:

The following NEW packages will be INSTALLED:

    beautifulsoup4: 4.6.0-py36_0  conda-forge
    conda-build:    2.1.18-py36_0 conda-forge
    conda-verify:   2.0.0-py36_0  conda-forge
    filelock:       2.0.6-py36_0  conda-forge
    jinja2:         2.10-py36_0   conda-forge
    markupsafe:     1.0-py36_0    conda-forge
    pkginfo:        1.4.1-py36_0  conda-forge
    pycrypto:       2.6.1-py36_1  conda-forge
    pyyaml:         3.12-py36_1   conda-forge

beautifulsoup4 100% |################################| Time: 0:00:02  59.83 kB/s
filelock-2.0.6 100% |################################| Time: 0:00:00   3.52 MB/s
markupsafe-1.0 100% |################################| Time: 0:00:00  29.10 kB/s
pkginfo-1.4.1- 100% |################################| Time: 0:00:00  83.65 kB/s
pycrypto-2.6.1 100% |################################| Time: 0:00:05  86.19 kB/s
pyyaml-3.12-py 100% |################################| Time: 0:00:02  70.36 kB/s
conda-verify-2 100% |################################| Time: 0:00:00  62.62 kB/s
jinja2-2.10-py 100% |################################| Time: 0:00:02  76.46 kB/s
conda-build-2. 100% |################################| Time: 0:00:03  81.03 kB/s
In [31]:
# 一旦一个新的食谱创建了,我们就可以构建
conda build recipes/seqtk/
BUILD START: seqtk-1.2-0
updating index in: /Users/perry/miniconda3/conda-bld/osx-64
updating index in: /Users/perry/miniconda3/conda-bld/noarch

The following NEW packages will be INSTALLED:

    cctools:       895-h7512d6f_0              
    ld64:          274.2-h7c2db76_0            
    libcxx:        4.0.1-h579ed51_0            
    libcxxabi:     4.0.1-hebd6815_0            
    llvm:          4.0.1-hc748206_0            
    llvm-lto-tapi: 4.0.1-h6701bc3_0            
    zlib:          1.2.11-0         conda-forge


WARNING: conda-build appears to be out of date. You have version 2.1.18 but the
latest version is 3.3.0. Run

conda update -n root conda-build

to get the latest version.

Source cache directory is: /Users/perry/miniconda3/conda-bld/src_cache
Downloading source to cache: v1.2.tar.gz
Downloading https://github.com/lh3/seqtk/archive/v1.2.tar.gz
Success
Extracting download
Package: seqtk-1.2-0
source tree in: /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/work/seqtk-1.2
+ source /Users/perry/miniconda3/bin/activate /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac
+ export C_INCLUDE_PATH=/Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/include
+ C_INCLUDE_PATH=/Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/include
+ export LIBRARY_PATH=/Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib
+ LIBRARY_PATH=/Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib
+ make all
gcc -g -Wall -O2 -Wno-unused-function seqtk.c -o seqtk -lz -lm
+ mkdir -p /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin
+ cp -f seqtk /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin/
INFO:conda_build.build:Packaging seqtk-1.2-0
number of files: 1
Fixing permissions
Fixing linking of @rpath/libz.1.dylib in /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin/seqtk
Fixing linking of /usr/lib/libSystem.B.dylib in /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin/seqtk
install_name_tool -add_rpath @loader_path/../lib/ /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin/seqtk

Fixing permissions
/Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2
updating index in: /Users/perry/miniconda3/conda-bld
updating index in: /Users/perry/miniconda3/conda-bld/noarch
updating index in: /Users/perry/miniconda3/conda-bld/osx-64
updating: seqtk-1.2-0.tar.bz2
updating index in: /Users/perry/miniconda3/conda-bld
TEST START: /Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2
Deleting work directory, /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/work/seqtk-1.2

The following NEW packages will be INSTALLED:

    seqtk: 1.2-0    local      
    zlib:  1.2.11-0 conda-forge


WARNING: conda-build appears to be out of date. You have version 2.1.18 but the
latest version is 3.3.0. Run

conda update -n root conda-build

to get the latest version.

+ source /Users/perry/miniconda3/bin/activate /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/_t_env
+ /bin/bash -x -e /Users/perry/miniconda3/conda-bld/seqtk_1517365865334/test_tmp/run_test.sh
+ seqtk seq

Usage:   seqtk seq [options] <in.fq>|<in.fa>

Options: -q INT    mask bases with quality lower than INT [0]
         -X INT    mask bases with quality higher than INT [255]
         -n CHAR   masked bases converted to CHAR; 0 for lowercase [0]
         -l INT    number of residues per line; 0 for 2^32-1 [0]
         -Q INT    quality shift: ASCII-INT gives base quality [33]
         -s INT    random seed (effective with -f) [11]
         -f FLOAT  sample FLOAT fraction of sequences [1]
         -M FILE   mask regions in BED or name list FILE [null]
         -L INT    drop sequences with length shorter than INT [0]
         -c        mask complement region (effective with -M)
         -r        reverse complement
         -A        force FASTA output (discard quality)
         -C        drop comments at the header lines
         -N        drop sequences containing ambiguous bases
         -1        output the 2n-1 reads only
         -2        output the 2n reads only
         -V        shift quality by '(-Q) - 33'
         -U        convert all bases to uppercases
         -S        strip of white spaces in sequences

TEST END: /Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2
INFO:conda_build.config:--dirty flag and --keep-old-work not specified.Removing build/test folder after successful build/test.

# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload /Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []
In [32]:
# 我们刚创建包的归档在哪里?
conda build recipes/seqtk/ --output
/Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2
In [34]:
# 安装本地构建的包(使用'local' channel)
conda install -y --use-local seqtk

# 或者直接使用包的tar.bz2压缩包,或者存储它的http://链接
# conda install /Users/perry/miniconda3/conda-bld/osx-64/seqtk-1.2-0.tar.bz2
# conda install http://bioinformatics.erc.monash.edu/home/andrewperry/conda/seqtk-1.2-0.tar.bz2
Fetching package metadata .................
Solving package specifications: .

Package plan for installation in environment /Users/perry/miniconda3:

The following NEW packages will be INSTALLED:

    seqtk: 1.2-0 local

在Anaconda.org上发布

(在个人的conda channel上,独立于Bioconda项目channel)

步骤 1: 在https://anaconda.org/创建一个账号

In [ ]:
# 步骤 2: 安装`anaconda-client`包
conda install anaconda-client

# 步骤 3: 登陆和上传
anaconda login
# use the path to the package reported by `conda build recipes/seqtk/ --output`
anaconda upload <path_to_package_bz2>

# 步骤 4: 测试包是否正常工作 —— 从你上传的channel上安装
conda uninstall bigdatascript
conda install -c https://conda.anaconda.org/pansapiens bigdatascript

Bioconda方式

http://bioconda.github.io/contributing.html

添加一个食谱并在本地测试。

第一步 - 打开 https://github.com/bioconda/bioconda-recipes 然后Fork仓库。

然后克隆你的Fork。

export MY_GIT_USERNAME=pansapiens
git clone https://github.com/${MY_GIT_USERNAME}/bioconda-recipes.git
cd bioconda-recipes

为你的食谱创建一个新的分支。

git branch mynewtool
git checkout mynewtool

编辑你的食谱。使用一个已经存在的食谱作为模板是一个很好的方式(也可以使用conda skeleton)。

vi recipes/mynewtool/meta.yaml
vi recipes/mynewtool/build.sh

git commit -a -m "Added new recipe for mynewtool."

激活TravisCI环境进行测试。

# 这个Bioconda脚本会创建一个新的Miniconda安装
./simulate-travis.py --bootstrap /tmp/anaconda --overwrite

# 构建你的食谱并运行测试
# --packages 是可选选项,只有版本和构建改变的食谱会构建
./simulate-travis.py --disable-docker --packages mynewtool --force

如果测试通过,提交commit并推送到远程分支。

git push origin
  • https://github.com/bioconda/bioconda-recipes 创建一个合并请求。
  • TravisCI 会自动构建你的分支。
  • 如果 TravisCI 测试通过,Bioconda团队会审查你的合并请求,查看是否可以合并。
  • Bioconda主分支的食谱会自动在Linux和macOS系统上构建并上传到Anaconda的bioconda channel上。

谢谢!