Path A - Module 46: Geometric Transformations (Space)#

To build a complex or to analyze an interaction, you often need to move your molecules manually. Maybe you want to pull a peptide away from its target, or rotate it to explore a different binding pose.

In this module, you will learn to master the spatial transformations of MolSysMT: translate(), rotate(), and center().

import molsysmt as msm
from molsysmt import systems
import numpy as np

# Load our complex
fibril = msm.convert('pdb:2BEG', to_form='molsysmt.MolSys')
peptide = msm.build.build_peptide('KLVFF')
molsys = msm.merge([fibril, peptide])

1. Centering the System#

Before any transformation, it’s a good practice to place your main target at the center of the world (coordinate 0,0,0).

# Center the fibril at the origin
msm.structure.center(molsys, selection='molecule_type=="protein"', in_place=True)

center = msm.structure.get_center(molsys, selection='molecule_type=="protein"')
print(f"New center of the fibril: {center}")

2. Translating (Moving)#

Let’s pull the peptide away from the fibril by moving it 2 nanometers along the X-axis.

# Move the peptide selection by a vector [2.0, 0.0, 0.0] nm
vector = np.array([2.0, 0.0, 0.0]) * msm.pyunitwizard.unit('nm')
msm.structure.translate(molsys, selection='molecule_type=="peptide"', translation=vector, in_place=True)

print("Peptide translated away from the core.")

3. Rotating#

You can rotate a selection around a specific axis by a certain angle. This is essential for docking studies.

# Rotate the peptide 90 degrees around the Y axis and its own center
rotation = np.array([[0.0, 0.0, 1.0], [0.0, 1.0, 0.0], [-1.0, 0.0, 0.0]])
rotation_center = msm.structure.get_center(molsys, selection='molecule_type=="peptide"')
msm.structure.rotate(
    molsys, selection='molecule_type=="peptide"', rotation=rotation,
    rotation_center=rotation_center, in_place=True
)

print("Peptide rotated 90 degrees.")
msm.view(molsys)

🏁 END OF PHASE 5: THE PHYSICS LAB#

Congratulations! You have mastered the environment and the dynamics of your systems. You can now:

  1. Manage Boxes and PBC.

  2. Wrap and Unwrap coordinates.

  3. Calculate Energies and Forces.

  4. Minimize and Simulate in OpenMM.

  5. Translate, Rotate, and Center your systems in space.

Your project is physically sound. Now, we enter the final stretch. In Phase 6: Pipeline Developer, we will learn how to handle Big Data trajectories and automate your analysis for professional production.