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_models(self):
41 for m in self: 42 yield m
43
44 - def get_chains(self):
45 for m in self.get_models(): 46 for c in m: 47 yield c
48
49 - def get_residues(self):
50 for c in self.get_chains(): 51 for r in c: 52 yield r
53
54 - def get_atoms(self):
55 for r in self.get_residues(): 56 for a in r: 57 yield a
58