7.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()

MDAnalysis.transformations.translate.translate(vector)[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
Returns:
Return type:Timestep object
MDAnalysis.transformations.translate.center_in_box(ag, center='geometry', point=None, wrap=False)[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.
Returns:

Return type:

Timestep object