
Molecular Dynamics
Analyze protein MD trajectories in Python with MDAnalysis selections, RMSD/RMSF, and common analysis modules without memorizing the API.
Overview
Molecular-dynamics is an agent skill for the Build phase that teaches MDAnalysis Universe loading, selection language, and standard trajectory analyses for molecular simulation data.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill molecular-dynamicsWhat is this skill?
- MDAnalysis Universe patterns for topology plus trajectory (DCD) or single-structure PDB loads
- Atom Selection Language recipes: protein, backbone, around ligand, charged residues, boolean combos
- Trajectory metadata: n_frames, dt, totaltime for time-aware reporting
- Pointers to RMSD/RMSF via MDAnalysis.analysis.rms and align.AlignTraj
- Copy-paste snippets for ligand proximity, hydrophobic/charged subsets, and region slicing by resid
Adoption & trust: 516 installs on skills.sh; 27.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have MD trajectories or structures but keep stopping to look up MDAnalysis selection syntax and which analysis modules to import.
Who is it for?
Indie builders or researchers shipping Python tooling around protein/ligand MD outputs who want agent-assisted analysis scaffolding.
Skip if: Teams with no simulation data yet, non-Python stacks, or workflows that need full MD engine setup rather than post-trajectory analysis.
When should I use this skill?
You need MDAnalysis selection patterns, Universe setup, or RMSD/RMSF analysis stubs for existing simulation outputs.
What do I get? / Deliverables
Your agent produces working MDAnalysis snippets for selections, alignment, and RMSD/RMSF-style analyses you can drop into scripts or notebooks.
- MDAnalysis code snippets for selections and Universe loading
- Starter analysis scripts using align and RMS modules
Recommended Skills
Journey fit
Molecular-dynamics is a build-phase integration skill for scripting scientific analysis against simulation outputs, not ideation or go-to-market work. It plugs analysis code into existing MD workflows (Universe loading, AtomGroup selections, trajectory iteration)—classic integrations work on top of research artifacts.
How it compares
Reference skill for MDAnalysis scripting—not a generic data-science tutor or a replacement for dedicated MD GUI suites.
Common Questions / FAQ
Who is molecular-dynamics for?
Solo builders and small teams analyzing molecular dynamics trajectories in Python who want their coding agent to follow MDAnalysis conventions.
When should I use molecular-dynamics?
During Build when you are writing integration scripts to load trajectories, select protein/ligand regions, compute RMSD/RMSF, or iterate frames for custom metrics.
Is molecular-dynamics safe to install?
Review the Security Audits panel on this Prism page and inspect the skill package in your repo before running agent-generated analysis on sensitive paths.
SKILL.md
READMESKILL.md - Molecular Dynamics
# MDAnalysis Analysis Reference ## MDAnalysis Universe and AtomGroup ```python import MDAnalysis as mda # Load Universe u = mda.Universe("topology.pdb", "trajectory.dcd") # or for single structure: u = mda.Universe("structure.pdb") # Key attributes print(u.atoms.n_atoms) # Total atoms print(u.residues.n_residues) # Total residues print(u.trajectory.n_frames) # Number of frames print(u.trajectory.dt) # Time step in ps print(u.trajectory.totaltime) # Total simulation time in ps ``` ## Atom Selection Language MDAnalysis uses a rich selection language: ```python # Basic selections protein = u.select_atoms("protein") backbone = u.select_atoms("backbone") # CA, N, C, O calpha = u.select_atoms("name CA") water = u.select_atoms("resname WAT or resname HOH or resname TIP3") ligand = u.select_atoms("resname LIG") # By residue number region = u.select_atoms("resid 10:50") specific = u.select_atoms("resid 45 and name CA") # By proximity near_ligand = u.select_atoms("protein and around 5.0 resname LIG") # By property charged = u.select_atoms("resname ARG LYS ASP GLU") hydrophobic = u.select_atoms("resname ALA VAL LEU ILE PRO PHE TRP MET") # Boolean combinations active_site = u.select_atoms("(resid 100 102 145 200) and protein") # Inverse not_water = u.select_atoms("not (resname WAT HOH)") ``` ## Common Analysis Modules ### RMSD and RMSF ```python from MDAnalysis.analysis import rms, align # Align trajectory to first frame align.AlignTraj(u, u, select='backbone', in_memory=True).run() # RMSD R = rms.RMSD(u, u, select='backbone', groupselections=['name CA']) R.run() # R.results.rmsd: shape (n_frames, 3) = [frame, time, RMSD] # RMSF (per-atom fluctuations) from MDAnalysis.analysis.rms import RMSF rmsf = RMSF(u.select_atoms('backbone')).run() # rmsf.results.rmsf: per-atom RMSF values in Angstroms ``` ### Radius of Gyration ```python rg = [] for ts in u.trajectory: rg.append(u.select_atoms("protein").radius_of_gyration()) import numpy as np print(f"Mean Rg: {np.mean(rg):.2f} Å") ``` ### Secondary Structure Analysis ```python from MDAnalysis.analysis.dssp import DSSP # DSSP secondary structure assignment per frame dssp = DSSP(u).run() # dssp.results.dssp: per-residue per-frame secondary structure codes # H = alpha-helix, E = beta-strand, C = coil ``` ### Hydrogen Bonds ```python from MDAnalysis.analysis.hydrogenbonds import HydrogenBondAnalysis hbonds = HydrogenBondAnalysis( u, donors_sel="protein and name N", acceptors_sel="protein and name O", d_h_cutoff=1.2, # donor-H distance (Å) d_a_cutoff=3.0, # donor-acceptor distance (Å) d_h_a_angle_cutoff=150 # D-H-A angle (degrees) ) hbonds.run() # Count H-bonds per frame import pandas as pd df = pd.DataFrame(hbonds.results.hbonds, columns=['frame', 'donor_ix', 'hydrogen_ix', 'acceptor_ix', 'DA_dist', 'DHA_angle']) ``` ### Principal Component Analysis (PCA) ```python from MDAnalysis.analysis import pca pca_analysis = pca.PCA(u, select='backbone', align=True).run() # PC variances print(pca_analysis.results.variance[:5]) # % variance of first 5 PCs # Project trajectory onto PCs projected = pca_analysis.transform(u.select_atoms('backbone'), n_components=3) # Shape: (n_frames, n_components) ``` ### Free Energy Surface (FES) ```python import numpy as np import matplotlib.pyplot as plt from scipy.stats import gaussian_kde def plot_free_energy_surface(x, y, bins=50, T=300, xlabel="PC1", ylabel="PC2", output="fes.png"): """ Compute 2D free energy surface from two order parameters. FES = -kT * ln(P(x,y)) """ kB = 0.0083144621 # kJ/mol/K kT = kB * T # 2D histogram H, xedges, yedges = np.histogram2d(x, y, bins=bins, density=True) H = H.T # Free energy H_safe = np.where(H > 0, H, np.nan) fes = -kT * np.log(H_safe) fes -= np.nanmin(fes) # Shift minimum to 0 # Plot fig, ax