Skip to content

Commit

Permalink
Pilon: allow adjustment of allocated memory (#6195)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tstoeriko authored Aug 17, 2024
1 parent ad07a82 commit 29d01cb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/nf-core/pilon/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29d01cb

Please sign in to comment.