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()).
Learning Outcomes
By the end of this module, you will be able to:
Calculate spatial centroids and center molecular systems at the origin using
msm.structure.get_center()andmsm.structure.center().Translate 3D spatial coordinates using unit-safe translation vectors with
msm.structure.translate().Calculate coordinate RMSD and perform rigid structural superpositions using
msm.structure.get_rmsd()andmsm.structure.least_rmsd_align().
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
Hint
msm.structure.get_center(): Computes the geometric centroid (unweighted mean coordinates) of a molecular system or selection. See API doc: molsysmt.structure.get_center().
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
Hint
msm.structure.translate(): Shifts 3D spatial coordinates of a molecular system or selection along a specified displacement vector. See API doc: molsysmt.structure.translate().
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
Hint
msm.structure.get_rmsd(): Computes the Root-Mean-Square Deviation between two coordinate structures or structural selections. See API doc: molsysmt.structure.get_rmsd().
🏆 Challenge 16: The Structural Master#
Load the T4 Lysozyme system (
systems['T4 lysozyme L99A']['181l.bcif.gz']).Calculate its initial spatial center using
msm.structure.get_center().Translate the system by
[2.0, 0.0, 0.0] nmusingmsm.structure.translate().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.
See also
API Documentation for Functions in this Module:
molsysmt.structure.get_center()— Spatial centroid calculation.molsysmt.structure.translate()— Spatial translation engine.molsysmt.structure.get_rmsd()— Root-Mean-Square Deviation calculator.molsysmt.structure.least_rmsd_align()— Least-RMSD structural alignment engine.
Related Course Modules & Guides:
Previous Module: Module 15: Semantic Labeling
Next Module: Module 17: Merging and Growing Systems
User Guide: user-foundations