rmsx 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rmsx-0.1.0/LICENSE +21 -0
- rmsx-0.1.0/PKG-INFO +273 -0
- rmsx-0.1.0/README.md +247 -0
- rmsx-0.1.0/pyproject.toml +53 -0
- rmsx-0.1.0/rmsx/__init__.py +46 -0
- rmsx-0.1.0/rmsx/__main__.py +5 -0
- rmsx-0.1.0/rmsx/addons/__init__.py +0 -0
- rmsx-0.1.0/rmsx/addons/lddt.py +862 -0
- rmsx-0.1.0/rmsx/cli.py +95 -0
- rmsx-0.1.0/rmsx/commands.cxc +9 -0
- rmsx-0.1.0/rmsx/core.py +2882 -0
- rmsx-0.1.0/rmsx/flipbook.py +667 -0
- rmsx-0.1.0/rmsx/molstar_static/script.js +2678 -0
- rmsx-0.1.0/rmsx/molstar_static/vendor/molstar/5.4.2/NOTICE.txt +16 -0
- rmsx-0.1.0/rmsx/molstar_static/vendor/molstar/5.4.2/molstar.css +3 -0
- rmsx-0.1.0/rmsx/molstar_static/vendor/molstar/5.4.2/molstar.js +7536 -0
- rmsx-0.1.0/rmsx/molstar_viewer.py +847 -0
- rmsx-0.1.0/rmsx/output_safety.py +187 -0
- rmsx-0.1.0/rmsx/r_scripts/install_deps.R +5 -0
- rmsx-0.1.0/rmsx/r_scripts/plot_rmsx.R +708 -0
- rmsx-0.1.0/rmsx/test_files/1UBQ.pdb +1233 -0
- rmsx-0.1.0/rmsx/test_files/mon_sys.dcd +0 -0
- rmsx-0.1.0/rmsx/test_files/protease_backbone.pdb +793 -0
- rmsx-0.1.0/rmsx/test_files/short_protease_backbone.dcd +0 -0
- rmsx-0.1.0/rmsx/vmd_scripts/__init__.py +12 -0
- rmsx-0.1.0/rmsx/vmd_scripts/grid_color_scale_centered_xaxis_hotkeys.tcl +460 -0
- rmsx-0.1.0/rmsx/vmd_scripts/render_flipbook_4k.tcl +60 -0
- rmsx-0.1.0/rmsx/vmd_scripts/render_flipbook_8k.tcl +53 -0
- rmsx-0.1.0/rmsx/vmd_scripts/vmd_finder.py +150 -0
- rmsx-0.1.0/rmsx/vmd_scripts/wait_to_load.tcl +96 -0
- rmsx-0.1.0/rmsx.egg-info/PKG-INFO +273 -0
- rmsx-0.1.0/rmsx.egg-info/SOURCES.txt +41 -0
- rmsx-0.1.0/rmsx.egg-info/dependency_links.txt +1 -0
- rmsx-0.1.0/rmsx.egg-info/entry_points.txt +2 -0
- rmsx-0.1.0/rmsx.egg-info/requires.txt +5 -0
- rmsx-0.1.0/rmsx.egg-info/top_level.txt +2 -0
- rmsx-0.1.0/setup.cfg +4 -0
- rmsx-0.1.0/tests/test_flipbook_masking.py +136 -0
- rmsx-0.1.0/tests/test_lddt_masking.py +176 -0
- rmsx-0.1.0/tests/test_masking.py +267 -0
- rmsx-0.1.0/tests/test_molstar_viewer.py +173 -0
- rmsx-0.1.0/tests/test_notebook_safety.py +132 -0
- rmsx-0.1.0/tests/test_output_dir_safety.py +142 -0
rmsx-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Finn2400
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
rmsx-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rmsx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Residue-level molecular-dynamics motion analysis and visualization
|
|
5
|
+
Author: Finn Beruldsen
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://antuneslab.github.io/rmsx/
|
|
8
|
+
Project-URL: Documentation, https://antuneslab.github.io/rmsx/
|
|
9
|
+
Project-URL: Repository, https://github.com/AntunesLab/rmsx
|
|
10
|
+
Project-URL: Issues, https://github.com/AntunesLab/rmsx/issues
|
|
11
|
+
Keywords: molecular dynamics,protein dynamics,trajectory analysis,RMSF,RMSD,ChimeraX,bioinformatics
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: MDAnalysis>=2.0.0
|
|
22
|
+
Requires-Dist: pandas>=1.1.0
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# RMSX and Flipbook: Simple-to-use, high-resolution mapping of molecular motions over time
|
|
28
|
+
|
|
29
|
+
## Start Here: [Launch RMSX + Molstar in Google Colab](https://colab.research.google.com/github/AntunesLab/rmsx/blob/main/RMSX_Molstar_Colab_Demo.ipynb)
|
|
30
|
+
|
|
31
|
+
[](https://colab.research.google.com/github/AntunesLab/rmsx/blob/main/RMSX_Molstar_Colab_Demo.ipynb)
|
|
32
|
+
|
|
33
|
+
**No installation required.** Run the bundled RMSX examples and explore interactive Molstar Flipbooks directly in your browser.
|
|
34
|
+
|
|
35
|
+
RMSX and Flipbook are described in our *Scientific Reports* paper, “High resolution mapping of protein motions in time and space with RMSX and Flipbook” ([DOI: 10.1038/s41598-026-39869-7](https://doi.org/10.1038/s41598-026-39869-7)). RMSX combines features of RMSD and RMSF into a simple-to-understand and simple-to-implement approach for understanding how proteins move over time. It works with simulation files from common MD simulation suites, including GROMACS, NAMD, and AMBER, and is designed to generate high-resolution, publication-ready motion maps and Flipbook visualizations with minimal setup.
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
### Run Locally
|
|
40
|
+
|
|
41
|
+
Download the [Quick Start Guide Notebook](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb), or clone this repository and run `pip install -e .`.
|
|
42
|
+
|
|
43
|
+
### Video Walkthrough
|
|
44
|
+
|
|
45
|
+
If you'd like a guided overview of the method, watch the tutorial here:
|
|
46
|
+
[RMSX + Flipbook Method Walkthrough](https://www.youtube.com/watch?v=UoN0GQKHCsw)
|
|
47
|
+
|
|
48
|
+
### Interactive Flipbooks in Notebooks
|
|
49
|
+
|
|
50
|
+
Flipbook includes a Molstar viewer for interactive 3D visualization inside Jupyter notebooks and Google Colab. Use `viewer="molstar"` with `run_rmsx_flipbook(...)`, or call `write_molstar_flipbook(...)` on an existing folder of `slice_*_first_frame.pdb` outputs. ChimeraX and VMD remain available as optional local viewers.
|
|
51
|
+
|
|
52
|
+
### 1. Prerequisites (click for install instructions)
|
|
53
|
+
- [**Git**](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git#:~:text=Installing%20on%20Windows&text=Just%20go%20to%20https%3A%2F%2F,to%20https%3A%2F%2Fgitforwindows.org.) Installed and added to your path (likely already done if you are using macOS or Linux)
|
|
54
|
+
- [**Python**](https://www.python.org/) If not already installed (tested with 3.8+)
|
|
55
|
+
- [**Jupyter Notebooks**](https://phoenixnap.com/kb/install-jupyter-notebook#:~:text=Install%20Jupyter%20Notebook%20on%20Linux,via%20pip) (Recommended)
|
|
56
|
+
- [**R**](https://cran.r-project.org/) installed and in your PATH (the `Rscript` command must be available).
|
|
57
|
+
- **Molstar requires no separate installation** and is the simplest option for notebooks and Colab.
|
|
58
|
+
- [**ChimeraX**](https://www.cgl.ucsf.edu/chimerax/download.html) or [**VMD**](https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=VMD) are optional local viewers.
|
|
59
|
+
- The RMSX code will attempt to install R packages like `ggplot2`, `viridis`, `dplyr`, etc., if they’re missing.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### 2. Installation
|
|
63
|
+
|
|
64
|
+
Once you have those installed, just download and run the [**Quick Start Guide Notebook**](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb)
|
|
65
|
+
It will walk you through the process and allow you to try RMSX, Trajectory Maps, and Flipbook on your own trajectories or bundled demo inputs from our publication.
|
|
66
|
+
|
|
67
|
+
The packaged notebook flow now works like this:
|
|
68
|
+
- Demo **inputs** are bundled inside the installed `rmsx` package.
|
|
69
|
+
- Demo **outputs** are written to `./rmsx_demo_outputs` next to the notebook, not back into the packaged demo-data directory.
|
|
70
|
+
|
|
71
|
+
1. **Clone this repository**:
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/AntunesLab/rmsx.git
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. **Install RMSX** in editable mode:
|
|
77
|
+
```bash
|
|
78
|
+
cd rmsx
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
This also installs the required Python libraries (e.g., MDAnalysis).
|
|
82
|
+
|
|
83
|
+
*(If installing on HPC or unusual platforms, you may need to manually install R libraries, but typically the R script handles that automatically.)*
|
|
84
|
+
|
|
85
|
+
### 3. Single-Chain Analysis Example
|
|
86
|
+
|
|
87
|
+
Below is a minimal example showing how to analyze **one chain**. We add a brief comment for each parameter:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from rmsx import run_rmsx
|
|
91
|
+
|
|
92
|
+
pdb_file = "/path/to/your_structure.pdb" # Topology file (PDB or GRO)
|
|
93
|
+
dcd_file = "/path/to/your_trajectory.dcd" # Trajectory file (DCD, XTC, etc.)
|
|
94
|
+
output_dir = "/path/to/output_directory" # Folder where results go
|
|
95
|
+
|
|
96
|
+
run_rmsx(
|
|
97
|
+
topology_file=pdb_file, # PDB or topology file
|
|
98
|
+
trajectory_file=dcd_file, # Trajectory file
|
|
99
|
+
output_dir=output_dir, # Location for RMSX outputs
|
|
100
|
+
num_slices=9, # Divide trajectory into 9 slices
|
|
101
|
+
slice_size=None, # (Alternately specify slice_size in frames)
|
|
102
|
+
rscript_executable='Rscript', # Path to Rscript
|
|
103
|
+
verbose=True, # Print detailed logs
|
|
104
|
+
interpolate=False, # Disable heatmap interpolation
|
|
105
|
+
triple=True, # Generate RMSX, RMSD, and RMSF plots
|
|
106
|
+
overwrite=True, # Overwrite existing folder
|
|
107
|
+
palette="mako", # Color palette
|
|
108
|
+
chain_sele="A", # Target chain ID
|
|
109
|
+
start_frame=0, # First frame to analyze
|
|
110
|
+
end_frame=None # Last frame (None = all frames)
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
You can optionally mask intrinsically disordered or unstable regions from the clipping range by passing raw MDAnalysis selections:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
run_rmsx(
|
|
118
|
+
...,
|
|
119
|
+
mask="segid A and resid 204:260"
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Masked residues are clipped against the unmasked floor/ceiling, excluded from top/bottom summaries, shown with hatch overlays in heatmaps, and rendered transparently in Flipbook viewers.
|
|
124
|
+
|
|
125
|
+
**What it does**:
|
|
126
|
+
1. Reads frames from your trajectory, slices them, computes RMSX (slice-wise RMSF).
|
|
127
|
+
2. Also calculates RMSD and RMSF for the full simulation (if `triple=True`).
|
|
128
|
+
3. Creates raster heatmaps (`.png`) with the chosen palette and optionally a triple-plot figure.
|
|
129
|
+
4. Updates `.pdb` slice files in the output directory, storing RMSX values in the B-factor column.
|
|
130
|
+
|
|
131
|
+
### 4. Multi-Chain Analysis
|
|
132
|
+
|
|
133
|
+
If your system has multiple chains (e.g., chain A, chain B):
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from rmsx import all_chain_rmsx
|
|
137
|
+
|
|
138
|
+
pdb_file_multi = "/path/to/multichain_structure.pdb"
|
|
139
|
+
traj_file_multi = "/path/to/multichain_trajectory.xtc"
|
|
140
|
+
output_dir_multi = "/path/to/multichain_output"
|
|
141
|
+
|
|
142
|
+
all_chain_rmsx(
|
|
143
|
+
topology_file=pdb_file_multi, # Multi-chain structure
|
|
144
|
+
trajectory_file=traj_file_multi, # Trajectory
|
|
145
|
+
output_dir=output_dir_multi, # Output folder
|
|
146
|
+
num_slices=12, # Number of slices
|
|
147
|
+
slice_size=None, # or specify frames per slice
|
|
148
|
+
rscript_executable='Rscript',
|
|
149
|
+
verbose=True,
|
|
150
|
+
interpolate=False,
|
|
151
|
+
triple=True,
|
|
152
|
+
overwrite=True,
|
|
153
|
+
palette="turbo",
|
|
154
|
+
start_frame=0,
|
|
155
|
+
end_frame=None,
|
|
156
|
+
sync_color_scale=True # Use a shared color scale across all chains
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**What it does**:
|
|
161
|
+
1. Detects each chain ID in the topology.
|
|
162
|
+
2. Runs per-chain RMSX (and RMSD/RMSF) analysis.
|
|
163
|
+
3. If `sync_color_scale=True`, waits until all chains’ data is computed, finds a global min/max, and then plots each chain’s heatmap using the same color range.
|
|
164
|
+
|
|
165
|
+
### 5. Flipbook Visualization
|
|
166
|
+
|
|
167
|
+
To **analyze** your system and **automatically generate** an interactive 3D Flipbook, use:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from rmsx import run_rmsx_flipbook
|
|
171
|
+
|
|
172
|
+
run_rmsx_flipbook(
|
|
173
|
+
topology_file=pdb_file, # Topology (PDB/GRO)
|
|
174
|
+
trajectory_file=dcd_file, # Trajectory
|
|
175
|
+
output_dir=output_dir, # Output folder
|
|
176
|
+
num_slices=9, # or slice_size=...
|
|
177
|
+
rscript_executable='Rscript',
|
|
178
|
+
verbose=True,
|
|
179
|
+
interpolate=False,
|
|
180
|
+
triple=True, # Also generate RMSD & RMSF plots
|
|
181
|
+
overwrite=True,
|
|
182
|
+
palette="mako",
|
|
183
|
+
spacingFactor="0.6", # Space out models for clarity
|
|
184
|
+
viewer="molstar", # "molstar", "chimerax", or "vmd"
|
|
185
|
+
molstar_camera_mode="orthographic", # or "perspective"
|
|
186
|
+
start_frame=0,
|
|
187
|
+
end_frame=None
|
|
188
|
+
)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
1. Produces the RMSX heatmaps/plots just like `run_rmsx`.
|
|
192
|
+
2. Writes multiple **PDB models** (one per time slice) into a single file.
|
|
193
|
+
3. With `viewer="molstar"`, writes a standalone HTML viewer and displays the interactive Flipbook directly in Jupyter or Colab.
|
|
194
|
+
4. With `viewer="chimerax"` or `viewer="vmd"`, launches the external desktop viewer if installed.
|
|
195
|
+
|
|
196
|
+
If you already have a folder of `slice_*_first_frame.pdb` outputs, you can build the notebook viewer without rerunning RMSX:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from rmsx import write_molstar_flipbook
|
|
200
|
+
|
|
201
|
+
write_molstar_flipbook(
|
|
202
|
+
"path/to/output/combined",
|
|
203
|
+
palette="mako",
|
|
204
|
+
camera_mode="orthographic", # or "perspective"
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 6. Additional Notes
|
|
209
|
+
- **First Runs** R takes some time to download all the required packages the first time the program is run. This only happens once.
|
|
210
|
+
- **Masked Heatmaps**: Patterned masked heatmaps use `ggpattern` and require **R 4.1+**.
|
|
211
|
+
- **Bundled Demo Inputs**: The Quick Start notebook looks for demo files inside the installed `rmsx` package first, then falls back to repo-style `test_files` folders if you are running from source.
|
|
212
|
+
- **Notebook Demo Outputs**: The Quick Start notebook writes demo results into `rmsx_demo_outputs` next to the notebook so packaged demo files stay read-only.
|
|
213
|
+
- **Chain IDs**: If your PDB has chain “A” or “B”, but `chain_sele="C"` is passed, you’ll see errors or zero B-factors. Ensure the chain ID matches.
|
|
214
|
+
- **ChimeraX**: [Download here](https://www.cgl.ucsf.edu/chimerax/download.html) if you’d like to visualize the Flipbook in ChimeraX.
|
|
215
|
+
- **Jupyter Notebook Behavior**: Use `viewer="molstar"` for an inline notebook/Colab viewer. If you use `viewer="chimerax"`, the next cell may not run until you close ChimeraX.
|
|
216
|
+
|
|
217
|
+
### 7. Citation
|
|
218
|
+
|
|
219
|
+
If you use RMSX + Flipbook in your work, please cite:
|
|
220
|
+
|
|
221
|
+
> Beruldsen, F., de Freitas, M.V. & Antunes, D.A. High resolution mapping of protein motions in time and space with RMSX and Flipbook. *Scientific Reports* (2026). https://doi.org/10.1038/s41598-026-39869-7
|
|
222
|
+
|
|
223
|
+
BibTeX:
|
|
224
|
+
|
|
225
|
+
```bibtex
|
|
226
|
+
@article{Beruldsen2026RMSXFlipbook,
|
|
227
|
+
author = {Beruldsen, F. and de Freitas, M. V. and Antunes, D. A.},
|
|
228
|
+
title = {High resolution mapping of protein motions in time and space with RMSX and Flipbook},
|
|
229
|
+
journal = {Scientific Reports},
|
|
230
|
+
year = {2026},
|
|
231
|
+
doi = {10.1038/s41598-026-39869-7},
|
|
232
|
+
url = {https://doi.org/10.1038/s41598-026-39869-7}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
RMSX now prints this citation reminder once per Python session when analysis functions are first run.
|
|
237
|
+
To suppress it in automated pipelines, set:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
export RMSX_NO_CITATION=1
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
**That’s it!** For more examples and advanced usage check out the [**Quick Start Guide**](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb). If you need anything, open an [issue on GitHub](https://github.com/AntunesLab/rmsx/issues).
|
|
246
|
+
|
|
247
|
+
### Color Palette Options
|
|
248
|
+
|
|
249
|
+
RMSX supports multiple perceptual palettes for heatmaps and flipbook coloring.
|
|
250
|
+
|
|
251
|
+

|
|
252
|
+
|
|
253
|
+

|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
rmsx-0.1.0/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# RMSX and Flipbook: Simple-to-use, high-resolution mapping of molecular motions over time
|
|
2
|
+
|
|
3
|
+
## Start Here: [Launch RMSX + Molstar in Google Colab](https://colab.research.google.com/github/AntunesLab/rmsx/blob/main/RMSX_Molstar_Colab_Demo.ipynb)
|
|
4
|
+
|
|
5
|
+
[](https://colab.research.google.com/github/AntunesLab/rmsx/blob/main/RMSX_Molstar_Colab_Demo.ipynb)
|
|
6
|
+
|
|
7
|
+
**No installation required.** Run the bundled RMSX examples and explore interactive Molstar Flipbooks directly in your browser.
|
|
8
|
+
|
|
9
|
+
RMSX and Flipbook are described in our *Scientific Reports* paper, “High resolution mapping of protein motions in time and space with RMSX and Flipbook” ([DOI: 10.1038/s41598-026-39869-7](https://doi.org/10.1038/s41598-026-39869-7)). RMSX combines features of RMSD and RMSF into a simple-to-understand and simple-to-implement approach for understanding how proteins move over time. It works with simulation files from common MD simulation suites, including GROMACS, NAMD, and AMBER, and is designed to generate high-resolution, publication-ready motion maps and Flipbook visualizations with minimal setup.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
### Run Locally
|
|
14
|
+
|
|
15
|
+
Download the [Quick Start Guide Notebook](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb), or clone this repository and run `pip install -e .`.
|
|
16
|
+
|
|
17
|
+
### Video Walkthrough
|
|
18
|
+
|
|
19
|
+
If you'd like a guided overview of the method, watch the tutorial here:
|
|
20
|
+
[RMSX + Flipbook Method Walkthrough](https://www.youtube.com/watch?v=UoN0GQKHCsw)
|
|
21
|
+
|
|
22
|
+
### Interactive Flipbooks in Notebooks
|
|
23
|
+
|
|
24
|
+
Flipbook includes a Molstar viewer for interactive 3D visualization inside Jupyter notebooks and Google Colab. Use `viewer="molstar"` with `run_rmsx_flipbook(...)`, or call `write_molstar_flipbook(...)` on an existing folder of `slice_*_first_frame.pdb` outputs. ChimeraX and VMD remain available as optional local viewers.
|
|
25
|
+
|
|
26
|
+
### 1. Prerequisites (click for install instructions)
|
|
27
|
+
- [**Git**](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git#:~:text=Installing%20on%20Windows&text=Just%20go%20to%20https%3A%2F%2F,to%20https%3A%2F%2Fgitforwindows.org.) Installed and added to your path (likely already done if you are using macOS or Linux)
|
|
28
|
+
- [**Python**](https://www.python.org/) If not already installed (tested with 3.8+)
|
|
29
|
+
- [**Jupyter Notebooks**](https://phoenixnap.com/kb/install-jupyter-notebook#:~:text=Install%20Jupyter%20Notebook%20on%20Linux,via%20pip) (Recommended)
|
|
30
|
+
- [**R**](https://cran.r-project.org/) installed and in your PATH (the `Rscript` command must be available).
|
|
31
|
+
- **Molstar requires no separate installation** and is the simplest option for notebooks and Colab.
|
|
32
|
+
- [**ChimeraX**](https://www.cgl.ucsf.edu/chimerax/download.html) or [**VMD**](https://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=VMD) are optional local viewers.
|
|
33
|
+
- The RMSX code will attempt to install R packages like `ggplot2`, `viridis`, `dplyr`, etc., if they’re missing.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### 2. Installation
|
|
37
|
+
|
|
38
|
+
Once you have those installed, just download and run the [**Quick Start Guide Notebook**](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb)
|
|
39
|
+
It will walk you through the process and allow you to try RMSX, Trajectory Maps, and Flipbook on your own trajectories or bundled demo inputs from our publication.
|
|
40
|
+
|
|
41
|
+
The packaged notebook flow now works like this:
|
|
42
|
+
- Demo **inputs** are bundled inside the installed `rmsx` package.
|
|
43
|
+
- Demo **outputs** are written to `./rmsx_demo_outputs` next to the notebook, not back into the packaged demo-data directory.
|
|
44
|
+
|
|
45
|
+
1. **Clone this repository**:
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/AntunesLab/rmsx.git
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. **Install RMSX** in editable mode:
|
|
51
|
+
```bash
|
|
52
|
+
cd rmsx
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
This also installs the required Python libraries (e.g., MDAnalysis).
|
|
56
|
+
|
|
57
|
+
*(If installing on HPC or unusual platforms, you may need to manually install R libraries, but typically the R script handles that automatically.)*
|
|
58
|
+
|
|
59
|
+
### 3. Single-Chain Analysis Example
|
|
60
|
+
|
|
61
|
+
Below is a minimal example showing how to analyze **one chain**. We add a brief comment for each parameter:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from rmsx import run_rmsx
|
|
65
|
+
|
|
66
|
+
pdb_file = "/path/to/your_structure.pdb" # Topology file (PDB or GRO)
|
|
67
|
+
dcd_file = "/path/to/your_trajectory.dcd" # Trajectory file (DCD, XTC, etc.)
|
|
68
|
+
output_dir = "/path/to/output_directory" # Folder where results go
|
|
69
|
+
|
|
70
|
+
run_rmsx(
|
|
71
|
+
topology_file=pdb_file, # PDB or topology file
|
|
72
|
+
trajectory_file=dcd_file, # Trajectory file
|
|
73
|
+
output_dir=output_dir, # Location for RMSX outputs
|
|
74
|
+
num_slices=9, # Divide trajectory into 9 slices
|
|
75
|
+
slice_size=None, # (Alternately specify slice_size in frames)
|
|
76
|
+
rscript_executable='Rscript', # Path to Rscript
|
|
77
|
+
verbose=True, # Print detailed logs
|
|
78
|
+
interpolate=False, # Disable heatmap interpolation
|
|
79
|
+
triple=True, # Generate RMSX, RMSD, and RMSF plots
|
|
80
|
+
overwrite=True, # Overwrite existing folder
|
|
81
|
+
palette="mako", # Color palette
|
|
82
|
+
chain_sele="A", # Target chain ID
|
|
83
|
+
start_frame=0, # First frame to analyze
|
|
84
|
+
end_frame=None # Last frame (None = all frames)
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You can optionally mask intrinsically disordered or unstable regions from the clipping range by passing raw MDAnalysis selections:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
run_rmsx(
|
|
92
|
+
...,
|
|
93
|
+
mask="segid A and resid 204:260"
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Masked residues are clipped against the unmasked floor/ceiling, excluded from top/bottom summaries, shown with hatch overlays in heatmaps, and rendered transparently in Flipbook viewers.
|
|
98
|
+
|
|
99
|
+
**What it does**:
|
|
100
|
+
1. Reads frames from your trajectory, slices them, computes RMSX (slice-wise RMSF).
|
|
101
|
+
2. Also calculates RMSD and RMSF for the full simulation (if `triple=True`).
|
|
102
|
+
3. Creates raster heatmaps (`.png`) with the chosen palette and optionally a triple-plot figure.
|
|
103
|
+
4. Updates `.pdb` slice files in the output directory, storing RMSX values in the B-factor column.
|
|
104
|
+
|
|
105
|
+
### 4. Multi-Chain Analysis
|
|
106
|
+
|
|
107
|
+
If your system has multiple chains (e.g., chain A, chain B):
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from rmsx import all_chain_rmsx
|
|
111
|
+
|
|
112
|
+
pdb_file_multi = "/path/to/multichain_structure.pdb"
|
|
113
|
+
traj_file_multi = "/path/to/multichain_trajectory.xtc"
|
|
114
|
+
output_dir_multi = "/path/to/multichain_output"
|
|
115
|
+
|
|
116
|
+
all_chain_rmsx(
|
|
117
|
+
topology_file=pdb_file_multi, # Multi-chain structure
|
|
118
|
+
trajectory_file=traj_file_multi, # Trajectory
|
|
119
|
+
output_dir=output_dir_multi, # Output folder
|
|
120
|
+
num_slices=12, # Number of slices
|
|
121
|
+
slice_size=None, # or specify frames per slice
|
|
122
|
+
rscript_executable='Rscript',
|
|
123
|
+
verbose=True,
|
|
124
|
+
interpolate=False,
|
|
125
|
+
triple=True,
|
|
126
|
+
overwrite=True,
|
|
127
|
+
palette="turbo",
|
|
128
|
+
start_frame=0,
|
|
129
|
+
end_frame=None,
|
|
130
|
+
sync_color_scale=True # Use a shared color scale across all chains
|
|
131
|
+
)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**What it does**:
|
|
135
|
+
1. Detects each chain ID in the topology.
|
|
136
|
+
2. Runs per-chain RMSX (and RMSD/RMSF) analysis.
|
|
137
|
+
3. If `sync_color_scale=True`, waits until all chains’ data is computed, finds a global min/max, and then plots each chain’s heatmap using the same color range.
|
|
138
|
+
|
|
139
|
+
### 5. Flipbook Visualization
|
|
140
|
+
|
|
141
|
+
To **analyze** your system and **automatically generate** an interactive 3D Flipbook, use:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from rmsx import run_rmsx_flipbook
|
|
145
|
+
|
|
146
|
+
run_rmsx_flipbook(
|
|
147
|
+
topology_file=pdb_file, # Topology (PDB/GRO)
|
|
148
|
+
trajectory_file=dcd_file, # Trajectory
|
|
149
|
+
output_dir=output_dir, # Output folder
|
|
150
|
+
num_slices=9, # or slice_size=...
|
|
151
|
+
rscript_executable='Rscript',
|
|
152
|
+
verbose=True,
|
|
153
|
+
interpolate=False,
|
|
154
|
+
triple=True, # Also generate RMSD & RMSF plots
|
|
155
|
+
overwrite=True,
|
|
156
|
+
palette="mako",
|
|
157
|
+
spacingFactor="0.6", # Space out models for clarity
|
|
158
|
+
viewer="molstar", # "molstar", "chimerax", or "vmd"
|
|
159
|
+
molstar_camera_mode="orthographic", # or "perspective"
|
|
160
|
+
start_frame=0,
|
|
161
|
+
end_frame=None
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
1. Produces the RMSX heatmaps/plots just like `run_rmsx`.
|
|
166
|
+
2. Writes multiple **PDB models** (one per time slice) into a single file.
|
|
167
|
+
3. With `viewer="molstar"`, writes a standalone HTML viewer and displays the interactive Flipbook directly in Jupyter or Colab.
|
|
168
|
+
4. With `viewer="chimerax"` or `viewer="vmd"`, launches the external desktop viewer if installed.
|
|
169
|
+
|
|
170
|
+
If you already have a folder of `slice_*_first_frame.pdb` outputs, you can build the notebook viewer without rerunning RMSX:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from rmsx import write_molstar_flipbook
|
|
174
|
+
|
|
175
|
+
write_molstar_flipbook(
|
|
176
|
+
"path/to/output/combined",
|
|
177
|
+
palette="mako",
|
|
178
|
+
camera_mode="orthographic", # or "perspective"
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 6. Additional Notes
|
|
183
|
+
- **First Runs** R takes some time to download all the required packages the first time the program is run. This only happens once.
|
|
184
|
+
- **Masked Heatmaps**: Patterned masked heatmaps use `ggpattern` and require **R 4.1+**.
|
|
185
|
+
- **Bundled Demo Inputs**: The Quick Start notebook looks for demo files inside the installed `rmsx` package first, then falls back to repo-style `test_files` folders if you are running from source.
|
|
186
|
+
- **Notebook Demo Outputs**: The Quick Start notebook writes demo results into `rmsx_demo_outputs` next to the notebook so packaged demo files stay read-only.
|
|
187
|
+
- **Chain IDs**: If your PDB has chain “A” or “B”, but `chain_sele="C"` is passed, you’ll see errors or zero B-factors. Ensure the chain ID matches.
|
|
188
|
+
- **ChimeraX**: [Download here](https://www.cgl.ucsf.edu/chimerax/download.html) if you’d like to visualize the Flipbook in ChimeraX.
|
|
189
|
+
- **Jupyter Notebook Behavior**: Use `viewer="molstar"` for an inline notebook/Colab viewer. If you use `viewer="chimerax"`, the next cell may not run until you close ChimeraX.
|
|
190
|
+
|
|
191
|
+
### 7. Citation
|
|
192
|
+
|
|
193
|
+
If you use RMSX + Flipbook in your work, please cite:
|
|
194
|
+
|
|
195
|
+
> Beruldsen, F., de Freitas, M.V. & Antunes, D.A. High resolution mapping of protein motions in time and space with RMSX and Flipbook. *Scientific Reports* (2026). https://doi.org/10.1038/s41598-026-39869-7
|
|
196
|
+
|
|
197
|
+
BibTeX:
|
|
198
|
+
|
|
199
|
+
```bibtex
|
|
200
|
+
@article{Beruldsen2026RMSXFlipbook,
|
|
201
|
+
author = {Beruldsen, F. and de Freitas, M. V. and Antunes, D. A.},
|
|
202
|
+
title = {High resolution mapping of protein motions in time and space with RMSX and Flipbook},
|
|
203
|
+
journal = {Scientific Reports},
|
|
204
|
+
year = {2026},
|
|
205
|
+
doi = {10.1038/s41598-026-39869-7},
|
|
206
|
+
url = {https://doi.org/10.1038/s41598-026-39869-7}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
RMSX now prints this citation reminder once per Python session when analysis functions are first run.
|
|
211
|
+
To suppress it in automated pipelines, set:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
export RMSX_NO_CITATION=1
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
**That’s it!** For more examples and advanced usage check out the [**Quick Start Guide**](https://github.com/AntunesLab/rmsx/raw/main/RMSX_FlipBook_Quickstart.ipynb). If you need anything, open an [issue on GitHub](https://github.com/AntunesLab/rmsx/issues).
|
|
220
|
+
|
|
221
|
+
### Color Palette Options
|
|
222
|
+
|
|
223
|
+
RMSX supports multiple perceptual palettes for heatmaps and flipbook coloring.
|
|
224
|
+
|
|
225
|
+

|
|
226
|
+
|
|
227
|
+

|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rmsx"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Residue-level molecular-dynamics motion analysis and visualization"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
authors = [{name="Finn Beruldsen"}]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
keywords = ["molecular dynamics", "protein dynamics", "trajectory analysis", "RMSF", "RMSD", "ChimeraX", "bioinformatics"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"MDAnalysis>=2.0.0",
|
|
25
|
+
"pandas>=1.1.0",
|
|
26
|
+
# "plotly>=4.14.3"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://antuneslab.github.io/rmsx/"
|
|
31
|
+
Documentation = "https://antuneslab.github.io/rmsx/"
|
|
32
|
+
Repository = "https://github.com/AntunesLab/rmsx"
|
|
33
|
+
Issues = "https://github.com/AntunesLab/rmsx/issues"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
docs = ["mkdocs-material>=9.5"]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
rmsx = "rmsx.cli:main"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["."]
|
|
43
|
+
include = ["rmsx*"]
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.package-data]
|
|
46
|
+
rmsx = [
|
|
47
|
+
"r_scripts/*.R",
|
|
48
|
+
"commands.cxc",
|
|
49
|
+
"vmd_scripts/*.tcl",
|
|
50
|
+
"molstar_static/script.js",
|
|
51
|
+
"molstar_static/vendor/molstar/5.4.2/*",
|
|
52
|
+
"test_files/*",
|
|
53
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"run_rmsx",
|
|
8
|
+
"combine_pdb_files",
|
|
9
|
+
"all_chain_rmsx",
|
|
10
|
+
"run_rmsx_flipbook",
|
|
11
|
+
"run_flipbook",
|
|
12
|
+
"run_shift_map",
|
|
13
|
+
"all_chain_shift_map",
|
|
14
|
+
"run_shift_flipbook",
|
|
15
|
+
"MolstarFlipbookResult",
|
|
16
|
+
"build_molstar_manifest",
|
|
17
|
+
"write_molstar_flipbook",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
_CORE_EXPORTS = {
|
|
21
|
+
"run_rmsx",
|
|
22
|
+
"combine_pdb_files",
|
|
23
|
+
"all_chain_rmsx",
|
|
24
|
+
"run_rmsx_flipbook",
|
|
25
|
+
"run_shift_map",
|
|
26
|
+
"all_chain_shift_map",
|
|
27
|
+
"run_shift_flipbook",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def __getattr__(name: str) -> Any:
|
|
32
|
+
if name in _CORE_EXPORTS:
|
|
33
|
+
core = import_module(".core", __name__)
|
|
34
|
+
return getattr(core, name)
|
|
35
|
+
if name == "run_flipbook":
|
|
36
|
+
flipbook = import_module(".flipbook", __name__)
|
|
37
|
+
return getattr(flipbook, name)
|
|
38
|
+
if name in {"MolstarFlipbookResult", "build_molstar_manifest", "write_molstar_flipbook"}:
|
|
39
|
+
molstar_viewer = import_module(".molstar_viewer", __name__)
|
|
40
|
+
return getattr(molstar_viewer, name)
|
|
41
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def __dir__() -> list[str]:
|
|
45
|
+
# Avoid importing heavy dependencies during introspection/test discovery.
|
|
46
|
+
return sorted(set(globals().keys()))
|
|
File without changes
|