make_whole
- mdtools.box.make_whole(ag, compound='fragments', reference='cog', inplace=True, debug=False)[source]
Make compounds of a MDAnalysis
AtomGroupwhole that are split across periodic boundaries.Note that all
Atomsof the inputAtomGroupare wrapped back into the primary unit cell before making compounds whole.- Parameters:
ag (
MDAnalysis.core.groups.AtomGroup instance) – The MDAnalysisAtomGroupwhose compounds shall be made whole.compound (
{'group', 'segments', 'residues', 'molecules', 'fragments'}, optional) – Which type of component to make whole. Note that in any case, allAtomswithin each compound must be interconnected by bonds, i.e. compounds must correspond to (parts of) molecules. This is always fulfilled forfragments, because a MDAnalysisfragmentis what is typically considered a molecule, i.e. anAtomGroupwhere anyAtomis reachable from any otherAtomin theAtomGroupby traversing bonds, and none of itsAtomsis bonded to anyAtomoutside theAtomGroup. A ‘molecule’ in MDAnalysis refers to a GROMACS-specific concept. See the MDAnalysis user guide for further information. Note that in any case, even if compound is e.g.'residues', only theAtomsbelonging to ag are taken into account, even if the compound might comprise additionalAtomsthat are not contained in ag. If you want entire molecules to be made whole, make sure that allAtomsof these molecules are part of ag.reference (
{'cog', 'com', None}, optional) – If ‘cog’ (center of geometry) or ‘com’ (center of mass), the compounds that were made whole will be shifted such that their individual reference point lies within the primary unit cell. IfNone, no such shift is performed.inplace (
bool, optional) – IfTrue, coordinates are modified in place.debug (
bool, optional) – IfTrue, check the input arguments. Default:False
- Returns:
pos (
numpy.ndarray) – Array of shape(ag.n_atoms, 3)containing the coordinates of allAtomsin ag after the specified compounds of ag were made whole.
See also
MDAnalysis.core.groups.AtomGroup.unwrap()Move
Atomsin theAtomGroupsuch that bonds within the group’s compounds aren’t split across periodic boundariesMDAnalysis.lib.mdamath.make_whole()Move all
Atomsin an MDAnalysisAtomGroupsuch that bonds don’t split over periodic imagesmdtools.box.wrap()Shift compounds of a MDAnalysis
AtomGroupback into the primary unit cell`
Notes
This function is just a wrapper around the
unwrap()method of the inputAtomGroupthat additionally checks the masses of allAtomsin ag when reference is set to'com'. Seemdtools.check.masses_new()for further information.Before making any compound whole, all
Atomsin ag are wrapped back into the primary unit cell. This is done to make sure that the unwrap algorithm (better “make whole” algorithm) ofunwrap()is working properly. This means that making compounds whole in an unwrappedtrajectorywhile keeping thetrajectoryunwrapped is not possible with this function.Todo
Check if it is really necessary to wrap all
Atomsback into the primary unit before callingunwrap(). This is a serious problem, because it implies an inplace change of theAtomcoordinates.Because
MDAnalysiswill pulltrajectorydata directly from the file it is reading from, changes toAtomcoordinates and boxdimensionswill not persist once theframeis changed (even if inplace isTrue). The only way to make these changes permanent is to load thetrajectoryinto memory, or to write a newtrajectoryto file for everyframe. See the MDAnalysis user guide about trajectories (second last paragraph) and in-memory trajectories.