Use snakemake's localrules in wildcard specific manner

Viewed 85

localrules can be used to run specific rule(s) locally instead of running it as a cluster job. Is it possible to define this in wildcard specific manner, in addition?

For example, in the example below, rule summer should be run locally to create file short_job.txt and run as a cluster job for file long_job.txt.


rule all:
    input: 
        "long_job.txt",
        "short_job.txt",


localrules: summer
rule summer:
    output: 
        "{sample}.txt"
    shell:  
        "touch {output}"
1 Answers

To solve this task I would use two separate rules:

rule all:
    input: 
        "long_job.txt",
        "short_job.txt",


rule summer:
    output: 
        "{sample}.txt"
    wildcard_constraints:
        sample=".*long.*"
    shell:  
        "touch {output}"


localrules: summer_local
rule summer_local:
    output: 
        "{sample}.txt"
    wildcard_constraints:
        sample=".*short.*"
    shell:  
        "touch {output}"
Related