Package generic_fns :: Package structure :: Module main
[hide private]
[frames] | no frames]

Module main

source code

Functions [hide private]
 
add_atom(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
 
connect_atom(index1=None, index2=None)
Connect two atoms.
source code
 
delete()
Simple function for deleting all structural data.
source code
 
displacement(model_from=None, model_to=None, atom_id=None, centroid=None)
Calculate the rotational and translational displacement between two structural models.
source code
 
find_pivot(models=None, atom_id=None, init_pos=None)
Superimpose a set of structural models.
source code
 
get_pos(spin_id=None, str_id=None, ave_pos=False)
Load the spins from the structural object into the relax data store.
source code
 
load_spins(spin_id=None, str_id=None, ave_pos=False)
Load the spins from the structural object into the relax data store.
source code
 
read_pdb(file=None, dir=None, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, parser='internal', verbosity=1, fail=True)
The PDB loading function.
source code
 
read_xyz(file=None, dir=None, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=1, fail=True)
The XYZ loading function.
source code
 
rotate(R=None, origin=None, model=None, atom_id=None)
Rotate the structural data about the origin by the specified forwards rotation.
source code
 
set_vector(spin=None, xh_vect=None)
Place the XH unit vector into the spin container object.
source code
 
superimpose(models=None, method='fit to mean', atom_id=None, centroid=None)
Superimpose a set of structural models.
source code
 
translate(T=None, model=None, atom_id=None)
Shift the structural data by the specified translation vector.
source code
 
vectors(attached=None, spin_id=None, model=None, verbosity=1, ave=True, unit=True)
Extract the bond vectors from the loaded structures and store them in the spin container.
source code
 
write_pdb(file=None, dir=None, model_num=None, compress_type=0, force=False)
The PDB writing function.
source code
Variables [hide private]
  __package__ = 'generic_fns.structure'

Imports: sqrt, generic_minimise, array, dot, float64, ndarray, zeros, norm, F_OK, access, search, replace, sys, warn, molmol, relax_re, create_spin, exists_mol_res_spin_data, generate_spin_id, linear_ave, return_molecule, return_residue, return_spin, spin_loop, pipes, Displacements, Internal, Scientific_data, fit_to_first, fit_to_mean, Pivot_finder, RelaxError, RelaxFileError, RelaxNoPdbError, RelaxNoSequenceError, get_file_path, open_write_file, write_spin_data, RelaxWarning, RelaxNoPDBFileWarning, RelaxZeroVectorWarning


Function Details [hide private]

add_atom(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'.

connect_atom(index1=None, index2=None)

source code 

Connect two atoms.

Parameters:
  • index1 (str) - The global index of the first atom.
  • index2 (str) - The global index of the first atom.

displacement(model_from=None, model_to=None, atom_id=None, centroid=None)

source code 

Calculate the rotational and translational displacement between two structural models.

Parameters:
  • model_from (int or None) - The optional model number for the starting position of the displacement.
  • model_to (int or None) - The optional model number for the ending position of the displacement.
  • atom_id (str or None) - The molecule, residue, and atom identifier string. This matches the spin ID string format.
  • centroid (list of float or numpy rank-1, 3D array) - An alternative position of the centroid, used for studying pivoted systems.

find_pivot(models=None, atom_id=None, init_pos=None)

source code 

Superimpose a set of structural models.

Parameters:
  • models (list of int or None) - The list of models to use. If set to None, then all models will be used.
  • atom_id (str or None) - The molecule, residue, and atom identifier string. This matches the spin ID string format.
  • init_pos (list of float or numpy rank-1, 3D array) - The starting pivot position for the pivot point optimisation.

get_pos(spin_id=None, str_id=None, ave_pos=False)

source code 

Load the spins from the structural object into the relax data store.

Parameters:
  • spin_id (str) - The molecule, residue, and spin identifier string.
  • str_id (int or str) - The structure identifier. This can be the file name, model number, or structure number.
  • ave_pos (bool) - A flag specifying if the average atom position or the atom position from all loaded structures is loaded into the SpinContainer.

load_spins(spin_id=None, str_id=None, ave_pos=False)

source code 

Load the spins from the structural object into the relax data store.

Parameters:
  • spin_id (str) - The molecule, residue, and spin identifier string.
  • str_id (int or str) - The structure identifier. This can be the file name, model number, or structure number.
  • ave_pos (bool) - A flag specifying if the average atom position or the atom position from all loaded structures is loaded into the SpinContainer.

read_pdb(file=None, dir=None, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, parser='internal', verbosity=1, fail=True)

source code 

The PDB loading function.

Parsers

A number of parsers are available for reading PDB files. These include:

  • 'scientific', the Scientific Python PDB parser.
  • 'internal', a low quality yet fast PDB parser built into relax.
Parameters:
  • file (str) - The name of the PDB file to read.
  • dir (str or None) - The directory where the PDB file is located. If set to None, then the file will be searched for in the current directory.
  • 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.
  • parser (str) - The parser to be used to read the PDB file.
  • fail (bool) - A flag which, if True, will cause a RelaxError to be raised if the PDB file does not exist. If False, then a RelaxWarning will be trown instead.
  • verbosity (int) - The amount of information to print to screen. Zero corresponds to minimal output while higher values increase the amount of output. The default value is 1.
Raises:
  • RelaxFileError - If the fail flag is set, then a RelaxError is raised if the PDB file does not exist.

read_xyz(file=None, dir=None, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, verbosity=1, fail=True)

source code 

The XYZ loading function.

Parameters:
  • file (str) - The name of the XYZ file to read.
  • dir (str or None) - The directory where the XYZ file is located. If set to None, then the file will be searched for in the current directory.
  • read_mol (None, int, or list of int) - The molecule(s) to read from the file, independent of model. 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.
  • fail (bool) - A flag which, if True, will cause a RelaxError to be raised if the XYZ file does not exist. If False, then a RelaxWarning will be trown instead.
  • verbosity (int) - The amount of information to print to screen. Zero corresponds to minimal output while higher values increase the amount of output. The default value is 1.
Raises:
  • RelaxFileError - If the fail flag is set, then a RelaxError is raised if the XYZ file does not exist.

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

source code 

Rotate the structural data about the origin by the specified forwards rotation.

Parameters:
  • R (numpy 3D, rank-2 array or a 3x3 list of floats) - The forwards rotation matrix.
  • origin (numpy 3D, rank-1 array or list of len 3 or None) - The origin of the rotation. If not supplied, the origin will be set to [0, 0, 0].
  • 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.

set_vector(spin=None, xh_vect=None)

source code 

Place the XH unit vector into the spin container object.

Parameters:
  • spin (SpinContainer instance) - The spin container object.
  • xh_vect (array of len 3) - The unit vector parallel to the XH bond.

superimpose(models=None, method='fit to mean', atom_id=None, centroid=None)

source code 

Superimpose a set of structural models.

Parameters:
  • models (list of int or None) - The list of models to superimpose. If set to None, then all models will be used.
  • method (str) - The superimposition method. It must be one of 'fit to mean' or 'fit to first'.
  • atom_id (str or None) - The molecule, residue, and atom identifier string. This matches the spin ID string format.
  • centroid (list of float or numpy rank-1, 3D array) - An alternative position of the centroid to allow for different superpositions, for example of pivot point motions.

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

source code 

Shift the structural data by the specified translation vector.

Parameters:
  • T (numpy rank-1, 3D array or list of float) - The translation vector.
  • model (int or None) - The model to translate. 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.

vectors(attached=None, spin_id=None, model=None, verbosity=1, ave=True, unit=True)

source code 

Extract the bond vectors from the loaded structures and store them in the spin container.

Parameters:
  • attached (str) - The name of the atom attached to the spin, as given in the structural file. Regular expression can be used, for example 'H*'. This uses relax rather than Python regular expression (i.e. shell like syntax).
  • spin_id (str) - The spin identifier string.
  • model (str) - The model to extract the vector from. If None, all vectors will be extracted.
  • verbosity (int) - The higher the value, the more information is printed to screen.
  • ave (bool) - A flag which if True will cause the average of all vectors to be extracted.
  • unit (bool) - A flag which if True will cause the function to calculate the unit vectors.

write_pdb(file=None, dir=None, model_num=None, compress_type=0, force=False)

source code 

The PDB writing function.

Parameters:
  • file (str) - The name of the PDB file to write.
  • dir (str or None) - The directory where the PDB file will be placed. If set to None, then the file will be placed in the current directory.
  • 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.
  • compress_type (int) - The compression type. The integer values correspond to the compression type: 0, no compression; 1, Bzip2 compression; 2, Gzip compression.
  • force (bool) - The force flag which if True will cause the file to be overwritten.