hi all. long time nextflow user, first time nf-cor...
# nostupidquestions
u
hi all. long time nextflow user, first time nf-core poster here. i was interested in separating all the containers from my processes and placing them in a config so it's easier to keep track of them centrally rather than editing each process directly. i also typically perform parameter sweeps (sometimes parameters, sometimes different software versions depending on use case in benchmarking) so got into the habit of providing a map (ConfigMap) containing arguments/versions as an input for the relevant processes. i was interested in using the following code in the container config that dynamically selects a container version using that input info. is this safe or am i overlooking something? can configs find ConfigMeta specific for a particular input or is it accessing a global variable with potential for mistakes? would it be safer to provide ConfigMeta.VERSION as task.ext.version instead or doesn't it matter? both seems to work but i'd appreciate a second opinion/sanity check. example of the config
Copy code
process {
    withName: '.*:SUBWORKFLOW:SOFTWARE:.*' {

        container = {
            if (ConfigMeta.VERSION.equals('1.1')){
                "####CONTAINER-v1.1####"
                }
            else if (ConfigMeta.VERSION.equals('1.2')){
                "####CONTAINER-v1.2####"
               }
            }

        }
}
example of the process
Copy code
input:

        tuple   val  (SampleMeta),
                    val (ConfigMeta,
                    path (INPUT)
e
Hi! I would branch the input channel based on the sample meta column you want, and call different processes for each container. e.g. SOFTWARE_CONTAINER1 and SOFTWARE_CONTAINER2
Then depending on what you want to do downstream, I would mix back into a single channel or not
I know this would duplicate the module, and there might be a conditional that lets you choose container inside the module (before inputs) but I've never seen it / done it
u
yeah i think i see what you mean. ideally i'd like to maintain fewer modules/processes. the dynamic container picker snippet that i put in my config was previously in my process under the container directive. i'm just not sure what nextflow is actually doing inside the process and the config or if it differs. i know task directives (e.g. task.cpus) have previously been used in dynamic config snippets but i was curious about the custom inputs. chatgpt tells me not to do what i've done but chatgpt lies
e
If it works, then keep doing it..it looks good to me!
u
ha yeah but i've fallen foul of "if it looks like it works before". i think maybe defining task.ext.version within process and using that in config is safer but input from anyone who knows more is welcome!