A Streamlit-based app for post-MD analyses and visualization of GROMACS simulation trajectories.
Supports standard analyses (RMSD, RMSF, SASA, Radius of Gyration, Protein–Ligand minimum distance), PCA (protein-only and protein–ligand), DCCM (dynamic cross-correlation matrix), and a trajectory visualizer that can extract frames, render PNGs with PyMOL, and assemble MP4 MD-trajectory videos.
- 📝 Overview
- 📦 Installation
- 🏃 How to run
- 📂 Input file formats & expected structure
- 🔄 App workflows and usage
- 📚 Citation
- 📸 Rendered plots and MD-trajectory
- ⚙️ Key implementation notes & limitations
This repository contains a Streamlit application (app.py) that:
- Detects and reads common GROMACS
.xvganalysis files. - Produces publication-quality time-series plots (RMSD, RMSF, SASA, Radius of Gyration, PL-Minimum Distance).
- Runs PCA on trajectories and produces PCA plots with time-based colorbars.
- Computes and visualizes DCCM heatmaps.
- Extracts frames from a trajectory, renders PNG frames using PyMOL, and creates trajectory motion videos.
Required Python packages:
streamlitnumpymatplotlibseabornscikit-learnMDAnalysisopencv-pythonscipy
Create new conda environment (Recommended):
From repository root, open terminal and run:
conda create -n mdviz python=3.11
conda activate mdviz
pip install -r requirements.txt
Install PyMOL from conda-forge instead of pip:
conda install -c conda-forge pymol-open-source
- Alternatively, download PyMOL from the official website and add it to the system's PATH.
From repository root, run in terminal:
streamlit run app.py
-
Provide a
main_input_dirwith subfolders named (case-insensitive):rmsd/rmsf/sasa/gyrate/pl-dist/
-
Each subfolder should contain
.xvgfiles for each complex. -
Use identical filenames across subfolders for each complex to ensure consistent line colors in all plots.
-
See
Examplesfolder for input directory format.⚠️ If your.xvgheaders are non-standard, detection may misclassify.
- Trajectory:
.xtc(GROMACS trajectory) - Input run file:
.tpror.pdb(GROMACS input run file or pdb file containing solvent and ions). - Ligand ID:
Residue name like
LIG,UNK,UNL, or custom defined during simulation. - Protein chain:
single-letter chain ID (e.g.,
A).
.xtc files before running the Dynamics Visualizer, otherwise molecules may drift across the box, leading to misleading or poor-quality results.
- Standard Analyses (RMSD, RMSF, SASA, Rg, PL-Dist)
- Principal Component Analysis (PCA)
- Dynamic Cross-Correlation Matrix (DCCM)
- Trajectory Visualizer
- Choose Standard Analyses.
- Input:
- Main input directory (contains subfolders described above).
- Main output directory.
- Click Run Visualizations.
- Output: PNGs for each analysis type saved in the output directory.
- Colors assigned per complex from fixed palette (20 colors by default).
- If the number of complexes exceeds the palette length, the app returns an error for that plot.
- Time-series smoothing is applied automatically; the smoothing window scales with the number of frames.
- Choose PCA, pick Protein-only or Protein-ligand.
- Provide trajectory (
.xtc), input run file (.tpror.pdb), ligand resname (for complex only), and output folder. - Run PCA. Output images:
protein_pca.png(always)ligand_pca.png(for complex)complex_pca.png(combined dual plot for complex)
- Trajectory alignment is performed before PCA.
- PCA operates on flattened coordinates; large systems/timeframes can be memory-heavy.
- Colorbars show progression over time in
ns.
- Choose DCCM, select Protein-only or Protein-ligand.
- Provide trajectory, input run file, ligand resname (if needed), and output folder.
- Output:
protein_dccm.pngcomplex_dccm.png
- DCCM computed from CA atoms (and ligand heavy atoms if included).
- Matrix is clipped to
[-1, 1]and plotted with a custom diverging colormap. - Quadrants annotated if PL-complex plot.
Steps:
- Provide
.xtc(trajectory) and input run file.tpr(or.pdb) - Provide protein chain ID, ligand resname (for PL-complex), and an output folder path.
- After validating the trajectory, choose the number of frames to extract.
- Set image dimensions (width, height), DPI, and Frames per second (FPS).
- The app extracts evenly spaced frames, writes per-frame PDBs to
pdb_frames/, renders PNG frames via PyMOL topng_frames/, and assembles:md-trajectory.mp4smooth-md_motion.mp4
- It also generates a frames extraction log file
md.log.
Important:
- PyMOL rendering (ray tracing) may require an X display, or
xvfbon headless machines. - Rendering many frames at high DPI is time- and disk-consuming.
Steps:
- Provide a directory path to existing PNG frames.
- Set FPS and provide output folder path.
- The app assembles frames into an MP4 and produces an MD-trajectory video.
- Use a lower FPS value (between 15 and 40) to generate smooth trajectory videos.
If you use this tool in your research, presentations, or publications, please consider citing it to acknowledge the effort behind its development:
Dynamics Visualizer. GitHub: https://github.com/usman4373/Dynamics-Visualizer
smooth-md_motion-compressed.mp4
-
.xvgfiles detection is heuristic. If files have atypical headers, detection may fail. Updatedetect_file_type()to match your.xvgheaders. -
PyMOL dependency Frame rendering relies on the PyMOL Python API. On headless servers, run under
xvfbor configure off-screen rendering. Ray tracing requires GPU/GL support; turn off ray tracing for the simplest headless runs. -
Memory usage PCA and DCCM load coordinates into memory. For large systems or long trajectories:
- Subsample frames.
- Use CA-only selections.
- Consider incremental/online PCA or random projection approaches for scale.
-
Performance DCCM is
O(n_atoms² × n_frames)— expensive for large atom counts. -
Video encoding OpenCV
VideoWriteris used; MP4 encoding/compatibility depends on platform codecs. Installing systemffmpegis recommended.