#!/bin/bash -Ceuo pipefail mkdir -p Sig_18_Blood # Determine whether to split based on params.split_fastq and file size if [ "true" == "false" ]; then split_args="" else file_size=$(stat -f%z Sig_18_Blood_S4_L002_R1_001.fastq.gz 2>/dev/null || stat -c%s Sig_18_Blood_S4_L002_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 Sig_18_Blood_S4_L002_R1_001.fastq.gz \ --in2 Sig_18_Blood_S4_L002_R2_001.fastq.gz \ --out1 Sig_18_Blood/Sig_18_Blood_R1.fastq.gz \ --out2 Sig_18_Blood/Sig_18_Blood_R2.fastq.gz \ --detect_adapter_for_pe \ --length_required 15 \ --json Sig_18_Blood.fastp.json \ --html Sig_18_Blood.fastp.html \ --thread 4 \ $split_args \ 2> >(tee Sig_18_Blood.fastp.log >&2) # Remove empty files created by fastp edge case (when reads/chunk_size == threads) find Sig_18_Blood -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 Sig_18_Blood/)" ]; then echo "" | gzip > Sig_18_Blood/Sig_18_Blood_R1.fastq.gz echo "" | gzip > Sig_18_Blood/Sig_18_Blood_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