3
if ! which amberparm_mass_to_lt.py > /dev/null; then
4
echo "\nError: \"amberparm_mass_to_lt.py\" not found. (Update your PATH?)\n" >&2
7
if ! which amberparm_pair_to_lt.py > /dev/null; then
8
echo "\nError: \"amberparm_pair_to_lt.py\" not found. (Update your PATH?)\n" >&2
11
if ! which amberparm_bond_to_lt.py > /dev/null; then
12
echo "\nError: \"amberparm_bond_to_lt.py\" not found. (Update your PATH?)\n" >&2
15
if ! which amberparm_angle_to_lt.py > /dev/null; then
16
echo "\nError: \"amberparm_angle_to_lt.py\" not found. (Update your PATH?)\n" >&2
19
if ! which amberparm_dihedral_to_lt.py > /dev/null; then
20
echo "\nError: \"amberparm_dihedral_to_lt.py\" not found. (Update your PATH?)\n" >&2
23
if ! which amberparm_improper_to_lt.py > /dev/null; then
24
echo "\nError: \"amberparm_improper_to_lt.py\" not found. (Update your PATH?)\n" >&2
28
SYNTAX_MSG=$(cat <<EOF
31
amberparm2lt.sh gaff.dat GAFF > gaff.lt
34
amberparm2lt.sh parm94.dat "AMBERFF94 inherits GAFF" > amberff94.lt
35
(However, this later usage may not work.
36
You may need to manually split the .dat file and run these scripts instead:
37
amberparm_pair_to_lt.py, amberparm_bond_to_lt.py, amberparm_angle_to_lt.py...)
38
Be sure that all of these .py files are in your PATH as well.)
43
if [ "$#" != "2" ]; then
44
echo "${SYNTAX_MSG}" >&2
46
echo "Error: This script requires two arguments," >&2
47
echo " 1) the name of the amber parm file to be converted (eg \"gaff.dat\")" >&2
48
echo " 2) the name of the moltemplate object to be created (eg \"GAFF\")" >&2
49
echo " (This may include the \"inherits\" keyword and parent classes.)" >&2
53
MOLTEMPLATE_USAGE_MSG=$(cat <<EOF
54
# Background information and usage explanation:
55
# This file contanis a list of atom types and rules for generating bonded
56
# interactions between these atoms (hopefully) according to AMBER conventions.
57
# By using the atom types shown below in your own molecules, bonds and angular
58
# interactions will be automatically generated.
59
# AMBER (GAFF) force-field parameters will also be assigned to each angle
60
# interaction (according to these atom types).
61
# One way to apply the GAFF force field to a particular type of molecule, is
62
# to use the "inherits" keyword when you define that molecule. For example:
64
# MoleculeType inherits GAFF {
65
# write_once("Data Atoms") {
66
# \$atom:C1 \$mol:... @atom:cx 0.0 4.183 3.194 13.285
67
# \$atom:C2 \$mol:... @atom:cx 0.0 4.291 4.618 13.382
71
#(See "Inheritance" and "short names vs. full names" in the moltemplate manual.)
74
# (Note that the full name of the atom type in this example is "@atom:/GAFF/cx"
75
# You can always refer to atom types this way as well. Using "inherits GAFF"
76
# allows you to use more conventient "@atom:cx" shorthand notation instead.)
78
echo "####################################################################"
79
echo "# To use this, LAMMPS currently must be compiled with the USER-MISC package."
80
echo "# (Type \"make yes-user-misc\" into the shell before compiling LAMMPS.)"
81
echo "####################################################################"
82
echo "# This moltemplate (LT) file was generated automatically using"
83
echo "# amberparm2lt.sh $1 $2"
84
echo "####################################################################"
85
echo "$MOLTEMPLATE_USAGE_MSG"
86
echo "####################################################################"
87
echo "# Moltemplate can not assign atom charge. You must assign atomic"
88
echo "# charges yourself. (Moltemplate is only a simple text manipulation tool.)"
89
echo "####################################################################"
97
# sections are separated by blank lines
98
# some sections have comment lines at the beginning
100
# The 1st section is the mass (note: skip the first line)
101
tail -n +2 < "$PARM_FILE" | \
102
awk -v n=1 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
103
> "${PARM_FILE}.mass"
105
# The 2nd section has the list of 2-body bond force-field params
106
awk -v n=2 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
109
> "${PARM_FILE}.bond"
111
# The 3rd section has the list of 3-body angle force-field params
112
awk -v n=3 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
114
> "${PARM_FILE}.angle"
116
# The 4th section has the list of 4-body dihedral force-field params
117
awk -v n=4 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
119
> "${PARM_FILE}.dihedral"
121
# The 5th section has the list of 4-body improper force-field params
122
awk -v n=5 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
124
> "${PARM_FILE}.improper"
126
# The 6th section has the hbond-parameters (no-longer used. ignore)
127
awk -v n=6 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
129
> "${PARM_FILE}.hbond"
131
# The 7th "section" is just a blank line. (skip that)
133
# The 8th section has the list of non-bonded ("pair") force-field parameters
134
awk -v n=8 '{if (NF==0) nblanks++; else {if (nblanks+1==n) print $0}}' \
137
> "${PARM_FILE}.pair"
140
amberparm_mass_to_lt.py < "${PARM_FILE}.mass" > "${PARM_FILE}.mass.lt"
141
amberparm_pair_to_lt.py < "${PARM_FILE}.pair" > "${PARM_FILE}.pair.lt"
142
amberparm_bond_to_lt.py < "${PARM_FILE}.bond" > "${PARM_FILE}.bond.lt"
143
amberparm_angle_to_lt.py < "${PARM_FILE}.angle" > "${PARM_FILE}.angle.lt"
144
amberparm_dihedral_to_lt.py \
145
< "${PARM_FILE}.dihedral" > "${PARM_FILE}.dihedral.lt"
146
amberparm_improper_to_lt.py \
147
< "${PARM_FILE}.improper" > "${PARM_FILE}.improper.lt"
151
echo " # ----------------------------------------------------------------------"
152
#echo " # This file was automatically generated by \"common/amber/amberparm2lt.sh\""
153
echo " # The basic atom nomenclature and conventions are explained here:"
154
echo " # http://ambermd.org/antechamber/gaff.pdf"
155
echo " # For reference, the original gaff.dat file and format documenation are here:"
156
echo " # http://ambermd.org/AmberTools-get.html"
157
echo " # http://ambermd.org/formats.html#parm.dat"
158
echo " # ----------------------------------------------------------------------"
161
cat "$PARM_FILE.mass.lt" \
162
"$PARM_FILE.pair.lt" \
163
"$PARM_FILE.bond.lt" \
164
"$PARM_FILE.angle.lt" \
165
"$PARM_FILE.dihedral.lt" \
166
"$PARM_FILE.improper.lt"
168
AMBER_STYLES_INIT=$(cat <<EOF
170
write_once("In Init") {
171
# Default styles and settings for AMBER based force-fields:
174
bond_style hybrid harmonic
175
angle_style hybrid harmonic
176
dihedral_style hybrid fourier
177
improper_style hybrid cvff
178
pair_style hybrid lj/charmm/coul/long 9.0 10.0 10.0
179
kspace_style pppm 0.0001
180
# If long-range coulombic forces are not needed, replace the previous two
181
# lines with "pair_style hybrid lj/charmm/coul/charmm 9.0 10.0 10.0"
182
pair_modify mix arithmetic
188
echo "$AMBER_STYLES_INIT"