-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathftdmp-form-casp15-assembly-answer
executable file
·126 lines (103 loc) · 2.21 KB
/
ftdmp-form-casp15-assembly-answer
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-form-casp15-assembly-answer' generates an assembly answer for CASP15
Options:
--target-name string * TARGET line value
--author-id string * AUTHOR line value
--method-line string METHOD line value, default is 'Various methods'
--help | -h flag to display help message and exit
Standard input:
model file paths
Standard output:
CASP15 assembly answer file
Example:
find ./selected_models/ -type f -name '*.pdb' | sort \
| ftdmp-form-casp15-assembly-answer --target-name 'T1999' --author-id '1234-5678-9000'
EOF
exit 1
}
################################################################################
if [ -z "$1" ]
then
print_help_and_exit
fi
TARGET_NAME=""
AUTHOR_ID=""
METHOD_LINE="Various methods"
HELP_MODE="false"
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
--target-name)
TARGET_NAME="$OPTARG"
shift
;;
--author-id)
AUTHOR_ID="$OPTARG"
shift
;;
--method-line)
METHOD_LINE="$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 "$TARGET_NAME" ]
then
echo >&2 "Error: target name not specified"
exit 1
fi
if [ -z "$AUTHOR_ID" ]
then
echo >&2 "Error: author ID not specified"
exit 1
fi
################################################################################
readonly TMPLDIR=$(mktemp -d)
trap "rm -r $TMPLDIR" EXIT
cat \
| tr ' ' '\n' \
| egrep '.' \
> "$TMPLDIR/models_list"
if [ ! -s "$TMPLDIR/models_list" ]
then
echo >&2 "Error: no model files specified"
exit 1
fi
while read -r MFILE
do
if [ ! -s "$MFILE" ] || [ "$(cat ${MFILE} | egrep '^ATOM ' | wc -l)" -lt "1" ]
then
echo >&2 "Error: invalid model file '$MFILE'"
exit 1
fi
done < "$TMPLDIR/models_list"
echo "PFRMAT TS"
echo "TARGET ${TARGET_NAME}"
echo "AUTHOR ${AUTHOR_ID}"
echo "METHOD $METHOD_LINE"
cat "$TMPLDIR/models_list" \
| awk '{print NR " " $1}' \
| while read -r MNUM MFILE
do
echo "MODEL ${MNUM}"
echo "PARENT N/A"
cat "$MFILE" | egrep '^ATOM |^TER'
echo "END"
done