comparison 0.4.0/workflows/nanofactory.nf @ 101:ce6d9548fe89

"planemo upload"
author kkonganti
date Thu, 04 Aug 2022 10:45:55 -0400
parents
children
comparison
equal deleted inserted replaced
100:9d9537c907bd 101:ce6d9548fe89
1 //
2 // Start nanofactory workflow. Since this is a special
3 // case workflow wherein most of the bioinformatics
4 // tools are not used, there won't be any modules or
5 // subworkflows and therefore all the processes
6 // reside here.
7 //
8
9 // Include any necessary methods.
10 include { addPadding; summaryOfParams; stopNow} \
11 from "${params.routines}"
12
13 /*
14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 PROCESS DEFINITIONS FOR NANOFACTORY
16 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 */
18
19 process SETPUBLISHDIR {
20 label 'process_femto'
21 module (params.enable_module ? params.enable_module : null)
22 conda (params.enable_conda ? params.enable_conda : null)
23
24 input:
25 val options
26
27 output:
28 stdout
29
30 shell:
31 '''
32 project_setup.py -s !{options.sample_sheet} \
33 !{options.alt_settings} !{options.verbose} -b
34 '''
35 }
36
37 process PROJECTSETUP {
38 label 'process_femto'
39 publishDir "${publish_dir.trim()}", mode: 'copy', overwrite: false
40 module (params.enable_module ? params.enable_module : null)
41 conda (params.enable_conda ? params.enable_conda : null)
42
43 input:
44 val options
45 val publish_dir
46
47 output:
48 stdout
49
50 script:
51 params.publish_dir = "${publish_dir.trim()}"
52
53 shell:
54 '''
55 project_setup.py -y -s !{options.sample_sheet} !{options.alt_settings} \
56 !{options.purge} !{options.runtype} !{options.logfile} \
57 !{options.loglevel} !{options.verbose} !{options.nocopy} \
58 !{options.fix_existing}
59
60 cat < original_source.txt
61 '''
62 }
63
64 process TRIMDEMUX {
65 label 'process_pico'
66 module (params.enable_module ? params.enable_module : null)
67 conda (params.enable_conda ? params.enable_conda : null)
68 cpus "${params.guppy_threads}"
69
70 input:
71 val options
72 val original_source
73
74 output:
75 path 'source.txt'
76
77 shell:
78 '''
79 trim_demux.py -s !{options.sample_sheet} !{options.verbose} \
80 !{options.alt_settings} !{options.guppy_config} -t !{options.guppy_threads}
81 '''
82 }
83
84 /*
85 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86 WORKFLOW ENTRY POINT
87 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88 */
89
90 workflow NANOFACTORY {
91
92 if ( params.help ) {
93 log.info help()
94 } else if ( params.sample_sheet == null ||
95 params.sample_sheet.length() == 0 ) {
96
97 log.info help()
98 stopNow("Please provide absolute path to a JSON formatted sample sheet using the\n" +
99 "--sample_sheet option.")
100 } else {
101 log.info summaryOfParams()
102
103 options = Channel.empty()
104 Channel
105 .from(setOptions())
106 .set { options }
107
108 take:
109 options
110
111 main:
112 SETPUBLISHDIR(options)
113 PROJECTSETUP(options, SETPUBLISHDIR.out)
114 TRIMDEMUX(options, PROJECTSETUP.out)
115 }
116 }
117
118
119 /*
120 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121 THE END
122 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123 */
124
125
126 /*
127 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128 HELPER METHODS FOR NANOFACTORY WORKFLOW
129 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 */
131
132 def setOptions() {
133
134 Map options = [:]
135
136 options['sample_sheet'] ?= "${params.sample_sheet}"
137 options['verbose'] = params.verbose ? "-v" : ""
138 options['alt_settings'] = params.global_settings ? "-c ${params.global_settings}" : ""
139 options['purge'] = params.setup_purge_existing ? "-p" : ""
140 options['logfile'] = params.log_file ? "-l ${params.log_file}" : ""
141 options['loglevel'] = params.log_level ? "--loglevel ${params.log_level}" : ""
142 options['nocopy'] = params.setup_nocopy ? "--nocopy" : ""
143 options['runtype'] = params.setup_runtype ? "-r ${params.setup_runtype}" : ""
144 options['fix_existing'] = params.setup_fix_existing ? "-f" : ""
145 options['guppy_config'] = params.guppy_config ? " -g ${params.guppy_config}" : ""
146 options['mode'] = params.mode ? "-m ${params.mode}" : "-m prod"
147 options['mail_group'] = params.mail_group ? "-g ${params.mail_group}" : "-g stakeholders"
148 options['guppy_threads'] = params.guppy_threads ? "${params.guppy_threads}" : 1
149 options['pad'] = pad.toInteger()
150 options['nocapitalize'] = true
151
152 return options
153 }
154
155 def help() {
156
157 Map helptext = [:]
158
159 helptext['help'] = true
160 helptext['nocapitalize'] = true
161 helptext['Workflow'] = "${params.pipeline}"
162 helptext['Author'] = "${params.workflow_author}"
163 helptext['Version'] = "${params.workflow_version}\n"
164 helptext['Usage'] = "cpipes --pipeline nanofactory [options]\n"
165 helptext['Required'] = ""
166 helptext['--sample_sheet'] = "The JSON-formatted sample sheet for this run. Normally provided by Pore Refiner.\n"
167 helptext['Other options'] = ""
168 helptext['--global_settings'] = "An alternate global settings file. If not present the installed default will be used."
169 helptext['--log_file'] = "Path and file name to a log file relative to the project directory (Default: 'logs/workflow.log')"
170 helptext['--log_level'] = "One of 'debug', 'info', 'warning', 'error', 'fatal' (Default: 'info')"
171 helptext['--mode'] = "Set the run mode. One of 'dev', 'test', 'stage', or 'prod' (Default: 'prod')"
172 helptext['--verbose'] = "Use to enable more verbose console output from each tool\n"
173 helptext['Project setup options'] = ""
174 helptext['--disable_project_setup'] = "Do not do project setup (Default: setup is enabled)"
175 helptext['--setup_purge_existing'] = "Before setting up the project area delete any existing files (Default: don't purge)"
176 helptext['--setup_nocopy'] = "During setup, do NOT copy the original data files to the scrach location (Default: copy)"
177 helptext['--setup_runtype'] = "Set things up for the indicated run type (Currently not used)"
178 helptext['--setup_runtype'] = "Set things up for the indicated run type (Currently not used)"
179 helptext['--enable_module'] = "Software environment module. Ex: --enable_module 'nanofactory/current'"
180 helptext['--enable_conda'] = "CONDA environment module. Ex: --enable_conda nanofactory\n"
181 helptext['Help options'] = ""
182 helptext['--help'] = "Display this message.\n"
183
184 return addPadding(helptext)
185 }