我想運行一個簡單的腳本“script.py”,它將運行一些 caculayions 并定期吐出一個 step_000n.txt 檔案,其中 n 取決于總檔案執行時間。然后我希望snakemake 對所有生成的檔案運行另一條規則。什么是正確的 Snakefile 輸入?IE
1. run scipt.py
2. get step_000{1,2,3,4 ..}.txt (n being variable and not determined)
3. apply `process.py -in step_000{n}.txt -out step_000{n}.png` on all step_000{1,2,3,4 ..}.txt
我明顯錯誤的嘗試如下
rule all:
input: expand("{step}.png", step=list(map(lambda x: x.split(".")[0], glob.glob("model0*.txt"))))
rule txt:
input: "{step}.txt"
output: "{step}.png"
shell:
"process.py -in {input} -out {output}"
rule first:
output: "{step}.txt"
script: "script.py"
我不知道如何在這里定義輸出目標。
uj5u.com熱心網友回復:
我會將所有step_000n.txt檔案寫入專用目錄,然后處理該目錄中的所有檔案。就像是:
rule all:
input:
'processed.txt',
rule split:
output:
directory('processed_dir'),
shell:
r"""
# Write out step_001.txt, step_002.txt, ..., step_000n.txt
# in output directory `processed_dir`
mkdir {output}
script.py ...
"""
rule process:
input:
indir= 'processed_dir',
output:
out= 'processed.txt',
shell:
r"""
process.py -n {input.indir}/step_*.txt -out {output.out}
"""
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/490102.html
上一篇:添加轉換后物件渲染奇怪
