forked from nf-core/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
179 lines (140 loc) · 6.59 KB
/
main.nf
File metadata and controls
179 lines (140 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env nextflow
/*
========================================================================================
{{ cookiecutter.name }}
========================================================================================
{{ cookiecutter.name }} Analysis Pipeline.
#### Homepage / Documentation
https://github.com/{{ cookiecutter.name }}
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
////////////////////////////////////////////////////
/* -- PRINT HELP -- */
////////////////////////////////////////////////////
def json_schema = "$projectDir/nextflow_schema.json"
if (params.help) {
// TODO nf-core: Update typical command used to run pipeline
def command = "nextflow run {{ cookiecutter.name }} --input samplesheet.csv -profile docker"
log.info Schema.params_help(workflow, params, json_schema, command)
exit 0
}
////////////////////////////////////////////////////
/* -- GENOME PARAMETER VALUES -- */
////////////////////////////////////////////////////
params.fasta = Checks.get_genome_attribute(params, 'fasta')
////////////////////////////////////////////////////
/* -- VALIDATE PARAMETERS -- */
////////////////////////////////////////////////////
def unexpectedParams = []
if (params.validate_params) {
unexpectedParams = Schema.validateParameters(params, json_schema, log)
}
////////////////////////////////////////////////////
/* -- PRINT PARAMETER SUMMARY -- */
////////////////////////////////////////////////////
def summary_params = Schema.params_summary_map(workflow, params, json_schema)
log.info Schema.params_summary_log(workflow, params, json_schema)
////////////////////////////////////////////////////
/* -- PARAMETER CHECKS -- */
////////////////////////////////////////////////////
// Check that conda channels are set-up correctly
if (params.enable_conda) {
Checks.check_conda_channels(log)
}
// Check AWS batch settings
Checks.aws_batch(workflow, params)
// Check the hostnames against configured profiles
Checks.hostname(workflow, params, log)
// Check genome key exists if provided
Checks.genome_exists(params, log)
////////////////////////////////////////////////////
/* -- VALIDATE INPUTS -- */
////////////////////////////////////////////////////
// TODO nf-core: Add all file path parameters for the pipeline to the list below
// Check input path parameters to see if they exist
checkPathParamList = [ params.input, params.multiqc_config, params.fasta ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Check mandatory parameters
if (params.input) { ch_input = file(params.input) } else { exit 1, 'Input samplesheet not specified!' }
if (params.fasta) { ch_fasta = file(params.fasta) } else { exit 1, 'Genome fasta file not specified!' }
////////////////////////////////////////////////////
/* -- CONFIG FILES -- */
////////////////////////////////////////////////////
ch_multiqc_config = file("$projectDir/assets/multiqc_config.yaml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config) : Channel.empty()
////////////////////////////////////////////////////
/* -- IMPORT MODULES / SUBWORKFLOWS -- */
////////////////////////////////////////////////////
// Don't overwrite global params.modules, create a copy instead and use that within the main script.
def modules = params.modules.clone()
def multiqc_options = modules['multiqc']
multiqc_options.args += params.multiqc_title ? " --title \"$params.multiqc_title\"" : ''
// Local: Modules
include { GET_SOFTWARE_VERSIONS } from './modules/local/process/get_software_versions' addParams( options: [publish_files : ['csv':'']] )
// Local: Sub-workflows
include { INPUT_CHECK } from './modules/local/subworkflow/input_check' addParams( options: [:] )
// nf-core/modules: Modules
include { FASTQC } from './modules/nf-core/software/fastqc/main' addParams( options: modules['fastqc'] )
include { MULTIQC } from './modules/nf-core/software/multiqc/main' addParams( options: multiqc_options )
////////////////////////////////////////////////////
/* -- RUN MAIN WORKFLOW -- */
////////////////////////////////////////////////////
// Info required for completion email and summary
def multiqc_report = []
workflow {
ch_software_versions = Channel.empty()
/*
* SUBWORKFLOW: Read in samplesheet, validate and stage input files
*/
INPUT_CHECK (
ch_input
)
/*
* MODULE: Run FastQC
*/
FASTQC (
INPUT_CHECK.out.reads
)
ch_software_versions = ch_software_versions.mix(FASTQC.out.version.first().ifEmpty(null))
/*
* MODULE: Pipeline reporting
*/
GET_SOFTWARE_VERSIONS (
ch_software_versions.map { it }.collect()
)
/*
* MultiQC
*/
if (!params.skip_multiqc) {
workflow_summary = Schema.params_summary_multiqc(workflow, summary_params)
ch_workflow_summary = Channel.value(workflow_summary)
ch_multiqc_files = Channel.empty()
ch_multiqc_files = ch_multiqc_files.mix(Channel.from(ch_multiqc_config))
ch_multiqc_files = ch_multiqc_files.mix(ch_multiqc_custom_config.collect().ifEmpty([]))
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
ch_multiqc_files = ch_multiqc_files.mix(GET_SOFTWARE_VERSIONS.out.yaml.collect())
ch_multiqc_files = ch_multiqc_files.mix(FASTQC.out.zip.collect{it[1]}.ifEmpty([]))
MULTIQC (
ch_multiqc_files.collect()
)
multiqc_report = MULTIQC.out.report.toList()
ch_software_versions = ch_software_versions.mix(MULTIQC.out.version.ifEmpty(null))
}
}
////////////////////////////////////////////////////
/* -- COMPLETION EMAIL -- */
////////////////////////////////////////////////////
workflow.onComplete {
Completion.email(workflow, params, summary_params, projectDir, log, multiqc_report)
Completion.summary(workflow, params, log)
}
workflow.onError {
// Print unexpected parameters
for (p in unexpectedParams) {
log.warn "Unexpected parameter: ${p}"
}
}
////////////////////////////////////////////////////
/* -- THE END -- */
////////////////////////////////////////////////////