Skip to content

Commit

Permalink
rewrite so it works
Browse files Browse the repository at this point in the history
  • Loading branch information
sage-wright committed Nov 19, 2024
1 parent ad0b3d9 commit 0713cdd
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions tasks/utilities/file_handling/task_cat_lanes.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,23 @@ task cat_lanes {
command <<<
# exit task if anything throws an error (important for proper gzip format)
set -euo pipefail

exists() { [[ -f $1 ]]; }

# move reads into single directory
mkdir -v reads
mv -v ~{read1_lane1} \
~{read2_lane1} \
~{read1_lane2} \
~{read2_lane2} \
~{read1_lane3} \
~{read2_lane3} \
~{read1_lane4} \
~{read2_lane4} \
reads/
set -euo pipefail

# check for valid gzipped format (this task assumes FASTQ files are gzipped - they should be coming from ILMN instruments)
gzip -t reads/*.gz
cat ~{read1_lane1} ~{read1_lane2} ~{read1_lane3} ~{read1_lane4} > "~{samplename}_merged_R1.fastq.gz"

# run concatenate script and send STDOUT/ERR to STDOUT
# reminder: script will skip over samples that only have R1 file present
# reminder: script REQUIRES standard illumina file endings like: _L001_R1_001.fastq.gz and _L002_R2_001.fastq.gz
# see script here: https://github.com/theiagen/utilities/blob/main/scripts/concatenate-across-lanes.sh
concatenate-across-lanes.sh reads/
if exists ~{read2_lane1} ; then
cat ~{read2_lane1} ~{read2_lane2} ~{read2_lane3} ~{read2_lane4} > "~{samplename}_merged_R2.fastq.gz"
fi

# ensure newly merged FASTQs are valid gzipped format
gzip -t reads/*merged*.gz

# determine output filenames for outputs
mv -v reads/*_merged_R1.fastq.gz reads/~{samplename}_merged_R1.fastq.gz
mv -v reads/*_merged_R2.fastq.gz reads/~{samplename}_merged_R2.fastq.gz
gzip -t *merged*.gz
>>>
output {
File read1_concatenated = "reads/~{samplename}_merged_R1.fastq.gz"
File? read2_concatenated = "reads/~{samplename}_merged_R2.fastq.gz"
File read1_concatenated = "~{samplename}_merged_R1.fastq.gz"
File? read2_concatenated = "~{samplename}_merged_R2.fastq.gz"
}
runtime {
docker: "~{docker}"
Expand Down

0 comments on commit 0713cdd

Please sign in to comment.