我正在使用snakemake来构建工作流程,我想在运行工作流程时是否可以在每个规则的'shell'指令中添加块?
例如,我在snakefile中有这些规则:
rule rule1:
input:...
output:...
shell:"rule1command"
rule rule2:
input:...
output:...
shell:"rule2command"
当我运行工作流时,我想在执行每个shell命令时添加一个默认块,例如:
我想定义一个默认的前缀块:"hostname; echo 'good luck''"
,然后在执行rule1command和rule2command时,它应该首先输出主机名并回显“祝你好运”。
这可能吗?
答案 0 :(得分:1)
好的,我终于找到了FAQ部分中的snakemake文档中的解决方案:
You can set a prefix that will prepended to all shell commands by adding e.g.
shell.prefix("set -o pipefail; ")
答案 1 :(得分:0)
你可以使用字符串连接:
prefix_block = """
hostname
echo 'good luck'
"""
rule rule1:
input:...
output:...
shell: prefix_block + "rule1command"
rule rule2:
input:...
output:...
shell: prefix_block + "rule2command"