DSL2 : use of the same channel multiple times in process

1,127 views
Skip to first unread message

Sylvain Brohee

unread,
Mar 19, 2021, 6:19:12 AM3/19/21
to nextflow, bioinfo

Dear list,

I have a trivial question. Hopefully, it has not been answered already.

In the process trimFastq hereafter, the channel scriptPath is emitted only once while the other the tuple should be emitted several times but it stopped at the first iteration of the process.

From the nextflow documentation, I understood that this can be solved by using value channel but with path channel, I don't know how to make the process run as many times as I have tuples emmitted.

I thank you a lot for your kind help,

Sylvain


Channel
               .fromPath(params.fastqDir + '/' +"*.fastq.gz")
               .map(path ->
                                            tuple(
                                                           (path.getBaseName() =~ /(.+)_S\d+_L00[1-4]_R[1-2]_001/)[0][1]
                                                           ,path
                                                           ,(path.getBaseName() =~ /.+_S\d+_(L00[1-4])_R[1-2]_001/)[0][1]
                                                           ,(path.getBaseName() =~ /.+_S\d+_L00[1-4]_(R[1-2])_001/)[0][1]
                                                           )
                              )
               .set{fastq_ch}


Channel.fromPath(params.scriptPath).set{scriptpath_ch}

// WORKFLOW

workflow {
               // for seqFF
               trimFastq(fastq_ch.dump(),scriptpath_ch)
}

process trimFastq {
               label 'env_pysam'
               label 'cpusmem_std'
               input:
                              tuple val(sampleName),path(inputFastq),val(lane),val(orientation)
                              path scriptPath
               output:
                              tuple val(sampleName),path("${sampleName}_${lane}_${orientation}_trim${params.trimLength}.fastq.gz"),val(lane),val(orientation)
               script:
                              """
                              python ${scriptPath}/shallow_cnv/trimFastqToLenght.py -z -l ${params.trimLength} \
                              -i ${inputFastq} -o ${sampleName}_${lane}_${orientation}_trim${params.trimLength}.fastq.gz
                              """
}

sylvain...@gmail.com

unread,
Mar 19, 2021, 6:34:45 AM3/19/21
to Nextflow
I found the solution in the doc by re-reading carefully.


Channel.value(genomeFasta)
Reply all
Reply to author
Forward
0 new messages