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 string, array, copy 15 from Bio.Seq import Seq 16 from Bio.Seq import MutableSeq 17 2022 output = '' 23 for i in range(0, len(line), 80): 24 output = output + '%s\n' % line[ i: i + 80 ] 25 return output2628 if type(key) != type(''): 29 raise CrystalError('chain requires a string label') 30 if len(key) != 1: 31 raise CrystalError('chain label should contain one letter')3234 """ 35 This class exists to support the PDB hetero codes. 36 37 Supports only the 3 alphameric code. 38 The annotation is available from http://alpha2.bmc.uu.se/hicup/ 39 """6741 # Enforce string storage 42 if type(data) != type(""): 43 raise CrystalError('Hetero data must be an alphameric string') 44 if data.isalnum() == 0: 45 raise CrystalError('Hetero data must be an alphameric string') 46 if len(data) > 3: 47 raise CrystalError('Hetero data may contain up to 3 characters') 48 if len(data) < 1: 49 raise CrystalError('Hetero data must not be empty') 50 51 self.data = data[:].lower()52 55 5961 return "%s" % self.data6264 return "%s" % self.data6521170 self.data = [] 71 if type(residues) == type(''): 72 residues = residues.replace('*', ' ') 73 residues = residues.strip() 74 elements = residues.split() 75 self.data = map(Hetero, elements) 76 elif type(residues) == type([]): 77 for element in residues: 78 if not isinstance(element, Hetero): 79 raise CrystalError('Text must be a string') 80 for residue in residues: 81 self.data.append(residue) 82 elif isinstance(residues, Chain): 83 for residue in residues: 84 self.data.append(residue) 85 self.validate()86 91 9597 output = '' 98 i = 0 99 for element in self.data: 100 output = output + '%s ' % element 101 output = output.strip() 102 output = wrap_line(output) 103 return output104 105107 if len(self.data) != len(other.data): 108 return 0 109 ok = reduce(lambda x, y: x and y, map(lambda x, y: x == y, self.data, other.data)) 110 return ok111 115 118120 try: 121 self.validate_element(item) 122 except TypeError: 123 item = Hetero(item.lower()) 124 self.data[i] = item125 128 132134 i = max(i, 0); j = max(j, 0) 135 if isinstance(other, Chain): 136 self.data[i:j] = other.data 137 elif isinstance(other, type(self.data)): 138 self.data[i:j] = other 139 elif type(other) == type(''): 140 self.data[ i:j ] = Chain(other).data 141 else: 142 raise TypeError143 147149 try: 150 self.validate_element(item) 151 except TypeError: 152 item = Hetero(item.lower()) 153 return item in self.data154156 try: 157 self.validate_element(item) 158 except TypeError: 159 item = Hetero(item.lower()) 160 self.data.append(item)161163 try: 164 self.validate_element(item) 165 except TypeError: 166 item = Hetero(item.lower()) 167 self.data.insert(i, item)168 172174 try: 175 self.validate_element(item) 176 except TypeError: 177 item = Hetero(item.lower()) 178 return self.data.count(item)179181 try: 182 self.validate_element(item) 183 except TypeError: 184 item = Hetero(item.lower()) 185 return self.data.index(item)186188 if isinstance(other, Chain): 189 return self.__class__(self.data + other.data) 190 elif type(other) == type(''): 191 return self.__class__(self.data + Chain(other).data) 192 else: 193 raise TypeError194196 if isinstance(other, Chain): 197 return self.__class__(other.data + self.data) 198 elif type(other) == type(''): 199 return self.__class__(Chain(other).data + self.data) 200 else: 201 raise TypeError202279214 # Enforcestorage 215 if type(data) != type({}): 216 raise CrystalError('Crystal must be a dictionary') 217 self.data = data 218 self.fix()219221 data = self.data 222 for key in data.keys(): 223 element = data[ key ] 224 if isinstance(element, Chain): 225 pass 226 elif type(element) == type(''): 227 data[ key ] = Chain(element) 228 else: 229 raise TypeError230232 output = '' 233 keys = self.data.keys() 234 keys.sort() 235 for key in keys: 236 output = output + '%s : %s\n' % (key, self.data[ key ]) 237 return output238240 output = '' 241 keys = self.data.keys() 242 keys.sort() 243 for key in keys: 244 output = output + '%s : %s\n' % (key, self.data[ key ]) 245 return output246248 return self.data249253 if isinstance(item, Chain): 254 self.data[key] = item 255 elif type(item) == type(''): 256 self.data[ key ] = Chain(item) 257 else: 258 raise TypeError259 267 268 #TODO - Define the __in__ method? 269
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Dec 25 10:56:43 2008 | http://epydoc.sourceforge.net |