是否可以在 Snakemake 文件的所有规则中传递一组(多个)通配符?

发布于 2025-01-09 14:03:28 字数 945 浏览 1 评论 0原文

所以,由于我是 Snakemake 的新手,我不确定我是否完全理解它,所以尽我最大的努力以我理解的方式。我正在尝试运行我的规则,该规则实际上使用另一个不同的规则,并根据其输出创建一组新文件。然而,这两个有不同的通配符,这就带来了麻烦。

configfile: "config.yaml"
include: "rules/rule_with_query.smk"
rule all:
        expand(rules.query_hail.output, id=config['listID'], conf=config['confs'])

rule all 实际上不接受多个通配符。然而,我的规则需要两个,因为前一个规则使用 confs ,当前规则需要 id

这是我的规则:

def get_query_fName(wildcards):
    return config["listID"][wildcards.listID]
rule query_hail:
    input:
        rules.prev_rule.output
    params:
        config['id1_or_id2']
    output:
        "file_with_data{id}.tsv"
    script:
        "../scripts/script_for_data.py"

因此,如果我同时尝试两个通配符(我放置第二个的通配符)将不起作用。我还尝试将它们放在方括号中,即作为列表,但这也不起作用。

    expand(rules.query_hail.output, [conf=config['conf'], idlocus=config['listID']])

那么我应该怎么做,我应该如何调用通配符以便我的规则起作用?

So, as I am new at Snakemake I'm not sure whether I am fully getting it, so trying my best the way I understand it. I am trying to run my rule, which actually uses another different rule and based on its output creates a new set of files. However, those two have different wildcards and here comes trouble.

configfile: "config.yaml"
include: "rules/rule_with_query.smk"
rule all:
        expand(rules.query_hail.output, id=config['listID'], conf=config['confs'])

The rule all actually doesn't accept several wildcards. However my rule needs two, as there the previous rule, which uses confs and the current one requiring id.

Here's my rule:

def get_query_fName(wildcards):
    return config["listID"][wildcards.listID]
rule query_hail:
    input:
        rules.prev_rule.output
    params:
        config['id1_or_id2']
    output:
        "file_with_data{id}.tsv"
    script:
        "../scripts/script_for_data.py"

So, if I try two wildcards at the same time either (the one I put the second) won't work. I have also tried to put them in square brackets, i.e. as a list, but that doesn't work either.

    expand(rules.query_hail.output, [conf=config['conf'], idlocus=config['listID']])

What should I do then, how should I call wildcards so my rule will work?

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

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

发布评论

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

评论(1

镜花水月 2025-01-16 14:03:28

由于 conf 不在 query_hail 的输出中,Snakemake 不知道如何处理它 - expand 本质上相当于

"file_with_data{id}.tsv".format(id=some_id_from_id_list, conf=some_conf_from_conf_list)

对于 listID 中的所有 id 和confs 中的所有conf。 conf 无处可去。

如果仅编写 rule all as

rule all:
    input:
        expand("file_with_data{id}.tsv", id=config['listID'])

不起作用,您可能需要更多内容来确保可以从 query_hail 推断出 prev_rule 中的通配符。

Since conf isn't in the output of query_hail, Snakemake doesn't know what to do with it - that expand is essentially the equivalent of

"file_with_data{id}.tsv".format(id=some_id_from_id_list, conf=some_conf_from_conf_list)

for all ids in listID and all confs in confs. There's nowhere for that conf to go.

If just writing rule all as

rule all:
    input:
        expand("file_with_data{id}.tsv", id=config['listID'])

doesn't work, you may need something more to make sure the wildcards in prev_rule can be inferred from query_hail.

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