命名规则和本地规则

发布于 2025-01-22 02:04:42 字数 1063 浏览 1 评论 0原文

版本7.3.8

我通常构建我的config.yaml,以便可以使用以下情况自动下载公共数据集:

# config.yaml
paths:
  vcf: 'path/to/vcf_{chrom}.vcf'
  ...
urls:
  vcf: 'ftp://path_to_vcf_{chrom}.vcf'
  ...
# Snakefile
for key, url in config['urls'].items():
    rule:
        name: f'download_{key}'
        output: config['paths'][key]
        params: url=url
        shell: # do download

因为添加了name指令,我可以给出规则有意义的名称(这很棒!)。问题是我想指定所有这些下载规则是localrules。我可以使用

# Snakefile
localrules:
    download_vcf,
    ...

download_vcf是一个令牌,而不是字符串,因此我必须手动将该列表与我的配置保持最新。我想编程将每个URL添加到本地规则中。我可以做类似的事情:

workflow._localrules.update(f'download_{key}' for key in config['urls'])

但是我想避免使用私有变量。

还有其他建议吗?这是值得的功能请求吗?更新本地列的方法或新指令localrule替换rule(类似于checkpoint)?我对它的思考越多,将规则标记为本地而不是单独的本地列说明,就越有意义。

Version 7.3.8

I commonly structure my config.yaml such that public datasets can be automatically downloaded if not present using:

# config.yaml
paths:
  vcf: 'path/to/vcf_{chrom}.vcf'
  ...
urls:
  vcf: 'ftp://path_to_vcf_{chrom}.vcf'
  ...
# Snakefile
for key, url in config['urls'].items():
    rule:
        name: f'download_{key}'
        output: config['paths'][key]
        params: url=url
        shell: # do download

Since the addition of the name directive, I can give the rules meaningful names (which is great!). The issue is I'd like to specify all these download rules are localrules. I can use

# Snakefile
localrules:
    download_vcf,
    ...

where download_vcf is a token, not a string, so I have to manually keep that list up to date with my config. I'd like to programmatically add each url to local rules. I can do something like:

workflow._localrules.update(f'download_{key}' for key in config['urls'])

but I'd like to avoid using the private variable.

Any other recommendations? Is this something worth a feature request? Either a method to update localrules or a new directive localrule to replace rule (similar to checkpoint)? The more I think about it, the more it makes sense to label a rule as local instead of a separate localrules directive.

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

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

发布评论

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

评论(1

聆听风音 2025-01-29 02:04:42

The localrule directive has been added as of version 7.25.0

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