<@UE6D8290F> In your review comment here, advising...
# mcmicro
j
@Maxime Garcia In your review comment here, advising against switch statements in modules.config, did you have any alternatives that would achieve our goals? The idea is to normalize the published output filename format for multiple modules that are alternative implementations of the same step, where the tool itself doesn't offer any control over output naming. https://github.com/nf-core/mcmicro/pull/120/changes#diff-bf809c928cb10b54d251dec8a140a2d5505150f97175d8d7b51dda9cc57971feR69-R80
👀 1
m
if statements
j
Even when there are 2+ arms and they're all checking the same variable (
filename
)? This seems like the perfect application for a switch. Otherwise the variable name needs to be repeated for each condition, which feels redundant. I do agree if it was only if/else then an if or
a?b:c
would be better.
Groovy 4 added switch expressions which would be even cleaner but I found the nextflow parser doesn't handle them. https://blog.mrhaki.com/2022/06/groovy-goodness-using-switch-expression.html
m
Yeah, that's why I suggested to drop them over if statements
You can chain multiple a?bc?de
j
OK so something like this, from scrnaseq:
Copy code
saveAs: { filename ->
    if (filename.equals('versions.yml')) { null }
    else if (!filename.contains('combined_')) { "${meta.id}/${filename}" }
    else filename
}
100 rainbow 1