Path B - Module 41: Wrapping & Unwrapping#

In a periodic simulation, atoms can “jump” from one side of the box to the other. While this is physically correct, it makes the molecule look broken or exploded. For your industrial enzyme study, you need a continuous structure to perform distance and RMSD calculations.

In this module, you will learn to fix these visual and structural artifacts using MolSysMT.

import molsysmt as msm
from molsysmt import systems

# Load a trajectory where the enzyme crosses the box boundaries
villin_traj = systems['chicken villin HP35']['traj_chicken_villin_HP35_solvated.dcd']
villin_topo = systems['chicken villin HP35']['chicken_villin_HP35_solvated.h5msm']
molsys = [villin_topo, villin_traj]

1. Identifying the “Broken” State#

When you visualize a raw simulation frame, you might see long, artificial bonds. This happens because some atoms of the PETase are on the left side of the box and others on the right.

# Visual check of frame 0
msm.view(molsys, structure_indices=0)

2. The Unwrapping Solution#

The function unwrap() restores temporal continuity independently for each atom across trajectory frames. To make bonded molecules whole within a frame, use a wrapping function with keep_covalent_bonds=True.

# Restore temporal continuity for protein atom trajectories
unwrapped_molsys = msm.pbc.unwrap(molsys, selection='molecule_type=="protein"')

print("The enzyme atom trajectories are now temporally continuous.")

3. Minimum Image Convention (MIC)#

If you want to measure the distance between the BHET substrate and the catalytic Serine, MolSysMT needs to find the closest image in the periodic space. wrap_to_mic() ensures your coordinates are ready for this.

# Wrap the solvent back into the primary box around the enzyme
wrapped_molsys = msm.pbc.wrap_to_pbc(molsys, selection='molecule_type=="water"', keep_covalent_bonds=True)

print("Solvent wrapped back to the primary unit cell.")

🏆 Path B Challenge: The Space Cleaner#

  1. Apply msm.pbc.unwrap() to the entire system (protein and water).

  2. Visualize the result. Does the water now look like a “cloud” around the protein instead of a box?

  3. Use msm.pbc.wrap_to_mic() on the ions to make sure they are within the nearest image of the enzyme.

  4. Verify with msm.get() that no atom coordinates are physically impossible after unwrapping.

You now have a continuous simulation world! In Module 42, we will start talking about the forces that drive the movement: Molecular Mechanics (Energies).