Package generic_fns :: Package structure :: Module internal :: Class Internal
[hide private]
[frames] | no frames]

Class Internal

source code


The internal relax structural data object.

The structural data object for this class is a container possessing a number of different arrays corresponding to different structural information. These objects are described in the structural container docstring.

Instance Methods [hide private]
tuple consisting of the atom number (int), atom name (str), element name (str), and atomic position (Numeric array of len 3)
_bonded_atom(self, attached_atom, index, mol)
Find the atom named attached_atom directly bonded to the atom located at the index.
source code
 
_find_bonded_atoms(self, index, mol, radius=1.2)
Find all atoms within a sphere and say that they are attached to the central atom.
source code
str or None
_get_chemical_name(self, hetID)
Return the chemical name corresponding to the given residue ID.
source code
tuple of int and array of str
_parse_models_pdb(self, file_path)
Generator function for looping over the models in the PDB file.
source code
tuple of int and array of str
_parse_models_xyz(self, file_path)
Generator function for looping over the models in the XYZ file.
source code
tuple of int and list of str
_parse_mols(self, records)
Generator function for looping over the molecules in the PDB records of a model.
source code
 
_validate_data_arrays(self, struct)
Check the validity of the data arrays in the given structure object.
source code
 
_mol_type(self, mol)
Determine the type of molecule.
source code
 
_protein_connect(self, mol)
Set up the connectivities for the protein.
source code
 
_protein_intra_connect(self, mol, res_atoms)
Set up the connectivities for the protein.
source code
str
_translate(self, data, format='str')
Convert the data into a format for writing to file.
source code
 
add_atom(self, mol_name=None, 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)
Add a new atom to the structural data object.
source code
ModelContainer instance
add_model(self, model=None, coords_from=None)
Add a new model to the store.
source code
 
add_molecule(self, name=None)
Add a new molecule to the store.
source code
tuple consisting of optional molecule name (str), residue number (int), residue name (str), atom number (int), atom name(str), element name (str), and atomic position (array of len 3).
atom_loop(self, atom_id=None, str_id=None, model_num=None, model_num_flag=False, mol_name_flag=False, res_num_flag=False, res_name_flag=False, atom_num_flag=False, atom_name_flag=False, element_flag=False, pos_flag=False, ave=False)
Generator function for looping over all atoms in the internal relax structural object.
source code
list of numpy arrays (or a tuple if return_name or return_warnings are set)
bond_vectors(self, attached_atom=None, model_num=None, mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, return_name=False, return_warnings=False)
Find the bond vector between the atoms of 'attached_atom' and 'atom_id'.
source code
 
connect_atom(self, mol_name=None, index1=None, index2=None)
Connect two atoms in the structural data object.
source code
 
delete(self)
Delete all the structural information.
source code
MolContainer instance or None
get_molecule(self, molecule, model=None)
Return the molecule.
source code
bool
load_pdb(self, file_path, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=False)
Method for loading structures from a PDB file.
source code
bool
load_xyz(self, file_path, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=False)
Method for loading structures from a XYZ file.
source code
 
rotate(self, R=None, origin=None, model=None, atom_id=None)
Rotate the structural information about the given origin.
source code
 
translate(self, T=None, model=None, atom_id=None)
Displace the structural information by the given translation vector.
source code
 
validate_models(self)
Check that the models are consistent with each other.
source code
 
write_pdb(self, file, model_num=None)
Method for the creation of a PDB file from the structural data.
source code

Inherited from api_base.Base_struct_API: __init__, attached_atom, empty, from_xml, get_model, model_loop, num_models, num_molecules, pack_structs, target_mol_name, to_xml, validate

Class Variables [hide private]
  id = 'internal'
Method Details [hide private]

_bonded_atom(self, attached_atom, index, mol)

source code 

Find the atom named attached_atom directly bonded to the atom located at the index.

Parameters:
  • attached_atom (str) - The name of the attached atom to return.
  • index (int) - The index of the atom which the attached atom is attached to.
  • mol (MolContainer instance) - The molecule container.
Returns: tuple consisting of the atom number (int), atom name (str), element name (str), and atomic position (Numeric array of len 3)
A tuple of information about the bonded atom.

_find_bonded_atoms(self, index, mol, radius=1.2)

source code 

Find all atoms within a sphere and say that they are attached to the central atom.

The found atoms will be added to the 'bonded' data structure.

Parameters:
  • index (int) - The index of the central atom.
  • mol (MolContainer instance) - The molecule container.

_get_chemical_name(self, hetID)

source code 

Return the chemical name corresponding to the given residue ID.

The following names are currently returned:

________________________________________________
|        |                                     |
| hetID  | Chemical name                       |
|________|_____________________________________|
|        |                                     |
| TNS    | Tensor                              |
| COM    | Centre of mass                      |
| AXS    | Tensor axes                         |
| SIM    | Monte Carlo simulation tensor axes  |
| PIV    | Pivot point                         |
| CON    | Cone object                         |
| AVE    | Average vector                      |
|________|_____________________________________|

