-
Notifications
You must be signed in to change notification settings - Fork 30
/
DeepAffinity_inference.sh
executable file
·156 lines (146 loc) · 4.81 KB
/
DeepAffinity_inference.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
#!/bin/bash
# POSIX
show_help() {
cat << EOF
Usage: ${0##*/} [-h] [-p|--prot PROTEIN_FILE] [-c|--comp COMPOUND_FILE] [-l|--label LABEL_FILE] [-o|--output OUTPUT_FILE_NAME] [-l|--label LABEL_FILE] [-t|--labeltype LABEL_TYPE] [-m|--checkpoint CHECKPOINT_FILE]
Run the DeepAffinity with given data or run our code with default IC50 dataset.
no argument run with default IC50 dataset
-h display this help and exit
-o|--output OUTPUT_FILE_NAME specify output filename
-p|--prot PROTEIN_SPS_FILE replace test_sps with user's protein sps format file
-c|--comp COMPOUND_SMILE_FILE replace test_smile with user's compound SIMLE format file
-l|--label LABEL_FILE replace test_ic50 with user's label file
-t|--labeltype LABEL_TYPE specify the label type you are using, it can be either IC50(default), EC50, Ki or Kd
-m|--checkpoint CHECKPOINT_FILE test your data by checkpoint
EOF
}
die() {
printf '%s\n' "$1" >&2
exit 1
}
if [ "$#" -eq 0 ]; then
echo "dealing with data"
cp data/dataset/IC50.tar.xz Joint_models/joint_attention/joint_warm_start/data/
cd Joint_models/joint_attention/joint_warm_start/data/
tar -xf IC50.tar.xz
echo "Running default DeepAffinity"
cd ..
python joint-Model.py|tee output
echo "Result has been saved to file ./Joint_models/joint_attention/joint_warm_start/output"
elif [ "$#" -eq 2 ]; then
output=$2
echo "dealing with data"
cp data/dataset/IC50.tar.xz Joint_models/joint_attention/joint_warm_start/data/
cd Joint_models/joint_attention/joint_warm_start/data/
tar -xf IC50.tar.xz
echo "Running default DeepAffinity"
cd ..
python joint-Model.py|tee $output
echo "Result has been saved to file ./Joint_models/joint_attention/joint_warm_start/$output"
else
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit
;;
-m|--checkpoint)
if [ "$2" ]; then
checkpoint=$2
shift
else
die 'ERROR: "--checkpoint" requires a non-empty option argument.'
fi
;;
-p|--prot)
if [ "$2" ]; then
prot=$2
shift
else
die 'ERROR: "--prot" requires a non-empty option argument.'
fi
;;
-c|--comp)
if [ "$2" ]; then
comp=$2
shift
else
die 'ERROR: "--comp" requires a non-empty option argument.'
fi
;;
-l|--label)
if [ "$2" ]; then
label=$2
shift
else
die 'ERROR: "--label" requires a non-empty option argument.'
fi
;;
-o|--output)
if [ "$2" ]; then
output=$2
shift
else
die 'ERROR: "--output" requires a non-empty option argument.'
fi
;;
-t|--labeltype)
if [ "$2" ]; then
labeltype=$2
shift
else
die 'ERROR: "--labeltype" requires a non-empty option argument.'
fi
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
;;
*)
break
esac
shift
done
if ! [ -v output ]; then
output="./output"
fi
if ! [ -v labeltype ]; then
labeltype="IC50"
fi
if ! [ "$labeltype" = "IC50" ] && ! [ "$labeltype" = "EC50" ] && ! [ "$labeltype" = "Ki" ] && ! [ "$labeltype" = "Kd" ]; then
die 'ERROR: labeltype can only be "IC50", "EC50", "Ki" or "Kd".'
fi
num1=$(cat $prot|wc -l)
num2=$(cat $comp|wc -l)
if ! [ $num1 -eq $num2 ]; then
die 'Error! Different Number of lines in $prot and $comp'
fi
if [ -v checkpoint ]; then
checkpoint_filename="$(basename -- $checkpoint)"
model_path="./Joint_models/joint_attention/testing/"
file_name="joint-Model_test.py"
if ! [ -f $model_path${checkpoint_filename}.meta ]; then
cp ${checkpoint}.* $model_path
fi
else
model_path="./Joint_models/joint_attention/joint_warm_start/"
file_name="joint-Model.py"
fi
echo "dealing with data"
tar -xf ./data/dataset/${labeltype}.tar.xz
cp $prot ./${labeltype}/SPS/test_sps
cp $comp ./${labeltype}/SPS/test_smile
if [ -v label ]; then
cp $label ./${labeltype}/SPS/test_ic50
fi
cp ./${labeltype}/SPS/* ${model_path}data/
rm -r ./${labeltype}
rm ${model_path}data/*.ids*
echo "Running default DeepAffinity"
cd ${model_path}
if [ -v label ]; then
python ${file_name} $checkpoint_filename $labeltype|tee $output
else
python joint-Model_predict.py $checkpoint_filename |tee $output
fi
echo "Output has been saved to file ${model_path}${output}"
fi