mdcheck 1.0.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.
- mdcheck-1.0.0/LICENSE +21 -0
- mdcheck-1.0.0/PKG-INFO +195 -0
- mdcheck-1.0.0/README.md +154 -0
- mdcheck-1.0.0/mdcheck/__init__.py +42 -0
- mdcheck-1.0.0/mdcheck/cli.py +254 -0
- mdcheck-1.0.0/mdcheck/core/__init__.py +36 -0
- mdcheck-1.0.0/mdcheck/core/autocorrelation.py +178 -0
- mdcheck-1.0.0/mdcheck/core/bootstrap.py +83 -0
- mdcheck-1.0.0/mdcheck/core/drift.py +152 -0
- mdcheck-1.0.0/mdcheck/core/equilibration.py +193 -0
- mdcheck-1.0.0/mdcheck/core/replicas.py +197 -0
- mdcheck-1.0.0/mdcheck/core/scoring.py +216 -0
- mdcheck-1.0.0/mdcheck/parsers/__init__.py +14 -0
- mdcheck-1.0.0/mdcheck/parsers/amber_namd.py +87 -0
- mdcheck-1.0.0/mdcheck/parsers/generic.py +88 -0
- mdcheck-1.0.0/mdcheck/parsers/gromacs.py +101 -0
- mdcheck-1.0.0/mdcheck/reporters/__init__.py +13 -0
- mdcheck-1.0.0/mdcheck/reporters/html_report.py +360 -0
- mdcheck-1.0.0/mdcheck/reporters/manuscript_prep.py +109 -0
- mdcheck-1.0.0/mdcheck/reporters/plot_generator.py +157 -0
- mdcheck-1.0.0/mdcheck.egg-info/PKG-INFO +195 -0
- mdcheck-1.0.0/mdcheck.egg-info/SOURCES.txt +32 -0
- mdcheck-1.0.0/mdcheck.egg-info/dependency_links.txt +1 -0
- mdcheck-1.0.0/mdcheck.egg-info/entry_points.txt +2 -0
- mdcheck-1.0.0/mdcheck.egg-info/requires.txt +13 -0
- mdcheck-1.0.0/mdcheck.egg-info/top_level.txt +1 -0
- mdcheck-1.0.0/pyproject.toml +73 -0
- mdcheck-1.0.0/setup.cfg +4 -0
- mdcheck-1.0.0/tests/test_autocorrelation.py +60 -0
- mdcheck-1.0.0/tests/test_drift.py +37 -0
- mdcheck-1.0.0/tests/test_equilibration.py +40 -0
- mdcheck-1.0.0/tests/test_parsers.py +66 -0
- mdcheck-1.0.0/tests/test_replicas.py +53 -0
- mdcheck-1.0.0/tests/test_scoring.py +63 -0
mdcheck-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andre Monreal-Hernández
|
|
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.
|
mdcheck-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mdcheck
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations
|
|
5
|
+
Author-email: Andre Monreal-Hernández <amonreal@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/sircalch/mdcheck
|
|
8
|
+
Project-URL: Documentation, https://github.com/sircalch/mdcheck#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/sircalch/mdcheck.git
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/sircalch/mdcheck/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/sircalch/mdcheck/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: molecular-dynamics,gromacs,amber,openmm,convergence,statistical-inefficiency,equilibration,reproducibility,quality-assurance,science,biophysics
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: numpy>=1.20.0
|
|
29
|
+
Requires-Dist: scipy>=1.7.0
|
|
30
|
+
Requires-Dist: pandas>=1.3.0
|
|
31
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
32
|
+
Requires-Dist: jinja2>=3.0.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
39
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# MDCheck
|
|
43
|
+
|
|
44
|
+
[](https://github.com/sircalch/mdcheck/actions)
|
|
45
|
+
[](https://pypi.org/project/mdcheck/)
|
|
46
|
+
[](https://pypi.org/project/mdcheck/)
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
[](https://doi.org/10.5281/zenodo.1234567)
|
|
49
|
+
|
|
50
|
+
> **Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations.**
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Overview
|
|
55
|
+
|
|
56
|
+
**MDCheck** is an open-source scientific toolkit that solves a universal methodological need in biomolecular and materials simulations: **certifying whether a molecular dynamics trajectory has converged, reached equilibrium, and accumulated sufficient statistically independent observations for publication.**
|
|
57
|
+
|
|
58
|
+
Instead of manually inspecting plots or guessing equilibration cutoffs, `mdcheck` analyzes raw timeseries (`.xvg`, `.csv`, `.dat`, `.log`) with a single command and delivers:
|
|
59
|
+
|
|
60
|
+
- 🎯 **Automated Equilibration Detection ($t_{\text{eq}}$)** via statistical inefficiency minimization.
|
|
61
|
+
- ⏱️ **Integrated Autocorrelation Time ($\tau_{\text{int}}$)** & **Statistical Inefficiency ($g$)** using Madras-Sokal self-consistent windowing.
|
|
62
|
+
- 🔢 **Effective Sample Size ($N_{\text{eff}} = N / g$)** to ensure statistically rigorous error estimation.
|
|
63
|
+
- 🔄 **Multi-Replica Reproducibility Matrix ($R_1 \text{ vs } R_2 \text{ vs } R_3$)** based on Jensen-Shannon Divergence (JSD) and Essential Subspace Overlap (RMSIP).
|
|
64
|
+
- 📉 **Linear & CUSUM Systematic Drift Diagnostics** and Flyvbjerg-Petersen block averaging.
|
|
65
|
+
- 🚦 **Quality Certification Badges (`PASS` / `WARNING` / `FAIL`)** with unambiguous diagnostic messages.
|
|
66
|
+
- 📑 **Publication-Ready Outputs**: Interactive self-contained `report.html`, vector plots (SVG/PDF/PNG 300 DPI), LaTeX summary tables (`.tex`), and a draft **Methods & Supporting Information** text snippet with automated **BibTeX citations**.
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
Simulations (.xvg, .csv, .dat)
|
|
70
|
+
│
|
|
71
|
+
▼
|
|
72
|
+
┌───────────────────────────────────────────────────────────┐
|
|
73
|
+
│ MDCheck │
|
|
74
|
+
│ ├── Auto Equilibration (max N_eff) │
|
|
75
|
+
│ ├── Autocorrelation & Inefficiency (tau_int, g) │
|
|
76
|
+
│ ├── Multi-Replica Overlap (Jensen-Shannon, RMSIP) │
|
|
77
|
+
│ └── Drift Detection & Block Averaging │
|
|
78
|
+
└───────────────────────────────────────────────────────────┘
|
|
79
|
+
│
|
|
80
|
+
▼
|
|
81
|
+
┌───────────────────────────────────────────────────────────┐
|
|
82
|
+
│ Publication Deliverables │
|
|
83
|
+
│ ├── report.html (Interactive Dashboard & Badges) │
|
|
84
|
+
│ ├── mdcheck_convergence_overview.pdf/svg/png │
|
|
85
|
+
│ ├── mdcheck_summary_table.tex / .csv │
|
|
86
|
+
│ ├── methods_snippet.txt (Ready for Manuscript) │
|
|
87
|
+
│ └── citation.bib (BibTeX Reference) │
|
|
88
|
+
└───────────────────────────────────────────────────────────┘
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
### From PyPI
|
|
96
|
+
```bash
|
|
97
|
+
pip install mdcheck
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### From Source (Development Mode)
|
|
101
|
+
```bash
|
|
102
|
+
git clone https://github.com/sircalch/mdcheck.git
|
|
103
|
+
cd mdcheck
|
|
104
|
+
pip install -e .[dev]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Quickstart (CLI)
|
|
110
|
+
|
|
111
|
+
### 1. Test Demo Mode (Instant Synthetic Multi-Replica Simulation)
|
|
112
|
+
```bash
|
|
113
|
+
mdcheck demo -o my_demo_results/
|
|
114
|
+
```
|
|
115
|
+
Open `my_demo_results/report.html` in any web browser to see the interactive report!
|
|
116
|
+
|
|
117
|
+
### 2. Assess GROMACS XVG Trajectory
|
|
118
|
+
```bash
|
|
119
|
+
mdcheck assess -i rmsd.xvg gyrate.xvg energy.xvg -o md_quality_report/
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 3. Assess Multi-Replica Convergence (R1, R2, R3)
|
|
123
|
+
```bash
|
|
124
|
+
mdcheck assess -i rep1_rmsd.xvg -r rep2_rmsd.xvg rep3_rmsd.xvg -o replica_assessment/
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Python API Usage
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import numpy as np
|
|
133
|
+
from mdcheck import assess_trajectory_quality
|
|
134
|
+
from mdcheck.reporters import generate_publication_figures, generate_manuscript_assets, generate_html_report
|
|
135
|
+
|
|
136
|
+
# Load or define your timeseries (e.g. Backbone RMSD over 100 ns)
|
|
137
|
+
time_coords = np.linspace(0, 100, 2000) # ns
|
|
138
|
+
rmsd_series = ... # 1D numpy array
|
|
139
|
+
|
|
140
|
+
# Assess simulation quality
|
|
141
|
+
report = assess_trajectory_quality(
|
|
142
|
+
timeseries_dict={"Backbone_RMSD": rmsd_series},
|
|
143
|
+
time_coords=time_coords
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
print(f"Overall Quality Status: {report.overall_status}")
|
|
147
|
+
print(f"Equilibration Time: {report.observables['Backbone_RMSD'].t_eq_time:.2f} ns")
|
|
148
|
+
print(f"Effective Sample Size (N_eff): {report.observables['Backbone_RMSD'].n_eff:.0f}")
|
|
149
|
+
|
|
150
|
+
# Export publication figures and LaTeX tables
|
|
151
|
+
generate_publication_figures({"Backbone_RMSD": rmsd_series}, time_coords, report, "output_dir/")
|
|
152
|
+
generate_manuscript_assets(report, "output_dir/")
|
|
153
|
+
generate_html_report(report, "output_dir/report.html")
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Scientific Foundations & Methodology
|
|
159
|
+
|
|
160
|
+
### 1. Automated Equilibration Detection ($t_{\text{eq}}$)
|
|
161
|
+
The initial non-equilibrium transient phase is automatically identified by maximizing the total effective sample size in the subsequent production interval:
|
|
162
|
+
$$\hat{t}_{\text{eq}} = \arg\max_{t_0} N_{\text{eff}}(t_0) = \arg\max_{t_0} \frac{N - t_0}{g(t_0)}$$
|
|
163
|
+
|
|
164
|
+
### 2. Autocorrelation & Statistical Inefficiency ($g$)
|
|
165
|
+
MD frames are temporally correlated. MDCheck computes the integrated autocorrelation time $\tau_{\text{int}}$ using the Madras-Sokal self-consistent cutoff window:
|
|
166
|
+
$$\tau_{\text{int}} = \frac{1}{2} + \sum_{k=1}^{M} C(k), \quad M \ge 6 \tau_{\text{int}}$$
|
|
167
|
+
$$g = 1 + 2\tau_{\text{int}}, \quad N_{\text{eff}} = \frac{N_{\text{prod}}}{g}$$
|
|
168
|
+
|
|
169
|
+
### 3. Multi-Replica Conformational Overlap
|
|
170
|
+
Conformational consistency between independent trajectories ($R_1, R_2, R_3$) is evaluated via the square-root of Jensen-Shannon Divergence ($\mathrm{JSD} \in [0, 1]$) and Root-Mean-Square Inner Product (RMSIP) across essential PCA subspaces:
|
|
171
|
+
$$\mathrm{JSD}(P \parallel Q) = \frac{1}{2} D_{\text{KL}}(P \parallel M) + \frac{1}{2} D_{\text{KL}}(Q \parallel M)$$
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Citation
|
|
176
|
+
|
|
177
|
+
If you use MDCheck to evaluate trajectory convergence, equilibration, statistical inefficiency, or replica reproducibility in your research, please cite:
|
|
178
|
+
|
|
179
|
+
```bibtex
|
|
180
|
+
@software{monreal2026mdcheck,
|
|
181
|
+
author = {Monreal-Hern{\'a}ndez, Andre},
|
|
182
|
+
title = {{MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations}},
|
|
183
|
+
year = {2026},
|
|
184
|
+
version = {1.0.0},
|
|
185
|
+
publisher = {Zenodo},
|
|
186
|
+
url = {https://github.com/sircalch/mdcheck}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
|
|
195
|
+
|
mdcheck-1.0.0/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# MDCheck
|
|
2
|
+
|
|
3
|
+
[](https://github.com/sircalch/mdcheck/actions)
|
|
4
|
+
[](https://pypi.org/project/mdcheck/)
|
|
5
|
+
[](https://pypi.org/project/mdcheck/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://doi.org/10.5281/zenodo.1234567)
|
|
8
|
+
|
|
9
|
+
> **Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations.**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
**MDCheck** is an open-source scientific toolkit that solves a universal methodological need in biomolecular and materials simulations: **certifying whether a molecular dynamics trajectory has converged, reached equilibrium, and accumulated sufficient statistically independent observations for publication.**
|
|
16
|
+
|
|
17
|
+
Instead of manually inspecting plots or guessing equilibration cutoffs, `mdcheck` analyzes raw timeseries (`.xvg`, `.csv`, `.dat`, `.log`) with a single command and delivers:
|
|
18
|
+
|
|
19
|
+
- 🎯 **Automated Equilibration Detection ($t_{\text{eq}}$)** via statistical inefficiency minimization.
|
|
20
|
+
- ⏱️ **Integrated Autocorrelation Time ($\tau_{\text{int}}$)** & **Statistical Inefficiency ($g$)** using Madras-Sokal self-consistent windowing.
|
|
21
|
+
- 🔢 **Effective Sample Size ($N_{\text{eff}} = N / g$)** to ensure statistically rigorous error estimation.
|
|
22
|
+
- 🔄 **Multi-Replica Reproducibility Matrix ($R_1 \text{ vs } R_2 \text{ vs } R_3$)** based on Jensen-Shannon Divergence (JSD) and Essential Subspace Overlap (RMSIP).
|
|
23
|
+
- 📉 **Linear & CUSUM Systematic Drift Diagnostics** and Flyvbjerg-Petersen block averaging.
|
|
24
|
+
- 🚦 **Quality Certification Badges (`PASS` / `WARNING` / `FAIL`)** with unambiguous diagnostic messages.
|
|
25
|
+
- 📑 **Publication-Ready Outputs**: Interactive self-contained `report.html`, vector plots (SVG/PDF/PNG 300 DPI), LaTeX summary tables (`.tex`), and a draft **Methods & Supporting Information** text snippet with automated **BibTeX citations**.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Simulations (.xvg, .csv, .dat)
|
|
29
|
+
│
|
|
30
|
+
▼
|
|
31
|
+
┌───────────────────────────────────────────────────────────┐
|
|
32
|
+
│ MDCheck │
|
|
33
|
+
│ ├── Auto Equilibration (max N_eff) │
|
|
34
|
+
│ ├── Autocorrelation & Inefficiency (tau_int, g) │
|
|
35
|
+
│ ├── Multi-Replica Overlap (Jensen-Shannon, RMSIP) │
|
|
36
|
+
│ └── Drift Detection & Block Averaging │
|
|
37
|
+
└───────────────────────────────────────────────────────────┘
|
|
38
|
+
│
|
|
39
|
+
▼
|
|
40
|
+
┌───────────────────────────────────────────────────────────┐
|
|
41
|
+
│ Publication Deliverables │
|
|
42
|
+
│ ├── report.html (Interactive Dashboard & Badges) │
|
|
43
|
+
│ ├── mdcheck_convergence_overview.pdf/svg/png │
|
|
44
|
+
│ ├── mdcheck_summary_table.tex / .csv │
|
|
45
|
+
│ ├── methods_snippet.txt (Ready for Manuscript) │
|
|
46
|
+
│ └── citation.bib (BibTeX Reference) │
|
|
47
|
+
└───────────────────────────────────────────────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### From PyPI
|
|
55
|
+
```bash
|
|
56
|
+
pip install mdcheck
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### From Source (Development Mode)
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/sircalch/mdcheck.git
|
|
62
|
+
cd mdcheck
|
|
63
|
+
pip install -e .[dev]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Quickstart (CLI)
|
|
69
|
+
|
|
70
|
+
### 1. Test Demo Mode (Instant Synthetic Multi-Replica Simulation)
|
|
71
|
+
```bash
|
|
72
|
+
mdcheck demo -o my_demo_results/
|
|
73
|
+
```
|
|
74
|
+
Open `my_demo_results/report.html` in any web browser to see the interactive report!
|
|
75
|
+
|
|
76
|
+
### 2. Assess GROMACS XVG Trajectory
|
|
77
|
+
```bash
|
|
78
|
+
mdcheck assess -i rmsd.xvg gyrate.xvg energy.xvg -o md_quality_report/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 3. Assess Multi-Replica Convergence (R1, R2, R3)
|
|
82
|
+
```bash
|
|
83
|
+
mdcheck assess -i rep1_rmsd.xvg -r rep2_rmsd.xvg rep3_rmsd.xvg -o replica_assessment/
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Python API Usage
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import numpy as np
|
|
92
|
+
from mdcheck import assess_trajectory_quality
|
|
93
|
+
from mdcheck.reporters import generate_publication_figures, generate_manuscript_assets, generate_html_report
|
|
94
|
+
|
|
95
|
+
# Load or define your timeseries (e.g. Backbone RMSD over 100 ns)
|
|
96
|
+
time_coords = np.linspace(0, 100, 2000) # ns
|
|
97
|
+
rmsd_series = ... # 1D numpy array
|
|
98
|
+
|
|
99
|
+
# Assess simulation quality
|
|
100
|
+
report = assess_trajectory_quality(
|
|
101
|
+
timeseries_dict={"Backbone_RMSD": rmsd_series},
|
|
102
|
+
time_coords=time_coords
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
print(f"Overall Quality Status: {report.overall_status}")
|
|
106
|
+
print(f"Equilibration Time: {report.observables['Backbone_RMSD'].t_eq_time:.2f} ns")
|
|
107
|
+
print(f"Effective Sample Size (N_eff): {report.observables['Backbone_RMSD'].n_eff:.0f}")
|
|
108
|
+
|
|
109
|
+
# Export publication figures and LaTeX tables
|
|
110
|
+
generate_publication_figures({"Backbone_RMSD": rmsd_series}, time_coords, report, "output_dir/")
|
|
111
|
+
generate_manuscript_assets(report, "output_dir/")
|
|
112
|
+
generate_html_report(report, "output_dir/report.html")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Scientific Foundations & Methodology
|
|
118
|
+
|
|
119
|
+
### 1. Automated Equilibration Detection ($t_{\text{eq}}$)
|
|
120
|
+
The initial non-equilibrium transient phase is automatically identified by maximizing the total effective sample size in the subsequent production interval:
|
|
121
|
+
$$\hat{t}_{\text{eq}} = \arg\max_{t_0} N_{\text{eff}}(t_0) = \arg\max_{t_0} \frac{N - t_0}{g(t_0)}$$
|
|
122
|
+
|
|
123
|
+
### 2. Autocorrelation & Statistical Inefficiency ($g$)
|
|
124
|
+
MD frames are temporally correlated. MDCheck computes the integrated autocorrelation time $\tau_{\text{int}}$ using the Madras-Sokal self-consistent cutoff window:
|
|
125
|
+
$$\tau_{\text{int}} = \frac{1}{2} + \sum_{k=1}^{M} C(k), \quad M \ge 6 \tau_{\text{int}}$$
|
|
126
|
+
$$g = 1 + 2\tau_{\text{int}}, \quad N_{\text{eff}} = \frac{N_{\text{prod}}}{g}$$
|
|
127
|
+
|
|
128
|
+
### 3. Multi-Replica Conformational Overlap
|
|
129
|
+
Conformational consistency between independent trajectories ($R_1, R_2, R_3$) is evaluated via the square-root of Jensen-Shannon Divergence ($\mathrm{JSD} \in [0, 1]$) and Root-Mean-Square Inner Product (RMSIP) across essential PCA subspaces:
|
|
130
|
+
$$\mathrm{JSD}(P \parallel Q) = \frac{1}{2} D_{\text{KL}}(P \parallel M) + \frac{1}{2} D_{\text{KL}}(Q \parallel M)$$
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Citation
|
|
135
|
+
|
|
136
|
+
If you use MDCheck to evaluate trajectory convergence, equilibration, statistical inefficiency, or replica reproducibility in your research, please cite:
|
|
137
|
+
|
|
138
|
+
```bibtex
|
|
139
|
+
@software{monreal2026mdcheck,
|
|
140
|
+
author = {Monreal-Hern{\'a}ndez, Andre},
|
|
141
|
+
title = {{MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations}},
|
|
142
|
+
year = {2026},
|
|
143
|
+
version = {1.0.0},
|
|
144
|
+
publisher = {Zenodo},
|
|
145
|
+
url = {https://github.com/sircalch/mdcheck}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
|
|
154
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility
|
|
3
|
+
Assessment for Molecular Dynamics Simulations.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "1.0.0"
|
|
7
|
+
__author__ = "Andre Monreal-Hernández"
|
|
8
|
+
__license__ = "MIT"
|
|
9
|
+
|
|
10
|
+
from mdcheck.core.autocorrelation import (
|
|
11
|
+
compute_autocorrelation,
|
|
12
|
+
integrated_autocorrelation_time,
|
|
13
|
+
effective_sample_size,
|
|
14
|
+
statistical_inefficiency
|
|
15
|
+
)
|
|
16
|
+
from mdcheck.core.equilibration import detect_equilibration, geweke_diagnostic
|
|
17
|
+
from mdcheck.core.replicas import (
|
|
18
|
+
assess_replica_consistency,
|
|
19
|
+
jensen_shannon_distance,
|
|
20
|
+
subspace_overlap_rmsip
|
|
21
|
+
)
|
|
22
|
+
from mdcheck.core.drift import assess_drift, block_averaging
|
|
23
|
+
from mdcheck.core.bootstrap import bootstrap_ci
|
|
24
|
+
from mdcheck.core.scoring import assess_trajectory_quality, SimulationQualityReport
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"__version__",
|
|
28
|
+
"compute_autocorrelation",
|
|
29
|
+
"integrated_autocorrelation_time",
|
|
30
|
+
"effective_sample_size",
|
|
31
|
+
"statistical_inefficiency",
|
|
32
|
+
"detect_equilibration",
|
|
33
|
+
"geweke_diagnostic",
|
|
34
|
+
"assess_replica_consistency",
|
|
35
|
+
"jensen_shannon_distance",
|
|
36
|
+
"subspace_overlap_rmsip",
|
|
37
|
+
"assess_drift",
|
|
38
|
+
"block_averaging",
|
|
39
|
+
"bootstrap_ci",
|
|
40
|
+
"assess_trajectory_quality",
|
|
41
|
+
"SimulationQualityReport"
|
|
42
|
+
]
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command Line Interface (CLI) for MDCheck.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
import os
|
|
7
|
+
import argparse
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from mdcheck import __version__
|
|
11
|
+
from mdcheck.parsers.generic import load_timeseries_file
|
|
12
|
+
from mdcheck.core.scoring import assess_trajectory_quality
|
|
13
|
+
from mdcheck.reporters.plot_generator import generate_publication_figures
|
|
14
|
+
from mdcheck.reporters.manuscript_prep import generate_manuscript_assets
|
|
15
|
+
from mdcheck.reporters.html_report import generate_html_report
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def print_banner():
|
|
19
|
+
banner = rf"""
|
|
20
|
+
__ __ _____ _____ _ _
|
|
21
|
+
| \/ | __ \ / ____| | | |
|
|
22
|
+
| \ / | | | | | | |__ ___ ___| | __
|
|
23
|
+
| |\/| | | | | | | '_ \ / _ \/ __| |/ /
|
|
24
|
+
| | | | |__| | |____| | | | __/ (__| <
|
|
25
|
+
|_| |_|_____/ \_____|_| |_|\___|\___|_|\_\ v{__version__}
|
|
26
|
+
|
|
27
|
+
Molecular Dynamics Convergence & Statistical Inefficiency Toolkit
|
|
28
|
+
Monreal-Hernández et al., 2026
|
|
29
|
+
"""
|
|
30
|
+
print(banner)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def run_demo(output_dir: str = "mdcheck_demo_output"):
|
|
34
|
+
"""
|
|
35
|
+
Generates a realistic 3-replica molecular dynamics dataset (RMSD, Radius of Gyration, Potential Energy)
|
|
36
|
+
and executes the full MDCheck assessment pipeline.
|
|
37
|
+
"""
|
|
38
|
+
print(f"\n[MDCheck] Running demonstration mode...")
|
|
39
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
40
|
+
|
|
41
|
+
n_frames = 2000
|
|
42
|
+
time_coords = np.linspace(0.0, 100.0, n_frames) # 100 ns simulation
|
|
43
|
+
|
|
44
|
+
rng = np.random.default_rng(42)
|
|
45
|
+
|
|
46
|
+
# Simulate Replica 1, 2, 3
|
|
47
|
+
# Observable 1: RMSD (Equilibrating from 0.8 to 1.8 A over first 20 ns, then stable fluctuations)
|
|
48
|
+
def make_rmsd(seed):
|
|
49
|
+
r = np.random.default_rng(seed)
|
|
50
|
+
noise = np.zeros(n_frames)
|
|
51
|
+
# AR(1) correlated noise
|
|
52
|
+
phi = 0.85
|
|
53
|
+
for i in range(1, n_frames):
|
|
54
|
+
noise[i] = phi * noise[i-1] + np.sqrt(1 - phi**2) * r.normal(0, 0.08)
|
|
55
|
+
# Equilibration rise in first 400 frames (20 ns)
|
|
56
|
+
eq_curve = 1.0 * (1.0 - np.exp(-time_coords / 8.0)) + 0.8
|
|
57
|
+
return eq_curve + noise
|
|
58
|
+
|
|
59
|
+
# Observable 2: Radius of Gyration Rg (stable around 1.45 nm)
|
|
60
|
+
def make_rg(seed):
|
|
61
|
+
r = np.random.default_rng(seed)
|
|
62
|
+
noise = np.zeros(n_frames)
|
|
63
|
+
phi = 0.80
|
|
64
|
+
for i in range(1, n_frames):
|
|
65
|
+
noise[i] = phi * noise[i-1] + np.sqrt(1 - phi**2) * r.normal(0, 0.02)
|
|
66
|
+
eq_curve = 0.05 * np.exp(-time_coords / 5.0) + 1.45
|
|
67
|
+
return eq_curve + noise
|
|
68
|
+
|
|
69
|
+
r1_rmsd = make_rmsd(101)
|
|
70
|
+
r2_rmsd = make_rmsd(102)
|
|
71
|
+
r3_rmsd = make_rmsd(103)
|
|
72
|
+
|
|
73
|
+
r1_rg = make_rg(201)
|
|
74
|
+
r2_rg = make_rg(202)
|
|
75
|
+
r3_rg = make_rg(203)
|
|
76
|
+
|
|
77
|
+
primary_timeseries = {
|
|
78
|
+
"Backbone_RMSD": r1_rmsd,
|
|
79
|
+
"Radius_of_Gyration": r1_rg
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
replica_dict = {
|
|
83
|
+
"Backbone_RMSD": [r1_rmsd, r2_rmsd, r3_rmsd],
|
|
84
|
+
"Radius_of_Gyration": [r1_rg, r2_rg, r3_rg]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
print(" -> Evaluating trajectory equilibration, autocorrelation, and replica overlap...")
|
|
88
|
+
report = assess_trajectory_quality(
|
|
89
|
+
timeseries_dict=primary_timeseries,
|
|
90
|
+
time_coords=time_coords,
|
|
91
|
+
replica_dict=replica_dict
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# Generate assets
|
|
95
|
+
print(" -> Generating publication-ready vector figures (SVG/PDF/PNG)...")
|
|
96
|
+
generate_publication_figures(primary_timeseries, time_coords, report, output_dir, replica_dict=replica_dict)
|
|
97
|
+
|
|
98
|
+
print(" -> Formulating Methods text snippet, summary LaTeX tables, and BibTeX citations...")
|
|
99
|
+
text_assets = generate_manuscript_assets(report, output_dir)
|
|
100
|
+
|
|
101
|
+
with open(text_assets["methods_text"], "r", encoding="utf-8") as f:
|
|
102
|
+
methods_content = f.read()
|
|
103
|
+
with open(text_assets["citation_bib"], "r", encoding="utf-8") as f:
|
|
104
|
+
bib_content = f.read()
|
|
105
|
+
|
|
106
|
+
html_path = os.path.join(output_dir, "report.html")
|
|
107
|
+
print(f" -> Rendering interactive HTML report at {html_path}...")
|
|
108
|
+
generate_html_report(report, html_path, methods_text=methods_content, citation_bib=bib_content)
|
|
109
|
+
|
|
110
|
+
print("\n" + "="*70)
|
|
111
|
+
print(f" [RESULT] Overall Trajectory Certification: {report.overall_status}")
|
|
112
|
+
print(f" [SCORE] {report.score_summary}")
|
|
113
|
+
print("="*70)
|
|
114
|
+
for name, obs in report.observables.items():
|
|
115
|
+
print(f" * {name:20s}: t_eq = {obs.t_eq_time:5.2f} ns | N_eff = {obs.n_eff:6.0f} | Mean = {obs.mean_prod:.3f} [{obs.ci_lower_95:.3f}, {obs.ci_upper_95:.3f}] | Status: {obs.status}")
|
|
116
|
+
if report.replica_assessment:
|
|
117
|
+
print(f" * Multi-Replica Overlap : Mean JSD = {report.replica_assessment['mean_jsd']:.3f} | Status: {report.replica_assessment['status']}")
|
|
118
|
+
print("="*70)
|
|
119
|
+
print(f"\nAll outputs successfully saved to: {os.path.abspath(output_dir)}/")
|
|
120
|
+
print(f"Open {os.path.abspath(html_path)} in your browser to inspect the full report.\n")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def run_assess(args):
|
|
124
|
+
"""
|
|
125
|
+
Executes assessment on user-provided input files.
|
|
126
|
+
"""
|
|
127
|
+
output_dir = args.output
|
|
128
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
129
|
+
|
|
130
|
+
input_files = args.input
|
|
131
|
+
replica_files = args.replicas if args.replicas else []
|
|
132
|
+
|
|
133
|
+
if not input_files and not replica_files:
|
|
134
|
+
print("[Error] Please specify input files with --input or --replicas.", file=sys.stderr)
|
|
135
|
+
sys.exit(1)
|
|
136
|
+
|
|
137
|
+
all_files = input_files + replica_files
|
|
138
|
+
print(f"\n[MDCheck] Loading timeseries from {len(all_files)} file(s)...")
|
|
139
|
+
|
|
140
|
+
loaded_data = []
|
|
141
|
+
for fp in all_files:
|
|
142
|
+
t, s_dict, meta = load_timeseries_file(fp)
|
|
143
|
+
loaded_data.append((t, s_dict, meta, fp))
|
|
144
|
+
print(f" -> Loaded '{meta['title']}': {len(t)} frames, observables: {list(s_dict.keys())}")
|
|
145
|
+
|
|
146
|
+
primary_t, primary_dict, primary_meta, _ = loaded_data[0]
|
|
147
|
+
|
|
148
|
+
replica_dict = None
|
|
149
|
+
if len(loaded_data) > 1:
|
|
150
|
+
replica_dict = {}
|
|
151
|
+
for obs_name in primary_dict.keys():
|
|
152
|
+
rep_list = []
|
|
153
|
+
for _, s_dict, _, _ in loaded_data:
|
|
154
|
+
if obs_name in s_dict:
|
|
155
|
+
rep_list.append(s_dict[obs_name])
|
|
156
|
+
if len(rep_list) > 1:
|
|
157
|
+
replica_dict[obs_name] = rep_list
|
|
158
|
+
|
|
159
|
+
print("\n[MDCheck] Performing statistical convergence, equilibration, and inefficiency analysis...")
|
|
160
|
+
report = assess_trajectory_quality(
|
|
161
|
+
timeseries_dict=primary_dict,
|
|
162
|
+
time_coords=primary_t,
|
|
163
|
+
replica_dict=replica_dict
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
print(" -> Generating publication-quality vector charts...")
|
|
167
|
+
generate_publication_figures(primary_dict, primary_t, report, output_dir, replica_dict=replica_dict)
|
|
168
|
+
|
|
169
|
+
print(" -> Generating manuscript text, LaTeX summary table, and BibTeX citations...")
|
|
170
|
+
text_assets = generate_manuscript_assets(report, output_dir)
|
|
171
|
+
|
|
172
|
+
with open(text_assets["methods_text"], "r", encoding="utf-8") as f:
|
|
173
|
+
methods_content = f.read()
|
|
174
|
+
with open(text_assets["citation_bib"], "r", encoding="utf-8") as f:
|
|
175
|
+
bib_content = f.read()
|
|
176
|
+
|
|
177
|
+
html_path = os.path.join(output_dir, "report.html")
|
|
178
|
+
print(f" -> Writing HTML quality report to {html_path}...")
|
|
179
|
+
generate_html_report(report, html_path, methods_text=methods_content, citation_bib=bib_content)
|
|
180
|
+
|
|
181
|
+
print("\n" + "="*70)
|
|
182
|
+
print(f" [RESULT] Overall Trajectory Certification: {report.overall_status}")
|
|
183
|
+
print(f" [SCORE] {report.score_summary}")
|
|
184
|
+
print("="*70)
|
|
185
|
+
for name, obs in report.observables.items():
|
|
186
|
+
print(f" * {name:20s}: t_eq = {obs.t_eq_time:5.2f} | N_eff = {obs.n_eff:6.0f} | Mean = {obs.mean_prod:.3f} [{obs.ci_lower_95:.3f}, {obs.ci_upper_95:.3f}] | Status: {obs.status}")
|
|
187
|
+
if report.replica_assessment:
|
|
188
|
+
print(f" * Multi-Replica Overlap : Mean JSD = {report.replica_assessment['mean_jsd']:.3f} | Status: {report.replica_assessment['status']}")
|
|
189
|
+
print("="*70)
|
|
190
|
+
print(f"\nReport ready at: {os.path.abspath(html_path)}\n")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def print_citation():
|
|
194
|
+
bib = """@software{monreal2026mdcheck,
|
|
195
|
+
author = {Monreal-Hern\\'andez, Andre},
|
|
196
|
+
title = {{MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations}},
|
|
197
|
+
year = {2026},
|
|
198
|
+
version = {1.0.0},
|
|
199
|
+
publisher = {Zenodo},
|
|
200
|
+
url = {https://github.com/sircalch/mdcheck}
|
|
201
|
+
}"""
|
|
202
|
+
print("\nIf you use MDCheck in your publications, please cite:\n")
|
|
203
|
+
print("APA Style:")
|
|
204
|
+
print("Monreal-Hernández, A. (2026). MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations (v1.0.0). Zenodo. https://github.com/sircalch/mdcheck\n")
|
|
205
|
+
print("BibTeX:")
|
|
206
|
+
print(bib)
|
|
207
|
+
print()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def main():
|
|
211
|
+
parser = argparse.ArgumentParser(
|
|
212
|
+
prog="mdcheck",
|
|
213
|
+
description="MDCheck: Automated Convergence, Statistical Inefficiency, and Reproducibility Assessment for Molecular Dynamics Simulations."
|
|
214
|
+
)
|
|
215
|
+
parser.add_argument("-v", "--version", action="version", version=f"mdcheck {__version__}")
|
|
216
|
+
|
|
217
|
+
subparsers = parser.add_subparsers(dest="command", help="Available subcommands")
|
|
218
|
+
|
|
219
|
+
# Assess command
|
|
220
|
+
assess_parser = subparsers.add_parser("assess", help="Assess trajectory convergence, equilibration, and reproducibility")
|
|
221
|
+
assess_parser.add_argument("-i", "--input", nargs="+", help="Primary trajectory timeseries file(s) (.xvg, .csv, .dat, .txt)")
|
|
222
|
+
assess_parser.add_argument("-r", "--replicas", nargs="+", help="Multi-replica files for consistency comparison")
|
|
223
|
+
assess_parser.add_argument("-o", "--output", default="mdcheck_output", help="Directory to save report, plots, and manuscript assets (default: mdcheck_output)")
|
|
224
|
+
|
|
225
|
+
# Demo command
|
|
226
|
+
demo_parser = subparsers.add_parser("demo", help="Run MDCheck on a synthetic multi-replica simulation dataset")
|
|
227
|
+
demo_parser.add_argument("-o", "--output", default="mdcheck_demo_output", help="Output directory (default: mdcheck_demo_output)")
|
|
228
|
+
|
|
229
|
+
# Cite command
|
|
230
|
+
subparsers.add_parser("cite", help="Display BibTeX and APA citation details")
|
|
231
|
+
|
|
232
|
+
if len(sys.argv) == 1:
|
|
233
|
+
print_banner()
|
|
234
|
+
parser.print_help()
|
|
235
|
+
sys.exit(0)
|
|
236
|
+
|
|
237
|
+
args = parser.parse_args()
|
|
238
|
+
|
|
239
|
+
if args.command == "assess":
|
|
240
|
+
print_banner()
|
|
241
|
+
run_assess(args)
|
|
242
|
+
elif args.command == "demo":
|
|
243
|
+
print_banner()
|
|
244
|
+
run_demo(args.output)
|
|
245
|
+
elif args.command == "cite":
|
|
246
|
+
print_banner()
|
|
247
|
+
print_citation()
|
|
248
|
+
else:
|
|
249
|
+
parser.print_help()
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
if __name__ == "__main__":
|
|
253
|
+
main()
|
|
254
|
+
|