BioContainers 标准化¶
一句话概述:BioContainers 是生信工具的标准化容器注册中心,为 Bioconda 中的每个工具自动生成 Docker 和 Singularity 镜像,一行命令就能拉取即用。
核心知识点¶
| 概念 | 白话解释 |
|---|---|
| BioContainers | 生信容器注册中心 = 收录 10000+ 生信工具的容器镜像 |
| Multi-tool | 多工具容器 = 一个容器包含多个工具(如 samtools + bwa) |
| mulled | 自动构建 = Bioconda 配方自动生成容器 |
| Quay.io | 镜像仓库 = BioContainers 的主要托管平台 |
| Reproducibility | 可重复性 = 容器确保任何人都能复现分析结果 |
安装配置¶
# 无需安装 — 直接拉取使用
# Docker
docker pull biocontainers/samtools:v1.20_cv1 # 拉取 samtools
docker pull biocontainers/bwa:v0.7.18_cv1 # 拉取 bwa
# Singularity(HPC 推荐)
apptainer pull docker://biocontainers/samtools:v1.20_cv1 # 拉取为 SIF
# 搜索可用镜像
# 网页:https://biocontainers.pro/registry
# 命令行
docker search biocontainers/ | head -20 # 搜索
基本使用¶
# 直接用容器运行工具
docker run --rm -v $(pwd):/data -w /data \
biocontainers/samtools:v1.20_cv1 \
samtools view -bS input.sam -o output.bam # SAM 转 BAM
docker run --rm -v $(pwd):/data -w /data \
biocontainers/fastqc:v0.12.1_cv1 \
fastqc /data/sample.fastq.gz # 质控
# Singularity(HPC 集群)
apptainer exec --bind /data:/data \
samtools_v1.20_cv1.sif \
samtools sort /data/input.bam -o /data/sorted.bam # 排序
# 多工具容器(mulled)
docker pull quay.io/biocontainers/mulled-v2-<hash> # 多工具镜像
在工作流中使用¶
// Nextflow 中使用 BioContainers
process SAMTOOLS_SORT {
container 'biocontainers/samtools:v1.20_cv1' // 指定容器
input:
path bam
output:
path "sorted.bam"
script:
"""
samtools sort ${bam} -o sorted.bam
"""
}
# WDL 中使用 BioContainers
task samtools_sort {
input { File input_bam }
command <<<
samtools sort ~{input_bam} -o sorted.bam
>>>
runtime {
docker: "biocontainers/samtools:v1.20_cv1"
}
output { File sorted_bam = "sorted.bam" }
}
高级用法¶
自定义多工具容器¶
# 用 mulled-build 创建多工具容器
pip install galaxy-tool-util # 安装构建工具
# 构建包含 samtools + bwa 的容器
mulled-build build \
"samtools=1.20,bwa=0.7.18" \
--destination docker # 构建 Docker 镜像
# 手动构建多工具镜像
FROM biocontainers/biocontainers:latest
RUN conda install -c bioconda -c conda-forge \
samtools=1.20 bwa=0.7.18 bcftools=1.20 \
&& conda clean -afy
常见报错¶
| 报错信息 | 原因 | 解决方法 |
|---|---|---|
manifest unknown | 标签不存在 | 在 registry 查正确标签名 |
permission denied | Docker 权限不足 | 用 sudo 或加入 docker 组 |
no space left | 磁盘空间不足 | docker system prune 清理 |
速查表¶
# === 拉取镜像 ===
docker pull biocontainers/<工具>:<版本>_cv<修订> # Docker
apptainer pull docker://biocontainers/<工具>:<版本> # Singularity
# === 运行 ===
docker run --rm -v $(pwd):/data -w /data biocontainers/<工具> <命令>
apptainer exec --bind /data:/data <工具>.sif <命令>
# === 常用镜像 ===
# biocontainers/samtools:v1.20_cv1
# biocontainers/bwa:v0.7.18_cv1
# biocontainers/fastqc:v0.12.1_cv1
# biocontainers/bcftools:v1.20_cv1
# biocontainers/gatk4:4.5.0.0--py310_0
# === 注册中心 ===
# https://biocontainers.pro/registry — 搜索镜像
# https://quay.io/organization/biocontainers — Quay.io 托管
参考:BioContainers | GitHub | 更新于 2026 年