如何使用{threads}变量使Snakemake包装器工作



EDIT 27-07-2018:包装器不考虑线程。此外,我在这里尝试的语法不起作用,而且据我所知,不支持类似的语法。答案来自下面Snakemake谷歌群组和meono的交叉帖子。

我正在使用Snakemake,我对此很满意。然而,对于某些流程,我使用包装纸(即FastQC和Trimmomatic(。但是,我注意到这些包装器没有考虑{threads}变量。有人能解释一下什么是正确的语法吗?

我尝试设置threads: 4,然后在代码中的适当位置指定{threads}(例如,对于FastQC:params: "--threads {threads}"(。同样,我测试了设置{wildcards.threads}{snakemake.threads}。看起来包装器代码块无法"查看"线程变量的值。

请参阅下面的示例。

注意:我查看了Bitbucket Snakemakewrapper repo并阅读了docs自述文件,但找不到答案。

rule FastQC_preTrim:
input:
join(RAW_DATA, PATTERN_ANY)
output:
html="FastQC_pretrim/{sample}.html",
zip="FastQC_pretrim/{sample}_fastqc.zip"
threads: 4
params:
"--threads {wildcards.threads}"   # Also tried {threads}
wrapper:
"0.20.1/bio/fastqc"

(会把它放在评论中,但没有代表(

fastqc包装器不考虑规则中的threads。我认为

params:
"--threads 4"

会为你工作。

我在尝试使用snakemakewrappers时遇到了同样的问题,但在params中指定{threads}或任何其他通配符时失败。

一种变通方法是明确地定义";线程";参数,然后从那里调用它。例如:

# In config.yaml
thread_use: 32

# In rule
rule some_rule_with_wrapper:
input:
"path/to/input"
output:
"path/to/output"
params:
extra="-t "+str(config["thread_use"])  # Remember to coerce int to string
threads: 32
wrapper:
"some/wrapper"

最新更新