I have the params variable declared in nextflow.config. I would like to determine which variables within params have been declared. The ‘in’ operator seems to work, but gives a warning when I use it to check if a nonexistant parameter exists in params. Example:
params = {
a = 1
b = 2
}
print(“c” in params)
WARN: Access to undefined parameter c – Initialise it to a default value eg. params.c = some_value
Is there a way to check that doesn’t produce this warning?
My version of your code doesn’t work at all, is it the contents of the Nextflow script or configuration?
Nextflow is fairly lenient about accessing parameters that aren’t defined, it will throw a warning and continue. You should be able to access the contents of params in all the ways that Groovy supports with maps:
params.a = "a"
params.b = "b"
workflow {
println params.a
println params.b
println params.c
println params?.c
println params?["c"]
println params.get("c")
if ( !params.c ) {
println "c is not defined!"
}
}