-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPDBTM_Topology_Pred.sh
executable file
·349 lines (318 loc) · 8.38 KB
/
PDBTM_Topology_Pred.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#!/bin/bash
# ----- usage ------ #
usage()
{
echo "PDBTM_Topology_Pred v1.05 [Mar-05-2019] "
echo " Predict PDBTM Topology labels using sequence or profile information "
echo ""
echo "USAGE: ./PDBTM_Topology_Pred.sh <-i input_fasta | input_tgt> [-o out_root] "
echo " [-t threshold] [-k keep_file] [-l real_label] [-H home]"
echo ""
echo "Options:"
echo ""
echo "***** required arguments *****"
echo "-i input_fasta : input protein sequence file in FASTA format"
echo "(or)"
echo "-i input_tgt : input protein profile file in TGT format"
echo ""
echo "***** optional arguments *****"
echo "-o out_root : default output would be XXXX.topo_MODE at the current directory,"
echo " where XXXX is the input name, and MODE is profile or noprof."
echo " we also output XXXX.topo_simp for simplified result."
echo " [default = './' ]"
echo ""
echo "-t threshold : threshold to determine transmembrane residue. [default = 0.5]"
echo ""
echo "-k keep_file : keep the intermediate files if its value is 1 [default = 0]"
echo ""
echo "-l real_label : real PDBTM Topology label file, in three lines [default = null]"
echo ""
echo "-H home : home directory of PDBTM_Topology_Pred.sh "
echo " [default = `dirname $0`] "
echo ""
exit 1
}
if [ $# -lt 1 ];
then
usage
fi
curdir="$(pwd)"
# ----- main directory ---#
util=bin
# ----- get arguments ----- #
#-> required arguments
input=""
input_fasta=""
input_tgt=""
amino_only=0
label_file=""
out_root="./" #-> output to current directory
#-> optional arguments
threshold=""
threshold_ami=0.5
threshold_pro=0.5
Keep_file=0
home=`dirname $0` #-> home directory
#-> parse arguments
while getopts ":i:o:t:k:l:H:" opt;
do
case $opt in
#-> required arguments
i)
input=$OPTARG
;;
#-> optional arguments
o)
out_root=$OPTARG
;;
t)
threshold=$OPTARG
;;
k)
Keep_file=$OPTARG
;;
l)
label_file=$OPTARG
;;
H)
home=$OPTARG
;;
#-> default
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# ------ judge fasta or tgt -------- #
filename=`basename $input`
extension=${filename##*.}
filename=${filename%.*}
if [ "$extension" == "tgt" ]
then
input_tgt=$input
amino_only=0
else
input_fasta=$input
amino_only=1
fi
# ------ check required arguments ------ #
#-> check input_tgt
has_tgt=0
if [ ! -f "$curdir/$input_tgt" ]
then
if [ ! -f "$input_tgt" ]
then
has_tgt=0
else
has_tgt=1
fi
else
input_tgt=$curdir/$input_tgt
has_tgt=1
fi
#-> check input_fasta
has_fasta=0
if [ ! -f "$curdir/$input_fasta" ]
then
if [ ! -f "$input_fasta" ]
then
has_fasta=0
else
has_fasta=1
fi
else
input_fasta=$curdir/$input_fasta
has_fasta=1
fi
# ------ final check ------#
if [ $has_fasta -eq 0 ] && [ $has_tgt -eq 0 ]
then
echo "input_fasta $input_fasta or input_tgt $input_tgt not found" >&2
exit 1
fi
# ------ part 0 ------ # related path
if [ $has_fasta -eq 1 ]
then
fulnam=`basename $input_fasta`
relnam=${fulnam%.*}
fi
if [ $has_tgt -eq 1 ]
then
fulnam=`basename $input_tgt`
relnam=${fulnam%.*}
fi
# ------ check home directory ---------- #
if [ ! -d "$home" ]
then
echo "home directory $home not exist " >&2
exit 1
fi
home=`readlink -f $home`
# ------ check output directory -------- #
mkdir -p $out_root
out_root=`readlink -f $out_root`
# --- create temporary folder --#
DATE=`date '+%Y_%m_%d_%H_%M_%S'`
tmp="${out_root}/TMP_PDBTM_${relnam}_${RANDOM}_${DATE}"
mkdir -p $tmp
# ----- pre process ------ #
rm -f $tmp/$relnam.seq
if [ $has_fasta -eq 1 ]
then
cp $input_fasta $tmp/$relnam.seq
fi
if [ $has_tgt -eq 1 ]
then
cp $input_tgt $tmp/$relnam.tgt
echo ">$relnam" > $tmp/$relnam.seq
head -n4 $tmp/$relnam.tgt | tail -n1 | awk '{print $3}' >> $tmp/$relnam.seq
fi
# ----- main procedure ------ #
program_suc=1
for ((i=0;i<1;i++))
do
# ------------ profile mode ---------- #
if [ $amino_only -eq 0 ]
then
# ----- buildFeature ------ #
if [ ! -f "$tmp/$relnam.tgt" ]
then
echo "please generate TGT file first by TGT_Package for $relnam"
program_suc=0
break
fi
# ----- DeepCNF_SS_Con ----- #
$home/$util/DeepCNF_SS_Con -t $tmp/$relnam.tgt > $tmp/$relnam.ss8
OUT=$?
if [ $OUT -ne 0 ]
then
echo "Failed in generating SS8 file for sequence $relnam"
program_suc=0
break
fi
# ----- generate feature ----- #
if [ "$label_file" == "" ]
then
$home/$util/MemProt_Feat $tmp/$relnam.tgt $tmp/$relnam.ss8 null > $tmp/$relnam.feat_profile
else
$home/$util/MemProt_Feat $tmp/$relnam.tgt $tmp/$relnam.ss8 $label_file > $tmp/$relnam.feat_profile
fi
OUT=$?
if [ $OUT -ne 0 ]
then
echo "Failed in generating feature file (profile mode) for sequence $relnam"
program_suc=0
break
fi
# ----- determine threshold --- #
if [ "$threshold" == "" ]
then
threshold=$threshold_pro
fi
# ------------ amionly mode ---------- #
else
# ----- generate predicted SSE and ACC ----- #
$home/util/runxxxpred_single.sh $tmp/$relnam.seq $tmp $home 1> $tmp/$relnam.ws1 2> $tmp/$relnam.ws2
rm -f $tmp/$relnam.ss $tmp/$relnam.horiz $tmp/$relnam.ws1 $tmp/$relnam.ws2
# ----- generate feature ----- #
if [ "$label_file" == "" ]
then
$home/$util/MemProt_Feat_noprof $tmp/$relnam.seq $tmp/$relnam.ss2 $tmp/$relnam.solv null > $tmp/$relnam.feat_noprof
else
$home/$util/MemProt_Feat_noprof $tmp/$relnam.seq $tmp/$relnam.ss2 $tmp/$relnam.solv $label_file > $tmp/$relnam.feat_noprof
fi
OUT=$?
if [ $OUT -ne 0 ]
then
echo "Failed in generating feature file (no_profile mode) for sequence $relnam"
program_suc=0
break
fi
# ----- determine threshold --- #
if [ "$threshold" == "" ]
then
threshold=$threshold_ami
fi
fi
# ---------- predict order/disorder regions ----------- #
outnam=$relnam.topo
outfeat=$relnam.feat
if [ $amino_only -eq 0 ]
then
$home/$util/DeepCNF_Pred -i $tmp/$relnam.feat_profile -w 5,5,5,5,5 -d 100,100,100,100,100 -s 9 -l 68 -m $home/parameters/MemProt_profile_model > $tmp/$relnam.topo_profile 2> $tmp/$relnam.pred_log2
OUT=$?
if [ $OUT -ne 0 ]
then
echo "Failed in prediction of membrane topology (profile mode )for sequence $relnam"
program_suc=0
break
fi
outnam=$relnam.topo_profile
outfeat=$relnam.feat_profile
else
$home/$util/DeepCNF_Pred -i $tmp/$relnam.feat_noprof -w 5,5,5,5,5 -d 100,100,100,100,100 -s 9 -l 87 -m $home/parameters/MemProt_noprof_model > $tmp/$relnam.topo_noprof 2> $tmp/$relnam.pred_log2
OUT=$?
if [ $OUT -ne 0 ]
then
echo "Failed in prediction of membrane topology (no_profile mode) for sequence $relnam"
program_suc=0
break
fi
outnam=$relnam.topo_noprof
outfeat=$relnam.feat_noprof
fi
# ------ final copy ------ #
cp $tmp/$outnam $out_root
# ------ transform the raw result into DisoPred format ------ #
if [ $amino_only -eq 0 ]
then
$home/$util/TopoPred_Trans $tmp/$relnam.seq $tmp/$outnam $threshold $amino_only 0 > $out_root/$relnam.tm2_profile
$home/$util/TopoPred_Trans $tmp/$relnam.seq $tmp/$outnam $threshold $amino_only 1 > $out_root/$relnam.tm8_profile
else
$home/$util/TopoPred_Trans $tmp/$relnam.seq $tmp/$outnam $threshold $amino_only 0 > $out_root/$relnam.tm2_noprof
$home/$util/TopoPred_Trans $tmp/$relnam.seq $tmp/$outnam $threshold $amino_only 1 > $out_root/$relnam.tm8_noprof
fi
done
#============== output oneline prediction in FASTA format: 0 for non-TM region and 1 for TM region ===============#
if true
then
grep -v "#" $tmp/$outnam | awk '{a=$6;if(a>0.5){printf "1"}else{printf "0"}}END{printf "\n"}' > $tmp/$relnam.topo_simp_helix
grep -v "#" $tmp/$outnam | awk '{b=$5;if(b>0.5){printf "1"}else{printf "0"}}END{printf "\n"}' > $tmp/$relnam.topo_simp_sheet
#-> check for predicted transmembrane region
str1=`tail -n1 $tmp/$relnam.topo_simp_helix`
top1="${str1//[^1]}"
num1=${#top1}
str2=`tail -n1 $tmp/$relnam.topo_simp_sheet`
top2="${str2//[^1]}"
num2=${#top2}
#-> determine helix_type or sheet_type
cat $tmp/$relnam.seq > $tmp/$relnam.topo_simp
if [ $num1 -ge $num2 ]
then
tail -n1 $tmp/$relnam.topo_simp_helix >> $tmp/$relnam.topo_simp
else
tail -n1 $tmp/$relnam.topo_simp_sheet >> $tmp/$relnam.topo_simp
fi
#-> final copy
cp $tmp/$relnam.topo_simp $out_root
fi
# ----- return back ----#
if [ $Keep_file -eq 0 ]
then
rm -rf $tmp/
else
rm -rf $out_root/"TMP_PDBTM_"${relnam}
mv $tmp $out_root/"TMP_PDBTM_"${relnam}
fi
# ---- exit ----- #
if [ $program_suc -ne 0 ]
then
exit 0
else
exit 1
fi