-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_energygrp.sh
executable file
·126 lines (107 loc) · 3.42 KB
/
gen_energygrp.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
#!/bin/bash
# generate energygrps and energygrp_table variables for .mdp file.
# Append script output to .mdp file.
# do not include SC - SC (they use the generic table.xvg).
# read in 1 letter-code sequence to determine list of interactions.
#
# Optional:
# -no_lipid: don't include lipid parameters
#
# name of amino acids.
# Special 1-letter codes:
# - Z corresponds to end cap (CAP);
# - B: Arginine (+);
# - J: Aspartic acid (-);
# - O: Glutamic acid (-);
# - U: Lysine (+);
die() {
echo $@
exit 1
}
flag_lipid=0
[ -z $1 ] && die "Missing sequence file"
for (( c=1; c<=$#; c++ )); do
eval arg=\$$c
d=`echo "$c + 1" | bc -l`
eval argn=\$$d
if [ $arg == "-no_lipid" ]; then
flag_lipid=1
else
seq_file=$arg
fi
done
seq_lines=`cat $seq_file | wc -l`
list_lipid=(CH PH GL ES AS AD AE)
list_pep_bb=(N C)
list3aa=(ALA ARG0 ARGP ASN ASP0 ASPM CYS GLN GLU0 GLUM GLY HIS ILE LEU LYS0 LYSP MET PHE PRO SER THR TRP TYR VAL CAP)
list1aa=(A R B N D J C Q E O G H I L K U M F P S T W Y V Z )
seq_aa=()
for (( l=1; l<=$seq_lines; ++l )); do
seq_length=`head -n $l $seq_file | tail -1 | wc -c`
seq=`head -n $l $seq_file | tail -1`
for (( i=0; i<$seq_length; ++i )); do
letter=${seq:$i:1}
if [ "$letter" != "" ] && [ "$letter" != " " ] && [ "$letter" != "\n" ]; then
seq_index=-1
for (( j=0; j<${#list1aa[@]}; ++j )); do
[ "$letter" == "${list1aa[$j]}" ] && seq_index=$j
done
[ "$seq_index" == "-1" ] && die "Amino acid code $letter is unrecognized."
# if the residue hasn't been added to the list yet, add it now
res_in_list=0
for (( k=0; k<${#seq_aa[@]}; ++k )); do
[ "${seq_aa[$k]}" == "$seq_index" ] && res_in_list=1
done
# Exclude GLY
[ "$res_in_list" == "0" ] && [ "$seq_index" != "10" ] \
&& seq_aa=( ${seq_aa[@]-} $seq_index )
fi
done
done
n_list_lipid=${#list_lipid[@]}
n_laa=${#list3aa[@]}
echo -ne "energygrps = "
if [ $flag_lipid == 0 ]; then
for ((i=0;i<$n_list_lipid;++i)); do
echo -ne "${list_lipid[$i]} ";
done;
fi
# backbone
for (( k=0; k<${#list_pep_bb[@]}; ++k)); do
echo -ne "${list_pep_bb[$k]} ";
done;
# side chains
for (( k=0; k<${#seq_aa[@]}; ++k )); do
echo -ne "${list3aa[${seq_aa[$k]}]} ";
done;
echo -ne "\nenergygrp_table = "
if [ $flag_lipid == 0 ]; then
for ((i=0;i<$n_list_lipid;++i)); do
for ((j=$i;j<$n_list_lipid;++j)); do
echo -ne "${list_lipid[$i]} ${list_lipid[$j]} ";
done;
done;
for ((i=0;i<$n_list_lipid;++i)); do
for (( k=0; k<${#seq_aa[@]}; ++k )); do
echo -ne "${list3aa[${seq_aa[$k]}]} ${list_lipid[$i]} ";
done;
done;
for ((i=0;i<$n_list_lipid;++i)); do
for (( k=0; k<${#list_pep_bb[@]}; ++k )); do
echo -ne "${list_pep_bb[$k]} ${list_lipid[$i]} ";
done;
done;
fi
# backbone backbone
for ((i=0;i<${#list_pep_bb[@]};++i)); do
for (( k=$i; k<${#list_pep_bb[@]}; ++k)); do
echo -ne "${list_pep_bb[$k]} ${list_pep_bb[$i]} ";
done;
done;
# backbone sidechain
for ((i=0;i<${#seq_aa[@]};++i)); do
for (( k=0; k<${#list_pep_bb[@]}; ++k)); do
echo -ne "${list_pep_bb[$k]} ${list3aa[${seq_aa[$i]}]} ";
done;
done;
echo ""