shell.executable("bash")

rule all:
    input: "stringbar.txt", "localbar.txt", "globalbar.txt", "ambig.u.ous.log"


##: NB: setting output: "{foo}.in" only works for globalwildcard rule
## since constraints will be set to "globalbar"
rule infile:
    output: temp("{foo,(globalbar|localbar|stringbar)}.in")
    shell: "touch {output}"


rule stringwildcard:
    input: "{foo}.in"
    output: "{foo,stringbar}.txt"
    log: "{foo}.log"
    shell: "echo {input} {output} {log} > {output}; touch {log}"


rule localwildcard:
    input: "{foo}.in"
    output: "{foo}.txt"
    wildcard_constraints: foo="localbar"
    log: "{foo}.log"
    shell: "echo {input} {output} {log} > {output}; touch {log}"


rule globalwildcard:
    input: "{foo}.in"
    output: "{foo}.txt"
    log: "{foo}.log"
    shell: "echo {input} {output} {log} > {output}; touch {log}"


rule ambigouslog:
    output: "{foo}.{bar}.txt"
    log: "{foo}.{bar}.log"
    wildcard_constraints: foo="ambig", bar=".+"
    shell: "echo a={wildcards.foo} b={wildcards.bar} > {output}; touch {log}"


wildcard_constraints:
    foo='globalbar',
    bar='out/{SM,[a-z]+}_{PU,[0-9]+}'
