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