kkonganti@17
|
1 process {
|
kkonganti@17
|
2 publishDir = [
|
kkonganti@17
|
3 path: {
|
kkonganti@17
|
4 "${task.process.tokenize(':')[-1].toLowerCase()}" == "multiqc" ?
|
kkonganti@17
|
5 "${params.output}${params.fs}${params.pipeline.toLowerCase()}-${task.process.tokenize(':')[-1].toLowerCase()}" :
|
kkonganti@17
|
6 "${params.output}${params.fs}${task.process.tokenize(':')[-1].toLowerCase()}"
|
kkonganti@17
|
7 },
|
kkonganti@17
|
8 mode: params.publish_dir_mode,
|
kkonganti@17
|
9 overwrite: params.publish_dir_overwrite,
|
kkonganti@17
|
10 saveAs: { filename -> filename =~ /^versions\.yml|genome_paths\.txt|[bettercallsalbcs].+?_mqc.*/ ? null : filename }
|
kkonganti@17
|
11 ]
|
kkonganti@17
|
12
|
kkonganti@17
|
13 errorStrategy = {
|
kkonganti@17
|
14 ![0].contains(task.exitStatus) ? dynamic_retry(task.attempt, 10) : 'finish'
|
kkonganti@17
|
15 }
|
kkonganti@17
|
16
|
kkonganti@17
|
17 maxRetries = 0
|
kkonganti@17
|
18 resourceLabels = {[
|
kkonganti@17
|
19 process: task.process,
|
kkonganti@17
|
20 memoryRequested: task.memory.toString(),
|
kkonganti@17
|
21 cpusRequested: task.cpus.toString()
|
kkonganti@17
|
22 ]}
|
kkonganti@17
|
23
|
kkonganti@17
|
24 withLabel: 'process_femto' {
|
kkonganti@17
|
25 cpus = { 1 * task.attempt }
|
kkonganti@17
|
26 memory = { 1.GB * task.attempt }
|
kkonganti@17
|
27 time = { 1.h * task.attempt }
|
kkonganti@17
|
28 }
|
kkonganti@17
|
29
|
kkonganti@17
|
30 withLabel: 'process_pico' {
|
kkonganti@17
|
31 cpus = { min_cpus(2) * task.attempt }
|
kkonganti@17
|
32 memory = { 4.GB * task.attempt }
|
kkonganti@17
|
33 time = { 2.h * task.attempt }
|
kkonganti@17
|
34 }
|
kkonganti@17
|
35
|
kkonganti@17
|
36 withLabel: 'process_nano' {
|
kkonganti@17
|
37 cpus = { min_cpus(4) * task.attempt }
|
kkonganti@17
|
38 memory = { 8.GB * task.attempt }
|
kkonganti@17
|
39 time = { 4.h * task.attempt }
|
kkonganti@17
|
40 }
|
kkonganti@17
|
41
|
kkonganti@17
|
42 withLabel: 'process_micro' {
|
kkonganti@17
|
43 cpus = { min_cpus(8) * task.attempt }
|
kkonganti@17
|
44 memory = { 16.GB * task.attempt }
|
kkonganti@17
|
45 time = { 8.h * task.attempt }
|
kkonganti@17
|
46 }
|
kkonganti@17
|
47
|
kkonganti@17
|
48 withLabel: 'process_only_mem_low' {
|
kkonganti@17
|
49 cpus = { 1 * task.attempt }
|
kkonganti@17
|
50 memory = { 60.GB * task.attempt }
|
kkonganti@17
|
51 time = { 20.h * task.attempt }
|
kkonganti@17
|
52 }
|
kkonganti@17
|
53
|
kkonganti@17
|
54 withLabel: 'process_only_mem_medium' {
|
kkonganti@17
|
55 cpus = { 1 * task.attempt }
|
kkonganti@17
|
56 memory = { 100.GB * task.attempt }
|
kkonganti@17
|
57 time = { 30.h * task.attempt }
|
kkonganti@17
|
58 }
|
kkonganti@17
|
59
|
kkonganti@17
|
60 withLabel: 'process_only_mem_high' {
|
kkonganti@17
|
61 cpus = { 1 * task.attempt }
|
kkonganti@17
|
62 memory = { 120.GB * task.attempt }
|
kkonganti@17
|
63 time = { 60.h * task.attempt }
|
kkonganti@17
|
64 }
|
kkonganti@17
|
65
|
kkonganti@17
|
66 withLabel: 'process_low' {
|
kkonganti@17
|
67 cpus = { min_cpus(10) * task.attempt }
|
kkonganti@17
|
68 memory = { 60.GB * task.attempt }
|
kkonganti@17
|
69 time = { 20.h * task.attempt }
|
kkonganti@17
|
70 }
|
kkonganti@17
|
71
|
kkonganti@17
|
72 withLabel: 'process_medium' {
|
kkonganti@17
|
73 cpus = { min_cpus(10) * task.attempt }
|
kkonganti@17
|
74 memory = { 100.GB * task.attempt }
|
kkonganti@17
|
75 time = { 30.h * task.attempt }
|
kkonganti@17
|
76 }
|
kkonganti@17
|
77
|
kkonganti@17
|
78 withLabel: 'process_high' {
|
kkonganti@17
|
79 cpus = { min_cpus(10) * task.attempt }
|
kkonganti@17
|
80 memory = { 120.GB * task.attempt }
|
kkonganti@17
|
81 time = { 60.h * task.attempt }
|
kkonganti@17
|
82 }
|
kkonganti@17
|
83
|
kkonganti@17
|
84 withLabel: 'process_higher' {
|
kkonganti@17
|
85 cpus = { min_cpus(10) * task.attempt }
|
kkonganti@17
|
86 memory = { 225.GB * task.attempt }
|
kkonganti@17
|
87 time = { 60.h * task.attempt }
|
kkonganti@17
|
88 }
|
kkonganti@17
|
89
|
kkonganti@17
|
90 withLabel: 'process_gigantic' {
|
kkonganti@17
|
91 cpus = { min_cpus(10) * task.attempt }
|
kkonganti@17
|
92 memory = { 500.GB * task.attempt }
|
kkonganti@17
|
93 time = { 60.h * task.attempt }
|
kkonganti@17
|
94 }
|
kkonganti@17
|
95 }
|
kkonganti@17
|
96
|
kkonganti@17
|
97 if ( ( ( params.input || params.metadata ) && params.pipeline ) ||
|
kkonganti@17
|
98 ( params.pipeline.toString().equalsIgnoreCase('bettercallsal_db') && params.output) ) {
|
kkonganti@17
|
99 try {
|
kkonganti@17
|
100 includeConfig "${params.workflowsconf}${params.fs}process${params.fs}${params.pipeline}.process.config"
|
kkonganti@17
|
101 } catch (Exception e) {
|
kkonganti@17
|
102 System.err.println('-'.multiply(params.linewidth) + "\n" +
|
kkonganti@17
|
103 "\033[0;31m${params.cfsanpipename} - ERROR\033[0m\n" +
|
kkonganti@17
|
104 '-'.multiply(params.linewidth) + "\n" + "\033[0;31mCould not load " +
|
kkonganti@17
|
105 "default pipeline's process configuration. Please provide a pipeline \n" +
|
kkonganti@17
|
106 "name using the --pipeline option.\n\033[0m" + '-'.multiply(params.linewidth) + "\n")
|
kkonganti@17
|
107 System.exit(1)
|
kkonganti@17
|
108 }
|
kkonganti@17
|
109 }
|
kkonganti@17
|
110
|
kkonganti@17
|
111 // Function will return after sleeping for some time.
|
kkonganti@17
|
112 // Sleep time increases exponentially by task attempt.
|
kkonganti@17
|
113 def dynamic_retry(task_retry_num, factor_by) {
|
kkonganti@17
|
114 // sleep(Math.pow(2, task_retry_num.toInteger()) * factor_by.toInteger() as long)
|
kkonganti@17
|
115 sleep(Math.pow(1.27, task_retry_num.toInteger()) as long)
|
kkonganti@17
|
116 return 'retry'
|
kkonganti@17
|
117 }
|
kkonganti@17
|
118
|
kkonganti@17
|
119 // Function that will adjust the minimum number of CPU
|
kkonganti@17
|
120 // cores depending as requested by the user.
|
kkonganti@17
|
121 def min_cpus(cores) {
|
kkonganti@17
|
122 return Math.min(cores as int, "${params.max_cpus}" as int)
|
kkonganti@17
|
123 }
|