如何使Snakemake通配符适用于空字符串?

huangapple go评论66阅读模式
英文:

How to make Snakemake wildcard work for empty string?

问题

我期望Snakemake允许通配符为空字符串,然而,事实并非如此。

如何使通配符接受空字符串?

英文:

I expected Snakemake to allow wildcards to be empty strings, alas, this isn't the case.

How can I make a wildcard accept an empty string?

答案1

得分: 4

通配符默认只匹配正则表达式.+,意味着匹配一切除了空字符串。不幸的是,除了Google小组讨论之外,这一点未记录

要使通配符匹配空字符串,只需在规则范围内或全局添加自定义通配符约束wildcard_constraints: foo=".*"

# 选项 1
wildcard_constraints:
    foo=".*"

rule a:
    input: in{foo}.txt
    output: out{foo}.txt
    wildcard_constraints: foo=".*"  # 选项 2
    shell: "cp {input} {output}"
英文:

Wildcards by default only match the regex .+ meaning everything but empty strings. This is unfortunately not documented beyond a Google group conversation.

To make a wildcard accept empty strings, simply add a custom wildcard constraint wildcard_constraints: foo=".*", either within the scope of a rule or globally:

# Option 1
wildcard_constraints:
    foo=".*"

rule a:
    input: in{foo}.txt
    output: out{foo}.txt
    wildcard_constraints: foo=".*"  # Option 2
    shell: "cp {input} {output}"

huangapple
  • 本文由 发表于 2023年2月24日 02:29:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548903.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定