process fastqc { tag "$sample_id" publishDir "${params.outdir}/trim_galore", mode: 'copy', saveAs: {filename -> if (filename.indexOf("_fastqc") > 0) "FastQC/$filename" else if (filename.indexOf("trimming_report.txt") > 0) "logs/$filename" else filename } container 'quay.io/biocontainers/trim-galore:0.6.5--0' input: tuple sample_id, path(reads) output: tuple name, path("*fq.gz") path "*trimming_report.txt" path "*_fastqc.{zip,html}" script: c_r1 = clip_r1 > 0 ? "--clip_r1 ${clip_r1}" : '' c_r2 = clip_r2 > 0 ? "--clip_r2 ${clip_r2}" : '' tpc_r1 = three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${three_prime_clip_r1}" : '' tpc_r2 = three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${three_prime_clip_r2}" : '' nextseq = params.trim_nextseq > 0 ? "--nextseq ${params.trim_nextseq}" : '' if (params.singleEnd) { """ trim_galore --fastqc --gzip $c_r1 $tpc_r1 $nextseq $reads """ } else { """ trim_galore --paired --fastqc --gzip $c_r1 $c_r2 $tpc_r1 $tpc_r2 $nextseq $reads """ } }