From 62187ada0588d3a8da0e30c90b98979b1876b5a2 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Thu, 5 Dec 2024 22:31:38 -0600 Subject: [PATCH] More logic --- modules/nf-core/trimgalore/main.nf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/nf-core/trimgalore/main.nf b/modules/nf-core/trimgalore/main.nf index 962dc096c105..7ef8c2ba494d 100644 --- a/modules/nf-core/trimgalore/main.nf +++ b/modules/nf-core/trimgalore/main.nf @@ -28,21 +28,21 @@ process TRIMGALORE { // Calculate number of --cores for TrimGalore based on value of task.cpus // See: https://github.com/FelixKrueger/TrimGalore/blob/master/Changelog.md#version-060-release-on-1-mar-2019 // See: https://github.com/nf-core/atacseq/pull/65 - // Each --cores N uses: N(read) + N(write) + N(Cutadapt) + 2(extra Cutadapt) + 1(TrimGalore) - // E.g., --cores 2 uses up to 9 cores, --cores 4 uses up to 15 cores + // Each --cores N requires: + // Single-end: 3 base cores + N cutadapt cores + // Paired-end: 4 base cores + N cutadapt cores def cores = 1 - // Calculate max cores that won't exceed available CPUs if (task.cpus) { - // Divide by ~4 since each core specified multiplies - cores = (task.cpus as int) / 4 - // Cap at 4 cores due to diminishing returns + // Calculate available cores for cutadapt after accounting for base usage + def available = (task.cpus as int) - (meta.single_end ? 3 : 4) + if (available > 0) { + cores = available + } + // Cap at 4 cores due to diminishing returns (confirmed by @FelixKrueger) + // NOTE: https://github.com/nf-core/atacseq/pull/65#issuecomment-558163045 if (cores > 4) { cores = 4 } - // Ensure at least 1 core - if (cores < 1) { - cores = 1 - } } // Added soft-links to original fastqs for consistent naming in MultiQC