Source for file Macromolecule.php
Documentation is available at Macromolecule.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> |
// +----------------------------------------------------------------------+
require_once "Science/Chemistry.php";
require_once "Science/Chemistry/Atom.php";
require_once "Science/Chemistry/Molecule.php";
* Represents a macromolecule, composed of several
* Science_Chemistry_Molecule objects
* @author Jesus M. Castagnetto <jmcastagnetto@php.net>
* @package Science_Chemistry
* Array of molecular objects
* Number of molecules/subunits
* Constructor for the class, requires a macromolecule name
* and an optional array of Science_Chemistry_Molecule objects
* @param optional array $molecules
* @return object Science_Chemistry_Macromolecule
* @see initMacromolecule()
* Initializes the array of Science_Chemistry_Molecule objects
* @param array $molecules
for ($i=0; $i < count($molecules); $i++ ) {
* Adds a Science_Chemistry_Molecule object to the list of molecules in the macromolecule
* @param object Science_Chemistry_Molecule $mol
* @see initMacromolecule()
$this->molecules[] = $mol;
* Returns an array of Science_Chemistry_Molecule objects
* Checks if the object is an instance of Science_Chemistry_Macromolecule
* @param object Science_Chemistry_Macromolecule $obj
* Returns a string representation of the macromolecule
* as a multiple molecule XYZ-format file
$out = "# Number of molecules: ". $this->num_molecules. "\n";
for ($i=0; $i < $this->num_molecules; $i++ )
$out .= "# Molecule ". ($i+1 ). "\n". $this->molecules[$i]->toString (). "\n";
* Returns a string representation of the macromolecule
* as a multiple molecule XYZ-format file
* Returns a CML representation of the molecule
* Accepts an optional id, and a flag to signal
* printing of the connection table
* @param optional string $id
* @param optional boolean $connect
function toCML($title= "macromolecule", $id= "macromol1", $connect=false ) {
$out = " <molecule title=\"$title\" id=\"$id\">\n";
$out .= "<list title=\"molecules\">\n";
for ($i=0; $i < $this->num_molecules; $i++ ) {
$mol = & $this->molecules[$i];
$out .= $mol->toCML ($mol->name , ($i+1 ), $connect);
$out .= "</list>\n</molecule>\n";
} // end of Science_Chemistry_Macromolecule
// vim: expandtab: ts=4: sw=4
Documentation generated on Mon, 11 Mar 2019 15:48:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|