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