I have a problem with indexing my snakemake wildcards in a function. For some reason the order of how the the variables are stored in the "Wildcards" list varies. I use the function to generate the paths for the input files for one of my rules, and as the position of the correct values changes, the rule only succeeds once every couple queries. How can I control or fix the position of wildcard in the "Wildcards" list? I added the relevant content of my Snakefile.
Thank you, zuup
#!/usr/bin/env python3
import glob
import re
R_BIN = "Rscript"
pop = "lineA lineB".split()
group = "test control".split()
chrom = "X Y".split()
def getInput(Wildcards):
pop = str(Wildcards[0])
group = str(Wildcards[1])
chrom = str(Wildcards[2])
path = "Resources/bed/" + pop + "_" + group + r"_rep[1-5]/" + pop + "_" + group + r"_rep[1-5]_chr" + chrom + ".bed"
return(glob.glob(path))
rule BED2BS:
input:
getInput
output:
wd + "Resources/bs/{pop}_{group}/{group}_chr{chrom}.RDS"
shell:
R_BIN + " Scripts/Script1.R {input} {output}"