Calculate

Calculate

class calculate.Calculate[source]

Bases: object

Base class containing methods to calculate properties of system object.

Examples

First example shows how to use class methods from system object:

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_mass()
47896.61864599498

Second example shows how to use class methods directly:

>>> import sasmol.system as system
>>> import sasmol.calculate as calculate
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> calculate.Calculate.calculate_mass(molecule)
47896.61864599498

Note

self parameter is not shown in the Parameters section in the documentation

TODO: Need to write a generic driver to loop over single or multiple frames

calculate_center_of_mass(frame, **kwargs)[source]

This method calculates the center of mass of the object.

Parameters:
  • frame – integer : trajectory frame number to use
  • kwargs – optional future arguments
Returns:

coordinates of center of mass

Return type:

numpy array

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_center_of_mass(0)
array([ -6.79114736, -23.71577133,   8.06558513])
calculate_mass(**kwargs)[source]

Note

atomic weights are contained in the properties.py file

http://physics.nist.gov/cgi-bin/Compositions/stand_alone.pl?ele=&ascii=html&isotype=some

standard atomic weight is based on the natural istopic composition

NOTE: deuterium is ‘D’ 2H1 and ‘1H’ is 1H1, all other elements have their natural abundance weight. These elements are located at the end of the dictionary.

Parameters:kwargs – optional future arguments
Returns:mass of object in Daltons
Return type:float

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_mass()
47896.61864599498
calculate_minimum_and_maximum(**kwargs)[source]

This method calculates the minimum and maximum values of of the object in (x,y,z)

The default usage is to evaluate all frames

A numpy array of minimum and maximum values for each dimension are returned

Parameters:kwargs – frames = [] : integer list of frames to process
Returns:nested list of minimum and maximum values [ [ min_x, min_y, min_z ], [max_x, max_y, max_z] ]
Return type:numpy array

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_minimum_and_maximum()
[array([-31.29899979, -93.23899841, -85.81900024]), array([ 19.64699936,  30.37800026,  99.52999878])]
>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.read_dcd('hiv1_gag_200_frames')
>>> molecule.calculate_minimum_and_maximum()
[array([ -94.47146606, -121.88082886,  -99.94940948]), array([  52.85133362,   65.53725433,  100.76850891])]
>>> molecule.calculate_minimum_and_maximum(frames=[0,1,2,3])
[array([-30.9330883 , -92.68256378, -84.51082611]), array([ 20.98281288,  38.45230484,  99.91564178])]
calculate_molecular_formula(**kwargs)[source]

Method to determine the number of each element in the molecule

Parameters:kwargs – optional future arguments
Returns:{element : integer number, ... }
Return type:dictionary

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_molecular_formula()
{'H': 3378, 'C': 2080, 'S': 24, 'O': 632, 'N': 616}
calculate_principle_moments_of_inertia(frame, **kwargs)[source]

This method calculates the principal moments of inertia of the object. It uses the center method from operate.Move to center the molecule. The present method is designated for the non-linear system with non-singular moment of inertia matrix only. For the linear systems, it will return eigenvectors and I as None. Testing for non-None return values should be done in the calling method.

Parameters:
  • frame – integer : trajectory frame number to use
  • kwargs – optional future arguments
Returns:

principle moments of inertia of object : eigenvalues, eigenvectors, and I

Return type:

tuple of numpy arrays

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_principle_moments_of_inetia(0)
(array([  1.30834716e+07,   1.91993314e+08,   1.85015201e+08]),
array([[-0.08711655, -0.97104917,  0.22242802],
       [-0.512547  ,  0.23514759,  0.82583363],
       [ 0.85422847,  0.04206103,  0.51819358]]),
array([[  1.90290278e+08,  -9.27036144e+06,   1.25097100e+07],
       [ -9.27036144e+06,   1.40233826e+08,   7.53462715e+07],
       [  1.25097100e+07,   7.53462715e+07,   5.95678834e+07]]))
calculate_radius_of_gyration(frame, **kwargs)[source]

This method calculates the radius of gyration of the object

Parameters:
  • frame – integer : trajectory frame number to use
  • kwargs – optional future arguments
Returns:

radius of gyration of object

Return type:

float

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_radius_of_gyration(0)
64.043168998442368
calculate_residue_charge(**kwargs)[source]

Method to sum the atomic charges and assign the net charge of the resiude to a new variable that is attached to each atom.

Note

Requires that the atom_charge() attribute of object is complete

Parameters:kwargs – optional future arguments
Returns:charge per residue assigned to object
Return type:float

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.calculate_residue_charge()
>>> single_molecule.calculate_residue_charge()
>>> residue_charge = single_molecule.residue_charge()
>>> print('res-charge = ',residue_charge[0])
calculate_root_mean_square_deviation(other, **kwargs)[source]

This method calculates the radius root mean square deviation (rmsd) of one set of coordinates compared to another

self contains the coordinates of set 1 other contains the coordinates of set 2

the number of coordinates in each set must be equal

To use this over multiple frames you must call this function repeatedly.

Parameters:
  • other – system object with coordinates with equal number of frames
  • kwargs – optional future arguments
Returns:

root mean square deviation between objects

Return type:

float

Examples