Package Bio :: Package PDB :: Module Model
[hide private]
[frames] | no frames]

Source Code for Module Bio.PDB.Model

 1  # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk) 
 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  """Model class, used in Structure objects.""" 
 7   
 8  from Bio.PDB.Entity import Entity 
 9   
10   
11 -class Model(Entity):
12 """ 13 The object representing a model in a structure. In a structure 14 derived from an X-ray crystallography experiment, only a single 15 model will be present (with some exceptions). NMR structures 16 normally contain many different models. 17 """ 18
19 - def __init__(self, id, serial_num=None):
20 """ 21 Arguments: 22 o id - int 23 o serial_num - int 24 """ 25 self.level="M" 26 if serial_num is None: 27 self.serial_num=id 28 else: 29 self.serial_num=serial_num 30 31 Entity.__init__(self, id)
32 33 # Private methods 34
35 - def _sort(self, c1, c2):
36 """Sort the Chains instances in the Model instance. 37 38 Chain instances are sorted alphabetically according to 39 their chain id. Blank chains come last, as they often consist 40 of waters. 41 42 Arguments: 43 o c1, c2 - Chain objects 44 """ 45 id1=c1.get_id() 46 id2= c2.get_id() 47 # make sure blank chains come last (often waters) 48 if id1==" " and not id2==" ": 49 return 1 50 elif id2==" " and not id1==" ": 51 return -1 52 return cmp(id1, id2)
53 54 # Special methods 55
56 - def __repr__(self):
57 return "<Model id=%s>" % self.get_id()
58 59 # Public 60
61 - def get_residues(self):
62 for c in self: 63 for r in c: 64 yield r
65
66 - def get_atoms(self):
67 for r in self.get_residues(): 68 for a in r: 69 yield a
70