Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.PDB.StructureBuilder.StructureBuilder Class Reference

List of all members.

Public Member Functions

def __init__
def set_header
def set_line_counter
def init_structure
def init_model
def init_chain
def init_seg
def init_residue
def init_atom
def set_anisou
def set_siguij
def set_sigatm
def get_structure
def set_symmetry

Public Attributes

 line_counter
 header
 structure
 model
 chain
 segid
 residue
 atom

Private Member Functions

def _is_completely_disordered

Detailed Description

Deals with contructing the Structure object. The StructureBuilder class is used
by the PDBParser classes to translate a file to a Structure object.

Definition at line 24 of file StructureBuilder.py.


Constructor & Destructor Documentation

Definition at line 29 of file StructureBuilder.py.

00029 
00030     def __init__(self):
00031         self.line_counter=0
00032         self.header={}


Member Function Documentation

Definition at line 33 of file StructureBuilder.py.

00033 
00034     def _is_completely_disordered(self, residue):
00035         "Return 1 if all atoms in the residue have a non blank altloc."
00036         atom_list=residue.get_unpacked_list()
00037         for atom in atom_list:
00038             altloc=atom.get_altloc()
00039             if altloc==" ":
00040                 return 0
00041         return 1

Definition at line 246 of file StructureBuilder.py.

00246 
00247     def get_structure(self):
00248         "Return the structure."
00249         # first sort everything
00250         # self.structure.sort()
00251         # Add the header dict
00252         self.structure.header=self.header
00253         return self.structure

def Bio.PDB.StructureBuilder.StructureBuilder.init_atom (   self,
  name,
  coord,
  b_factor,
  occupancy,
  altloc,
  fullname,
  serial_number = None,
  element = None 
)
Initiate a new Atom object.

Arguments:
o name - string, atom name, e.g. CA, spaces should be stripped
o coord - Numeric array (Float0, size 3), atomic coordinates
o b_factor - float, B factor
o occupancy - float
o altloc - string, alternative location specifier
o fullname - string, atom name including spaces, e.g. " CA "
o element - string, upper case, e.g. "HG" for mercury

Definition at line 161 of file StructureBuilder.py.

00161 
00162                   serial_number=None, element=None):
00163         """
00164         Initiate a new Atom object.
00165 
00166         Arguments:
00167         o name - string, atom name, e.g. CA, spaces should be stripped
00168         o coord - Numeric array (Float0, size 3), atomic coordinates
00169         o b_factor - float, B factor
00170         o occupancy - float
00171         o altloc - string, alternative location specifier
00172         o fullname - string, atom name including spaces, e.g. " CA "
00173         o element - string, upper case, e.g. "HG" for mercury
00174         """
00175         residue=self.residue
00176         # if residue is None, an exception was generated during
00177         # the construction of the residue
00178         if residue is None:
00179             return
00180         # First check if this atom is already present in the residue. 
00181         # If it is, it might be due to the fact that the two atoms have atom 
00182         # names that differ only in spaces (e.g. "CA.." and ".CA.",
00183         # where the dots are spaces). If that is so, use all spaces
00184         # in the atom name of the current atom. 
00185         if residue.has_id(name):
00186                 duplicate_atom=residue[name]
00187                 # atom name with spaces of duplicate atom
00188                 duplicate_fullname=duplicate_atom.get_fullname()
00189                 if duplicate_fullname!=fullname:
00190                     # name of current atom now includes spaces
00191                     name=fullname
00192                     warnings.warn("Atom names %r and %r differ "
00193                                   "only in spaces at line %i."
00194                                   % (duplicate_fullname, fullname,
00195                                      self.line_counter),
00196                                   PDBConstructionWarning)
00197         atom=self.atom=Atom(name, coord, b_factor, occupancy, altloc,
00198                             fullname, serial_number, element)
00199         if altloc!=" ":
00200             # The atom is disordered
00201             if residue.has_id(name):
00202                 # Residue already contains this atom
00203                 duplicate_atom=residue[name]
00204                 if duplicate_atom.is_disordered()==2:
00205                     duplicate_atom.disordered_add(atom)     
00206                 else:
00207                     # This is an error in the PDB file:
00208                     # a disordered atom is found with a blank altloc
00209                     # Detach the duplicate atom, and put it in a 
00210                     # DisorderedAtom object together with the current 
00211                     # atom.
00212                     residue.detach_child(name)
00213                     disordered_atom=DisorderedAtom(name)
00214                     residue.add(disordered_atom)
00215                     disordered_atom.disordered_add(atom)
00216                     disordered_atom.disordered_add(duplicate_atom)
00217                     residue.flag_disordered()
00218                     warnings.warn("WARNING: disordered atom found "
00219                                   "with blank altloc before line %i.\n"
00220                                   % self.line_counter,
00221                                   PDBConstructionWarning)
00222             else:
00223                 # The residue does not contain this disordered atom
00224                 # so we create a new one.
00225                 disordered_atom=DisorderedAtom(name)
00226                 residue.add(disordered_atom)
00227                 # Add the real atom to the disordered atom, and the 
00228                 # disordered atom to the residue
00229                 disordered_atom.disordered_add(atom)
00230                 residue.flag_disordered()
00231         else:   
00232             # The atom is not disordered
00233             residue.add(atom)

