Operate

Operate

class sasmol.operate.Move[source]

Bases: object

Base class containing methods to perform basic translation, rotation, and alignment operations on instances of system objects.

The methods in this class move entire objects, not pieces of single objects (i.e. no intra-object movements)

Examples

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

>>> import sasmol.system as system ; import math
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0 ; axis = 'x' ; theta = 45.0 * math.pi / 180.0
>>> molecule.rotate(frame, axis, theta)

Second example shows how to use class methods directly:

>>> import sasmol.system as system ; import math
>>> import sasmol.operate as operate
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0 ; axis = 'x' ; theta = 45.0 * math.pi / 180.0
>>> operate.Move.rotate(molecule, frame, axis, theta)

Note

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

align(other, self_basis=None, other_basis=None, mode='production', align_variables=None, **kwargs)[source]

Alignment of one object on top of another “self” is aligned onto “other” using the basis of molecule 2 to align onto the basis of molecule 1 and the transformation is then done to all the atoms of molecule 2

self = molecule_2

other = molecule_1

self aligned to other

molecule_2 aligned to molecule_1

Parameters
  • frame – integer : trajectory frame number to use

  • other – system object : molecule 1

  • self_basis – string : unique description of atoms used for alignment (only needed in initialization mode)

  • other_basis – string : unique description of atoms used for alignment (only needed in initialization mode)

  • mode – string : ‘initialization’ or ‘production’

  • align_variables – dict : data from initialization mode to be used in production mode

  • kwargs – optional future arguments

Returns

updated self._coor or initialization data

Return type

None or dict

Examples

>>> import sasmol.system as system
>>> molecule_1 = system.Molecule('hiv1_gag.pdb')
>>> molecule_2 = system.Molecule('moved_and_rotated_hiv1_gag.pdb')
>>> frame = 0
>>> basis_1 = 'name[i] == "CA"'
>>> basis_2 = 'name[i] == "CA"'
>>> align_variables = molecule_2.align(molecule_1, basis_1, basis_2, mode='initialization')
>>> molecule_2.align(molecule_1, align_variables=align_variables)
>>> com_sub_2 = molecule_2.calculate_center_of_mass(frame)

Note

mass_check determines if mass is defined for the object so that center of mass can be calculated

align_pmi_on_axis(frame, pmi_eigenvector, alignment_vector_axis)[source]

aligns one principal moment eigenvector to the given axis

align_pmi_on_cardinal_axes(frame)[source]

aligns all principal moment eigenvectors to cardinal x, y, & z axes

center(frame, **kwargs)[source]

Method moves the center of mass of object to [0.0, 0.0, 0.0]

Parameters
  • frame – integer : trajectory frame number to use

  • kwargs – optional future arguments

Returns

updated self._coor and self._center_of_mass

Return type

None

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0
>>> molecule.calculate_center_of_mass(frame)
array([ -6.79114736, -23.71577133,   8.06558513])
>>> molecule.center(frame)
>>> molecule.calculate_center_of_mass(frame)
array([  7.11544707e-13,   2.48159571e-12,  -8.45832820e-13])

Note

mass_check is called to validate self._total_mass()

Can achieve same result using self.translate(frame, [0,0,0], point=True)

mass_check(**kwargs)[source]

Note

mass_check determines if mass is defined for the object so that center of mass can be calculated

Parameters

kwargs – optional future arguments

Returns

updated self._total_mass

Return type

None

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.mass_check()
rotate(frame, axis, theta, **kwargs)[source]

Simple rotation about the x, y, or z axis.

Parameters
  • frame – integer : trajectory frame number to use

  • axis – string : ‘x’, ‘y’, or ‘z’

  • theta – float : angle in radians

  • kwargs – optional future arguments

Returns

updated self._coor

Return type

None

Examples

>>> import sasmol.system as system ; import math
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0 ; axis = 'x' ; theta = 45.0 * math.pi / 180.0
>>> molecule.rotate(frame, axis, theta)

Note

Calculations are carried out using radians

rotate_euler(frame, phi, theta, psi, **kwargs)[source]

Rotate the molecule by a euler angle set (phi,theta,psi)

Parameters
  • frame – integer : trajectory frame number to use

  • phi – float : phi angle

  • theta – float : theta angle

  • psi – float : psi angle

  • kwargs – optional future arguments

Returns

updated self._coor

Return type

None

Examples

>>> import sasmol.system as system ; import math
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0
>>> phi = 45.0 * math.pi / 180.0
>>> theta = 45.0 * math.pi / 180.0
>>> psi = 32.0 * math.pi / 180.0
>>> molecule.euler_rotate(frame, phi, theta, psi)

Note

Calculations are carried out using radians

rotate_general_axis(frame, theta, unit_axis, **kwargs)[source]

The general rotation of a molecule along an arbitrarily given unit axis (ux,uy,uz) by an angle theta.

Parameters
  • frame – integer : trajectory frame number to use

  • theta – float : angle in radians

  • unit_axis – float : [ux, uy, uz] components of unit axis

  • kwargs – optional future arguments

Returns

updated self._coor

Return type

None

Examples

>>> import sasmol.system as system ; import math
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0 ; theta = 45.0 * math.pi / 180.0
>>> unit_axis = [ 0.2, 1.3, -3.5 ]
>>> molecule.rotate_general_axis(frame, theta, unit_axis)

Note

Calculations are carried out using radians

translate(frame, value, **kwargs)[source]

translate moves the object

Parameters
  • frame – integer : trajectory frame number to use

  • value – list of x, y, z float values

  • kwargs

    point = Truewill translate to a fixed point

    given by value variable

Returns

updated self._coor and self._center_of_mass

Return type

None

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0
>>> molecule.calculate_center_of_mass(frame)
array([ -6.79114736, -23.71577133,   8.06558513])
>>> displacement = [3.0, 4.0, 5.0]
>>> molecule.translate(frame, displacement)
>>> molecule.calculate_center_of_mass(frame)
array([ -3.79114736, -19.71577133,  13.06558513])
>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> frame = 0
>>> final_position = [3.0, 4.0, 5.0]
>>> molecule.translate(frame, final_position, point=True)
>>> molecule.calculate_center_of_mass(frame)
array([ 3.,  4.,  5.])

Note

mass_check is called to validate self._total_mass()

sasmol.operate.set_average_vdw(mol)[source]

# NOTE: atom_vdw must be shape (natoms,2); only column 2 (radius) is used by pairs.f