2 回答
TA贡献1921条经验 获得超9个赞
temp() 在这种情况下确实有效。
rule all:
input: 'raw1.a.b.c.a.d.csv',
'raw2.a.b.c.d.a.csv'
rule a:
input: '{path}.csv'
output: temp('{path}.a.csv')
shell: 'cp {input} {output}'
rule b:
input: '{path}.csv'
output: '{path}.b.csv'
shell: 'cp {input} {output}'
rule c:
input: '{path}.csv'
output: temp('{path}.c.csv')
shell: 'cp {input} {output}'
rule d:
input: '{path}.csv'
output: '{path}.d.csv'
shell: 'cp {input} {output}'
执行此操作将导致创建文件raw1.a.b.c.a.d.csv , raw1.a.b.csv, raw2.a.b.c.d.csv, raw2.a.b.csv和自动删除文件raw1.a.csv, raw2.a.csv, raw1.a.b.c.csv, raw2.a.b.c.csv, raw1.a.b.c.a.csv, raw2.a.b.c.d.a.csv。
TA贡献1859条经验 获得超6个赞
编辑:实际上,这个解决方案不起作用..它会导致竞争条件......
好吧,我想通了...
rule a:
input: '{path}.csv'
output: '{path}.a.csv'
shell: 'cp {input} {output}'
rule b:
input: '{path}.csv'
output: '{path}.b.csv'
shell: 'cp {input} {output}'
rule c:
input: '{path}.csv'
output: '{path}.c.csv'
shell: 'cp {input} {output}'
rule d:
input: '{path}.csv'
output: '{path}.d.csv'
shell: 'cp {input} {output}'
rule remove: # <-- rule to delete a file
input: '{path}'
output: touch('{path}.removed')
shell: 'rm {input}'
rule all:
input: 'raw1.a.b.c.a.d.csv',
'raw2.a.b.c.d.a.csv',
'raw1.a.csv.removed', # <-- specify which files to rm
'raw2.a.b.c.csv.removed', # <-- specify which files to rm
这是dag:
$ snakemake --dag all | dot -Tpng > dag.png
添加回答
举报