For any other residues, no description is returned.

Parameters:
  • hetID (str) - The residue ID.
Returns: str or None
The chemical name.

_parse_models_pdb(self, file_path)

source code 

Generator function for looping over the models in the PDB file.

Parameters:
  • file_path (str) - The full path of the PDB file.
Returns: tuple of int and array of str
The model number and all the records for that model.

_parse_models_xyz(self, file_path)

source code 

Generator function for looping over the models in the XYZ file.

Parameters:
  • file_path (str) - The full path of the XYZ file.
Returns: tuple of int and array of str
The model number and all the records for that model.

_parse_mols(self, records)

source code 

Generator function for looping over the molecules in the PDB records of a model.

Parameters:
  • records (list of str) - The list of PDB records for the model, or if no models exist the entire PDB file.
Returns: tuple of int and list of str
The molecule number and all the records for that molecule.

_validate_data_arrays(self, struct)

source code 

Check the validity of the data arrays in the given structure object.

Parameters:
  • struct (Structure_container instance) - The structural object.

_mol_type(self, mol)

source code 

Determine the type of molecule.

Parameters:
  • mol (MolContainer instance) - The molecule data container.

_protein_connect(self, mol)

source code 

Set up the connectivities for the protein.

Parameters:
  • mol (MolContainer instance) - The molecule data container.

_protein_intra_connect(self, mol, res_atoms)

source code 

Set up the connectivities for the protein.

Parameters:
  • mol (MolContainer instance) - The molecule data container.
  • res_atoms (list of int) - The list of atom indices corresponding to the residue.

_translate(self, data, format='str')

source code 

Convert the data into a format for writing to file.

Parameters:
  • data (anything) - The data to convert to the required format.
  • format (str) - The format to convert to. This can be 'str', 'float', or 'int'.
Returns: str
The converted version of the data.

