I have two wildcards, the first for a species, the second is basically a counter for each file from a specific species. So I have Cow_A, Cow_B and Pig_A, Pig_B, Pig_C for example (the amount of files varies from species to species)
Now what I want is in the Input to select all files of one species using something like this
input: expand("{{species}}_{rep}", rep=count(species))
output: "{species}_combined"
How do I tell the input function count to use the current species wildcard?
You may use a function (or lambda) in the input section:
input:
lambda wildcards: expand("{species}_{rep}", species=[wildcards.species], rep=get_reps(wildcards.species))
output:
"{species}_combined"
You need to define a function that returns the reps for a species. That may be read from config or you may employ the glob_wildcards function:
def get_reps(species):
return glob_wildcards(f"{species}_{{rep}}").rep