-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvoronota-membrane
executable file
·234 lines (198 loc) · 6.07 KB
/
voronota-membrane
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'voronota-membrane' script provides a way for fitting a membrane
for a protein struture using VoroMQA-based surface frustration analysis.
Options:
--input | -i string * input structure file in PDB or mmCIF format
--input-filter-query string input atoms filtering query, default is ''
--membrane-width number membrane width, default is 30.0
--output-atoms string file to output analyzed atoms with annotations
--output-membraneness-pdb string file to output PDB file with membraneness in b-factors
--output-log string file to output detailed log on calculations
--output-header flag to output header before result line
--help | -h flag to display help message and exit
Standard output (one line):
{input file} {membrane fitting score} {direction x} {direction y} {direction z} {center projection}
EOF
exit 1
}
readonly ZEROARG=$0
if [[ $ZEROARG == *"/"* ]]
then
cd "$(dirname ${ZEROARG})"
export PATH="$(pwd):${PATH}"
cd - &> /dev/null
fi
export LC_ALL=C
command -v voronota &> /dev/null || { echo >&2 "Error: 'voronota' executable not in binaries path"; exit 1; }
command -v voronota-resources &> /dev/null || { echo >&2 "Error: 'voronota-resources' executable not in binaries path"; exit 1; }
command -v jq &> /dev/null || { echo >&2 "Error: 'jq' executable not in binaries path"; exit 1; }
command -v bc &> /dev/null || { echo >&2 "Error: 'bc' executable not in binaries path"; exit 1; }
INFILE=""
INPUT_FILTER_QUERY=""
MEMBRANE_WIDTH="30.0"
OUTPUT_ATOMS=""
OUTPUT_MEMBRANENESS_PDB=""
OUTPUT_LOG=""
OUTPUT_HEADER=false
HELP_MODE=false
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
-i|--input)
INFILE="$OPTARG"
shift
;;
--input-filter-query)
INPUT_FILTER_QUERY="$OPTARG"
shift
;;
--membrane-width)
MEMBRANE_WIDTH="$OPTARG"
shift
;;
--output-atoms)
OUTPUT_ATOMS="$OPTARG"
shift
;;
--output-membraneness-pdb)
OUTPUT_MEMBRANENESS_PDB="$OPTARG"
shift
;;
--output-log)
OUTPUT_LOG="$OPTARG"
shift
;;
--output-header)
OUTPUT_HEADER=true
;;
-h|--help)
HELP_MODE=true
;;
*)
echo >&2 "Error: invalid command line option '$OPTION'"
exit 1
;;
esac
done
if [ -z "$INFILE" ] || $HELP_MODE
then
print_help_and_exit
fi
if [ ! -s "$INFILE" ]
then
echo >&2 "Error: input file does not exist"
exit 1
fi
if [ "$(echo "$MEMBRANE_WIDTH < 6.0" | bc -l)" == "1" ] || [ "$(echo "$MEMBRANE_WIDTH > 100.0" | bc -l)" == "1" ]
then
echo >&2 "Error: membrane width value '$MEMBRANE_WIDTH' not in range (6,100]"
exit 1
fi
readonly TMPLDIR=$(mktemp -d)
trap "rm -r $TMPLDIR" EXIT
voronota-resources radii > "$TMPLDIR/radii"
if [ ! -s "$TMPLDIR/radii" ]
then
echo >&2 "Error: failed to get the predefined atomic radii"
exit 1
fi
{
if [[ "$INFILE" == *".gz" ]]
then
zcat "$INFILE"
else
cat "$INFILE"
fi
} \
| voronota get-balls-from-atoms-file \
--annotated \
--input-format detect \
--radii-file $TMPLDIR/radii \
| voronota query-balls \
--drop-altloc-indicators \
| voronota query-balls $INPUT_FILTER_QUERY \
> $TMPLDIR/balls
if [ ! -s "$TMPLDIR/balls" ]
then
echo >&2 "Error: no atoms in input file '$INFILE'"
exit 1
fi
voronota-resources voromqa_v1_energy_potential > "$TMPLDIR/voromqa_v1_energy_potential"
voronota-resources voromqa_v1_energy_means_and_sds > "$TMPLDIR/voromqa_v1_energy_means_and_sds"
{
cat << EOF
setup-voromqa --potential '$TMPLDIR/voromqa_v1_energy_potential' --means-and-sds '$TMPLDIR/voromqa_v1_energy_means_and_sds'
import -format plain -file $TMPLDIR/balls
construct-contacts
describe-exposure -probe-min 1.4 -probe-max 30.0 -adj-atom-exposure-value buriedness -weight-power 3 -expansion 0.5 -smoothing-iterations 3 -smoothing-depth 1
voromqa-global
voromqa-frustration -adj-atom-frustration-energy-mean frustration -adj-contact-frustration-energy-mean cfem -smoothing-iterations 3 -smoothing-depth 1
voromqa-membrane-place -adj-contact-frustration-value cfem -adj-atom-membrane-place-value membraneness -membrane-width $MEMBRANE_WIDTH -adj-atom-exposure-value buriedness
EOF
if [ -n "$OUTPUT_ATOMS" ]
then
cat << EOF
export-atoms -file $TMPLDIR/result_atoms
EOF
fi
if [ -n "$OUTPUT_MEMBRANENESS_PDB" ]
then
cat << EOF
export-atoms -as-pdb -pdb-b-factor membraneness -file $TMPLDIR/result_membraneness.pdb
EOF
fi
} \
| voronota run-script --exit-on-first-failure --max-unfolding 5 \
> "$TMPLDIR/result_log.txt"
GLOBAL_SUCCESS="$(cat "$TMPLDIR/result_log.txt" | jq -c '.results_summary | .count_successful == .count_all')"
if [ -n "$OUTPUT_LOG" ]
then
if [ "$OUTPUT_LOG" == "-" ]
then
cat >&2 "$TMPLDIR/result_log.txt"
else
cat "$TMPLDIR/result_log.txt" > "$OUTPUT_LOG"
fi
fi
if [ "$GLOBAL_SUCCESS" != "true" ]
then
if [ "$OUTPUT_LOG" != "-" ]
then
cat >&2 "$TMPLDIR/result_log.txt"
fi
echo >&2 "Error: failed to complete all steps, see the log above."
exit 1
fi
if [ -n "$OUTPUT_ATOMS" ] && [ ! -s "$TMPLDIR/result_atoms" ]
then
echo >&2 "Error: failed to output atoms."
exit 1
fi
if [ -n "$OUTPUT_MEMBRANENESS_PDB" ] && [ ! -s "$TMPLDIR/result_membraneness.pdb" ]
then
echo >&2 "Error: failed to output membraneness as PDB file."
exit 1
fi
MEMBRANE_INFO="$(jq -c '.results[] | select(.command_line | contains("voromqa-membrane-place")) | .output' < "$TMPLDIR/result_log.txt")"
MEMBRANE_FITTING_CORE="$(echo "$MEMBRANE_INFO" | jq -c '.best_score')"
DIRECTION="$(echo "$MEMBRANE_INFO" | jq -c '.direction' | tail -1 | tr -d '[' | tr -d ']' | tr ',' ' ')"
CENTER_PROJECTION="$(echo "$MEMBRANE_INFO" | jq -c '.projection_center')"
if $OUTPUT_HEADER
then
echo "input_file membrane_fitting_score direction_x direction_y direction_z center_projection"
fi
echo "$INFILE $MEMBRANE_FITTING_CORE $DIRECTION $CENTER_PROJECTION"
if [ -n "$OUTPUT_ATOMS" ] && [ -s "$TMPLDIR/result_atoms" ]
then
mv "$TMPLDIR/result_atoms" "$OUTPUT_ATOMS"
fi
if [ -n "$OUTPUT_MEMBRANENESS_PDB" ] && [ -s "$TMPLDIR/result_membraneness.pdb" ]
then
mv "$TMPLDIR/result_membraneness.pdb" "$OUTPUT_MEMBRANENESS_PDB"
fi