/*
 * -------------------------------------------------
 *  nf-core/rnafusion 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.
 */

params {
  // Defaults only, expecting to be overwritten
  max_memory = 128.GB
  max_cpus = 16
  max_time = 240.h
  igenomes_base = 's3://ngi-igenomes/igenomes/'
}

process {

  container = params.container

  cpus = { check_max( 1, 'cpus' ) }
  memory = { check_max( 8.GB * task.attempt, 'memory' ) }
  time = { check_max( 2.h * task.attempt, 'time' ) }

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

  // Process-specific resource requirements
  withName: fastqc {
    errorStrategy = { task.exitStatus in [143,137] ? 'retry' : 'ignore' }
  }
  withName: multiqc {
    errorStrategy = { task.exitStatus in [143,137] ? 'retry' : 'ignore' }
  }
  withName:build_star_index {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 4.h * task.attempt, 'time' ) }
  }
  withName:star_fusion {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 4.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:star-fusion_v${params.container_version}"
  }
  withName:fusioncatcher {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 12.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:fusioncatcher_v${params.container_version}"
  }
  withName:fusion_inspector {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 12.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:fusion-inspector_v${params.container_version}"
  }
  withName:ericscript {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 12.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:ericscript_v${params.container_version}"
  }
  withName:pizzly {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 4.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:pizzly_v${params.container_version}"
  }
  withName:squid {
    cpus = { check_max (24, 'cpus')}
    memory = { check_max( 60.GB * task.attempt, 'memory' ) }
    time = { check_max( 4.h * task.attempt, 'time' ) }
    container = "nfcore/rnafusion:squid_v${params.container_version}"
  }
  withName:summary {
    container = "nfcore/rnafusion:summary-report_v${params.container_version}"
  }
}
