Path A - Module 34: Comparison & Superposition#

How much does your model change during simulation? To answer this, you cannot just look at coordinates, because the whole system might have rotated or translated in the box. You need to Align the structures first.

In this module, you will learn to calculate structural similarity using the RMSD (Root Mean Square Deviation) and perform spatial superpositions.

import molsysmt as msm
from molsysmt import systems

# Let's use two different frames from the Villin trajectory to compare them
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. Raw RMSD (No Alignment)#

If you calculate RMSD without aligning, you are measuring both the change in shape AND the change in position. Usually, this is not what you want.

# Measure RMSD between frame 0 and frame 100 without alignment
rmsd_raw = msm.structure.get_rmsd(molsys, selection='molecule_type=="protein"', 
                        structure_indices=100, reference_structure_index=0)

print(f"Raw RMSD: {rmsd_raw}")

2. Least-RMSD Alignment#

To see only the change in shape, we must rotate and translate the structures to minimize the distance between them. MolSysMT does this automatically with least_rmsd_align().

# Align frame 100 to frame 0 and get the optimized RMSD
rmsd_opt = msm.structure.least_rmsd_align(molsys, selection='molecule_type=="protein"', 
                                          structure_indices=100, reference_structure_index=0)

print(f"Optimized RMSD after alignment: {rmsd_opt}")

3. Fitting a Whole Trajectory#

You can align an entire trajectory to a reference frame (e.g., the first one) to create a centered and stable movie for analysis.

# Align all frames of the protein to the first frame
# (Note: This returns a new object with the modified coordinates)
aligned_molsys = msm.structure.least_rmsd_fit(molsys, selection='molecule_type=="protein"')

print("Full trajectory alignment completed.")

🏆 Path A Challenge: The Structural Judge#

  1. Calculate the RMSD profile (RMSD vs time) for the whole Villin trajectory using the first frame as a reference.

  2. Find the frame with the highest RMSD (the most deformed structure).

  3. Align that frame with the first one and visualize both of them superimposed in the viewer.

Alignment is critical for meaningful comparisons. In Module 35, we will learn how to reduce the complexity of these motions using Principal Component Analysis (PCA).