1
2
3
4
5
6 """
7 Module to represent the NDB Atlas structure (a minimal subset of PDB format).
8
9 Hetero, Crystal and Chain exist to represent the NDB Atlas structure. Atlas
10 is a minimal subset of the PDB format. Heteo supports a 3 alphameric code.
11 The NDB web interface is located at http://ndbserver.rutgers.edu/NDB/index.html
12 """
13
14 import copy
15
18
20 output = ''
21 for i in range(0, len(line), 80):
22 output = output + '%s\n' % line[ i: i + 80 ]
23 return output
24
26 if type(key) != type(''):
27 raise CrystalError('chain requires a string label')
28 if len(key) != 1:
29 raise CrystalError('chain label should contain one letter')
30
32 """
33 This class exists to support the PDB hetero codes.
34
35 Supports only the 3 alphameric code.
36 The annotation is available from http://alpha2.bmc.uu.se/hicup/
37 """
50
53
55 """Returns true iff self is not equal to other."""
56 return not self.__eq__(other)
57
59 return "%s" % self.data
60
62 return "%s" % self.data
63
65
84
89
91 if not isinstance(element, Hetero):
92 raise TypeError
93
95 output = ''
96 i = 0
97 for element in self.data:
98 output = output + '%s ' % element
99 output = output.strip()
100 output = wrap_line(output)
101 return output
102
103
105 if len(self.data) != len(other.data):
106 return 0
107 ok = reduce(lambda x, y: x and y, map(lambda x, y: x == y, self.data, other.data))
108 return ok
109
111 """Returns true iff self is not equal to other."""
112 return not self.__eq__(other)
113
115
117 if isinstance(index, int):
118 return self.data[index]
119 elif isinstance(index, slice):
120 return self.__class__(self.data[index])
121 else:
122 raise TypeError
123
142
145
152
159
166
170
177
184
192
200
209
217
219 data = self.data
220 for key in data:
221 element = data[key]
222 if isinstance(element, Chain):
223 pass
224 elif type(element) == type(''):
225 data[key] = Chain(element)
226 else:
227 raise TypeError
228
230 output = ''
231 keys = self.data.keys()
232 keys.sort()
233 for key in keys:
234 output = output + '%s : %s\n' % (key, self.data[ key ])
235 return output
236
238 output = ''
239 keys = self.data.keys()
240 keys.sort()
241 for key in keys:
242 output = output + '%s : %s\n' % (key, self.data[ key ])
243 return output
244
247
251 if isinstance(item, Chain):
252 self.data[key] = item
253 elif type(item) == type(''):
254 self.data[ key ] = Chain(item)
255 else:
256 raise TypeError
257
267 - def get(self, key, failobj=None):
268 return self.data.get(key, failobj)
270 if key not in self.data:
271 self.data[key] = failobj
272 return self.data[key]
275