Why won't my workflow work when I use the syntax labels? (take and main) #5334
-
Hey there! I'm not sure what I'm doing wrong. I'm reading the documentation on DSL2 Workflows and so far I have an implicit worflow that works, but only if I don't define the input channels with This workflow works fine:
I want to eventually make this a subworkflow, so I created channels for those parameters I was using
Trying to run this results on the error: What am I doing wrong? I tried naming that workflow and then adding another implicit wokflow calling that one as This at least begins to run, however, it fails on the second step - Seemingly because the Which seems wrong to me - nowhere in the documentation did I find anything mentioning this syntax is only valid for named workflows, and the examples of subworkflow invocations in the documentation don't really have process outputs being explicitly called again, or even being in the Any help understanding this syntax better will be greatly appreciated!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @julia-luz , it's an understandable mistake as some of these rules are not clearly documented. I will make a note to expand the workflow docs on this point The entry workflow can't have You could construct the input channels in the entry workflow: workflow {
reads_ch = Channel.fromPath(params.reads_tsv, checkIfExists: true )
.splitCsv( header: true, sep: '\t' )
.map { row -> tuple( row.sample_name, file(row.fq1, checkIfExists: true) ) }
NAMED(reads_ch)
}
workflow NAMED {
take:
reads_ch
main:
first_step(reads_ch)
// ...
} Or you could pass only the params and construct the channels in the named workflow: workflow {
NAMED(params.reads_tsv)
}
workflow NAMED {
take:
reads_tsv
main:
reads_ch = Channel.fromPath(reads_tsv, checkIfExists: true )
.splitCsv( header: true, sep: '\t' )
.map { row -> tuple( row.sample_name, file(row.fq1, checkIfExists: true) ) }
first_step(reads_ch)
// ...
} So it's a matter of what you consider to be "in scope' for your named workflow. The second option would allow you to re-use the subworkflow with any input channel, not necessarily one from a csv file, which is why I tend to take the second approach. But it's up to you. Hope that clears things up for you. |
Beta Was this translation helpful? Give feedback.
Hi @julia-luz , it's an understandable mistake as some of these rules are not clearly documented. I will make a note to expand the workflow docs on this point
The entry workflow can't have
take:
oremit:
because you can't call it. Meanwhile, thetake:
inputs can be channels or even just regular values, so you have some flexibility in how you define the interface for your named workflow.You could construct the input channels in the entry workflow: