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

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

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. # 选项 1
  2. wildcard_constraints:
  3. foo=".*"
  4. rule a:
  5. input: in{foo}.txt
  6. output: out{foo}.txt
  7. wildcard_constraints: foo=".*" # 选项 2
  8. 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:

  1. # Option 1
  2. wildcard_constraints:
  3. foo=".*"
  4. rule a:
  5. input: in{foo}.txt
  6. output: out{foo}.txt
  7. wildcard_constraints: foo=".*" # Option 2
  8. 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:

确定