命名规则和本地规则
版本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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
localrule dimentrule指令.0
The localrule directive has been added as of version 7.25.0