Repository navigation
Expand file tree
/
Copy pathdownload.nf
More file actions
217 lines (160 loc) · 5.23 KB
/
Copy pathdownload.nf
File metadata and controls
217 lines (160 loc) · 5.23 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
#!/usr/bin/env nextflow
/*
* Copyright (c) 2017-2021, Centre for Genomic Regulation (CRG)
*
* Copyright (c) 2021, Toni Hermoso Pulido
*
* Functional Annotation Pipeline for protein annotation from non-model organisms
* from Genome Annotation Team in Catalonia (GATC) implemented in Nextflow
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// default parameters
params.help = false
// Main result and log dirs
params.dbPath = "/nfs/db"
// Version
params.iprscanVersion = "5.52-86.0"
params.koVersion = "2021-05-02"
// URLs
params.iprscanURL = "https://ftp.ebi.ac.uk/pub/software/unix/iprscan/5/${params.iprscanVersion}/interproscan-${params.iprscanVersion}-64-bit.tar.gz "
params.koURLlist = "ftp://ftp.genome.jp/pub/db/kofam/archives/${params.koVersion}/ko_list.gz"
params.koURLprofiles = "ftp://ftp.genome.jp/pub/db/kofam/archives/${params.koVersion}/profiles.tar.gz"
params.goOboURL = "http://www.geneontology.org/ontology/gene_ontology.obo"
// NCBI DB list
params.blastDBList = "swissprot,pdbaa"
params.blastTimeout = 600
// Specific DB Paths
Date date = new Date()
String datePart = date.format("yyyyMM")
params.blastDbFolder = "${params.dbPath}/ncbi/${datePart}/blastdb/db"
params.dbipscanPath = "${params.dbPath}/iprscan/${params.iprscanVersion}"
params.dbKOPath = "${params.dbPath}/kegg/${params.koVersion}"
params.oboFolder = "${params.dbPath}/geneontology/${datePart}"
// Mail for sending reports
params.email = ""
//print usage
if ( params.help ) {
log.info ''
log.info 'Functional Annotation - Download datasets pipeline'
log.info '----------------------------------------------------'
log.info ''
log.info 'Usage: '
log.info " ./nextflow run download.nf --config params.config [options]"
log.info ''
log.info 'Options:'
log.info '-resume resume pipeline from the previous step, i.e. in case of error'
log.info '-help this message'
exit 1
}
if ( params.dbPath == null || params.dbPath == "" ) {
log.info "No target directory specified"
exit 1
}
if ( params.blastDBList == null || params.blastDBList == "" ) {
log.info "No BLAST DBs provided"
exit 1
}
blastDBChannel = Channel.fromList( params.blastDBList?.tokenize(',') )
process oboFile {
publishDir params.oboFolder, mode: 'copy'
label 'download'
output:
file "gene_ontology.obo" into oboFile
"""
curl --retry 3 -o gene_ontology.obo ${params.goOboURL};
"""
}
process downloadNCBI {
publishDir params.blastDbFolder, mode: 'copy'
label 'blast'
input:
val db from blastDBChannel
output:
set val(db), file ("*") into blastdb
"""
update_blastdb.pl ${db} --timeout ${params.blastTimeout} --decompress
blastdbcmd -dbtype prot -db ${db} -entry all -out ${db}.fa
"""
}
process formatDIAMOND {
publishDir params.blastDbFolder, mode: 'copy'
label 'diamond'
input:
set db, file(fasta) from blastdb
output:
file "*" into formatted_blastdb
"""
diamond makedb --in ${db}.fa --db ${db}
"""
}
process downloadInterPro {
publishDir params.dbipscanPath, mode: 'copy'
label 'ipscan'
output:
file "*" into interpro_data
"""
curl --retry 3 -o iprscan.tar.gz ${params.iprscanURL};
tar zxf iprscan.tar.gz
rm iprscan.tar.gz
cd interproscan-${params.iprscanVersion}
python3 initial_setup.py
cd ..
mv interproscan-${params.iprscanVersion}/data .
rm -rf interproscan-${params.iprscanVersion}
mv data/* .
"""
}
process downloadKO {
publishDir params.dbKOPath, mode: 'copy'
label 'download'
output:
file "ko_list" into ko_list
file "profiles" into ko_profiles
file "ko_store" into ko_store
"""
curl --retry 3 -o ko_list.gz ${params.koURLlist};
gunzip ko_list.gz;
curl --retry 3 -o profiles.tar.gz ${params.koURLprofiles};
tar zxf profiles.tar.gz; rm profiles.tar.gz;
mkdir ko_store
bulkDownloadKEGG.pl ko_list ko_store
"""
}
// On finising
workflow.onComplete {
println ( workflow.success ? "\nDone! Check downloaded datasets in --> $params.dbPath\n" : "Oops .. something went wrong" )
}
workflow.onError {
println( "Something went wrong" )
}
if (params.email == "yourmail@yourdomain" || params.email == "") {
log.info 'Skipping email\n'
} else {
log.info "Sending email to ${params.email}\n"
workflow.onComplete {
def msg = """\
Pipeline execution summary
---------------------------
Completed at: ${workflow.complete}
Duration : ${workflow.duration}
Success : ${workflow.success}
workDir : ${workflow.workDir}
exit status : ${workflow.exitStatus}
Error report: ${workflow.errorReport ?: '-'}
"""
.stripIndent()
sendMail(to: params.email, subject: "[FA-nf] Download finished", body: msg)
}
}