How to communicate cluster resources to rules. # SOLUTION 1 rule delly: input: bamlist="{batch}/bamlist.list", excluded="exclusion/excluded.bed", reference = REFERENCE, fai = REFERENCE + ".fai" output: "{batch}/delly/delly_{chrom}_{svtype}.bcf" params: template = EMPTY_TEMPLATE, reference = os.path.abspath(REFERENCE) threads: get_threads("delly", 4) log: stdout = "{batch}/logs/delly/{chrom}_{svtype}.o", stderr = "{batch}/logs/delly/{chrom}_{svtype}.e" shell: "export OMP_NUM_THREADS={threads} ; " "delly.py -b {input.bamlist} -c {wildcards.chrom}" " -g {params.reference} -x {input.excluded} -t {wildcards.svtype}" " -o {output} -e {params.template}" " 1>{log.stdout} 2>{log.stderr}" with def get_threads(rule, default): cluster_config = snakemake.workflow.cluster_config if rule in cluster_config and "threads" in cluster_config[rule]: return cluster_config[rule]["threads"] if "default" in cluster_config and "threads" in cluster_config["default"]: return cluster_config["default"]["threads"] return default ## SOLUTION 2 #config.yaml resources: resources.yaml # Snakefile with open(config["resources"]) as yml: config.update(yaml.load(yml)) rule rsem_count: input: expand("Results/Rsem_Index/" + os.path.splitext(os.path.basename(config["fasta_ref"]))[0]+".{suffix}", suffix=RSEM_SUFFIX[1:]), rsem_idx="Results/Rsem_Index/" + os.path.splitext(os.path.basename(config["fasta_ref"]))[0]+".grp", bam=get_RSEM_inbam output: "Results/{dir}/{prefix}.genes.results", "Results/{dir}/{prefix}.isoforms.results" params: forward_prob = lambda wildcards : table[table.forward_read.str.contains('^' + wildcards.prefix)]["oriented"].tolist()[0], mode = lambda wildcards : "--paired-end" if table[table.forward_read.str.contains('^' + wildcards.prefix)]["reverse_read"].any() else "" , prefixOut="Results/{dir}/{prefix}" threads: config["rsem_count"]["cpu"] shell: "rsem-calculate-expression --ci-memory 30000 {params.mode} --bam --no-bam-output --estimate-rspd --calc-ci --seed 12345 -p {threads} --forward-prob {params.forward_prob} {input.bam} `echo {input.rsem_idx} | sed 's/.grp//'` {params.prefixOut}" # launch Snakemake snakemake \ --snakefile $SNAKEDIR/Snakefile \ --configfile config.yaml \ --jobs 999 --cluster-config resources.yaml --cluster "sbatch -p unlimitq -e LOG/run1/%x.err -o LOG/run1/%x.out --cpus-per-task={cluster.cpu} --time={cluster.time} --mem-per-cpu={cluster.mem}" \ --printshellcmds --latency-wait 30 --until star_aln_pass1 --notemp