snakemake / snakemake-executor-plugin-slurm

A Snakemake executor plugin for submitting jobs to a SLURM cluster
MIT License
18 stars 19 forks source link

Define job groups in cluster config.yaml #171

Closed freekvh closed 1 week ago

freekvh commented 1 week ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I would like to set job groups in the cluster config.yaml file instead of in the rules. This would make it easier to keep the overview + it is a parameter that is specific to a cluster's resources so naturally it would find its place in the cluster config.yaml. At the moment I can only get job-grouping to work using this inside rules:

rule salmon:
    input:
        read1 = rules.trim_galore.output.fastq_read1,
        read2 = rules.trim_galore.output.fastq_read2,
    output:
        genes_quantification = os.path.join(config['Directories']['analyzed_dir'], 'salmon_{sample}', 'quant.genes.sf'),
    threads: 12
    conda:
        "../envs/salmon.yaml"
    params:
        salmon_index = os.path.join(config['Global_directories']['reference_files'], config['References']['salmon_index']),
        gtf_file = os.path.join(config['Global_directories']['reference_files'], config['References']['gtf_file']),
    group:
        "quantification"    
    shell:
        '''
        salmon quant \
        --index {params.salmon_index} \
        --geneMap {params.gtf_file} \
        --libType A \
        --mates1 {input.read1} \
        --mates2 {input.read2} \
        --validateMappings \
        --threads {threads} \
        --output {config[Directories][analyzed_dir]}/salmon_{wildcards.sample}
        '''

Describe the solution you'd like It would be nice if I could set the groups inside the cluster.yaml file, perhaps in the set-resources section, like to:

set-resources:
  salmon:
    mem_mb: 20000 # This seems to work, but can we do with less?
    runtime: 600
    group: "quantification"
  TPM_normalization:
    group: "quantification"

Describe alternatives you've considered Perhaps this can already be done, and I'm implementing it wrong but I have read all relevant documentation as far as I am aware.

Additional context

cmeesters commented 1 week ago

Consider this: The group job is a property of the workflow itself. Snakemake allows for group jobs to support piped information flow. To rely on profiles to provide for such information can break a workflow.

On the other hand, every property of a workflow can be defined on the command line, too. And in configuration files. I did not test this for group jobs, because I would not recommend it for the reason named above.

Besides, this is a property of Snakemake. This plugin repo only contains the code for job submissions using the SLURM batch system. Snakemake issues should be reported in the Snakemake repository.