1
2
3
4
5
6
7 import numpy
8
9
10 from Entity import DisorderedEntityWrapper
11 from Vector import Vector
12
13 __doc__="Atom class, used in Structure objects."
14
16 - def __init__(self, name, coord, bfactor, occupancy, altloc, fullname, serial_number):
17 """
18 Atom object.
19
20 The Atom object stores atom name (both with and without spaces),
21 coordinates, B factor, occupancy, alternative location specifier
22 and (optionally) anisotropic B factor and standard deviations of
23 B factor and positions.
24
25 @param name: atom name (eg. "CA"). Note that spaces are normally stripped.
26 @type name: string
27
28 @param coord: atomic coordinates (x,y,z)
29 @type coord: Numeric array (Float0, size 3)
30
31 @param bfactor: isotropic B factor
32 @type bfactor: number
33
34 @param occupancy: occupancy (0.0-1.0)
35 @type occupancy: number
36
37 @param altloc: alternative location specifier for disordered atoms
38 @type altloc: string
39
40 @param fullname: full atom name, including spaces, e.g. " CA ". Normally
41 these spaces are stripped from the atom name.
42 @type fullname: string
43 """
44 self.level="A"
45
46 self.parent=None
47
48 self.name=name
49 self.fullname=fullname
50 self.coord=coord
51 self.bfactor=bfactor
52 self.occupancy=occupancy
53 self.altloc=altloc
54 self.full_id=None
55 self.id=name
56 self.disordered_flag=0
57 self.anisou_array=None
58 self.siguij_array=None
59 self.sigatm_array=None
60 self.serial_number=serial_number
61
62 self.xtra={}
63
64
65
67 "Print Atom object as <Atom atom_name>."
68 return "<Atom %s>" % self.get_id()
69
71 """
72 Calculate distance between two atoms.
73
74 Example:
75 >>> distance=atom1-atom2
76
77 @param other: the other atom
78 @type other: L{Atom}
79 """
80 diff=self.coord-other.coord
81 return numpy.sqrt(numpy.dot(diff,diff))
82
83
84
87
90
93
96
98 self.occupancy=occupancy
99
101 """
102 Set standard deviation of atomic parameters.
103
104 The standard deviation of atomic parameters consists
105 of 3 positional, 1 B factor and 1 occupancy standard
106 deviation.
107
108 @param sigatm_array: standard deviations of atomic parameters.
109 @type sigatm_array: Numeric array (length 5)
110 """
111 self.sigatm_array=sigatm_array
112
114 """
115 Set standard deviations of anisotropic temperature factors.
116
117 @param siguij_array: standard deviations of anisotropic temperature factors.
118 @type siguij_array: Numeric array (length 6)
119 """
120 self.siguij_array=siguij_array
121
123 """
124 Set anisotropic B factor.
125
126 @param anisou_array: anisotropic B factor.
127 @type anisou_array: Numeric array (length 6)
128 """
129 self.anisou_array=anisou_array
130
131
132
133
135 """Set the disordered flag to 1.
136
137 The disordered flag indicates whether the atom is disordered or not.
138 """
139 self.disordered_flag=1
140
142 "Return the disordered flag (1 if disordered, 0 otherwise)."
143 return self.disordered_flag
144
146 """Set the parent residue.
147
148 Arguments:
149 o parent - Residue object
150 """
151 self.parent=parent
152
154 "Remove reference to parent."
155 self.parent=None
156
158 "Return standard deviation of atomic parameters."
159 return self.sigatm_array
160
162 "Return standard deviations of anisotropic temperature factors."
163 return self.siguij_array
164
166 "Return anisotropic B factor."
167 return self.anisou_array
168
170 "Return parent residue."
171 return self.parent
172
174 return self.serial_number
175
177 "Return atom name."
178 return self.name
179
181 "Return the id of the atom (which is its atom name)."
182 return self.id
183
185 """Return the full id of the atom.
186
187 The full id of an atom is the tuple
188 (structure id, model id, chain id, residue id, atom name, altloc).
189 """
190 return self.parent.get_full_id()+((self.name, self.altloc),)
191
193 "Return atomic coordinates."
194 return self.coord
195
197 "Return B factor."
198 return self.bfactor
199
201 "Return occupancy."
202 return self.occupancy
203
205 "Return the atom name, including leading and trailing spaces."
206 return self.fullname
207
209 "Return alternative location specifier."
210 return self.altloc
211
214
231
233 """
234 Return coordinates as Vector.
235
236 @return: coordinates as 3D vector
237 @rtype: Vector
238 """
239 x,y,z=self.coord
240 return Vector(x,y,z)
241
242
244 """
245 This class contains all Atom objects that represent the same disordered
246 atom. One of these atoms is "selected" and all method calls not caught
247 by DisorderedAtom are forwarded to the selected Atom object. In that way, a
248 DisorderedAtom behaves exactly like a normal Atom. By default, the selected
249 Atom object represents the Atom object with the highest occupancy, but a
250 different Atom object can be selected by using the disordered_select(altloc)
251 method.
252 """
260
261
262
264 return "<Disordered Atom %s>" % self.get_id()
265
279