Skip to content

Commit

Permalink
add gzip checks in gather step
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetit3 committed Aug 26, 2023
1 parent a64b215 commit 2da04df
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 46 deletions.
44 changes: 40 additions & 4 deletions modules/local/bactopia/gather/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,52 @@ process GATHER {
rm -f ${prefix}-paired-end-error.txt
fi
if ! check-fastqs.py --fq1 r1.json --fq2 r2.json \${OPTS}; then
ERROR=1
if [[ -s r1.json ]] && [[ -s r2.json ]]; then
if ! check-fastqs.py --fq1 r1.json --fq2 r2.json \${OPTS}; then
ERROR=1
fi
else
NOT_GZIP=0
if ! gzip -t fastqs/${prefix}_R1.fastq.gz; then
NOT_GZIP=1
elif ! gzip -t fastqs/${prefix}_R2.fastq.gz; then
NOT_GZIP=1
fi
if [ "\${NOT_GZIP}" -eq "0" ]; then
echo "${prefix} FASTQs are empty. Please check the input FASTQs.
Further analysis is discontinued." | \\
sed 's/^\\s*//' > ${prefix}-empty-error.txt
ERROR=1
else
echo "${prefix} FASTQs failed Gzip tests. Please check the input FASTQs.
Further analysis is discontinued." | \\
sed 's/^\\s*//' > ${prefix}-gzip-error.txt
ERROR=1
fi
fi
rm r1.json r2.json
else
# Single-end
IS_PAIRED="false"
gzip -cd fastqs/${prefix}.fastq.gz | fastq-scan > r1.json
if ! check-fastqs.py --fq1 r1.json \${OPTS}; then
ERROR=1
if [[ -s r1.json ]]; then
if ! check-fastqs.py --fq1 r1.json \${OPTS}; then
ERROR=1
fi
else
if ! gzip -t fastqs/${prefix}.fastq.gz; then
echo "${prefix} FASTQs failed Gzip tests. Please check the input FASTQs.
Further analysis is discontinued." | \\
sed 's/^\\s*//' > ${prefix}-gzip-error.txt
ERROR=1
elif ! gzip -t fastqs/${prefix}_R2.fastq.gz; then
echo "${prefix} FASTQs are empty. Please check the input FASTQs.
Further analysis is discontinued." | \\
sed 's/^\\s*//' > ${prefix}-empty-error.txt
ERROR=1
fi
fi
rm r1.json
fi
Expand Down
24 changes: 24 additions & 0 deletions subworkflows/local/gather/test.nf
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,27 @@ workflow test_gather_error_low_depth_se {

GATHER ( inputs )
}

workflow test_gather_empty_pe {

inputs = tuple(
[id:'output', runtype:'paired-end', genome_size:params.genome_size],
[file(params.test_data['empty']['fastq'], checkIfExists: true)],
[file(params.test_data['empty']['fastq'], checkIfExists: true)],
file(params.test_data['empty']['fna'], checkIfExists: true)
)

GATHER ( inputs )
}

workflow test_gather_empty_se {

inputs = tuple(
[id:'output', runtype:'single-end', genome_size:params.genome_size],
[file(params.test_data['empty']['fastq'], checkIfExists: true)],
[file(params.test_data['empty']['fastq'], checkIfExists: true)],
file(params.test_data['empty']['fna'], checkIfExists: true)
)

GATHER ( inputs )
}
Loading

0 comments on commit 2da04df

Please sign in to comment.