2 回答

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊
temp() 在這種情況下確實(shí)有效。
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}'
執(zhí)行此操作將導(dǎo)致創(chuàng)建文件raw1.a.b.c.a.d.csv , raw1.a.b.csv, raw2.a.b.c.d.csv, raw2.a.b.csv和自動(dòng)刪除文件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貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊
編輯:實(shí)際上,這個(gè)解決方案不起作用..它會(huì)導(dǎo)致競(jìng)爭(zhēng)條件......
好吧,我想通了...
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
添加回答
舉報(bào)