File Info

Filename
.command.sh
Full Path
s3://natera-rnd-pltf-dev-nextflow-scratch-01/work/8b/9e2e0e13bc3a3f359fceda1201678b/.command.sh
Size
1.5 KB
Attempt
#!/bin/bash -Ceuo pipefail
mkdir -p HCC1395_tumor

# Determine whether to split based on params.split_fastq and file size
if [ "true" == "false" ]; then
    split_args=""
else
    file_size=$(stat -f%z HCC1395_tumor_S1_L008_R1_001.fastq.gz 2>/dev/null || stat -c%s HCC1395_tumor_S1_L008_R1_001.fastq.gz)
    if [ 8880000000 -gt 0 ] && [ $file_size -lt 8880000000 ]; then
        split_args=""
    else
        split_args="--split_by_lines 400000000"
    fi
fi

fastp \
    --in1 HCC1395_tumor_S1_L008_R1_001.fastq.gz \
    --in2 HCC1395_tumor_S1_L008_R2_001.fastq.gz \
    --out1 HCC1395_tumor/HCC1395_tumor_R1.fastq.gz \
    --out2 HCC1395_tumor/HCC1395_tumor_R2.fastq.gz \
    --detect_adapter_for_pe \
    --length_required 15 \
    --json HCC1395_tumor.fastp.json \
    --html HCC1395_tumor.fastp.html \
    --thread 4 \
    $split_args \
    2> >(tee HCC1395_tumor.fastp.log >&2)

# Remove empty files created by fastp edge case (when reads/chunk_size == threads)
find HCC1395_tumor -name "*.fastq.gz" -size 0 -delete

# Handle 0-read input: fastp exits 0 but creates no output files.
# Create empty gzip files so the output glob matches and downstream sees 0 reads.
if [ -z "$(ls -A HCC1395_tumor/)" ]; then
    echo "" | gzip > HCC1395_tumor/HCC1395_tumor_R1.fastq.gz
    echo "" | gzip > HCC1395_tumor/HCC1395_tumor_R2.fastq.gz
fi

fastp_version=$(fastp --version 2>&1 | sed 's/fastp //')

cat <<-END_VERSIONS > versions.yml
"DAQ:FASTP":
    fastp: $fastp_version
END_VERSIONS