Referring to input function of another Snakemake rule

Viewed 313

I'm having problems referring top the input function of another Snakemake rule. I illustrated this in the code below:

rule bla:
    output: '{x}.txt'
    shell: 'touch {output}'


rule all_dogs:
    input: expand(rules.bla.output, x=['goofy', 'buster', 'fifi'])

rule all_cats:
    input: expand(rules.bla.output, x=['tom', 'felix', 'sylvester'])

def all_birds_infun(wildcards):
    return expand(rules.bla.output, x=['tweety', 'donald'])

rule all_birds:
    input: all_birds_infun

rule all_mammals:
    input: rules.all_dogs.input,
           rules.all_cats.input

rule all_animals:
    input: rules.all_dogs.input,
           rules.all_cats.input,
           rules.all_birds.input

localrules: bla

The rule all_mammals refers to the inputs of two other rules and works fine. The rule all_animals, however, does not work because it refers to the input of all_birds, which uses an input function as a rule. I realize that as a workaround, I could simply refer to the input function all_birds_infun directly, but in my real world example that would mean copy&pasting some parameterized functions, which would be very ugly.

The error I get from referring to rules.all_birds.input is

TypeError in line 25 of Snakefile:
expected string or bytes-like object
  File "Snakefile", line 25, in <module>
0 Answers
Related