-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.nf
executable file
·183 lines (145 loc) · 5.44 KB
/
main.nf
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
#!/usr/bin/env nextflow
nextflow.preview.dsl=2
/*
Nextflow -- Analysis Pipeline
Author: someone@gmail.com
*/
/**************************
* META & HELP MESSAGES
**************************/
/*
Comment section: First part is a terminal print for additional user information,
followed by some help statements (e.g. missing input) Second part is file
channel input. This allows via --list to alter the input of --nano & --illumina
to add csv instead. name,path or name,pathR1,pathR2 in case of illumina
*/
// terminal prints
if (params.help) { exit 0, helpMSG() }
println " "
println "\u001B[32mProfile: $workflow.profile\033[0m"
println " "
println "\033[2mCurrent User: $workflow.userName"
println "Nextflow-version: $nextflow.version"
println "Starting time: $nextflow.timestamp"
println "Workdir location:"
println " $workflow.workDir\u001B[0m"
println " "
if (workflow.profile == 'standard') {
println "\033[2mCPUs to use: $params.cores"
println "Output dir name: $params.output\u001B[0m"
println " "}
if (params.profile) { exit 1, "--profile is WRONG use -profile" }
if (params.nano == '' && params.illumina == '' ) { exit 1, "input missing, use [--nano] or [--illumina]"}
/**************************
* INPUT CHANNELS
**************************/
// nanopore reads input & --list support
if (params.nano && params.list) { nano_input_ch = Channel
.fromPath( params.nano, checkIfExists: true )
.splitCsv()
.map { row -> [row[0], file("${row[1]}", checkIfExists: true)] }
.view() }
else if (params.nano) { nano_input_ch = Channel
.fromPath( params.nano, checkIfExists: true)
.map { file -> tuple(file.baseName, file) }
.view()
}
// illumina reads input & --list support
if (params.illumina && params.list) { illumina_input_ch = Channel
.fromPath( params.illumina, checkIfExists: true )
.splitCsv()
.map { row -> [row[0], [file("${row[1]}", checkIfExists: true), file("${row[2]}", checkIfExists: true)]] }
.view() }
else if (params.illumina) { illumina_input_ch = Channel
.fromFilePairs( params.illumina , checkIfExists: true )
.view()
}
/**************************
* MODULES
**************************/
/* Comment section: */
include example_db from './modules/get_db'
include module1 from './modules/module1'
include module2 from './modules/module2'
/**************************
* DATABASES
**************************/
/* Comment section:
The Database Section is designed to "auto-get" pre prepared databases.
It is written for local use and cloud use via params.cloudProcess.
*/
workflow download_db {
main:
// local storage via storeDir
if (!params.cloudProcess) { example_db(); db = example_db.out }
// cloud storage via db_preload.exists()
if (params.cloudProcess) {
db_preload = file("${params.cloudDatabase}/test_db/Chlamydia_gallinacea_08_1274_3.ASM47102v2.dna.toplevel.fa.gz")
if (db_preload.exists()) { db = db_preload }
else { example_db(); db = example_db.out }
}
emit: db
}
/**************************
* SUB WORKFLOWS
**************************/
/* Comment section: */
workflow subworkflow_1 {
take:
nano_input_ch
db
main:
module2(module1(nano_input_ch, db))
}
/**************************
* WORKFLOW ENTRY POINT
**************************/
/* Comment section: */
workflow {
download_db()
db = download_db.out
if (params.nano && !params.illumina) {
subworkflow_1(nano_input_ch, db)
}
}
/**************************
* --help
**************************/
def helpMSG() {
c_green = "\033[0;32m";
c_reset = "\033[0m";
c_yellow = "\033[0;33m";
c_blue = "\033[0;34m";
c_dim = "\033[2m";
log.info """
____________________________________________________________________________________________
Workflow: Template
${c_yellow}Usage example:${c_reset}
nextflow run wf_template --nano '*/*.fastq'
${c_yellow}Input:${c_reset}
${c_green} --nano ${c_reset} '*.fasta' or '*.fastq.gz' -> one sample per file
${c_green} --illumina ${c_reset} '*.R{1,2}.fastq.gz' -> file pairs
${c_dim} ..change above input to csv:${c_reset} ${c_green}--list ${c_reset}
${c_yellow}Options:${c_reset}
--cores max cores for local use [default: $params.cores]
--memory max memory for local use [default: $params.memory]
--output name of the result folder [default: $params.output]
${c_yellow}Parameters:${c_reset}
--variable1 a variable [default: $params.variable1]
--variable2 a variable [default: $params.variable2]
${c_dim}Nextflow options:
-with-report rep.html cpu / ram usage (may cause errors)
-with-dag chart.html generates a flowchart for the process tree
-with-timeline time.html timeline (may cause errors)
${c_yellow}LSF computing:${c_reset}
For execution of the workflow on a HPC with LSF adjust the following parameters:
--databases defines the path where databases are stored [default: $params.cloudDatabase]
--workdir defines the path where nextflow writes tmp files [default: $params.workdir]
--cachedir defines the path where images (singularity) are cached [default: $params.cachedir]
Profile:
-profile standard (local, pure docker) [default]
conda
lsf (HPC w/ LSF, singularity/docker)
${c_reset}
""".stripIndent()
}