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

发布于 2025-01-13 05:12:14 字数 661 浏览 0 评论 0原文

我的 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规则,使其触发其他规则,意思是:

  • 它可以作为其他规则中的输入,所以运行 snakemake {placeholder_output} 也会触发之前的规则 create_file
  • 它可以包含在rule all中,因此运行snakemake会触发所有规则?

My Snakefile has a print_to_screen rule with no explicit output file. The following is a simplified example:

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}"

How can I write the print_to_screen rule so that it triggers other rules, meaning that:

  • it can be used as an input in other rules, so running snakemake {placeholder_output} also triggers the previous rule create_file?
  • it can be included in rule all, so running snakemake triggers all rules?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2025-01-20 05:12:14

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

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

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

如果您需要一些灵活性(例如您有多个类似的规则)你应该使用 标志

The output section of the rule is optional, but you need to make it the first rule (define it the first in your Snakefile) to take any effect:

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

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

If you need some flexibility (for example you have several rules like that) you should use flags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文