forked from qiyunzhu/woltka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwolsop.sh
283 lines (209 loc) · 6.78 KB
/
wolsop.sh
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/bash
#######################################
#
# Standard workflow for WoL + Woltka
#
#######################################
# Author: Qiyun Zhu
# License: BSD-3-Clause
# Version: 0.0.1-dev
# Email: [email protected]
# Last updated: 2021-04-22
# Usage: Customize the "Parameters" section, then run this script.
##############
# Parameters #
##############
# WoL data release directory
# available for download at: ftp://ftp.microbio.me/pub/wol-20April2021
# see WoL doc for details
db=
# input alignment file or directory
# can be a directory of multiple files, or a multiplexed file, or a mapping
# of sample IDs to files; supports SAM, BLAST and plain mappings, supports
# regular, gz, bz2 and xz files
# see Woltka doc for details
input=
# input file extension (optional)
ext=
# output format (biom or tsv)
fmt=biom
# taxonomy tree format (taxdump or lineage)
taxtree=taxdump
# taxonomic ranks
taxranks=phylum,class,order,family,genus,species
# GO classification (yes/no)
go=yes
# MetaCyc classification (yes/no)
metacyc=yes
# KEGG classification (specify KEGG directory path)
# this directory is not part of WoL data release, see Woltka doc for
# instruction
kegg=
#######
# SOP #
#######
[ "$fmt" == biom ] && altfmt= || altfmt="--to-tsv"
[ -z "$ext" ] && filext= || filext="--filext $ext"
# taxonomic classification (NCBI)
if [ "$taxtree" == taxdump ]; then
woltka classify \
--input $input \
--map $db/taxonomy/taxid.map \
--nodes $db/taxonomy/nodes.dmp \
--names $db/taxonomy/names.dmp \
--rank none,free,$taxranks \
$filext \
$altfmt \
--output .
else
woltka classify \
--input $input \
--lineage $db/taxonomy/lineages.txt \
--rank none,free,$taxranks \
$filext \
$altfmt \
--output .
fi
mv none.$fmt ogu.$fmt
# functional classification (UniRef)
woltka classify \
--input $input \
--coords $db/proteins/coords.txt.xz \
--map $db/function/uniref/uniref.map.xz \
--names $db/function/uniref/uniref.name.xz \
--rank none,uniref \
$filext \
$altfmt \
--output .
mv none.$fmt orf.$fmt
######
# GO #
######
if [ "$go" == yes ]; then
go=$db/function/go
mkdir -p go
cd go
# by domain
for domain in all component function process; do
woltka tools collapse -m $go/$domain.map.xz -n $go/name.txt \
-i ../uniref.$fmt -o $domain.$fmt
# GO slim (generic)
woltka tools collapse -m $go/generic/$domain.map -n $go/name.txt \
-i $domain.$fmt -o $domain.generic.$fmt
done
cd ..
fi
###########
# MetaCyc #
###########
if [ "$metacyc" == yes ]; then
mc=$db/function/metacyc
mkdir -p metacyc
cd metacyc
# ORF to protein
woltka tools collapse -m $mc/protein.map.xz -n $mc/protein_name.txt \
-i ../orf.$fmt -o protein.$fmt
# protein to enzrxn (enzymatic reaction)
woltka tools collapse -m $mc/protein-to-enzrxn.txt -n $mc/enzrxn_name.txt \
-i protein.$fmt -o enzrxn.$fmt
# enzrxn to reaction
woltka tools collapse -m $mc/enzrxn-to-reaction.txt -n $mc/reaction_name.txt \
-i enzrxn.$fmt -o reaction.$fmt
# reaction to pathway
woltka tools collapse -m $mc/reaction-to-pathway.txt -n $mc/pathway_name.txt \
-i reaction.$fmt -o pathway.$fmt
# pathway to super pathway
woltka tools collapse -m $mc/pathway-to-super_pathway.txt -n $mc/pathway_name.txt \
-i pathway.$fmt -o super_pathway.$fmt
# super pathway (or pathway) to pathway type
woltka tools collapse -m $mc/pathway_type.txt -n $mc/all_class_name.txt \
-i super_pathway.$fmt -o pathway_type.$fmt
# protein to gene
woltka tools collapse -m $mc/protein-to-gene.txt -n $mc/gene_name.txt \
-i protein.$fmt -o gene.$fmt
# protein to go
woltka tools collapse -m $mc/protein-to-go.txt \
-i protein.$fmt -o go.$fmt
# enzrxn to regulation to regulator
woltka tools collapse -m $mc/enzrxn-to-regulation.txt \
-i enzrxn.$fmt -o regulation.$fmt
woltka tools collapse -m $mc/regulation-to-regulator.txt -n $mc/compound_name.txt \
-i regulation.$fmt -o regulator.$fmt
# reaction to compound (left and right)
for side in left right; do
woltka tools collapse -m $mc/reaction-to-${side}_compound.txt -n $mc/compound_name.txt \
-i reaction.$fmt -o ${side}_compound.$fmt
# compound type
woltka tools collapse -m $mc/compound_type.txt -n $mc/all_class_name.txt \
-i ${side}_compound.$fmt -o ${side}_compound_type.$fmt
done
# compound and type (both sides)
woltka tools merge -i left_compound.$fmt -i right_compound.$fmt -o compound.$fmt
woltka tools merge -i left_compound_type.$fmt -i right_compound_type.$fmt -o compound_type.$fmt
# reaction to EC
woltka tools collapse -m $mc/reaction-to-ec.txt \
-i reaction.$fmt -o ec.$fmt
# pathway coverage (by reaction)
woltka tools coverage -m $mc/pathway-to-reaction_list.txt \
-i reaction.$fmt -o pathway_coverage.$fmt
cd ..
fi
########
# KEGG #
########
if [ -d "$kegg" ]; then
ke=$kegg
mkdir -p kegg
cd kegg
# entrance
# UniRef to KO
woltka tools collapse -m $db/function/kegg/ko.map.xz -n $db/function/kegg/ko.name \
-i ../uniref.$fmt -o ko.$fmt
# main cascade
# KO to reaction
woltka tools collapse -m $ke/ko-to-reaction.txt -n $ke/reaction_name.txt \
-i ko.$fmt -o reaction.$fmt
# reaction to module
woltka tools collapse -m $ke/reaction-to-module.txt -n $ke/module_name.txt \
-i reaction.$fmt -o module.$fmt
# module to pathway
woltka tools collapse -m $ke/module-to-pathway.txt -n $ke/pathway_name.txt \
-i module.$fmt -o pathway.$fmt
# classes
# reaction to rclass
woltka tools collapse -m $ke/reaction-to-rclass.txt -n $ke/rclass_name.txt \
-i reaction.$fmt -o rclass.$fmt
# module class
woltka tools collapse -m $ke/module-to-class.txt \
-i module.$fmt -o module_class.$fmt
# pathway class
woltka tools collapse -m $ke/pathway-to-class.txt \
-i pathway.$fmt -o pathway_class.$fmt
# compounds
for side in left right; do
woltka tools collapse -m $ke/reaction-to-${side}_compound.txt -n $ke/compound_name.txt \
-i reaction.$fmt -o ${side}_compound.$fmt
done
woltka tools merge -i left_compound.$fmt -i right_compound.$fmt -o compound.$fmt
# extended
# KO to EC
woltka tools collapse -m $ke/ko-to-ec.txt \
-i ko.$fmt -o ec.$fmt
# KO to GO
woltka tools collapse -m $ke/ko-to-go.txt \
-i ko.$fmt -o go.$fmt
# KO to COG
woltka tools collapse -m $ke/ko-to-cog.txt \
-i ko.$fmt -o cog.$fmt
# KO to disease
woltka tools collapse -m $ke/ko-to-disease.txt -n $ke/disease_name.txt \
-i ko.$fmt -o disease.$fmt
# coverage
# module coverage by reaction
woltka tools coverage -m $ke/module-to-reaction.txt \
-i reaction.$fmt -o module_coverage.$fmt
# pathway coverage by module
woltka tools coverage -m $ke/pathway-to-module.txt \
-i module.$fmt -o pathway_coverage.$fmt
cd ..
fi