-
Notifications
You must be signed in to change notification settings - Fork 8
/
readparm.README
167 lines (126 loc) · 8.93 KB
/
readparm.README
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
This is a document describing how the "readparm.py" python module.
Introduction:
This module, when imported into a python script/session, gives access
to AMBER prmtop manipulations. See the available functions and object
variables for instructions on use.
CONTAINS:
Classes:
** To create an instance of a class, assign it to a variable with
"variable = className(arguments)"
o amberParm(prm_name): This creates an amberParm object. For example,
to create an amberParm object in the variable "parm" using the "prmtop"
file, use the following command: parm = amberParm("prmtop")
Functions:
** These are functions intrinsic to each specified class. Therefore, it
only makes sense to invoke these functions with one of the associated
objects. The objects associated with each function is indicated in
brackets for each function. For example, if you want to perform some function
"func" on object "obj" with argument "arg", use the following command:
obj.func(arg)
o __init__(prm_name, <restart/inpcrd>) [amberParm]: The initialization routine called
automatically when an amberParm object is instantiated. You should never actually call
this.
o ptr(pointer) [amberParm]: Returns the value of the passed pointer. Example pointers
are "natom" and "nres". Passing an incorrect pointer to this functions returns a
list of valid pointers. The argument is case-INsensitive. returns value of pointer
or -1 in case of error
o rdparm() [amberParm]: Reads the prmtop and loads all of the data into the data
arrays and dictionaries. This is called automatically in __init__ when an amberParm
object is instantiated, but it can be re-called to replace all data with a fresh
copy from the original prmtop anytime.
o writeParm(new_prmtop_name) [amberParm]: Writes a new AMBER prmtop file from the
current prmtop data in the object. Useful if you change, eg. charges, masses, etc.
and want to write out a new prmtop file. By default it will not overwrite the
original prmtop file. See "overwrite" in Variables below to change this behavior.
o totMass() [amberParm]: Calculates the mass of the whole prmtop as a sum of all masses
in the "MASS" section
o totCharge() [amberParm]: Calculates the net charge of the whole prmtop as a sum of all
charges in the "CHARGE" section.
o frcmod({frcmod}) [amberParm]: frcmod default name is "frcmod". This function will take
the prmtop object and extract all of the parameters in it, dumping it in an "frcmod"-
format file to the file passed to the function. If no file is passed, it will write to
the file "frcmod".
o fill_LJ() [amberParm]: This will take the Lennard Jones ACOEFF and BCOEFF and calculate
the well depth and VDW radii (i.e. that's found in amber parameter files). This is called
automatically in __init__ if there were no errors in rdparm() and assigning pointers. This
array is indexed by (self.parm_data['ATOM_TYPE_INDEX'][i]-1); the -1 is there because python
indexes start from 0 instead of 1. Thus, to get the radius and well depth of a given atom i,
use the indices of parm_data['ATOM_TYPE_INDEX'][i]-1 in LJ_radius and LJ_depth.
o recalculate_LJ() [amberParm]: This function will take the VDW well depths and radii and
fill in the LENNARD_JONES_(A/B)COEF arrays using the normal combining rules.
o LoadRst7(filename) [amberParm]: This function will load the info from restart/inpcrd
<filename> and load the appropriate data structures for that.
o writeOFF(off_file) [amberParm]: This function will write an OFF file from the given prmtop
with every residue in it. You need to load a restart/inpcrd in order to use this function.
Variables:
** Each instance of the object has its own set of the variables listed below. The class
associated with each variable is indicated in brackets. The type of variable that it
is is specified in curly braces right before that. Access the variable through the
object. For example, accessing variable "var" from object "obj" is done with the
following syntax: obj.var
o formats {Dictionary} [amberParm]: Lists all of the fortran format strings for each
section of the prmtop file. Each format can be accessed via the case-sensitive name
of the FLAG name. For example, the format of the numbers in the CHARGE section is
accessed via "formats['CHARGE']" (notice the quotes). To access this format in an object
"obj", use the following syntax: obj.formats["CHARGE"]
o parm_data {Dictionary} [amberParm]: Lists all of the data in the topology file split
up by section. The data in each section is stored in an array accessed in a manner
identical to the way formats are accessed above. For example, the charge of the first
atom of the system is stored in "parm_data['CHARGE'][0]". To access this value in an
object "obj", use the following syntax: obj.parm_data["CHARGE"][0]
o flag_list {Array} [amberParm]: Lists all of the flags in the order in which they appear
in the original prmtop file. These can all be used as keys to access data in formats
and parm_data described above.
o version {String} [amberParm]: Version string for each prmtop file. Contains the version
of the prmtop file as well as the time and date of its creation. Typically the first line
of each prmtop file. The time/date is changed by writeParm to the time at which writeParm
was called. It can be reset to the original (along with everything else) using the rdparm
function.
o prm_name {String} [amberParm]: Name of the prmtop file. It has to exist. If you change the
name, you'll have to re-run rdparm to load the data from that prmtop into the object.
o overwrite {Logical} [amberParm]: Logical that controls whether (True) or not (False)
writeParm will write a prmtop to the file with the name prm_name, overwriting the
original. Default is "False". Do not use quotes setting this variable. To allow over-
writing for object "obj", use the following command: obj.overwrite = True
o exists {Logical} [amberParm]: Logical that provides an easy test to see whether the prm_name
passed to amberParm was found or not. This is set to True in rdparm if an exception is not
raised trying to open the file. This is NOT meant to be changed by hand.
o pointers {Dictionary} [amberParm]: Dictionary that holds all of the pointers in the POINTERS
section of the prmtop file. The keys are the case-sensitive, upper-case variables used in
the AMBER programs. The ptr(pointer) function, described above, was meant to access this
dictionary, as it gives better error messages and removes case sensitivity, so it's suggested
that you use that function to access the values of the POINTERS rather than this dictionary
explicitly.
o LJ_type: Dictionary that maps AMBER_ATOM_TYPE to the type index from flag ATOM_TYPE_INDEX. The
only reason to use this instead of ATOM_TYPE_INDEX directly is if you have the ATOM_TYPE on hand
and *not* just the atom index.
o LJ_radius: LJ Radius of given atom type. It only fills in according to canonical AMBER combining
rules for now.
o LJ_depth: LJ well depths of a given atom type. It only fills in according to canonical AMBER
combining rules for now.
o rst7: A restart class loaded on top of the topology file that provides box info, coordinates,
and velocities (based on what is present in the restart file given when this class is instantiated)
o coords: Coordinates of each atom in [x1, y1, z1, x2, y2, z2, ..., xN, yN, zN] format. Only exists if
a restart file was loaded
o hasvels: If this object has velocities
o hasbox: If this object has a box
o vels: Velocities; only present if a restart was loaded and if hasvels is True
o box: Box dimensions/angles; only present if a restart was loaded and if hasbox is True
NOTES:
The charges in AMBER topology files are electron-charges multiplied by a factor of 18.2223. However,
this multiplicative factor is automatically removed in rdparm() and re-added before being written
again in writeParm(), and again removed after it's written. Therefore, only deal with charges in
terms of electron-charges when manipulating charges in amberParm objects.
EXAMPLE OF USE
The following python program will take an AMBER topology named "prmtop" and change the charge of the first
atom to -0.9. It will then print out the change that it made to the screen and write a new prmtop file
named "new.prmtop"
"""
from chemistry.amber.readparm import amberParm
prm = amberParm("prmtop")
orig_charge = prm.parm_data["CHARGE"][0]
prm.parm_data["CHARGE"][0] = -0.9
new_charge = prm.parm_data["CHARGE"][0]
prm.writeParm("new.prmtop")
print 'Charge changed from %s to %s' % (orig_charge, new_charge)
"""