Module 16: Structural Operations#

Welcome back, Apprentice Master. In Module 15: Semantic Labeling, you mastered generating human-readable nomenclature strings using msm.get_label(). Now we explore 3D spatial operations and coordinate manipulation using msm.structure.

Molecular systems possess 3D spatial coordinates that define their biological conformation. The msm.structure specialized module provides geometric analysis and spatial transformation functions, including spatial centering (msm.structure.center()), translation (msm.structure.translate()), spatial alignment (msm.structure.least_rmsd_align()), and Root-Mean-Square Deviation calculation (msm.structure.get_rmsd()).

1. Geometric Centering#

Let’s begin by importing MolSysMT, loading our T4 Lysozyme demonstration system, and converting it to a native MolSys object.

import molsysmt as msm
from molsysmt import systems

# Load T4 Lysozyme system
lysozyme = msm.convert(systems['T4 lysozyme L99A']['181l.bcif.gz'], to_form='molsysmt.MolSys')

# Calculate initial spatial center (centroid)
center_before = msm.structure.get_center(lysozyme)
print(f"Center before centering: {center_before}")
Center before centering: [[[3.494637057598893 1.1291843164469129 0.9497851492019409]]] nanometer

To center a molecular system so that its spatial centroid rests at the origin \((0, 0, 0)\text{ nm}\), use msm.structure.center():

# Center system at the origin
lysozyme_centered = msm.structure.center(lysozyme)

# Verify centered coordinates
center_after = msm.structure.get_center(lysozyme_centered)
print(f"Center after centering : {center_after}")
Center after centering : [[[-3.4032457629245257e-15 -1.4200992914566887e-15   1.6802042832078705e-15]]] nanometer

2. Spatial Translation#

You can translate a molecular system or selection in 3D space by specifying a displacement vector with physical units using msm.structure.translate():

# Translate system by 1.0 nm along the X axis
lysozyme_shifted = msm.structure.translate(lysozyme_centered, translation='[1.0, 0.0, 0.0] nanometers')

# Verify new center location
center_shifted = msm.structure.get_center(lysozyme_shifted)
print(f"Center after translation: {center_shifted}")
Center after translation: [[[0.9999999999999959 -1.4200992914566887e-15 1.6802042832078705e-15]]] nanometer

3. Structural Alignment and RMSD#

To compare or superimpose two conformational structures, use msm.structure.get_rmsd() to measure Root-Mean-Square Deviation, and msm.structure.least_rmsd_align() to perform rigid spatial alignment:

# Calculate RMSD between centered and shifted systems
rmsd_val = msm.structure.get_rmsd(lysozyme_centered, reference_molecular_system=lysozyme_shifted)
print(f"RMSD before alignment: {rmsd_val}")

# Perform optimal rigid alignment (least-RMSD fit)
aligned_sys = msm.structure.least_rmsd_align(lysozyme_shifted, reference_molecular_system=lysozyme_centered)

# Verify RMSD after alignment
rmsd_after = msm.structure.get_rmsd(lysozyme_centered, reference_molecular_system=aligned_sys)
print(f"RMSD after alignment : {rmsd_after}")
RMSD before alignment: [1.0] nanometer
RMSD after alignment : [0.32478039342852333] nanometer

🏆 Challenge 16: The Structural Master#

  1. Load the T4 Lysozyme system (systems['T4 lysozyme L99A']['181l.bcif.gz']).

  2. Calculate its initial spatial center using msm.structure.get_center().

  3. Translate the system by [2.0, 0.0, 0.0] nm using msm.structure.translate().

  4. Align the translated system back onto the original reference structure using msm.structure.least_rmsd_align() and verify that post-alignment RMSD is near zero.

Spatial coordinate manipulation sets the foundation for assembly and spatial positioning. In Module 17: Merging and Growing Systems, we will learn how to combine separate molecular components and structural series.