ted*_*oal 8 delete-file snakemake
当删除管道中较早创建的文件时,SnakeMake 似乎并不认为这是一个问题,只要后面的文件还在:
rule All:
input: "testC1.txt", "testC2.txt"
rule A:
input: "{X}{Y}.txt"
output: "{X}A{Y}.txt"
shell: "cp {input} {output}"
rule B:
input: "{X}A{Y}.txt"
output: "{X}B{Y}.txt"
shell: "cp {input} {output}"
rule C:
input: "{X}B{Y}.txt"
output: "{X}C{Y}.txt"
shell: "cp {input} {output}"
Run Code Online (Sandbox Code Playgroud)
将此 SnakeFile 保存在 test.sf 中并执行以下操作:
rm testA*.txt testB*.txt testC*.txt
echo "test1" >test1.txt
echo "test2" >test2.txt
snakemake -s test.sf
# Rerun:
snakemake -s test.sf
# SnakeMake says all is up to date, which it is.
# Remove intermediate results:
rm testA1.txt
# Rerun:
snakemake -s test.sf
Run Code Online (Sandbox Code Playgroud)
SnakeMake 说一切都是最新的。它不会检测丢失的 testA1.txt。
我似乎记得在线 SnakeMake 手册中关于此的一些内容,但我再也找不到了。
我认为这是 SnakeMake 的预期行为。它有时可能是所需的行为,但有时您可能希望它检测并重建丢失的文件。如何才能做到这一点?
正如在另一个答案中提到的,该-R参数可以提供帮助,但还有更多选项:
你打电话时
snakemake -F
Run Code Online (Sandbox Code Playgroud)
这将触发整个管道的重建。这基本上意味着,忘记所有中间文件并重新开始。这肯定会(重新)生成所有中间文件。缺点是:可能需要一些时间。
这是-R <rule>参数的领域。这将重新运行给定的规则和所有依赖于它的规则。所以在你的情况下
snakemake -R A -s test.sf
Run Code Online (Sandbox Code Playgroud)
将重新规则A(构建testA1.txt从test.txt)和规则B,C和所有的,因为它们依赖于A.记住,这是运行要求的规则A的所有副本,所以在你的榜样testA2.txt,并从它下面的一切还重建.
如果在您的示例中,您会testB1.txt改为删除规则,B并且C会重新运行。
如果我没记错的话,snakemake 会检测文件是否需要通过其 utime 重建。因此,如果您有一个testA1.txt比 更年轻的版本(如最近创建的)testB1.txt,testB1.txt则必须使用 重建rule B,以确保一切都是最新的。因此,testA1.txt除非您以某种方式更改文件的 utime,否则您无法轻松地重建,除非同时构建所有后续文件。
我还没有试过这个,但这可以通过snakemakes--touch参数来完成。如果您设法只运行规则A然后运行snakemake -R B -t,它涉及规则的所有输出文件B和以下,您可以获得有效的工作流状态,而无需实际重新运行其间的所有步骤。