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