-
Notifications
You must be signed in to change notification settings - Fork 4
/
db_setup.nf
233 lines (174 loc) · 5.05 KB
/
db_setup.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
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
224
225
226
227
228
229
230
231
232
233
process download_cog_cdd {
output:
tuple path("COG*.smp"), path("Cog.pn"), path("cdd.info")
script:
"""
wget ftp://ftp.ncbi.nih.gov/pub/mmdb/cdd/cdd.tar.gz
wget ftp://ftp.ncbi.nih.gov/pub/mmdb/cdd/cdd.info
tar xvf cdd.tar.gz && rm cdd.tar.gz
"""
}
process setup_cog_cdd {
container "$params.blast_container"
conda "$baseDir/conda/blast.yaml"
publishDir "$params.cog_db", mode: "move"
input:
tuple path(smps), path(pn), path(info)
output:
file "cog_db*"
file "cdd_to_cog"
path("${info}", includeInputs: true)
script:
"""
makeprofiledb -title COG -in Cog.pn -out cog_db -threshold 9.82 \
-scale 100.0 -dbtype rps -index true
grep "tag id" COG* | sed 's/.smp:.*tag id//' | \
sed 's/COG//' > cdd_to_cog
"""
}
process diamond_refseq {
publishDir "$params.refseq_db", mode: "move"
container "$params.diamond_container"
input:
path nr_refseq
output:
path "refseq_nr.dmnd"
script:
"""
diamond makedb --in $nr_refseq -d refseq_nr
"""
}
process download_pfam_db {
output:
tuple path("Pfam-A.hmm"), path("Pfam-A.hmm.dat"), path("Pfam.version")
script:
"""
wget ftp://ftp.ebi.ac.uk/pub/databases/Pfam/current_release/Pfam-A.hmm.gz
wget ftp://ftp.ebi.ac.uk/pub/databases/Pfam/current_release/Pfam-A.hmm.dat.gz
wget ftp://ftp.ebi.ac.uk/pub/databases/Pfam/current_release/Pfam.version.gz
gunzip < Pfam-A.hmm.gz > Pfam-A.hmm && rm -f Pfam-A.hmm.gz
gunzip < Pfam-A.hmm.dat.gz > Pfam-A.hmm.dat && rm -f Pfam-A.hmm.dat.gz
gunzip < Pfam.version.gz > Pfam.version && rm -f Pfam.version.gz
"""
}
process prepare_hmm {
container "$params.pfam_scan_container"
conda "$baseDir/conda/pfam_scan.yaml"
publishDir "$params.pfam_db", mode: "move"
input:
tuple path(pfam_hmm), path(pfam_defs), path(pfam_version)
output:
path "${pfam_hmm}.h3*"
path("${pfam_hmm}", includeInputs: true)
path("${pfam_defs}", includeInputs: true)
path("${pfam_version}", includeInputs: true)
script:
"""
hmmpress $pfam_hmm
"""
}
process download_ko_profiles {
publishDir "$params.ko_db", mode: "move"
output:
path "ko_list"
path "profiles/*.hmm"
path "profiles/prokaryote.hal"
path "version.txt"
script:
version="2022-03-01"
"""
wget https://www.genome.jp/ftp/db/kofam/archives/$version/ko_list.gz
wget https://www.genome.jp/ftp/db/kofam/archives/$version/profiles.tar.gz
gunzip < ko_list.gz > ko_list && rm -f ko_list.gz
tar xvf profiles.tar.gz
rm profiles.tar.gz
echo $version > version.txt
"""
}
process download_swissprot {
output:
tuple path("swissprot.fasta"), path("relnotes.txt")
script:
"""
wget ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_sprot.fasta.gz
wget ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/relnotes.txt
gunzip < uniprot_sprot.fasta.gz > swissprot.fasta
rm uniprot_sprot.fasta.gz
"""
}
process prepare_swissprot {
container "$params.blast_container"
conda "$baseDir/conda/blast.yaml"
publishDir "$params.swissprot_db", mode: "move"
input:
tuple path(swissprot_fasta), path(relnotes)
output:
path("*", includeInputs: true)
script:
"""
makeblastdb -dbtype prot -in swissprot.fasta
"""
}
process download_vfdb {
output:
tuple path("vfdb.fasta"), path("VFs.xls")
script:
"""
wget http://www.mgc.ac.cn/VFs/Down/VFDB_setB_pro.fas.gz
wget http://www.mgc.ac.cn/VFs/Down/VFs.xls.gz
gunzip < VFDB_setB_pro.fas.gz > vfdb.fasta
gunzip < VFs.xls.gz > VFs.xls
rm VFDB_setB_pro.fas.gz
rm VFs.xls.gz
"""
}
process prepare_vfdb {
container "$params.blast_container"
conda "$baseDir/conda/blast.yaml"
publishDir "$params.vf_db", mode: "move"
input:
tuple path(vfdb_fasta), path(vf_descr)
output:
path("*", includeInputs: true)
script:
"""
makeblastdb -dbtype prot -in $vfdb_fasta
"""
}
workflow setup_cogg_db {
download_cog_cdd() | setup_cog_cdd
}
/**
* NOTE: this assumes that the user already downloaded the refseq
* database (nr_refseq) and concatenated all the files into a single
* fasta file called "refseq_nr.fasta".
*/
workflow setup_refseq_db {
Channel.fromPath("${params.refseq_db}/refseq_nr.fasta") | diamond_refseq
}
workflow setup_pfam_db {
download_pfam_db() | prepare_hmm
}
workflow setup_ko_db {
download_ko_profiles()
}
workflow setup_swissprot_db {
download_swissprot() | prepare_swissprot
}
workflow setup_vfdb {
download_vfdb() | prepare_vfdb
}
workflow {
if( params.cog )
setup_cogg_db()
if ( params.diamond_refseq )
setup_refseq_db()
if ( params.pfam )
setup_pfam_db()
if ( params.ko )
setup_ko_db()
if ( params.blast_swissprot )
setup_swissprot_db()
if ( params.vfdb )
setup_vfdb()
}