add_atom(self, mol_name=None, 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 

Add a new atom to the structural data object.

Parameters:
  • mol_name (str) - The name of the molecule.
  • 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'.
Overrides: api_base.Base_struct_API.add_atom

add_model(self, model=None, coords_from=None)

source code 

Add a new model to the store.

The new model will be constructured with the structural information from the other models currently present. The coords_from argument allows the atomic positions to be taken from a certain model. If this argument is not set, then the atomic positions from the first model will be used.

Parameters:
  • model (int or None) - The number of the model to create.
  • coords_from (int or None) - The model number to take the coordinates from.
Returns: ModelContainer instance
The model container.
Overrides: api_base.Base_struct_API.add_model

add_molecule(self, name=None)

source code 

Add a new molecule to the store.

Parameters:
  • name (str) - The molecule identifier string.
Overrides: api_base.Base_struct_API.add_molecule

atom_loop(self, atom_id=None, str_id=None, model_num=None, model_num_flag=False, mol_name_flag=False, res_num_flag=False, res_name_flag=False, atom_num_flag=False, atom_name_flag=False, element_flag=False, pos_flag=False, ave=False)

source code 

Generator function for looping over all atoms in the internal relax structural object.

Parameters:
  • atom_id (str) - The molecule, residue, and atom identifier string. Only atoms matching this selection will be yielded.
  • str_id (str, int, or None) - The structure identifier. This can be the file name, model number, or structure number. If None, then all structures will be looped over.
  • model_num (int or None) - Only loop over a specific model.
  • model_num_flag (bool) - A flag which if True will cause the model number to be yielded.
  • mol_name_flag (bool) - A flag which if True will cause the molecule name to be yielded.
  • res_num_flag (bool) - A flag which if True will cause the residue number to be yielded.
  • res_name_flag (bool) - A flag which if True will cause the residue name to be yielded.
  • atom_num_flag (bool) - A flag which if True will cause the atom number to be yielded.
  • atom_name_flag (bool) - A flag which if True will cause the atom name to be yielded.
  • element_flag (bool) - A flag which if True will cause the element name to be yielded.
  • pos_flag (bool) - A flag which if True will cause the atomic position to be yielded.
  • ave (bool) - A flag which if True will result in this method returning the average atom properties across all loaded structures.
Returns: tuple consisting of optional molecule name (str), residue number (int), residue name (str), atom number (int), atom name(str), element name (str), and atomic position (array of len 3).
A tuple of atomic information, as described in the docstring.
Overrides: api_base.Base_struct_API.atom_loop

bond_vectors(self, attached_atom=None, model_num=None, mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, return_name=False, return_warnings=False)

source code 

Find the bond vector between the atoms of 'attached_atom' and 'atom_id'.

Parameters:
  • attached_atom (str) - The name of the bonded atom.
  • model_num (None or int) - The model of which to return the vectors from. If not supplied and multiple models exist, then vectors from all models will be returned.
  • mol_name (str) - The name of the molecule that attached_atom belongs to.
  • res_num (str) - The number of the residue that attached_atom belongs to.
  • res_name (str) - The name of the residue that attached_atom belongs to.
  • spin_num (str) - The number of the spin that attached_atom is attached to.
  • spin_name (str) - The name of the spin that attached_atom is attached to.
  • return_name (bool) - A flag which if True will cause the name of the attached atom to be returned together with the bond vectors.
  • return_warnings (bool) - A flag which if True will cause warning messages to be returned.
Returns: list of numpy arrays (or a tuple if return_name or return_warnings are set)
The list of bond vectors for each model.
Overrides: api_base.Base_struct_API.bond_vectors

connect_atom(self, mol_name=None, index1=None, index2=None)

source code 

Connect two atoms in the structural data object.

Parameters:
  • mol_name (str) - The name of the molecule.
  • index1 (str) - The global index of the first atom.
  • index2 (str) - The global index of the first atom.
Overrides: api_base.Base_struct_API.connect_atom

delete(self)

source code 

Delete all the structural information.

Overrides: api_base.Base_struct_API.delete

get_molecule(self, molecule, model=None)

source code 

Return the molecule.

Only one model can be specified.

Parameters:
  • molecule (int or None) - The molecule name.
  • model (int or None) - The model number.
Returns: MolContainer instance or None
The MolContainer corresponding to the molecule name and model number.
Raises:
  • RelaxError - If the model is not specified and there is more than one model loaded.
Overrides: api_base.Base_struct_API.get_molecule

load_pdb(self, file_path, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=False)

source code 

Method for loading structures from a PDB file.

Parameters:
  • file_path (str) - The full path of the PDB file.
  • read_mol (None, int, or list of int) - The molecule(s) to read from the file, independent of model. The molecules are determined differently by the different parsers, but are numbered consecutively from 1. If set to None, then all molecules will be loaded.
  • set_mol_name (None, str, or list of str) - Set the names of the molecules which are loaded. If set to None, then the molecules will be automatically labelled based on the file name or other information.
  • read_model (None, int, or list of int) - The PDB model to extract from the file. If set to None, then all models will be loaded.
  • set_model_num (None, int, or list of int) - Set the model number of the loaded molecule. If set to None, then the PDB model numbers will be preserved, if they exist.
  • verbosity (bool) - A flag which if True will cause messages to be printed.
Returns: bool
The status of the loading of the PDB file.
Overrides: api_base.Base_struct_API.load_pdb

load_xyz(self, file_path, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=False)

source code 

Method for loading structures from a XYZ file.

Parameters:
  • file_path (str) - The full path of the XYZ file.
  • read_mol (None, int, or list of int) - The molecule(s) to read from the file, independent of model. The molecules are determined differently by the different parsers, but are numbered consecutively from 1. If set to None, then all molecules will be loaded.
  • set_mol_name (None, str, or list of str) - Set the names of the molecules which are loaded. If set to None, then the molecules will be automatically labelled based on the file name or other information.
  • read_model (None, int, or list of int) - The XYZ model to extract from the file. If set to None, then all models will be loaded.
  • set_model_num (None, int, or list of int) - Set the model number of the loaded molecule. If set to None, then the XYZ model numbers will be preserved, if they exist.
  • verbosity (bool) - A flag which if True will cause messages to be printed.
Returns: bool
The status of the loading of the XYZ file.
Overrides: api_base.Base_struct_API.load_xyz

rotate(self, R=None, origin=None, model=None, atom_id=None)

source code 

Rotate the structural information about the given origin.

Parameters:
  • R (numpy 3D, rank-2 array) - The forwards rotation matrix.
  • origin (numpy 3D, rank-1 array) - The origin of the rotation.
  • model (int) - The model to rotate. If None, all models will be rotated.
  • atom_id (str or None) - The molecule, residue, and atom identifier string. Only atoms matching this selection will be used.
Overrides: api_base.Base_struct_API.rotate

translate(self, T=None, model=None, atom_id=None)

source code 

Displace the structural information by the given translation vector.

Parameters:
  • T (numpy 3D, rank-1 array) - The translation vector.
  • model (int) - The model to rotate. If None, all models will be rotated.
  • atom_id (str or None) - The molecule, residue, and atom identifier string. Only atoms matching this selection will be used.
Overrides: api_base.Base_struct_API.translate

validate_models(self)

source code 

Check that the models are consistent with each other.

This checks that the primary structure is identical between the models.

Overrides: api_base.Base_struct_API.validate_models

write_pdb(self, file, model_num=None)

source code 

Method for the creation of a PDB file from the structural data.

A number of PDB records including HET, HETNAM, FORMUL, HETATM, TER, CONECT, MASTER, and END are created. To create the non-standard residue records HET, HETNAM, and FORMUL, the data structure 'het_data' is created. It is an array of arrays where the first dimension corresponds to a different residue and the second dimension has the elements:

  1. Residue number.
  2. Residue name.
  3. Chain ID.
  4. Total number of atoms in the residue.
  5. Number of H atoms in the residue.
  6. Number of C atoms in the residue.
Parameters:
  • file (file object) - The PDB file object. This object must be writable.
  • model_num (None or int) - The model to place into the PDB file. If not supplied, then all models will be placed into the file.
Overrides: api_base.Base_struct_API.write_pdb