问题描述
我有一个使用全局奇异性图像和基于规则的conda包装器的管道。
但是,某些工具没有包装器(即 htslib
的{{1}}和bgzip
)。
现在我需要学习如何run jobs in containers。
最小可重复示例:
docker://
config.yaml
# Files
REF_GENOME: "c_elegans.PRJNA13758.WS265.genomic.fa"
GENOME_ANNOTATION: "c_elegans.PRJNA13758.WS265.annotations.gff3"
Snakefile
错误
# Directories------------------------------------------------------------------
configfile: "config.yaml"
# Setting the names of all directories
dir_list = ["REF_DIR","LOG_DIR","BENCHMARK_DIR","QC_DIR","TRIM_DIR","ALIGN_DIR","MARKDUP_DIR","CALLING_DIR","ANNOT_DIR"]
dir_names = ["refs","logs","benchmarks","qc","trimming","alignment","mark_duplicates","variant_calling","annotation"]
dirs_dict = dict(zip(dir_list,dir_names))
GENOME_INDEX=config["REF_GENOME"]+".fai"
VEP_ANNOT=config["GENOME_ANNOTATION"]+".gz"
VEP_ANNOT_INDEX=config["GENOME_ANNOTATION"]+".gz.tbi"
# Singularity with conda wrappers
singularity: "docker://continuumio/miniconda3:4.5.11"
# Rules -----------------------------------------------------------------------
rule all:
input:
expand('{REF_DIR}/{GENOME_ANNOTATION}{ext}',REF_DIR=dirs_dict["REF_DIR"],GENOME_ANNOTATION=config["GENOME_ANNOTATION"],ext=['','.gz','.gz.tbi']),expand('{REF_DIR}/{REF_GENOME}{ext}',REF_GENOME=config["REF_GENOME"],'.fai']),rule download_references:
params:
ref_genome=config["REF_GENOME"],genome_annotation=config["GENOME_ANNOTATION"],ref_dir=dirs_dict["REF_DIR"]
output:
os.path.join(dirs_dict["REF_DIR"],config["REF_GENOME"]),os.path.join(dirs_dict["REF_DIR"],config["GENOME_ANNOTATION"]),VEP_ANNOT),VEP_ANNOT_INDEX)
resources:
mem=80000,time=45
log:
os.path.join(dirs_dict["LOG_DIR"],"references","download.log")
singularity:
"shub://biocontainers/tabix"
shell: """
cd {params.ref_dir}
wget ftp://ftp.wormbase.org/pub/wormbase/releases/WS265/species/c_elegans/PRJNA13758/c_elegans.PRJNA13758.WS265.genomic.fa.gz
bgzip -d {params.ref_genome}.gz
wget ftp://ftp.wormbase.org/pub/wormbase/releases/WS265/species/c_elegans/PRJNA13758/c_elegans.PRJNA13758.WS265.annotations.gff3.gz
bgzip -d {params.genome_annotation}.gz
grep -v "#" {params.genome_annotation} | sort -k1,1 -k4,4n -k5,5n -t$'\t' | bgzip -c > {params.genome_annotation}.gz
tabix -p gff {params.genome_annotation}.gz
"""
rule index_reference:
input:
os.path.join(dirs_dict["REF_DIR"],config["REF_GENOME"])
output:
os.path.join(dirs_dict["REF_DIR"],GENOME_INDEX)
resources:
mem=2000,time=30,log:
os.path.join(dirs_dict["LOG_DIR"],"faidx_index.log")
wrapper:
"0.64.0/bio/samtools/faidx"
看来这是容器问题吗?
Building DAG of jobs...
Pulling singularity image shub://biocontainers/tabix.
WorkflowError:
Failed to pull singularity image from shub://biocontainers/tabix:
ESC[31mFATAL: ESC[0m While pulling shub image: Failed to get manifest for: shub://biocontainers/tabix: the requested manifest was not found in singularity hub
File "/home/moldach/anaconda3/envs/snakemake/lib/python3.7/site-packages/snakemake/deployment/singularity.py",line 88,in pull
~
实际上,我在其他(snakemake) [moldach@arc CONTAINER_TROUBLESHOOT]$ singularity pull shub://biocontainers/tabix
FATAL: While pulling shub image: Failed to get manifest for: shub://biocontainers/tabix: the requested manifest was not found in singularity hub
容器中遇到了这个问题。
例如,我还需要使用一个容器来做biocontainers
索引,这是我从bowtie2
到同一个工具biocontainers/bowtie2
的另一个开发人员容器的错误:
comics/bowtie2
有人知道为什么吗?
解决方法
生物容器不允许latest
作为其容器的标签,因此您需要指定要使用的标签。
来自他们的doc:
BioContainers社区已决定删除最新标签。然后,以下命令docker pull biocontainers / crux将失败。在Docker入门中了解有关此决定的更多信息
如果未指定标签,则默认为latest
标签,当然这里不允许这样做。有关bowtie2的标签,请参见here。这样的用法将起作用:
singularity pull docker://biocontainers/bowtie2:v2.4.1_cv1
,
使用另一个容器可以解决此问题;但是,由于这些错误非常普遍并且在文献中被用作示例,因此我从biocontainers
中获取错误的事实令人不安,因此我将把能够回答该特定问题的最佳答案授予任何人。
实际上,stackleader/bgzip-utility
的使用解决了在容器中实际运行此规则的问题。
container:
"docker://stackleader/bgzip-utility"
再说一次,对于那些发表这篇文章的人,最好在运行snakemake
,例如 singularity pull docker://stackleader/bgzip-utility
之前先测试任何容器。