Science_Chemistry
[ class tree: Science_Chemistry ] [ index: Science_Chemistry ] [ all elements ]

Source for file Macromolecule_PDB.php

Documentation is available at Macromolecule_PDB.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net>                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id$
  20. //
  21.  
  22. require_once "Science/Chemistry/Macromolecule.php";
  23. require_once "Science/Chemistry/Residue_PDB.php";
  24.  
  25. /**
  26.  * Represents a PDB macromolecule, composed of several
  27.  * Science_Chemistry_Residue_PDB objects
  28.  *
  29.  * @author  Jesus M. Castagnetto <jmcastagnetto@php.net>
  30.  * @version 1.0
  31.  * @access  public
  32.  * @package Science_Chemistry
  33.  */
  34.  
  35.     /**
  36.      * Constructor for the class
  37.      * 
  38.      * @param   string $pdb PDB ID of the containing file
  39.      * @param   array  $records Array of lines comprising the macromolecule
  40.      * @param   object  PDBFile $pdbfile    reference to the PDB file object
  41.      * @return  object  Science_Chemistry_Macromolecule_PDB 
  42.      * @access  public
  43.      * @see     $pdb
  44.      * @see     parseResidues()
  45.      */
  46.     function Science_Chemistry_Macromolecule_PDB($pdb$records$pdbfile=""{
  47.         $this->pdb $pdb;
  48.         $this->pdbfile $pdbfile;
  49.         $this->parseResidues($records);
  50.     }
  51.  
  52.     /**
  53.      * Makes the array of residues in the macromolecule
  54.      *
  55.      * @param   array   $records 
  56.      * @access  private
  57.      * @see     Science_Chemistry_Macromolecule_PDB()
  58.      */
  59.     function parseResidues($records{
  60.         $curr_res_id '';
  61.         $res_atoms = array();
  62.         $nrecs count($records);
  63.         for ($i=0; $i$nrecs$i++{
  64.             $atomrec $records[$i];
  65.             $res_name trim(substr($atomrec,17,3));
  66.             $chain trim(substr($atomrec,21,1));
  67.             $seq_num = (int) trim(substr($atomrec,22,4));
  68.             $res_id $res_name.":".$seq_num.":".$chain;
  69.             $res_atoms[$res_id][$atomrec;
  70.         }
  71.  
  72.          foreach ($res_atoms as $mol_id => $atoms_list{
  73.             $this->molecules[=new Science_Chemistry_Residue_PDB($this->pdb
  74.                                             $atoms_list$this);
  75.             $this->num_molecules++;
  76.         }
  77.         return true;
  78.     }
  79. // end of Science_Chemistry_Macromolecule_PDB
  80.  
  81. // vim: expandtab: ts=4: sw=4
  82. ?>

Documentation generated on Mon, 11 Mar 2019 15:48:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.