Skip to main content

RmsfPlan

Compute root-mean-square fluctuations (RMSF) of atomic positions.

Constructor

from warp_md import RmsfPlan

plan = RmsfPlan(selection)
selection
Selection
required
Atoms to analyze

run() Method

result = plan.run(
    trajectory,
    system,
    chunk_frames=128,
    device="auto"
)
Returns: 1D array of RMSF values in Å (one per atom in selection)

Example

import warp_md as wmd
import numpy as np

system = wmd.System("protein.pdb")
traj = wmd.open_trajectory("md.xtc", system)

# Calculate C-alpha RMSF
ca_atoms = system.select("name CA")
plan = wmd.RmsfPlan(ca_atoms)
rmsf = plan.run(traj, system)

# Identify flexible regions
flexible_residues = np.where(rmsf > 2.0)[0]
print(f"Flexible residues: {flexible_residues}")
RMSF is automatically computed after alignment to the average structure.

BfactorsPlan

Convert RMSF to crystallographic B-factors.

Constructor

plan = BfactorsPlan(selection)
selection
Selection
required
Atoms to analyze

run() Method

Returns: 1D array of B-factor values in Ų

Formula

B-factors are computed from RMSF using:
B = (8π²/3) × RMSF²

Example

# Calculate B-factors for comparison with crystal structure
backbone = system.select("backbone")
plan = wmd.BfactorsPlan(backbone)
bfactors = plan.run(traj, system)

# Map to residues (per-residue average)
atoms = system.atom_table()
resids = atoms["resid"]

import pandas as pd
df = pd.DataFrame({"resid": resids, "bfactor": bfactors})
per_residue = df.groupby("resid")["bfactor"].mean()

print(per_residue)

AtomicFluctPlan

Compute atomic fluctuations with full anisotropic displacement parameters (ADPs).

Constructor

plan = AtomicFluctPlan(selection, calcadp=False)
selection
Selection
required
Atoms to analyze
calcadp
bool
default:"False"
Calculate anisotropic displacement parameters (full tensor)

run() Method

When calcadp=False:
  • Returns: 1D array of RMSF values
When calcadp=True:
  • Returns: 2D array of shape (n_atoms, 7) containing:
    • Column 0: Atom index
    • Columns 1-3: Diagonal components (Uxx, Uyy, Uzz)
    • Columns 4-6: Off-diagonal components (Uxy, Uxz, Uyz)

Example

# Calculate anisotropic B-factors
protein = system.select("protein")
plan = wmd.AtomicFluctPlan(protein, calcadp=True)
adp_data = plan.run(traj, system)

atom_idx = adp_data[:, 0]
uxx = adp_data[:, 1]
uyy = adp_data[:, 2]
uzz = adp_data[:, 3]

# Calculate anisotropy
anisotropy = np.std([uxx, uyy, uzz], axis=0)
print(f"Max anisotropy: {anisotropy.max():.3f}")
Use calcadp=True to identify directional flexibility, useful for understanding protein dynamics.

Python Helper Functions

Alternatively, use the high-level Python API:
from warp_md.analysis import rmsf, bfactors, atomicfluct

# Simplified RMSF calculation
rmsf_data = rmsf(traj, system, mask="name CA", byres=True)

# B-factors by residue
bfac_data = bfactors(traj, system, mask="backbone", byres=True)

# Atomic fluctuations with ADP
adp_data = atomicfluct(traj, system, mask="protein", calcadp=True)
mask
str
Atom selection string
byres
bool
default:"False"
Average by residue
bymask
bool
default:"False"
Return single value averaged over entire mask
frame_indices
list
Specific frames to analyze

Build docs developers (and LLMs) love