Trees | Indices | Help |
---|
|
1 # Copyright 2002 by Katharine Lindner. All rights reserved. 2 # This code is part of the Biopython distribution and governed by its 3 # license. Please see the LICENSE file that should have been included 4 # as part of this package. 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 1820 output = '' 21 for i in range(0, len(line), 80): 22 output = output + '%s\n' % line[ i: i + 80 ] 23 return output2426 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')3032 """ 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 """6539 # Enforce string storage 40 if type(data) != type(""): 41 raise CrystalError('Hetero data must be an alphameric string') 42 if data.isalnum() == 0: 43 raise CrystalError('Hetero data must be an alphameric string') 44 if len(data) > 3: 45 raise CrystalError('Hetero data may contain up to 3 characters') 46 if len(data) < 1: 47 raise CrystalError('Hetero data must not be empty') 48 49 self.data = data[:].lower()50 53 5759 return "%s" % self.data6062 return "%s" % self.data6320968 self.data = [] 69 if type(residues) == type(''): 70 residues = residues.replace('*', ' ') 71 residues = residues.strip() 72 elements = residues.split() 73 self.data = map(Hetero, elements) 74 elif type(residues) == type([]): 75 for element in residues: 76 if not isinstance(element, Hetero): 77 raise CrystalError('Text must be a string') 78 for residue in residues: 79 self.data.append(residue) 80 elif isinstance(residues, Chain): 81 for residue in residues: 82 self.data.append(residue) 83 self.validate()84 89 9395 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 output102 103105 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 ok109 113 115117 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 TypeError123125 if isinstance(index, int): 126 try: 127 self.validate_element(value) 128 except TypeError: 129 value = Hetero(value.lower()) 130 self.data[index] = value 131 elif isinstance(index, slice): 132 if isinstance(value, Chain): 133 self.data[index] = value.data 134 elif isinstance(value, type(self.data)): 135 self.data[index] = value 136 elif isinstance(value, basestring): 137 self.data[index] = Chain(value).data 138 else: 139 raise TypeError 140 else: 141 raise TypeError142 145147 try: 148 self.validate_element(item) 149 except TypeError: 150 item = Hetero(item.lower()) 151 return item in self.data152154 try: 155 self.validate_element(item) 156 except TypeError: 157 item = Hetero(item.lower()) 158 self.data.append(item)159161 try: 162 self.validate_element(item) 163 except TypeError: 164 item = Hetero(item.lower()) 165 self.data.insert(i, item)166 170172 try: 173 self.validate_element(item) 174 except TypeError: 175 item = Hetero(item.lower()) 176 return self.data.count(item)177179 try: 180 self.validate_element(item) 181 except TypeError: 182 item = Hetero(item.lower()) 183 return self.data.index(item)184186 if isinstance(other, Chain): 187 return self.__class__(self.data + other.data) 188 elif type(other) == type(''): 189 return self.__class__(self.data + Chain(other).data) 190 else: 191 raise TypeError192194 if isinstance(other, Chain): 195 return self.__class__(other.data + self.data) 196 elif type(other) == type(''): 197 return self.__class__(Chain(other).data + self.data) 198 else: 199 raise TypeError200275212 # Enforcestorage 213 if type(data) != type({}): 214 raise CrystalError('Crystal must be a dictionary') 215 self.data = data 216 self.fix()217219 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 TypeError228230 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 output236238 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 output244246 return self.data247251 if isinstance(item, Chain): 252 self.data[key] = item 253 elif type(item) == type(''): 254 self.data[ key ] = Chain(item) 255 else: 256 raise TypeError257
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 1 00:42:53 2011 | http://epydoc.sourceforge.net |