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