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

Source Code for Module Bio.PDB.Structure

 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  # My Stuff 
 7  from Entity import Entity 
 8   
 9   
10  __doc__="The structure class, representing a macromolecular structure." 
11   
12   
13 -class Structure(Entity):
14 """ 15 The Structure class contains a collection of Model instances. 16 """
17 - def __init__(self, id):
18 self.level="S" 19 Entity.__init__(self, id)
20 21 # Special methods 22
23 - def __repr__(self):
24 return "<Structure id=%s>" % self.get_id()
25 26 # Private methods 27
28 - def _sort(self, m1, m2):
29 """Sort models. 30 31 This sorting function sorts the Model instances in the Structure instance. 32 The sorting is done based on the model id, which is a simple int that 33 reflects the order of the models in the PDB file. 34 35 Arguments: 36 o m1, m2 - Model instances 37 """ 38 return cmp(m1.get_id(), m2.get_id())
39 40 # Public 41
42 - def get_chains(self):
43 for m in self: 44 for c in m: 45 yield c
46
47 - def get_residues(self):
48 for c in self.get_chains(): 49 for r in c: 50 yield r
51
52 - def get_atoms(self):
53 for r in self.get_residues(): 54 for a in r: 55 yield a
56