Open jorgeamaya opened 2 weeks ago
workflow CutAdaptersWorkflow { input { File fastq_file }
# Task to check if the fastq file is empty
task CheckFileSize {
input {
File fastq_file
}
command <<<
if [[ $(zcat ${fastq_file} | wc -c) -eq 0 ]]; then
echo "EMPTY"
else
echo "NONEMPTY"
fi
>>>
output {
String file_status = read_string(stdout())
}
}
# Task to run cutadapt on non-empty fastq files
task RunCutadapt {
input {
File fastq_file
}
command {
# Run cutadapt (replace this with your cutadapt command)
cutadapt -o trimmed.fastq.gz ${fastq_file}
}
output {
File trimmed_fastq = "trimmed.fastq.gz"
}
}
# Define the workflow steps
call CheckFileSize { input: fastq_file = fastq_file }
# Conditional call to RunCutadapt only if the file is not empty
if (CheckFileSize.file_status == "NONEMPTY") {
call RunCutadapt { input: fastq_file = fastq_file }
}
}
cutadapters.wdl crashes if it encounters and empty fastq.gz file, crashing the whole pipeline. An exception must be added to deal with empty fastq files.
Example of an error message below: