From 29d01cb1de875d85c5df4a3d2d9984135cbac8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theresa=20St=C3=B6riko?= <73145457+tstoeriko@users.noreply.github.com> Date: Sat, 17 Aug 2024 14:24:15 +0200 Subject: [PATCH] Pilon: allow adjustment of allocated memory (#6195) * Allow adjusting the allocated memory Changes: - call pilon via JVM/jar file to allow non-default memory requirements - remove deprecated --threads option * Improve JVM heap size setting The changes in this commit ensure that the JVM heap size is always smaller than the allocate memory: - if < 2GB allocated memory, make heap size 80% of allocated memory - else make heap size 1GB smaller than allocated memory * Change default heap size to 1GB * Update default value in log message --- modules/nf-core/pilon/main.nf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/nf-core/pilon/main.nf b/modules/nf-core/pilon/main.nf index 8e476db8e8c..4003b4d7e80 100644 --- a/modules/nf-core/pilon/main.nf +++ b/modules/nf-core/pilon/main.nf @@ -28,11 +28,19 @@ process PILON { def prefix = task.ext.prefix ?: "${meta.id}" def valid_mode = ["frags", "jumps", "unpaired", "bam"] if ( !valid_mode.contains(pilon_mode) ) { error "Unrecognised mode to run Pilon. Options: ${valid_mode.join(', ')}" } + def mem_mb = 1024 + if (!task.memory) { + log.info '[Pilon] Available memory not known - defaulting to 1GB. Specify process memory requirements to change this.' + } else { + mem_mb = task.memory.giga < 2 ? (task.memory.mega*0.8).intValue() : task.memory.mega - 1024 + } """ - pilon \\ + # `which` allows us to get the directory that contains `pilon`, independent of whether we + # are in a container or conda environment. + PILON_JAR=\$(dirname \$(which pilon))/../share/pilon*/pilon.jar + java -Xmx${mem_mb}M -jar \$PILON_JAR \\ --genome $fasta \\ --output ${meta.id} \\ - --threads $task.cpus \\ $args \\ --$pilon_mode $bam