/*
 * -------------------------------------------------
 *  nf-core/hic 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 {

  // TODO nf-core: Check the defaults for all processes
  cpus = { check_max( 1 * task.attempt, 'cpus' ) }
  memory = { check_max( 8.GB * task.attempt, 'memory' ) }
  time = { check_max( 2.h * task.attempt, 'time' ) }

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

  // Process-specific resource requirements
  withName:makeBowtie2Index {
     cpus = { check_max( 1, 'cpus' ) }
     memory = { check_max( 10.GB * task.attempt, 'memory' ) }
     time = { check_max( 12.h * task.attempt, 'time' ) }
  }
  withName:bowtie2_end_to_end {
    cpus = { check_max( 4, 'cpus' ) }
    memory = { check_max( 4.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:bowtie2_on_trimmed_reads {
    cpus = { check_max( 4, 'cpus' ) }
    memory = { check_max( 4.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:merge_mapping_steps {
    cpus = { check_max( 4, 'cpus' ) }
    memory = { check_max( 8.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:trim_reads {
    cpus = { check_max (1, 'cpus')}
    memory = { check_max( 1.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:combine_mapped_files {
    cpus = { check_max( 1, 'cpus' ) }
    memory = { check_max( 4.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:get_valid_interaction {
    cpus = { check_max( 1, 'cpus' ) }
    memory = { check_max( 4.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:build_contact_maps {
    cpus = { check_max( 1, 'cpus' ) }
    memory = { check_max( 6.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
  withName:run_ice {
    cpus = { check_max( 1, 'cpus' ) }
    memory = { check_max( 10.GB * task.attempt, 'memory' ) }
    time = { check_max( 5.h * task.attempt, 'time' ) }
  }
}

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