I would like to print the parameters of my nextflow script as a help menu (e.g., nextflow run main.nf --help
), similar to the way arparse does it in python (i.e., script --help
).
I have trawled the web and help docs and have found how to print a custom menu using the log.info
command inside the script, but this only shows the custom log stdout when actually running the script.
My workaround is to grep the script as follows: grep -E '^params.+ +\=' main.nf
.
This provides me with something similar to:
params.publishdir = '$TMPDIR'
params.min. = 3
It would be great if nextflow run main.nf --help
gave me a similar output (even better if '$TMPDIR'
was expanded), but --help
is basically feeding the run params.help
; and nextflow run main.nf -h
gives me the top level program help, neither of which, ahem, help. Is there a nextflow builtin to solve this?
There's no builtin for this, but if your params are only simple values something like the following might suffice:
nextflow.enable.dsl=2
params.publish_dir = System.getenv('TMPDIR') ?: './results'
params.publish_mode = 'copy'
check_params()
workflow {
// your awesome workflow here
}
def check_params() {
if( params.remove('help') ) {
params.each{ k, v -> println "params.${k.padRight(25)} = ${v}" }
exit 0
}
// additional validation here
}
$ nextflow run main.nf --help
N E X T F L O W ~ version 21.04.3
Launching `main.nf` [gigantic_plateau] - revision: c61c697636
params.publish_dir = /tmp
params.publish_mode = copy
Note that publishing results to a temporary directory usually doesn't make much sense.