Search code examples
snakemake

Snakemake skips multiple of the rules with same input


Let's say I have 3 rules with the same input, snakemake skips 2 of them and only runs one of the rules. Is there a workaround to force all 3 rules to execute, since I need all 3 of them? I could add some other files as input to the existing input, but I feel like that's somewhat cheated and probably confusing to other people looking at my code, since I declare an input that is not used at all.


Solution

  • It appears target files were not defined. By default, snakemake executes the first rule in the snakefile.

    Example:

    rule all
       input: "a.txt", "b.png"
    
    rule x:
       output "a.txt"
       shell: "touch {output}"
    
    rule y:
       output "b.png"
       shell: "touch {output}"
    

    It is customary to name the first rule all which has all the desired output files.