title: Is there a way for Snakemake to evaluate dynamic Snakefile constructs like `eval` does in GNU Make?
body: <p>I would like to have various dynamic &quot;shortcuts&quot; (rule names) in my Snakemake workflow without needing marker files. The method I have in mind is similar to <a href="https://www.gnu.org/software/make/manual/html_node/Eval-Function.html" rel="nofollow noreferrer"><code>eval</code> in GNU Make</a>, but it doesn't seem like Snakemake can evaluate variable-expanded code in the Snakefile syntax. Is there a way to accomplish this?</p>
  <p>Here's a simplified example Snakefile. I want to have a rule name corresponding to each output &quot;stage&quot;, and right now I have to define them manually. Imagine if I had more &quot;stages&quot; and &quot;steps&quot; and wanted to have a rule that could make all &quot;b&quot;, &quot;d&quot;, or &quot;z&quot; files if I add those stages. It would be far more concise to dynamically define the rule name than to define every single combination, updated each time I add a new stage.</p>
  <pre class="lang-python prettyprint-override"><code>stages = ['a', 'b']
  steps = [1, 2]
  
  rule all:
      input:
          expand('{stage}{step}_file', stage=stages, step=steps)
  
  rule:
      output:
          touch('{stage}{step}_file')
  
  # Can these two be combined so that I don't have to add more
  # rules for each new &quot;stage&quot; above while retaining the shorthand
  # rule name corresponding to the stage?
  rule a:
      input: expand('a{step}_file', step=steps)
  
  rule b:
      input: expand('b{step}_file', step=steps)
  </code></pre>