8.6.1. Trajectory translation — MDAnalysis.transformations.translate

Translate the coordinates of a given trajectory by a given vector. The vector can either be user defined, using the function translate() or defined by centering an AtomGroup in the unit cell using the function center_in_box()

class MDAnalysis.transformations.translate.translate(vector, max_threads=None, parallelizable=True)[source]

Translates the coordinates of a given Timestep instance by a given vector.

Example

ts = MDAnalysis.transformations.translate([1,2,3])(ts)
Parameters

vector (array-like) – coordinates of the vector to which the coordinates will be translated

Return type

Timestep object

Changed in version 2.0.0: The transformation was changed from a function/closure to a class with __call__.

Changed in version 2.0.0: The transformation was changed to inherit from the base class for limiting threads and checking if it can be used in parallel analysis.

Parameters
  • max_threads (int, optional) – The maximum thread number can be used. Default is None, which means the default or the external setting.

  • parallelizable (bool, optional) – A check for if this can be used in split-apply-combine parallel analysis approach. Default is True.

class MDAnalysis.transformations.translate.center_in_box(ag, center='geometry', point=None, wrap=False, max_threads=None, parallelizable=True)[source]

Translates the coordinates of a given Timestep instance so that the center of geometry/mass of the given AtomGroup is centered on the unit cell. The unit cell dimensions are taken from the input Timestep object. If a point is given, the center of the atomgroup will be translated to this point instead.

Example

ag = u.residues[1].atoms
ts = MDAnalysis.transformations.center(ag,center='mass')(ts)
Parameters
  • ag (AtomGroup) – atom group to be centered on the unit cell.

  • center (str, optional) – used to choose the method of centering on the given atom group. Can be ‘geometry’ or ‘mass’

  • point (array-like, optional) – overrides the unit cell center - the coordinates of the Timestep are translated so that the center of mass/geometry of the given AtomGroup is aligned to this position instead. Defined as an array of size 3.

  • wrap (bool, optional) – If True, all the atoms from the given AtomGroup will be moved to the unit cell before calculating the center of mass or geometry. Default is False, no changes to the atom coordinates are done before calculating the center of the AtomGroup.

Return type

Timestep object

Changed in version 2.0.0: The transformation was changed from a function/closure to a class with __call__.

Changed in version 2.0.0: The transformation was changed to inherit from the base class for limiting threads and checking if it can be used in parallel analysis.

Parameters
  • max_threads (int, optional) – The maximum thread number can be used. Default is None, which means the default or the external setting.

  • parallelizable (bool, optional) – A check for if this can be used in split-apply-combine parallel analysis approach. Default is True.