Get radius of gyration#

Computing the radius of gyration of a molecular system.

The function molsysmt.structure.get_radius_of_gyration() measures the spatial distribution of atoms around their center of mass or geometric center, quantifying overall macromolecular compactness and shape fluctuations.

Added in version 1.0.0.

Basic usage#

Let’s show how to calculate the geometric radius of gyration over a pentalanine trajectory:

import molsysmt as msm
import matplotlib.pyplot as plt
import pyunitwizard as puw
molsys = msm.convert(msm.systems['pentalanine']['traj_pentalanine.h5msm'])

We calculate the geometric radius of gyration over all heavy atoms using molsysmt.structure.get_radius_of_gyration():

rg_geom = msm.structure.get_radius_of_gyration(molsys, selection='atom_type!="H"')
print('Radius of gyration shape:', rg_geom.shape)
print(f'Mean geometric Rg: {rg_geom.mean():.3f}')
Radius of gyration shape: (5000,)
Mean geometric Rg: 0.515 nanometer

Mass-weighted radius of gyration#

Passing weights='masses' calculates the physical, mass-weighted radius of gyration around the center of mass:

rg_mass = msm.structure.get_radius_of_gyration(molsys, selection='atom_type!="H"', weights='masses')
print(f'Mean mass-weighted Rg: {rg_mass.mean():.3f}')
Mean mass-weighted Rg: 0.514 nanometer

Radius of gyration evolution across structural ensembles#

We plot the time series and distribution of the radius of gyration to observe conformational transitions between compact and extended states:

time = msm.get(molsys, element='system', time=True)
time_val = puw.get_value(time, to_unit='ps')
rg_geom_val = puw.get_value(rg_geom, to_unit='nm')
rg_mass_val = puw.get_value(rg_mass, to_unit='nm')

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 4.5), gridspec_kw={'width_ratios': [2.5, 1]})

# Time series
ax1.plot(time_val, rg_geom_val, label='Geometric Rg', color='navy', lw=1.2, alpha=0.8)
ax1.plot(time_val, rg_mass_val, label='Mass-weighted Rg', color='darkorange', lw=1.2, alpha=0.8)
ax1.set_xlabel('Time (ps)')
ax1.set_ylabel('Radius of Gyration (nm)')
ax1.set_title('Radius of Gyration vs. Simulation Time')
ax1.grid(True, linestyle='--', alpha=0.5)
ax1.legend()

# Histogram distribution
ax2.hist(rg_mass_val, bins=30, orientation='horizontal', color='darkorange', alpha=0.7, edgecolor='black')
ax2.set_xlabel('Count')
ax2.set_title('Rg Distribution')
ax2.grid(True, linestyle='--', alpha=0.5)

plt.tight_layout()
plt.show()
../../../../_images/68c2da0de7e0b7280ed91d9c04e667729ad4e43b938a3c0264ef4582317dd580.png