Hi,
I am very new to nextflow
(I used to work with snakemake
in the past). I am trying to create a dummy workflow for understanding the basics of the _pipeline creation_ and the first step at designing my own.
For this I want to unzip my fastq files and create 2 dummy repports from the read length of the R2 read.
I have 2 scripts for now, main_qc.nf
(including the workflow) and modules_qc.nf
(with all processes) shown below:
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// Include in workflow
include {
GUNZIP_FASTQ;
GET_READ_LENGTH
} from "./modules_qc.nf"
// Initial parameters
datadir="/data"
bashdir="/shs"
params.sample = "s1"
params.fastq = "$datadir/fastqs/${params.sample}_2.fastq.gz"
workflow {
// Create
Channel
.fromFile(params.fastq)
.set { chFastqFile }
Channel
.of(params.sample)
.set { samples }
GUNZIP_FASTQ(chFastqFile)
GET_READ_LENGTH(samples, GUNZIP_FASTQ.out)
}
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// Unzipping files
process GUNZIP_FASTQ {
input:
path target
output:
path "${target.simpleName}.fastq"
script:
"""
gunzip -d -c ${target} > ${target.simpleName}.fastq
"""
}
// Export read length to file
process GET_READ_LENGTH {
input:
val sample_id
path fastq
output:
path "${sample_id}.readLength.txt"
script:
"""
bash ./shs/readLength.sh ${fastq} ${sample_id}.readLength.txt
"""
}
I want to first run the GUNZIP
process on all fastqs for all sample and then create one dummy repports per sample.
GUNZIP
processes have to run twice ad much as the other processes.
How should I proced?
Thank you very much
Your channel that goes in the GUNZIP_FASTQ is actually a queue channel, GUNZIP_FASTQ will be executed as long as you have item in said channel: https://www.nextflow.io/docs/latest/channel.html#channels
Your channel
chFastqFile
receives only one file :$datadir/fastqs/${params.sample}_2.fastq.gz
. You may want to include a glob*
operator, usefromPath
(afaicrfromFile
is deprecated) or adopt Pierre's full revamp.Thank you very much for all your insight. With all of this I was able to create what I hoped for!