跳转至

Bioconda 生信软件

一句话概述:Bioconda 是 Conda 的生物信息学专用频道,收录了 10000+ 生信工具(BWA、SAMtools、GATK 等),一条命令即可安装复杂的生信软件及其依赖。

核心知识点

概念白话解释
Channel频道 = 软件包的来源仓库(Bioconda 就是一个频道)
Recipe配方 = 描述如何编译打包一个软件的文件
conda-forge社区维护的通用频道(Bioconda 依赖它)
mulled自动生成的多工具容器镜像
Pin版本锁定 = 防止依赖升级导致冲突

安装配置

# 配置频道(顺序很重要!)
conda config --add channels defaults        # 默认频道
conda config --add channels bioconda        # 生信频道
conda config --add channels conda-forge     # 社区频道
conda config --set channel_priority strict  # 严格优先级(推荐)

# 验证频道配置
conda config --show channels
# 正确顺序:conda-forge > bioconda > defaults

# 推荐:用 mamba 替代 conda(快 10 倍)
conda install -n base -c conda-forge mamba  # 安装 mamba

基本使用

# 搜索软件
conda search -c bioconda samtools           # 搜索 samtools
mamba search -c bioconda "bwa*"             # 模糊搜索

# 安装生信工具
mamba install -c bioconda samtools=1.20     # 安装指定版本
mamba install -c bioconda bwa bowtie2 fastp # 一次装多个

# 创建项目专用环境
mamba create -n rnaseq \
  hisat2 stringtie samtools subread         # RNA-seq 分析环境

mamba create -n variant \
  bwa gatk4 samtools bcftools picard        # 变异检测环境

mamba create -n metagenome \
  kraken2 bracken metaphlan humann          # 宏基因组环境

# 查看已安装的生信工具
conda list | grep -i "bioconda"             # 列出 Bioconda 安装的包

用环境文件管理

# env_rnaseq.yml — RNA-seq 分析环境
name: rnaseq
channels:
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - hisat2=2.2.1
  - samtools=1.20
  - stringtie=2.2.3
  - subread=2.0.6
  - multiqc=1.22
  - python=3.11
  - pip:
    - HTSeq==2.0.5
# 从文件创建环境
mamba env create -f env_rnaseq.yml          # 创建
mamba env update -f env_rnaseq.yml          # 更新
conda env export > env_backup.yml           # 导出当前环境

高级用法

贡献 Bioconda 配方

# 克隆 bioconda-recipes 仓库
git clone https://github.com/bioconda/bioconda-recipes.git
cd bioconda-recipes

# 创建新配方
mkdir -p recipes/mytool
# recipes/mytool/meta.yaml — 配方文件
package:
  name: mytool
  version: "1.0.0"
source:
  url: https://github.com/user/mytool/archive/v1.0.0.tar.gz
  sha256: abc123...
build:
  number: 0
  script: python -m pip install . --no-deps
requirements:
  host:
    - python
    - pip
  run:
    - python
    - numpy
    - pysam
test:
  commands:
    - mytool --version
about:
  home: https://github.com/user/mytool
  license: MIT
  summary: My bioinformatics tool

多版本切换

# 同一工具的不同版本
mamba create -n samtools18 samtools=1.18    # 旧版本
mamba create -n samtools20 samtools=1.20    # 新版本

# 快速切换
conda activate samtools18                   # 用旧版
conda deactivate && conda activate samtools20  # 切换到新版

常见报错

报错信息原因解决方法
PackagesNotFoundError包名拼写错误或不在 Biocondaconda search -c bioconda 确认
UnsatisfiableError依赖冲突创建新环境或用 mamba 解决
ResolvePackageNotFound该平台无此包检查是否有 Linux/macOS 限制
CondaHTTPError网络问题配置镜像源或检查代理

速查表

# === 安装 ===
mamba install -c bioconda <工具名>          # 安装
mamba install -c bioconda <工具>=<版本>     # 指定版本
mamba create -n <环境名> <工具1> <工具2>    # 创建环境并安装

# === 搜索 ===
conda search -c bioconda <关键词>           # 搜索
conda search -c bioconda <工具> --info      # 查看详情

# === 常用生信工具 ===
# 比对: bwa, bowtie2, hisat2, minimap2, star
# 质控: fastqc, fastp, trimmomatic, multiqc
# 变异: gatk4, bcftools, freebayes, deepvariant
# 组装: spades, megahit, flye, hifiasm
# 注释: prokka, bakta, eggnog-mapper
# 宏基因组: kraken2, metaphlan, humann, qiime2

# === 频道顺序(重要)===
# conda-forge > bioconda > defaults

参考:Bioconda | 配方仓库 | 更新于 2026 年