Initiate a new Chain object with given id.

Arguments:
o chain_id - string

Definition at line 75 of file StructureBuilder.py.

00075 
00076     def init_chain(self, chain_id):
00077         """Initiate a new Chain object with given id.
00078 
00079         Arguments:
00080         o chain_id - string
00081         """
00082         if self.model.has_id(chain_id):
00083             self.chain=self.model[chain_id]
00084             warnings.warn("WARNING: Chain %s is discontinuous at line %i."
00085                           % (chain_id, self.line_counter),
00086                           PDBConstructionWarning)
00087         else:
00088             self.chain=Chain(chain_id)
00089             self.model.add(self.chain)

def Bio.PDB.StructureBuilder.StructureBuilder.init_model (   self,
  model_id,
  serial_num = None 
)
Initiate a new Model object with given id.

Arguments:
o id - int
o serial_num - int

Definition at line 65 of file StructureBuilder.py.

00065 
00066     def init_model(self, model_id, serial_num = None):
00067         """Initiate a new Model object with given id.
00068         
00069         Arguments:
00070         o id - int
00071         o serial_num - int
00072         """
00073         self.model=Model(model_id,serial_num)
00074         self.structure.add(self.model)

def Bio.PDB.StructureBuilder.StructureBuilder.init_residue (   self,
  resname,
  field,
  resseq,
  icode 
)
Initiate a new Residue object.

Arguments:
o resname - string, e.g. "ASN"
o field - hetero flag, "W" for waters, "H" for 
    hetero residues, otherwise blank.
o resseq - int, sequence identifier
o icode - string, insertion code

Definition at line 98 of file StructureBuilder.py.

00098 
00099     def init_residue(self, resname, field, resseq, icode):
00100         """
00101         Initiate a new Residue object.
00102 
00103         Arguments:
00104         o resname - string, e.g. "ASN"
00105         o field - hetero flag, "W" for waters, "H" for 
00106             hetero residues, otherwise blank.
00107         o resseq - int, sequence identifier
00108         o icode - string, insertion code
00109         """
00110         if field!=" ":
00111             if field=="H":
00112                 # The hetero field consists of H_ + the residue name (e.g. H_FUC)
00113                 field="H_"+resname 
00114         res_id=(field, resseq, icode) 
00115         if field==" ":
00116             if self.chain.has_id(res_id):
00117                 # There already is a residue with the id (field, resseq, icode).
00118                 # This only makes sense in the case of a point mutation.
00119                 warnings.warn("WARNING: Residue ('%s', %i, '%s') "
00120                               "redefined at line %i."
00121                               % (field, resseq, icode, self.line_counter),
00122                               PDBConstructionWarning)
00123                 duplicate_residue=self.chain[res_id]
00124                 if duplicate_residue.is_disordered()==2:
00125                     # The residue in the chain is a DisorderedResidue object.
00126                     # So just add the last Residue object. 
00127                     if duplicate_residue.disordered_has_id(resname):
00128                         # The residue was already made
00129                         self.residue=duplicate_residue
00130                         duplicate_residue.disordered_select(resname)
00131                     else:
00132                         # Make a new residue and add it to the already
00133                         # present DisorderedResidue
00134                         new_residue=Residue(res_id, resname, self.segid)
00135                         duplicate_residue.disordered_add(new_residue)
00136                         self.residue=duplicate_residue
00137                         return
00138                 else:
00139                     # Make a new DisorderedResidue object and put all
00140                     # the Residue objects with the id (field, resseq, icode) in it.
00141                     # These residues each should have non-blank altlocs for all their atoms.
00142                     # If not, the PDB file probably contains an error. 
00143                     if not self._is_completely_disordered(duplicate_residue):
00144                         # if this exception is ignored, a residue will be missing
00145                         self.residue=None
00146                         raise PDBConstructionException(\
00147                             "Blank altlocs in duplicate residue %s ('%s', %i, '%s')" \
00148                             % (resname, field, resseq, icode))
00149                     self.chain.detach_child(res_id)
00150                     new_residue=Residue(res_id, resname, self.segid)
00151                     disordered_residue=DisorderedResidue(res_id)
00152                     self.chain.add(disordered_residue)
00153                     disordered_residue.disordered_add(duplicate_residue)
00154                     disordered_residue.disordered_add(new_residue)
00155                     self.residue=disordered_residue
00156                     return
00157         residue=Residue(res_id, resname, self.segid)
00158         self.chain.add(residue)
00159         self.residue=residue

