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  """Model class, used in Structure objects.""" 
 7   
 8  from Bio.PDB.Entity import Entity 
 9   
10   
11 -class Model(Entity):
12 """The object representing a model in a structure. 13 14 In a structure derived from an X-ray crystallography experiment, 15 only a single model will be present (with some exceptions). NMR 16 structures normally contain many different models. 17 """ 18
19 - def __init__(self, id, serial_num=None):
20 """Initialize. 21 22 Arguments: 23 - id - int 24 - serial_num - int 25 26 """ 27 self.level = "M" 28 if serial_num is None: 29 self.serial_num = id 30 else: 31 self.serial_num = serial_num 32 33 Entity.__init__(self, id)
34
35 - def __repr__(self):
36 return "<Model id=%s>" % self.get_id()
37
38 - def get_chains(self):
39 for c in self: 40 yield c
41
42 - def get_residues(self):
43 for c in self.get_chains(): 44 for r in c: 45 yield r
46
47 - def get_atoms(self):
48 for r in self.get_residues(): 49 for a in r: 50 yield a
51