-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftdmp-build-complex
executable file
·149 lines (119 loc) · 3.26 KB
/
ftdmp-build-complex
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-build-complex' generates structure files from docking results
Options:
--monomer1 string * monomer 1 input file path
--monomer2 string * monomer 2 input file path
--output-prefix string * output file path prefix, default is ''
--output-suffix string output file path prefix, default is '.pdb'
--help | -h flag to display help message and exit
Standard input:
space-separated table of docking results
Standard output:
space-separated table of docking results
Example:
cat docking_results_table.txt | head -5 | ftdmp-build-complex --monomer1 monomer1.pdb --monomer2 monomer2.pdb --output-prefix complexes/
EOF
exit 1
}
if [ -z "$1" ]
then
print_help_and_exit
fi
if [ -z "$FTDMPDIR" ]
then
export FTDMPDIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
export PATH="${FTDMPDIR}/core/voronota/expansion_js:${FTDMPDIR}:${PATH}"
fi
command -v voronota-js &> /dev/null || { echo >&2 "Error: 'voronota-js' executable not in binaries path"; exit 1; }
MONOMERFILE1=""
MONOMERFILE2=""
OUTPUT_PREFIX=""
OUTPUT_SUFFIX=".pdb"
HELP_MODE="false"
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
--monomer1)
MONOMERFILE1="$OPTARG"
shift
;;
--monomer2)
MONOMERFILE2="$OPTARG"
shift
;;
--output-prefix)
OUTPUT_PREFIX="$OPTARG"
shift
;;
--output-suffix)
OUTPUT_SUFFIX="$OPTARG"
shift
;;
-h|--help)
HELP_MODE="true"
;;
*)
echo >&2 "Error: invalid command line option '$OPTION'"
exit 1
;;
esac
done
if [ "$HELP_MODE" == "true" ]
then
print_help_and_exit
fi
if [ -z "$MONOMERFILE1" ]
then
echo >&2 "Error: no static input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE1" ]
then
echo >&2 "Error: no static input file '$MONOMERFILE1'"
exit 1
fi
if [ -z "$MONOMERFILE2" ]
then
echo >&2 "Error: no static input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE2" ]
then
echo >&2 "Error: no mobile input file '$MONOMERFILE2'"
exit 1
fi
readonly TMPLDIR=$(mktemp -d)
trap "rm -r $TMPLDIR" EXIT
cat > "${TMPLDIR}/input"
if [ ! -s "${TMPLDIR}/input" ]
then
echo >&2 "Error: no input data in stdin"
exit 1
fi
mkdir -p "${TMPLDIR}/docklines"
cd "${TMPLDIR}/docklines"
cat ../input \
| awk -v m1="$MONOMERFILE1" -v m2="$MONOMERFILE2" -v prefix="$OUTPUT_PREFIX" -v suffix="$OUTPUT_SUFFIX" -v q="'" \
'{
if($1!="ID")
{
print "voronota_import_docking_result(\"-include-hydrogens -static-file " q m1 q " -mobile-file " q m2 q " -generic-transform " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 " " $12 " " $13 " " $14 " " $15 "\"); voronota_assert_full_success(\"Failed to import docking results for ID " $1 "\"); outfile=" q prefix $1 suffix q "; voronota_export_atoms(\"-as-pdb -file \"+outfile); voronota_assert_full_success(\"Failed to write file \"+outfile); writeln(outfile);" > $1;
}
}'
cd - &> /dev/null
mkdir -p "$(dirname "${OUTPUT_PREFIX}name${OUTPUT_SUFFIX}")"
find "${TMPLDIR}/docklines" -type f -not -empty \
| xargs -L 1 -P 1 voronota-js --no-setup-defaults \
> "${TMPLDIR}/output_file_paths"
if [ ! -s "${TMPLDIR}/output_file_paths" ]
then
echo >&2 "Error: no files generated"
exit 1
fi
cat "${TMPLDIR}/input"