我正在尝试创建一个snakemake规则,该规则为每个给定种子生成3个输出文件。我目前有以下几种:
SIM_OUTPUT = ["summary", "tripinfo", "vehroute"]
SEEDS = [1,2]
single_seed = 1
rule sumo_sim_1:
input:
config = "two-hours-ad-hoc.sumo.cfg"
output:
expand("xml/{file}.{seed}.xml", seed = single_seed, file=SIM_OUTPUT)
shell:
" sumo -c {input.config} --seed {single_seed}"
"--summary-output {output[0]} "
"--tripinfo-output {output[1]} "
"--vehroute-output {output[2]} "
上面的代码适用于单个种子,但我想不出一种方法来处理多个种子。
首先,您需要更改规则以使用种子通配符,如
rule sumo_sim_1:
output:
"xml/summary.{seed}.xml",
"xml/tripinfo.{seed}.xml",
"xml/vehroute.{seed}.xml",
shell:
" sumo -c {input.config} --seed {wildcards.seed} "
"--summary-output {output[0]} "
"--tripinfo-output {output[1]} "
"--vehroute-output {output[2]} "
然后,您的下游规则可以指定输入所需的种子,如下所示:
rule all:
input:
["xml/summary.1.xml", "xml/summary.2.xml", "xml/tripinfo.1.xml", "xml/tripinfo.2.xml", "xml/vehroute.1.xml", "xml/vehroute.2.xml"]