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