Add tex command for snakefile parameters
nstarman opened this issue · comments
It would be awesome if the params in the snakefile could be accessed by a command similar to \variable
.
For example, given the following
In the tex file I would like to write something like
We ran \snakeparameter{simulations["iterations"]} in our simulation.
SYW would then parse the snakefile and save the parameter to a text file so that \snakeparameter{rule[param]}
-> \input{output/snakefile/rule/param.txt}
.
This is an interesting suggestion. My initial feeling is that this would be pretty non-trivial to add to SYW in a general way, but probably wouldn't be too hard to add manually. I'd probably prefer to add this as an example to the docs (using \variable
directly), rather than trying to build it into SYW, but if you think you could make it work simply, please feel free to take a stab!
Just trying to think through the steps:
- Make a
snakefile
folder inoutput
(and thecache
) - Using the existing
variable
detection mechanism determine which files to generate, parsing if the file name starts withoutput/snakefile/
- Parse the file path for
[rule]
inoutput/snakefile/[rule]/[param].txt
andmkdir
that folder - parse the file path for
[param]
inoutput/snakefile/[rule]/[param].txt
, parse that parameter in the rule's parameter section and save that text to the file. This seems the least trivial portion.
I was imagining something simpler like adding params="params.tex"
as an output to the simulation
rule above, and then in your script do something like (untested):
with open(snakemake.output["params"], "w") as f:
f.write(f"\newcommand{{\paramseed}}{{{snakemake.params.seed}}}")
...