-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.nf
More file actions
223 lines (175 loc) · 8.6 KB
/
main.nf
File metadata and controls
223 lines (175 loc) · 8.6 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/env nextflow
/*
========================================================================================
nf-core/crisprquant
========================================================================================
nf-core/crisprquant Analysis Pipeline.
#### Homepage / Documentation
https://github.com/nf-core/crisprquant
----------------------------------------------------------------------------------------
*/
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 nf-core/crisprquant --input samplesheet.csv --library -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')
////////////////////////////////////////////////////
/* -- 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.library) { ch_library = file(params.library) } else { exit 1, 'Library file not specified!' }
//if (params.fasta) { ch_fasta = file(params.fasta) } else { exit 1, 'Genome fasta file not specified!' }
if (params.pinapl_config) { ch_pinaplconfig = file(params.pinapl_config) } else { exit 1, 'pinAPL-py config file does not exist' }
if (params.pinapl_datasheet) { ch_datasheet = file(params.pinapl_datasheet) } else { exit 1, 'pinAPL-py datasheet does not exist' }
////////////////////////////////////////////////////
/* -- 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: [:] )
include { GET_LIBRARY_FASTA } from './modules/local/subworkflow/get_library_fasta' addParams( options: [:] )
include { CONVERT_LIBRARY_FILE } from './modules/local/subworkflow/convert_library_file' addParams( options: [:] )
include { MAGECK_COUNT } from './modules/local/subworkflow/mageck_count' addParams( options: [:] )
include { PINAPLPY } from './modules/local/pinaplpy' 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 )
include { BOWTIE2_BUILD } from './modules/nf-core/software/bowtie2/build/main' addParams( options: [:] )
include { BOWTIE2_ALIGN } from './modules/nf-core/software/bowtie2/align/main' addParams( options: [:] )
include { CUTADAPT } from './modules/nf-core/software/cutadapt/main' addParams( options: [:] )
// include { TRIMGALORE } from './modules/nf-core/software/trimgalore/main' addParams( 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
)
CONVERT_LIBRARY_FILE (
ch_library
)
GET_LIBRARY_FASTA (
CONVERT_LIBRARY_FILE.out.mageck_library
)
// TODO: GUNZIP FASTQ FILES
/*
* MODULE: Run FastQC
*/
//INPUT_CHECK.out.reads.view()
// INPUT_CHECK.out.reads.buffer { it == "*.fastq.gz" }.view()
FASTQC (
INPUT_CHECK.out.reads
)
ch_software_versions = ch_software_versions.mix(FASTQC.out.version.first().ifEmpty(null))
BOWTIE2_BUILD (
GET_LIBRARY_FASTA.out
)
CUTADAPT (
INPUT_CHECK.out.reads
)
BOWTIE2_ALIGN (
CUTADAPT.out.reads, BOWTIE2_BUILD.out.index
)
// generate channel for mageck
BOWTIE2_ALIGN.out.bam.map{
meta, file ->
["group", meta, file]}.groupTuple().map{
group, meta, file ->
[meta, file]
}.set{aligned_reads}
CUTADAPT.out.reads.map {
meta, file ->
["group", meta, file]}.groupTuple().map{
group, meta, file ->
[meta, file]
}.set{trimmed_reads}
MAGECK_COUNT (
trimmed_reads, CONVERT_LIBRARY_FILE.out.mageck_library
)
PINAPLPY (
ch_pinaplconfig, ch_datasheet, CONVERT_LIBRARY_FILE.out.pinapl_library, aligned_reads
)
/*
* 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)
}
////////////////////////////////////////////////////
/* -- THE END -- */
////////////////////////////////////////////////////