Flag a change in segid.

Arguments:
o segid - string

Definition at line 90 of file StructureBuilder.py.

00090 
00091     def init_seg(self, segid):
00092         """Flag a change in segid.
00093         
00094         Arguments:
00095         o segid - string
00096         """
00097         self.segid=segid

Initiate a new Structure object with given id.

Arguments:
o id - string

Definition at line 57 of file StructureBuilder.py.

00057 
00058     def init_structure(self, structure_id):
00059         """Initiate a new Structure object with given id.
00060 
00061         Arguments:
00062         o id - string
00063         """
00064         self.structure=Structure(structure_id)

def Bio.PDB.StructureBuilder.StructureBuilder.set_anisou (   self,
  anisou_array 
)

Definition at line 234 of file StructureBuilder.py.

00234 
00235     def set_anisou(self, anisou_array):
00236         "Set anisotropic B factor of current Atom."
00237         self.atom.set_anisou(anisou_array)

Definition at line 44 of file StructureBuilder.py.

00044 
00045     def set_header(self, header):
00046         self.header=header

The line counter keeps track of the line in the PDB file that 
is being parsed.

Arguments:
o line_counter - int

Definition at line 47 of file StructureBuilder.py.

00047 
00048     def set_line_counter(self, line_counter):
00049         """
00050         The line counter keeps track of the line in the PDB file that 
00051         is being parsed.
00052         
00053         Arguments:
00054         o line_counter - int
00055         """
00056         self.line_counter=line_counter

def Bio.PDB.StructureBuilder.StructureBuilder.set_sigatm (   self,
  sigatm_array 
)

Definition at line 242 of file StructureBuilder.py.

00242 
00243     def set_sigatm(self, sigatm_array):
00244         "Set standard deviation of atom position of current Atom."
00245         self.atom.set_sigatm(sigatm_array)

def Bio.PDB.StructureBuilder.StructureBuilder.set_siguij (   self,
  siguij_array 
)

Definition at line 238 of file StructureBuilder.py.

00238 
00239     def set_siguij(self, siguij_array):
00240         "Set standard deviation of anisotropic B factor of current Atom."
00241         self.atom.set_siguij(siguij_array)

def Bio.PDB.StructureBuilder.StructureBuilder.set_symmetry (   self,
  spacegroup,
  cell 
)

Definition at line 254 of file StructureBuilder.py.

00254 
00255     def set_symmetry(self, spacegroup, cell):
00256         pass
00257 
00258 

Member Data Documentation

Definition at line 196 of file StructureBuilder.py.

Definition at line 82 of file StructureBuilder.py.

Definition at line 31 of file StructureBuilder.py.

Definition at line 30 of file StructureBuilder.py.

Definition at line 72 of file StructureBuilder.py.

Definition at line 128 of file StructureBuilder.py.

Definition at line 96 of file StructureBuilder.py.

Definition at line 63 of file StructureBuilder.py.


The documentation for this class was generated from the following file: