home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Macromolecule_PDB.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.2 KB  |  84 lines

  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: Macromolecule_PDB.php,v 1.4 2003/05/13 01:18:17 jmcastagnetto Exp $
  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. class Science_Chemistry_Macromolecule_PDB extends Science_Chemistry_Macromolecule {
  35.  
  36.     /**
  37.      * Constructor for the class
  38.      * 
  39.      * @param   string $pdb PDB ID of the containing file
  40.      * @param   array  $records Array of lines comprising the macromolecule
  41.      * @param   object  PDBFile $pdbfile    reference to the PDB file object
  42.      * @return  object  Science_Chemistry_Macromolecule_PDB
  43.      * @access  public
  44.      * @see     $pdb
  45.      * @see     parseResidues()
  46.      */
  47.     function Science_Chemistry_Macromolecule_PDB($pdb, $records, $pdbfile="") {
  48.         $this->pdb =& $pdb;
  49.         $this->pdbfile =& $pdbfile;
  50.         $this->parseResidues($records);
  51.     }
  52.  
  53.     /**
  54.      * Makes the array of residues in the macromolecule
  55.      *
  56.      * @param   array   $records
  57.      * @access  private
  58.      * @see     Science_Chemistry_Macromolecule_PDB()
  59.      */
  60.     function parseResidues($records) {
  61.         $curr_res_id = '';
  62.         $res_atoms = array();
  63.         $nrecs = count($records);
  64.         for ($i=0; $i< $nrecs; $i++) {
  65.             $atomrec = $records[$i];
  66.             $res_name = trim(substr($atomrec,17,3));
  67.             $chain = trim(substr($atomrec,21,1));
  68.             $seq_num = (int) trim(substr($atomrec,22,4));
  69.             $res_id = $res_name.":".$seq_num.":".$chain;
  70.             $res_atoms[$res_id][] = $atomrec;
  71.         }
  72.  
  73.          foreach ($res_atoms as $mol_id => $atoms_list) {
  74.             $this->molecules[] =& new Science_Chemistry_Residue_PDB(&$this->pdb, 
  75.                                             &$atoms_list, &$this);
  76.             $this->num_molecules++;
  77.         }
  78.         return true;
  79.     }
  80. } // end of Science_Chemistry_Macromolecule_PDB
  81.  
  82. // vim: expandtab: ts=4: sw=4
  83. ?>
  84.