I am new to Nextflow and I want to unzip a fastq.gz file. But It raised the error gunzip: SRR1659960_05pc_R1.fastq.gz is not a regular file
.
I tried to run the same command directly in my console, it works well.
My Nextflow script is:
process gz_uncompress{
input:
path fastq_r1_gz_path
output:
path fastq_r1_path
script:
"""
gunzip -kd $fastq_r1_gz_path > "fastq_r1_path.fastq"
"""
}
workflow{
gz_uncompress("/Users/test/PycharmProjects/nf-easyfuse/local_test/SRR1659960_05pc_R1.fastq.gz")
}
The error message is:
local_test ywan$ nextflow run t2.nf
N E X T F L O W ~ version 22.10.3
Launching `t2.nf` [peaceful_wilson] DSL2 - revision: bf9e3bc592
executor > local (1)
[36/f8301b] process > gz_uncompress [ 0%] 0 of 1
Error executing process > 'gz_uncompress'
Caused by:
Process `gz_uncompress` terminated with an error exit status (1)
Command executed:
gunzip -kd SRR1659960_05pc_R1.fastq.gz > "fastq_r1_path.fastq"
Command exit status:
1
executor > local (1)
[36/f8301b] process > gz_uncompress [100%] 1 of 1, failed: 1 ✘
Error executing process > 'gz_uncompress'
Caused by:
Process `gz_uncompress` terminated with an error exit status (1)
Command executed:
gunzip -kd SRR1659960_05pc_R1.fastq.gz > "fastq_r1_path.fastq"
Command exit status:
1
Command output:
(empty)
Command error:
gunzip: SRR1659960_05pc_R1.fastq.gz is not a regular file
Work dir:
/Users/test/PycharmProjects/nf-easyfuse/local_test/work/36/f8301b816e9eb834597ff1e6616c51
Tip: view the complete command output by changing to the process work dir and entering the command `cat .command.out`
But when I ran gunzip -kd SRR1659960_05pc_R1.fastq.gz > "fastq_r1_path.fastq"
in my console, there isn't any errors.
Could you please help me to figure out?
By default, Nextflow will try to stage process input files using symbolic links (this can be changed using the StageInMode
directive). With gunzip
, just make sure you write the output to stdout, using -c
:
-c --stdout --to-stdout
Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.
For example:
params.fastq = './test.fastq.gz'
process gunzip_fastq {
input:
path fastq_gz
output:
path fastq_gz.baseName
script:
"""
gunzip -c "${fastq_gz}" > "${fastq_gz.baseName}"
"""
}
workflow{
fastq = file( params.fastq )
gunzip_fastq( fastq )
}
On most systems, you could also just use zcat
for this. The zcat
command is identical to gunzip -c
.