【发布时间】:2019-12-30 18:51:09
【问题描述】:
我想将 Snakemake 用于需要重复执行某个步骤直到满足某些条件的流程。无法提前确定该步骤需要多少次。它可以是 1 或 6 或任何其他数字。
我的直觉是,这是 Snakemake 无法做到的,因为有向 非循环 Graph 和所有...
不过,我希望检查点可能会有所帮助,因为它会触发对 DAG 的重新评估,但我只是无法确切了解它是如何工作的。
Snakefile 中的循环是否可能?
谢谢!
在下面的优秀答案中添加一些关于实际发生的事情的评论。希望当我不可避免地重新审视这个问题时,它可以帮助其他人和我自己。
all: call function all_input to determine rule's input requirements.
all_input: file "succes.txt" doesn't exist. do checkpoint keep_trying with i == 1.
keep_trying: output "round_1" doesn't exist. do run section. random() decides to touch output[0], which is "round_1".
snakemake reevaluates graph after checkpoint is complete
all: call function all_input to determine rule's input requirements.
all_input: file "succes.txt" doesn't exist. do checkpoint keep_trying with i == 2.
keep_trying: output "round_2" doesn't exist. do run section. random() decides to touch output[0], which is "round_2".
snakemake reevaluates graph after checkpoint is complete
all: call function all_input to determine rule's input requirements.
all_input: file "succes.txt" doesn't exist. do checkpoint keep_trying with i == 3.
keep_trying: output "round_3" doesn't exist. do run section. random() decides to touch "succes.txt".
snakemake reevaluates graph after checkpoint is complete
all: call function all_input to determine rule's input requirements.
all_input: file "succes.txt" exists. return "success.txt" to rule all.
all: input requirement is "success.txt", which is now satisfied.
【问题讨论】:
标签: loops snakemake checkpoint