Package generic_fns :: Package structure :: Module internal :: 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_pdb_record(self, record)
Parse the PDB 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
 
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_pdb(self, records)
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)
Recreate the MolContainer from the XML molecule node.
source code
 
is_empty(self)
Check if the container is empty.
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_pdb_record(self, record)

source code 

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

The format of the ATOM and HETATM records is:

__________________________________________________________________________________________
|         |              |              |                                                |
| Columns | Data type    | Field        | Definition                                     |
|_________|______________|______________|________________________________________________|
|         |              |              |                                                |
|  1 -  6 | Record name  | "ATOM"       |                                                |
|  7 - 11 | Integer      | serial       | Atom serial number.                            |
| 13 - 16 | Atom         | name         | Atom name.                                     |
| 17      | Character    | altLoc       | Alternate location indicator.                  |
| 18 - 20 | Residue name | resName      | Residue name.                                  |
| 22      | Character    | chainID      | Chain identifier.                              |
| 23 - 26 | Integer      | resSeq       | Residue sequence number.                       |
| 27      | AChar        | iCode        | Code for insertion of residues.                |
| 31 - 38 | Real(8.3)    | x            | Orthogonal coordinates for X in Angstroms.     |
| 39 - 46 | Real(8.3)    | y            | Orthogonal coordinates for Y in Angstroms.     |
| 47 - 54 | Real(8.3)    | z            | Orthogonal coordinates for Z in Angstroms.     |
| 55 - 60 | Real(6.2)    | occupancy    | Occupancy.                                     |
| 61 - 66 | Real(6.2)    | tempFactor   | Temperature factor.                            |
| 73 - 76 | LString(4)   | segID        | Segment identifier, left-justified.            |
| 77 - 78 | LString(2)   | element      | Element symbol, right-justified.               |
| 79 - 80 | LString(2)   | charge       | Charge on the atom.                            |
|_________|______________|______________|________________________________________________|

The format of the TER record is:

__________________________________________________________________________________________
|         |              |              |                                                |
| Columns | Data type    | Field        | Definition                                     |
|_________|______________|______________|________________________________________________|
|         |              |              |                                                |
|  1 -  6 | Record name  | "TER   "     |                                                |
|  7 - 11 | Integer      | serial       | Serial number.                                 |
| 18 - 20 | Residue name | resName      | Residue name.                                  |
| 22      | Character    | chainID      | Chain identifier.                              |
| 23 - 26 | Integer      | resSeq       | Residue sequence number.                       |
| 27      | AChar        | iCode        | Insertion code.                                |
|_________|______________|______________|________________________________________________|

The format of the CONECT record is:

__________________________________________________________________________________________
|         |              |              |                                                |
| Columns | Data type    | Field        | Definition                                     |
|_________|______________|______________|________________________________________________|
|         |              |              |                                                |
|  1 -  6 | Record name  | "CONECT"     |                                                |
|  7 - 11 | Integer      | serial       | Atom serial number                             |
| 12 - 16 | Integer      | serial       | Serial number of bonded atom                   |
| 17 - 21 | Integer      | serial       | Serial number of bonded atom                   |
| 22 - 26 | Integer      | serial       | Serial number of bonded atom                   |
| 27 - 31 | Integer      | serial       | Serial number of bonded atom                   |
| 32 - 36 | Integer      | serial       | Serial number of hydrogen bonded atom          |
| 37 - 41 | Integer      | serial       | Serial number of hydrogen bonded atom          |
| 42 - 46 | Integer      | serial       | Serial number of salt bridged atom             |
| 47 - 51 | Integer      | serial       | Serial number of hydrogen bonded atom          |
| 52 - 56 | Integer      | serial       | Serial number of hydrogen bonded atom          |
| 57 - 61 | Integer      | serial       | Serial number of salt bridged atom             |
|_________|______________|______________|________________________________________________|
Parameters:
  • record (str) - The single line PDB record.
Returns: list of str
The list of atomic information, each element corresponding to the PDB fields as defined in "Protein Data Bank Contents Guide: Atomic Coordinate Entry Format Description" version 2.1 (draft), October 25, 1996.

_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'.

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_pdb(self, records)

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.

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)

source code 

Recreate the MolContainer from the XML molecule node.

Parameters:
  • mol_node (xml.dom.minicompat.NodeList instance) - The molecule XML node.

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.