使用snakemake的参数空间自定义模式
是否可以将自定义 wildcard_pattern
和 instance_patterns
与 snakemake.utils.Paramspace
?
示例:
说 Paramspace
看起来像这样
import snakemake
import pandas as pd
df = pd.DataFrame([
["default","2030"],
["default","2050"],
], columns=["scenario","year"])
paramspace = snakemake.utils.Paramspace(df)
那么 wildcard_pattern
和 instance_pattern
看起来像这样
print(paramsapce.wildcard_pattern)
# 'scenario~{scenario}/year~{year}'
print(list(paramspace.instance_patterns))
# ['scenario~default/year~2030', 'scenario~default/year~2050']
我想要做的是让这两种模式都没有名称前面加上通配符,即我希望它看起来像这样:
print(paramsapce.wildcard_pattern)
# '{scenario}/{year}'
print(list(paramspace.instance_patterns))
# ['default/2030', 'default/2050']
Is it possible to use a custom wildcard_pattern
and instance_patterns
with snakemake.utils.Paramspace
?
Example:
Say the Paramspace
looks like this
import snakemake
import pandas as pd
df = pd.DataFrame([
["default","2030"],
["default","2050"],
], columns=["scenario","year"])
paramspace = snakemake.utils.Paramspace(df)
Then the wildcard_pattern
and instance_pattern
look like this
print(paramsapce.wildcard_pattern)
# 'scenario~{scenario}/year~{year}'
print(list(paramspace.instance_patterns))
# ['scenario~default/year~2030', 'scenario~default/year~2050']
What I want to do is have both patterns without the name of the wildcard prepended, i.e. I would like it to look like this:
print(paramsapce.wildcard_pattern)
# '{scenario}/{year}'
print(list(paramspace.instance_patterns))
# ['default/2030', 'default/2050']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有公共函数,并且代码格式基于位置而不是名称,因此更改模式不会削减它。
我建议您编写自己的辅助函数来格式化您想要的模式。该代码在其格式调用中使用 iterrows 和 row.items。
您还可以提出一个问题,请求进行更改以禁止使用参数名称或提供自定义格式化程序。目前,您可以更改参数分隔符(默认
~
)。There isn't a public function, and the code formats based on position instead of name, so changing the pattern won't cut it.
I would recommend just writing your own helper function to format the pattern you want. The code uses iterrows and row.items in it's format call.
You could also open an issue requesting a change to either suppress having the parameter name or provide a custom formatter. Currently, you can change the param separator (default
~
).