如何编写没有输出的 Snakemake 规则?

How to write a Snakemake rule with no output?

我的 Snakefile 有一个 print_to_screen 规则 没有明确的输出文件 。以下是一个简化的例子:

rule all:
    placeholder_output  # What should I put here?

rule create_file:
    output:
        "file.txt"
    shell:
        "echo Hello World! > {output}"

rule print_to_screen:   # This rule has no output
    input:
        "file.txt"
    shell:
        "cat {input}"

如何编写print_to_screen规则,使其触发其他规则,意思是:

规则的 output 部分是可选的,但您需要将其设为第一条规则(在 Snakefile 中将其定义为第一条)才能生效:

rule print_to_screen:
    input:
        "file.txt"
    shell:
        "cat {input}"

rule create_file:
    output:
        "file.txt"
    shell:
        "echo Hello World! > {output}"

如果您需要一些灵活性(例如您有多个这样的规则),您应该使用 flags.