1
2
3
4
5
6 """
7 Hetero, Crystal and Chain exist to represent the NDB Atlas structure. Atlas is a minimal
8 subset of the PDB format. Heteo supports a 3 alphameric code.
9 The NDB web interface is located at http://ndbserver.rutgers.edu/NDB/index.html
10 """
11
12
13 import string, array, copy
14 from Bio.Seq import Seq
15 from Bio.Seq import MutableSeq
16
18 output = ''
19 for i in range( 0, len( line ), 80 ):
20 output = output + '%s\n' % line[ i: i + 80 ]
21 return output
22
28
34
36
37 """
38 message - description of error
39 """
40
43
45 """
46 This class exists to support the PDB hetero codes. Supports only the 3 alphameric code.
47 The annotation is available from http://alpha2.bmc.uu.se/hicup/
48 """
50
51 if( type(data) != type("") ):
52 raise CrystalError( 'Hetero data must be an alphameric string' )
53 if( data.isalnum() == 0 ):
54 raise CrystalError( 'Hetero data must be an alphameric string' )
55 if( len( data ) > 3 ):
56 raise CrystalError( 'Hetero data may contain up to 3 characters' )
57 if( len( data ) < 1 ):
58 raise CrystalError( 'Hetero data must not be empty' )
59
60 self.data = data[:].lower()
61
64
65
67 """Returns true iff self is not equal to other."""
68 return not self.__eq__(other)
69
71 return "%s" % self.data
72
74 return "%s" % self.data
75
76
78
97
102
106
108 output = ''
109 i = 0
110 for element in self.data:
111 output = output + '%s ' % element
112 output = output.strip()
113 output = wrap_line( output )
114 return output
115
116
118 if( len( self.data ) != len( other.data ) ):
119 return 0
120 ok = reduce( lambda x, y: x and y, map( lambda x, y: x == y, self.data, other.data ) )
121 return ok
122
124 """Returns true iff self is not equal to other."""
125 return not self.__eq__(other)
126
129
136
139
141 i = max(i, 0); j = max(j, 0)
142 return self.__class__(self.data[i:j])
143
145 i = max(i, 0); j = max(j, 0)
146 if isinstance(other, Chain):
147 self.data[i:j] = other.data
148 elif isinstance(other, type(self.data)):
149 self.data[i:j] = other
150 elif type( other ) == type( '' ):
151 self.data[ i:j ] = Chain( other ).data
152 else:
153 raise TypeError
154
156 i = max(i, 0); j = max(j, 0)
157 del self.data[i:j]
158
165
172
179
183
190
197
199 if isinstance(other, Chain):
200 return self.__class__(self.data + other.data)
201 elif type( other ) == type( '' ):
202 return self.__class__(self.data + Chain( other).data )
203 else:
204 raise TypeError
205
207 if isinstance(other, Chain):
208 return self.__class__( other.data + self.data )
209 elif type( other ) == type( '' ):
210 return self.__class__( Chain( other ).data + self.data )
211 else:
212 raise TypeError
213
215 if isinstance(other, Chain ):
216 self.data += other.data
217 elif type( other ) == type( '' ):
218 self.data += Chain( other ).data
219 else:
220 raise TypeError
221 return self
222
230
241
242
243
251
259
262
272
281 - def get(self, key, failobj=None):
289