Package lib :: Package structure :: Package internal :: Module molecules :: Class MolContainer
[hide private]
[frames] | no frames]

Class MolContainer

source code

The container for the molecular information.

The structural data object for this class is a container possessing a number of different arrays corresponding to different structural information. These objects include:

All arrays should be of equal length so that an atom index can retrieve all the corresponding data. Only the atom identification string is compulsory, all other arrays can contain None.

Instance Methods [hide private]
 
__init__(self)
Initialise the molecular container.
source code
int
_atom_index(self, atom_num)
Find the atom index corresponding to the given atom number.
source code
str or None
_det_pdb_element(self, atom_name)
Try to determine the element from the PDB atom name.
source code
list of str
_parse_gaussian_record(self, record)
Parse the Gaussian log record string and return an array of the corresponding atomic information.
source code
list of str
_parse_xyz_record(self, record)
Parse the XYZ record string and return an array of the corresponding atomic information.
source code
 
_sort(self)
Sort all structural data.
source code
 
_sort_key(self, i)
Return the information for sorting the sequence data.
source code
int
atom_add(self, atom_name=None, res_name=None, res_num=None, pos=[None, None, None], element=None, atom_num=None, chain_id=None, segment_id=None, pdb_record=None)
Method for adding an atom to the structural data object.
source code
 
atom_connect(self, index1=None, index2=None)
Method for connecting two atoms within the data structure object.
source code
 
fill_object_from_gaussian(self, records)
Method for generating a complete Structure_container object from the given Gaussian log records.
source code
 
fill_object_from_pdb(self, records, alt_loc_select=None)
Method for generating a complete Structure_container object from the given PDB records.
source code
 
fill_object_from_xyz(self, records)
Method for generating a complete Structure_container object from the given xyz records.
source code
 
from_xml(self, mol_node, file_version=1)
Recreate the MolContainer from the XML molecule node.
source code
 
is_empty(self)
Check if the container is empty.
source code
int
last_residue(self)
Return the number of the last residue.
source code
str, int
loop_residues(self)
Generator method for looping over the individual residues of the molecule.
source code
 
merge(self, mol_cont=None)
Merge the contents of the given molecule container into here.
source code
 
to_xml(self, doc, element)
Create XML elements for the contents of this molecule container.
source code
Method Details [hide private]

_atom_index(self, atom_num)

source code 

Find the atom index corresponding to the given atom number.

Parameters:
  • atom_num (int) - The atom number to find the index of.
Returns: int
The atom index corresponding to the atom.

_det_pdb_element(self, atom_name)

source code 

Try to determine the element from the PDB atom name.

Parameters:
  • atom_name (str) - The PDB atom name.
Returns: str or None
The element name, or None if unsuccessful.

_parse_gaussian_record(self, record)

source code 

Parse the Gaussian log record string and return an array of the corresponding atomic information.

The format of the Gaussian log records is:

__________________________________________________________________________________________
|         |              |                                                               |
| Columns | Data type    | Description                                                   |
|_________|______________|_______________________________________________________________|
|         |              |                                                               |
|  1      | int          | "Center Number" - the sequential atom number.                 |
|  2      | int          | "Atomic Number" - the atomic number.                          |
|  3      | int          | "Atomic Type" - the atomic type?                              |
|  4      | float        | X coordinate in Angstrom                                      |
|  5      | float        | Y coordinate in Angstrom                                      |
|  6      | float        | Z coordinate in Angstrom                                      |
|_________|______________|_______________________________________________________________|
Parameters:
  • record (str) - The single line Gaussian record.
Returns: list of str
The list of atomic information

_parse_xyz_record(self, record)

source code 

Parse the XYZ record string and return an array of the corresponding atomic information.

The format of the XYZ records is:

__________________________________________________________________________________________
|         |              |              |                                                |
| Columns | Data type    | Field        | Definition                                     |
|_________|______________|______________|________________________________________________|
|         |              |              |                                                |
|  1      | String       | element      |                                                |
|  2      | Real         | x            | Orthogonal coordinates for X in Angstroms      |
|  3      | Real         | y            | Orthogonal coordinates for Y in Angstroms      |
|  4      | Real         | z            | Orthogonal coordinates for Z in Angstroms      |
|_________|______________|______________|________________________________________________|
Parameters:
  • record (str) - The single line PDB record.
Returns: list of str
The list of atomic information

atom_add(self, atom_name=None, res_name=None, res_num=None, pos=[None, None, None], element=None, atom_num=None, chain_id=None, segment_id=None, pdb_record=None)

source code 

Method for adding an atom to the structural data object.

This method will create the key-value pair for the given atom.

Parameters:
  • atom_name (str or None) - The atom name, e.g. 'H1'.
  • res_name (str or None) - The residue name.
  • res_num (int or None) - The residue number.
  • pos (list (length = 3)) - The position vector of coordinates.
  • element (str or None) - The element symbol.
  • atom_num (int or None) - The atom number.
  • chain_id (str or None) - The chain identifier.
  • segment_id (str or None) - The segment identifier.
  • pdb_record (str or None) - The optional PDB record name, e.g. 'ATOM' or 'HETATM'.
Returns: int
The index of the added atom.

atom_connect(self, index1=None, index2=None)

source code 

Method for connecting two atoms within the data structure object.

This method will append index2 to the array at bonded[index1] and vice versa.

Parameters:
  • index1 (int) - The index of the first atom.
  • index2 (int) - The index of the second atom.

fill_object_from_gaussian(self, records)

source code 

Method for generating a complete Structure_container object from the given Gaussian log records.

Parameters:
  • records (list of str) - A list of structural Gaussian log records.

fill_object_from_pdb(self, records, alt_loc_select=None)

source code 

Method for generating a complete Structure_container object from the given PDB records.

Parameters:
  • records (list of str) - A list of structural PDB records.
  • alt_loc_select (str or None) - The PDB ATOM record 'Alternate location indicator' field value to select which coordinates to use.

fill_object_from_xyz(self, records)

source code 

Method for generating a complete Structure_container object from the given xyz records.

Parameters:
  • records (list of str) - A list of structural xyz records.

from_xml(self, mol_node, file_version=1)

source code 

Recreate the MolContainer from the XML molecule node.

Parameters:
  • mol_node (xml.dom.minicompat.NodeList instance) - The molecule XML node.
  • file_version (int) - The relax XML version of the XML file.

last_residue(self)

source code 

Return the number of the last residue.

Returns: int
The last residue number.

loop_residues(self)

source code 

Generator method for looping over the individual residues of the molecule.

Returns: str, int
The residue name and number.

merge(self, mol_cont=None)

source code 

Merge the contents of the given molecule container into here.

Parameters:
  • mol_cont (MolContainer instance) - The data structure for the molecule to merge.

to_xml(self, doc, element)

source code 

Create XML elements for the contents of this molecule container.

Parameters:
  • doc (xml.dom.minidom.Document instance) - The XML document object.
  • element (XML element object) - The element to add the molecule XML elements to.