-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.nf
180 lines (159 loc) · 5.82 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
#!/usr/bin/env nextflow
// enable dsl2
nextflow.enable.dsl=2
def help() {
log.info"""
Run the analysis:
nextflow <nextflow options> run main.nf -profile <profiles> --input <fastqs> --outdir <dir> --ticket <batch> <options>
Initialize the Shiver input:
nextflow <nextflow options> run main.nf --init -profile <profiles> --outdir <dir> <options>
Create database for host genome:
nextflow <nextflow options> run main.nf --setup -profile <profiles> --outdir <dir> <options>
Nextflow options:
-c Path to additional config file [Default: Nextflow uses nextflow.config in current and script
directory in addition to configurations in ~/.nextflow/config]
-C Path to config file. Other config files are ignored.
Options:
-profile Comma-separated list of run profiles to use: local,slurm,docker,singularity
--input Input directory with fastq files
--outdir Directory for results
--ticket Batch name
--primers Primers used during amplification [Default:?]
--adapters Sequencing adapters [Default:?]
--initDir Shiver initialization directory for configurations
--config Shiver configuration file [Default:?]
--references HIV reference dataset
--hostGenome Directory with reference database for host genome
--hostGenomeBase Name of reference database for host genome
--hostURL URL to download host reference genome from
--min_cov_eti Coverage threshold in time of infection calculations [Default: 300]
--large Use more computing resources
--help Display this help message and exit
Initialization options:
--primers Primers used during amplification [Default:?]
--adapters Sequencing adapters [Default:?]
--config Shiver configuration file [Default:?]
--references HIV reference dataset
Setup options:
--hostGenome Directory to create reference database for host genome in
--hostGenomeBase Name of reference database for host genome
--hostFasta Host reference genome path
"""
}
if (params.help) {
help()
exit 0
}
// Verify input parameters
if (!params.outdir){
println("Please specify directory for output with --outdir")
System.exit(1)
}
if ( params.setup ) {
if (!params.hostGenome){
println("Please specify reference database directory with --hostGenome")
System.exit(1)
}
if (!params.hostGenomeBase){
println("Please specify reference database name with --hostGenomeBase")
System.exit(1)
}
if (!params.hostFasta){
println("Please specify url for host reference fasta with --hostFasta")
System.exit(1)
}
}
else if ( params.init ) {
if (!params.references){
println("Please specify reference fasta file with --references")
System.exit(1)
}
if (!params.primers){
println("Please specify primers with --primers")
System.exit(1)
}
if (!params.adapters){
println("Please specify adapters with --adapters")
System.exit(1)
}
if (!params.config){
println("Please specify Shiver config file with --config")
System.exit(1)
}
}
else {
if (!params.input){
println("Please specify input directory with --input")
System.exit(1)
}
if (!params.ticket){
println("Please specify a name for the batch --ticket")
System.exit(1)
}
if (!params.initDir){
println("Please specify Shiver intialisation directory with --initDir")
System.exit(1)
}
if (!params.primers){
println("Please specify primers with --primers")
System.exit(1)
}
if (!params.adapters){
println("Please specify adapters with --adapters")
System.exit(1)
}
if (!params.config){
println("Please specify Shiver config file with --config")
System.exit(1)
}
}
// include workflows and modules
include {timeAnalysis} from './workflows/time.nf'
include {initialisation} from './workflows/initialisation.nf'
include {setup} from './workflows/pipeline_setup.nf'
include {getVersion} from './modules/version.nf'
workflow {
getVersion()
if ( params.setup ) {
// Set initialisation input
Channel.fromPath(params.hostFasta)
.set{ ch_hostFasta }
// Run setup
main:
setup(ch_hostFasta)
}
else if ( params.init ) {
// Set initialisation input
Channel.fromPath(params.references)
.set{ ch_referenceFile }
Channel.fromPath(params.primers)
.set{ ch_primersFile }
Channel.fromPath(params.adapters)
.set{ ch_adaptersFile }
Channel.fromPath(params.config)
.set{ ch_shiverConfigFile }
// Run initialisation
main:
initialisation(ch_primersFile, ch_adaptersFile, ch_shiverConfigFile, ch_referenceFile)
}
else {
// Set analysis input
Channel.fromFilePairs( params.input, size: 2 )
.filter { it =~/.*.fastq.gz|.*.fq.gz|.*.fastq|.*.fq/ }
.ifEmpty { exit 1, "Cannot find fastq-files in input directory" }
.set{ch_fastq}
Channel.fromPath(params.initDir)
.set{ ch_shiverInitDir }
Channel.fromPath(params.hostGenome)
.set{ ch_hostGenome }
Channel.fromPath(params.primers)
.set{ ch_primersFile }
Channel.fromPath(params.adapters)
.set{ ch_adaptersFile }
Channel.fromPath(params.config)
.set{ ch_shiverConfigFile }
// run analysis
main:
timeAnalysis(ch_fastq, ch_primersFile, ch_adaptersFile, ch_shiverConfigFile, ch_shiverInitDir, ch_hostGenome)
}
}