/*
 * -------------------------------------------------
 *  nf-core/neutronstar Nextflow base config file
 * -------------------------------------------------
 * A 'blank slate' config file, appropriate for general
 * use on most high performace compute environments.
 * Assumes that all software is installed and available
 * on the PATH. Runs in `local` mode - all jobs will be
 * run on the logged in environment.
 */

process {

    cpus = { check_max( 16 * task.attempt, 'cpus' ) }
    memory = { check_max( 256.GB * task.attempt, 'memory' ) }
    time = { check_max( 120.h * task.attempt, 'time' ) }

    errorStrategy = { task.exitStatus in [1,143,137,104,134,139] ? 'retry' : 'finish' }
    maxRetries = 3
    maxErrors = '-1'

    withLabel: 'supernova' {
        container = params.supernova_container
    }

    withName: get_software_versions {
        time = { check_max( 30.m * task.attempt, 'time') }
        cpus = { check_max( 2 * task.attempt, 'cpus') }
        memory = { check_max( 30.GB * task.attempt, 'memory') }
    }
    withName: supernova {
        //Check the configuration of your system where your scratch partition is located.
        //Rule of thumb: For each assembly, have at least 10 times free space as the input data.
        scratch = '$TMP'
    }
    withName: supernova_mkoutput {
        time = { check_max( 1.h * task.attempt, 'time') }
        cpus = { check_max( 2 * task.attempt, 'cpus') }
        memory = { check_max( 30.GB * task.attempt, 'memory') }
    }
    withName: quast {
        time = { check_max( 3.h * task.attempt, 'time') }
        cpus = { check_max( 4 * task.attempt, 'cpus') }
        memory = { check_max( 60.GB * task.attempt, 'memory') }
    }
    withName: busco {
        time = { check_max( 1.d * task.attempt, 'time') }
        cpus = { check_max( 8 * task.attempt, 'cpus') }
        memory = { check_max( 120.GB * task.attempt, 'memory') }
        maxRetries = 1
    }
    withName: multiqc {
        time = { check_max( 3.h * task.attempt, 'time') }
        cpus = { check_max( 2 * task.attempt, 'cpus') }
        memory = { check_max( 30.GB * task.attempt, 'memory') }
    }
}

params {
  // Defaults only, expecting to be overwritten
  max_memory = 256.GB
  max_cpus = 16
  max_time = 240.h
}
