New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow paramspace to separate filename params with custom separator #1299
feat: Allow paramspace to separate filename params with custom separator #1299
Conversation
Kudos, SonarCloud Quality Gate passed!
|
This is is a wonderful PR. I was about to sit down and code it up myself as I need that facility to interface Thanks so much @kpj! 🙏 |
@johanneskoester Any thoughts on this? :-) |
I would just use the Nevertheless, it does not hurt make this configurable. |
This is also what I do when a rule deals with a single parameter instance, but sometimes (e.g., when aggregating all individual results with snakemake@input$fname_list %>%
map_dfr(function(path) {
path_parts <- gtools::split_path(path, depth_first = FALSE)
param_str <- path_parts[[length(path_parts) - 1]]
tmp <- list()
for (param_pair in strsplit(param_str, "_")[[1]]) {
parts <- strsplit(param_pair, "~")[[1]]
tmp[parts[[1]]] <- parts[[2]]
}
read_csv(path) %>%
mutate(!!!tmp)
})
Agreed :-) My previous example is maybe somewhat obscure, but the |
Why not something like this?
|
That is a great point! I think I never considered this possibility because I did not want to rely on the seemingly implicit assumption that fname_list=expand(
f"results/{paramspace.wildcard_pattern}/path/{{replicate}}/{{method}}/enrichment_result.csv",
replicate=range(config["replicate_count"]),
method=method_list,
allow_missing=True,
), But I could probably do something like this to solve the issue: params:
instances=[params for params in paramspace.dataframe.iterrows() for _ in range(config["replicate_count"]) for _ in method_list] Now that I think about it, it's probably a much better solution. Thanks, I'll use this from now on :-) Regarding merging this PR, is there anything else that I could do? |
Nope, thanks! |
Kudos, SonarCloud Quality Gate passed!
|
Description
This PR allows using
Paramspace(df_params, filename_params="*", filename_sep="::")
to generate paths of the formcolumn1~{value1}::column2~{value2}
.This is useful when parameter names contain
_
and we want to retrieve their values from path names in some rule (is there a better way of doing this?).QC
docs/
) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).