|
| 1 | +params { |
| 2 | + max_memory = '800.GB' |
| 3 | + max_cpus = 16 |
| 4 | + max_time = '360.h' |
| 5 | +} |
| 6 | + |
| 7 | +def check_max(obj, type) { |
| 8 | + if (type == 'memory') { |
| 9 | + try { |
| 10 | + if (obj.compareTo(params.max_memory as nextflow.util.MemoryUnit) == 1) |
| 11 | + return params.max_memory as nextflow.util.MemoryUnit |
| 12 | + else |
| 13 | + return obj |
| 14 | + } catch (all) { |
| 15 | + println " ### ERROR ### Max memory '${params.max_memory}' is not valid! Using default value: $obj" |
| 16 | + return obj |
| 17 | + } |
| 18 | + } else if (type == 'time') { |
| 19 | + try { |
| 20 | + if (obj.compareTo(params.max_time as nextflow.util.Duration) == 1) |
| 21 | + return params.max_time as nextflow.util.Duration |
| 22 | + else |
| 23 | + return obj |
| 24 | + } catch (all) { |
| 25 | + println " ### ERROR ### Max time '${params.max_time}' is not valid! Using default value: $obj" |
| 26 | + return obj |
| 27 | + } |
| 28 | + } else if (type == 'cpus') { |
| 29 | + try { |
| 30 | + return Math.min( obj, params.max_cpus as int ) |
| 31 | + } catch (all) { |
| 32 | + println " ### ERROR ### Max cpus '${params.max_cpus}' is not valid! Using default value: $obj" |
| 33 | + return obj |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +process { |
| 39 | + cpus = { check_max( 1 * task.attempt, 'cpus' ) } |
| 40 | + memory = { check_max( 10.GB * task.attempt, 'memory' ) } |
| 41 | + time = { check_max( 1.h * task.attempt, 'time' ) } |
| 42 | + shell = ['/bin/bash', '-euo', 'pipefail'] |
| 43 | + |
| 44 | + // memory errors which should be retried. otherwise error out |
| 45 | + errorStrategy = { task.exitStatus in ((130..145) + 104 + 9) ? 'retry' : 'finish' } |
| 46 | + maxRetries = 6 |
| 47 | + maxErrors = '-1' |
| 48 | + |
| 49 | + // Process-specific resource requirements |
| 50 | + |
| 51 | + withLabel:process_single { |
| 52 | + cpus = { check_max( 1 , 'cpus' ) } |
| 53 | + memory = { check_max( 6.GB * task.attempt, 'memory' ) } |
| 54 | + time = { check_max( 4.h * task.attempt, 'time' ) } |
| 55 | + } |
| 56 | + withLabel:process_low { |
| 57 | + cpus = { check_max( 2 * task.attempt, 'cpus' ) } |
| 58 | + memory = { check_max( 12.GB * task.attempt, 'memory' ) } |
| 59 | + time = { check_max( 4.h * task.attempt, 'time' ) } |
| 60 | + } |
| 61 | + withLabel:process_medium { |
| 62 | + cpus = { check_max( 6 * task.attempt, 'cpus' ) } |
| 63 | + memory = { check_max( 36.GB * task.attempt, 'memory' ) } |
| 64 | + time = { check_max( 8.h * task.attempt, 'time' ) } |
| 65 | + } |
| 66 | + withLabel:process_high { |
| 67 | + cpus = { check_max( 12 * task.attempt, 'cpus' ) } |
| 68 | + memory = { check_max( 72.GB * task.attempt, 'memory' ) } |
| 69 | + time = { check_max( 16.h * task.attempt, 'time' ) } |
| 70 | + } |
| 71 | + withLabel:process_long { |
| 72 | + time = { check_max( 20.h * task.attempt, 'time' ) } |
| 73 | + } |
| 74 | + withLabel:process_high_memory { |
| 75 | + memory = { check_max( 200.GB * task.attempt, 'memory' ) } |
| 76 | + } |
| 77 | + withLabel:error_ignore { |
| 78 | + errorStrategy = 'ignore' |
| 79 | + } |
| 80 | + withLabel:error_retry { |
| 81 | + errorStrategy = 'retry' |
| 82 | + maxRetries = 2 |
| 83 | + } |
| 84 | + |
| 85 | + withName: 'GATK4_HAPLOTYPECALLER' { |
| 86 | + memory = { check_max( 50.GB * task.attempt, 'memory' ) } |
| 87 | + } |
| 88 | + withName: 'BWAMEM2_INDEX' { |
| 89 | + time = { check_max( 2.h * task.attempt, 'time' ) } |
| 90 | + memory = { check_max( 90.GB * task.attempt, 'memory' ) } |
| 91 | + } |
| 92 | + withName: 'SAMTOOLS_MPILEUP' { |
| 93 | + time = { check_max( 100.h * task.attempt, 'time' ) } |
| 94 | + } |
| 95 | + withName: 'FREEC_GERMLINE' { |
| 96 | + time = { check_max( 2.h * task.attempt, 'time' ) } |
| 97 | + memory = { check_max( 80.GB * task.attempt, 'memory' ) } |
| 98 | + cpus = { check_max( 6 * task.attempt, 'cpus' ) } |
| 99 | + } |
| 100 | + withName: 'GRIDSS' { |
| 101 | + time = { check_max( 16.h * task.attempt, 'time' ) } |
| 102 | + memory = { check_max( 200.GB * task.attempt, 'memory' ) } |
| 103 | + cpus = { check_max( 8 * task.attempt, 'cpus' ) } |
| 104 | + } |
| 105 | + withName: 'GATK4_MUTECT2' { |
| 106 | + cpus = { check_max( 6 * task.attempt, 'cpus' ) } |
| 107 | + memory = { check_max( 36.GB * task.attempt, 'memory' ) } |
| 108 | + time = { check_max( 8.h * task.attempt, 'time' ) } |
| 109 | + clusterOptions = "--gres=tmpspace:100G" |
| 110 | + } |
| 111 | + withName: 'GATK4_LEARNREADORIENTATIONMODEL' { |
| 112 | + time = { check_max( 2.h * task.attempt, 'time' ) } |
| 113 | + memory = { check_max( 20.GB * task.attempt, 'memory' ) } |
| 114 | + cpus = { check_max( 8 * task.attempt, 'cpus' ) } |
| 115 | + clusterOptions = "--gres=tmpspace:100G" |
| 116 | + } |
| 117 | + withName: 'BCFTOOLS_SMURF_SORT' { |
| 118 | + cpus = { check_max( 6 * task.attempt, 'cpus' ) } |
| 119 | + memory = { check_max( 36.GB * task.attempt, 'memory' ) } |
| 120 | + time = { check_max( 8.h * task.attempt, 'time' ) } |
| 121 | + clusterOptions = "--gres=tmpspace:100G" |
| 122 | + } |
| 123 | + withName: 'BCFTOOLS_SMURF_FILTERED_SORT' { |
| 124 | + cpus = { check_max( 6 * task.attempt, 'cpus' ) } |
| 125 | + memory = { check_max( 36.GB * task.attempt, 'memory' ) } |
| 126 | + time = { check_max( 8.h * task.attempt, 'time' ) } |
| 127 | + clusterOptions = "--gres=tmpspace:100G" |
| 128 | + } |
| 129 | + withName: 'REALIGNREADS' { |
| 130 | + cpus = { check_max( 2 * task.attempt, 'cpus' ) } |
| 131 | + memory = { check_max( 12.GB * task.attempt, 'memory' ) } |
| 132 | + time = { check_max( 4.h * task.attempt, 'time' ) } |
| 133 | + clusterOptions = "--gres=tmpspace:100G" |
| 134 | + } |
| 135 | + |
| 136 | +} |
| 137 | + |
0 commit comments