在snakemake中,我想从指令config中访问键shell:。我可以使用{input.foo}、{output.bar}、 和{params.baz},但{config.quux}不受支持。有办法实现这一点吗?
rule do_something:
input: "source.txt"
output: "target.txt"
params:
# access config[] here. parameter tracking is a side effect
tmpdir = config['tmpdir']
shell:
# using {config.tmpdir} or {config['tmpdir']} here breaks the build
"./scripts/do.sh --tmpdir {params.tmpdir} {input} > {output}; "
Run Code Online (Sandbox Code Playgroud)
我可以将我想要的配置部分分配给 下的一个键params,然后使用{param.x}替换,但这会产生不需要的副作用(例如参数保存在 Snakemake 元数据中(即.snakemake/params_tracking)。使用run:而不是shell:另一种解决方法,但是{config.tmpdir}直接从块访问shell将是最理想的。
"./scripts/do.sh --tmpdir {config[tmpdir]} {input} > {output}; "
应该在这里工作。
文档中有说明: http://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html#standard-configuration
“为了将配置占位符添加到 shell 命令中,Python 字符串格式化语法要求您省略键名称周围的引号,如下所示:”
shell:
"mycommand {config[foo]} ..."
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |