如何访问“shell”部分中的 Snakemake 配置变量?
How can one access Snakemake config variables inside `shell` section?
在 snakemake 中,我想从 shell:
指令中访问 config
中的键。我可以使用 {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}; "
我可以将我想要的配置部分分配给 params
下的一个键,然后使用 {param.x}
替换,但这有不需要的副作用(例如,参数保存在snakemake 元数据(即 .snakemake/params_tracking
)。使用 run:
而不是 shell:
是另一种解决方法,但是直接从 shell
块访问 {config.tmpdir}
将是最理想的.
"./scripts/do.sh --tmpdir {config[tmpdir]} {input} > {output}; "
应该在这里工作。
文档中有说明:
http://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html#standard-configuration
"For adding config placeholders into a shell command, Python string formatting syntax requires you to leave out the quotes around the key name, like so:"
shell:
"mycommand {config[foo]} ..."
在 snakemake 中,我想从 shell:
指令中访问 config
中的键。我可以使用 {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}; "
我可以将我想要的配置部分分配给 params
下的一个键,然后使用 {param.x}
替换,但这有不需要的副作用(例如,参数保存在snakemake 元数据(即 .snakemake/params_tracking
)。使用 run:
而不是 shell:
是另一种解决方法,但是直接从 shell
块访问 {config.tmpdir}
将是最理想的.
"./scripts/do.sh --tmpdir {config[tmpdir]} {input} > {output}; "
应该在这里工作。
文档中有说明: http://snakemake.readthedocs.io/en/stable/snakefiles/configuration.html#standard-configuration
"For adding config placeholders into a shell command, Python string formatting syntax requires you to leave out the quotes around the key name, like so:"
shell:
"mycommand {config[foo]} ..."