mahesh-panchal / nextflow-novice

This repository will soon be archived, to merge contribution with https://github.com/carpentries-incubator/workflows-nextflow
https://mahesh-panchal.github.io/nextflow-novice/
Other
1 stars 2 forks source link

Dev tip: Set java tmpdir and max memory for java tools. #2

Open mahesh-panchal opened 4 years ago

mahesh-panchal commented 4 years ago

Java programs should set tmp dir and max memory:

    script:
    sample_name = vcf.baseName
    mem = task.memory ? task.memory.toGiga() : task.cpus * 6
    // Also optionally check if ${task.scratch} is set, and use that, or staging dir.
    """
    snpEff -Djava.io.tmpdir=\$PWD -Xmx${mem}g \\
        ${params.snpeffDB_name} \\
        -csvStats ${sample_name}_snpEff.csv \\
        -dataDir \$PWD \\
        -canon \\
        -v \\
        ${vcf} \\
        > ${sample_name}_snpEff-ann.vcf
    mv snpEff_summary.html ${sample_name}_snpEff.summary.html
    """
mahesh-panchal commented 4 years ago

Qualimap needs setting in a different way:

process qualimap {

    input:
    path alignment // [ '<sample>.bam', '<sample.bam.csi>' ]

    output:
    path ("${bamfile.baseName}")

    script:
    bamfile = alignment.find { it =~ /\.bam$/ }
    mem = task.memory ? task.memory.toGiga() : task.cpus * 6
    """
    JAVA_OPTS="-Xms32m -Xmx${mem}G -Djava.io.tmpdir=${task.scratch}"
    qualimap bamqc -bam $bamfile -outdir ${bamfile.baseName} -outformat 'HTML' -nt ${task.cpus}
    """

}