import molsysmt as msm
from molsysmt import pyunitwizard as puw
import numpy as np
import matplotlib.pyplot as plt

Computing principal components#

Computing covariance eigenvectors and eigenvalues for a trajectory.

The first returned row is PC1, the eigenvector with the largest mean squared dispersion. Eigenvectors are dimensionless. Eigenvalues are returned from largest to smallest with squared-coordinate units, normally nm². This function does not return per-frame projections. The native eigensolver inherits the session CPU policy; parallel=False or parallel=True, num_threads=N overrides it for one analysis.

Added in version 1.0.0.

molecular_system = msm.systems['pentalanine']['traj_pentalanine.h5']
molecular_system = msm.convert(molecular_system, to_form='molsysmt.MolSys')
eigenvectors, eigenvalues = msm.structure.principal_component_analysis(molecular_system, selection='atom_name=="CA"')
eigenvalues