Align principal axes#

Aligning the principal inertia or geometric axes of a molecular system over reference coordinate axes.

The function molsysmt.structure.align_principal_axes() rotates a molecular system so that its principal axes of inertia (or geometric axes) align with a specified target orthonormal coordinate basis.

Added in version 1.0.0.

Basic usage#

Let’s demonstrate principal axes alignment using a POPC lipid molecule:

import molsysmt as msm
import numpy as np
crd = msm.systems['POPC']['popc.crd']
psf = msm.systems['POPC']['popc.psf']
molsys = msm.convert([crd, psf], to_form='molsysmt.MolSys')

We inspect the principal axes of inertia and their principal moments before alignment using molsysmt.structure.get_principal_axes():

axes, momenta = msm.structure.get_principal_axes(molsys)
for ii in range(3):
    print(f'Axis {ii}: {axes[0, ii]} | Moment: {momenta[0, ii]:.2f}')
Axis 0: [-0.09213962  0.02624376  0.9954002 ] | Moment: 13.38
Axis 1: [0.56239734 0.82631277 0.03027277] | Moment: 73.68
Axis 2: [-0.82171742  0.56259975 -0.09089556] | Moment: 78.33

Now we align the principal axes to the canonical Cartesian basis \([[1,0,0], [0,1,0], [0,0,1]]\):

molsys_aligned = msm.structure.align_principal_axes(molsys, axes=[[1,0,0], [0,1,0], [0,0,1]])

We verify that the principal axes of the aligned system match the canonical Cartesian directions:

axes_aligned, momenta_aligned = msm.structure.get_principal_axes(molsys_aligned)
for ii in range(3):
    print(f'Aligned Axis {ii}: {axes_aligned[0, ii]}')
Aligned Axis 0: [ 1.00000000e+00 -4.52971253e-16 -4.35450667e-16]
Aligned Axis 1: [4.52971253e-16 1.00000000e+00 8.88178420e-16]
Aligned Axis 2: [ 4.35450667e-16 -8.32667268e-16  1.00000000e+00]

Aligning macromolecular coordinates along target spatial axes#

We can similarly align globular protein structures, such as chicken villin HP35, and visualize the aligned system in 3D:

protein = msm.convert(msm.systems['chicken villin HP35']['chicken_villin_HP35.h5msm'])
protein_aligned = msm.structure.align_principal_axes(protein, axes=[[1,0,0], [0,1,0], [0,0,1]])
msm.view(protein_aligned)