gmxplot 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.
- gmxplot-0.1.0/.gitignore +11 -0
- gmxplot-0.1.0/LICENSE +8 -0
- gmxplot-0.1.0/PKG-INFO +432 -0
- gmxplot-0.1.0/README.md +402 -0
- gmxplot-0.1.0/gmxplot/__init__.py +3 -0
- gmxplot-0.1.0/gmxplot/cli.py +314 -0
- gmxplot-0.1.0/gmxplot/comparison.py +293 -0
- gmxplot-0.1.0/gmxplot/config.py +37 -0
- gmxplot-0.1.0/gmxplot/escape_codes.py +54 -0
- gmxplot-0.1.0/gmxplot/parser.py +247 -0
- gmxplot-0.1.0/gmxplot/plotting.py +268 -0
- gmxplot-0.1.0/gmxplot/stats.py +84 -0
- gmxplot-0.1.0/pyproject.toml +57 -0
gmxplot-0.1.0/.gitignore
ADDED
gmxplot-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
[Full GPL-3.0 text - see https://www.gnu.org/licenses/gpl-3.0.txt]
|
gmxplot-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gmxplot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: GROMACS XVG file visualization tool with auto type detection, comparison, and statistical summary
|
|
5
|
+
Project-URL: Homepage, https://github.com/MaybeBio/gmxplot
|
|
6
|
+
Project-URL: Issues, https://github.com/MaybeBio/gmxplot/issues
|
|
7
|
+
Author-email: Joe Hoye Dow <luxunisgod123@gmail.com>
|
|
8
|
+
License-Expression: GPL-3.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: bioinformatics,energy-plot,gromacs,molecular-dynamics,rmsd,rmsf,sasa,simulation,trajectory-analysis,visualization,xvg
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
24
|
+
Requires-Dist: numpy>=1.24.0
|
|
25
|
+
Requires-Dist: pandas>=2.0.0
|
|
26
|
+
Requires-Dist: rich>=13.0.0
|
|
27
|
+
Requires-Dist: seaborn>=0.12.0
|
|
28
|
+
Requires-Dist: typer>=0.9.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# ๐จ gmxplot โ GROMACS XVG File Visualization Tool
|
|
32
|
+
|
|
33
|
+
**Auto-detect, plot, compare, and summarize your GROMACS simulation data from the command line.**
|
|
34
|
+
|
|
35
|
+
`gmxplot` is a Python CLI tool that reads GROMACS XVG output files, automatically detects the type of simulation data (RMSD, RMSF, energy, SASA, PCA, gyration, etc.), and generates publication-ready matplotlib figures. It supports single-file plotting, two-file comparison, multi-file overlay, batch directory processing, and CSV statistical summaries โ all with sensible defaults and no manual type specification required.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Automatic type detection** โ No need to specify the plot type. `gmxplot` reads the XVG file headers and classifies the data as energy, RMSD, RMSF, gyration, SASA, PCA, or generic XY.
|
|
42
|
+
- **Publication-ready plots** โ Clean matplotlib + seaborn-styled figures with consistent color schemes and typography.
|
|
43
|
+
- **Rolling average overlay** โ Raw data shown with transparency; a rolling average line (auto-calculated at 5% of data range) highlights the trend.
|
|
44
|
+
- **Two-file comparison** โ Overlay two simulations (e.g., different mutants, temperatures, force fields) on the same axes with distinct colors.
|
|
45
|
+
- **Multi-file comparison** โ Compare 3+ files simultaneously with a cycling color palette (matplotlib tab10).
|
|
46
|
+
- **Batch processing** โ Automatically find and plot all XVG files in a directory.
|
|
47
|
+
- **Statistical summaries** โ Per-column CSV output with mean, std, min, q10, q50, q90, max, displayed as a Rich console table.
|
|
48
|
+
- **GROMACS escape code rendering** โ Automatic conversion of xmgrace formatting codes (`\S2\N` โ `$^{2}$`, `\sX\N` โ `$_{X}$`, `\f{...}` removed).
|
|
49
|
+
- **Metadata-driven axis labels** โ Axis titles are read from the XVG file headers, so units (ps vs ns, nm vs ร
) always match the data.
|
|
50
|
+
- **Multiple output formats** โ PNG (default), PDF, SVG, EPS, JPG, TIFF.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
### From source
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/MaybeBio/gmxplot.git
|
|
60
|
+
cd gmxplot
|
|
61
|
+
pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### With pip
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install gmxplot
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Dependencies
|
|
71
|
+
|
|
72
|
+
- Python โฅ 3.10
|
|
73
|
+
- numpy, pandas, matplotlib, seaborn, typer, rich
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Detect the type of an XVG file
|
|
81
|
+
gmxplot detect simulation.xvg
|
|
82
|
+
|
|
83
|
+
# Plot a single file (auto-detects type)
|
|
84
|
+
gmxplot plot simulation.xvg
|
|
85
|
+
|
|
86
|
+
# Plot with custom rolling average
|
|
87
|
+
gmxplot plot energy.xvg --roll-avg 50
|
|
88
|
+
|
|
89
|
+
# Save to a specific file
|
|
90
|
+
gmxplot plot rmsd.xvg -o rmsd.png
|
|
91
|
+
gmxplot plot rmsd.xvg -o rmsd.pdf
|
|
92
|
+
|
|
93
|
+
# Compare two simulations
|
|
94
|
+
gmxplot compare ref.xvg mutant.xvg --label1 WildType --label2 Mutant
|
|
95
|
+
|
|
96
|
+
# Compare 3+ files
|
|
97
|
+
gmxplot multi-compare run1/rmsd.xvg run2/rmsd.xvg run3/rmsd.xvg
|
|
98
|
+
|
|
99
|
+
# Batch process a directory
|
|
100
|
+
gmxplot batch ./simulation/ -o ./plots/ --stats
|
|
101
|
+
|
|
102
|
+
# Generate statistics CSV
|
|
103
|
+
gmxplot stats energy.xvg rmsd.xvg -o summary.csv
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## CLI Reference
|
|
109
|
+
|
|
110
|
+
### `gmxplot plot`
|
|
111
|
+
|
|
112
|
+
Plot a single XVG file with automatic type detection.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Usage: gmxplot plot [OPTIONS] FILE
|
|
116
|
+
|
|
117
|
+
Arguments:
|
|
118
|
+
FILE Path to XVG file [required]
|
|
119
|
+
|
|
120
|
+
Options:
|
|
121
|
+
-r, --roll-avg INTEGER Rolling average window size (auto if not set)
|
|
122
|
+
-o, --output TEXT Output file path (PNG, PDF, SVG, JPG)
|
|
123
|
+
-d, --dpi INTEGER DPI for saved image [default: 300]
|
|
124
|
+
--show Display plot in window
|
|
125
|
+
-m, --mean Plot mean line
|
|
126
|
+
-s, --std Plot mean +/- std lines
|
|
127
|
+
--latex / --no-latex Enable/disable LaTeX rendering (default: off)
|
|
128
|
+
--help Show this message and exit
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Examples:**
|
|
132
|
+
```bash
|
|
133
|
+
gmxplot plot energy.xvg
|
|
134
|
+
gmxplot plot rmsd.xvg -o rmsd.png --roll-avg 20
|
|
135
|
+
gmxplot plot sasa.xvg -o sasa.pdf --dpi 600
|
|
136
|
+
gmxplot plot gyrate.xvg -m -s # with mean and std lines
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### `gmxplot compare`
|
|
140
|
+
|
|
141
|
+
Compare two XVG files side-by-side or overlaid on the same axes.
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Usage: gmxplot compare [OPTIONS] FILE1 FILE2
|
|
145
|
+
|
|
146
|
+
Arguments:
|
|
147
|
+
FILE1 Path to first XVG file [required]
|
|
148
|
+
FILE2 Path to second XVG file [required]
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
-l1, --label1 TEXT Label for first dataset [default: prot_1]
|
|
152
|
+
-l2, --label2 TEXT Label for second dataset [default: prot_2]
|
|
153
|
+
-r, --roll-avg INTEGER Rolling average window size [default: 50]
|
|
154
|
+
-o, --output TEXT Output file path
|
|
155
|
+
-d, --dpi INTEGER DPI for saved image [default: 300]
|
|
156
|
+
--latex / --no-latex Enable/disable LaTeX rendering (default: off)
|
|
157
|
+
--help Show this message and exit
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Type-specific behavior:**
|
|
161
|
+
| Plot Type | Comparison Mode |
|
|
162
|
+
|-----------|----------------|
|
|
163
|
+
| energy | Multi-panel grid: one subplot per component, both datasets overlaid per panel |
|
|
164
|
+
| rmsd | Single axes: both RMSD rolling averages overlaid |
|
|
165
|
+
| rmsf | Single axes: both RMSF traces overlaid (no rolling average) |
|
|
166
|
+
| gyration | Single axes: both Rg traces overlaid |
|
|
167
|
+
| sasa | Single axes: both SASA rolling averages overlaid |
|
|
168
|
+
| pca | Side-by-side: two hexbin density plots |
|
|
169
|
+
| xy | Single axes: generic overlay of both files |
|
|
170
|
+
|
|
171
|
+
**Examples:**
|
|
172
|
+
```bash
|
|
173
|
+
gmxplot compare prot1/rmsd.xvg prot2/rmsd.xvg -l1 WT -l2 Mutant
|
|
174
|
+
gmxplot compare run1/energy.xvg run2/energy.xvg -o energy_compare.png
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `gmxplot multi-compare`
|
|
178
|
+
|
|
179
|
+
Compare multiple XVG files (3+) of the same type.
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
Usage: gmxplot multi-compare [OPTIONS] FILES...
|
|
183
|
+
|
|
184
|
+
Arguments:
|
|
185
|
+
FILES... Paths to XVG files (at least 2) [required]
|
|
186
|
+
|
|
187
|
+
Options:
|
|
188
|
+
-r, --roll-avg INTEGER Rolling average window size [default: 50]
|
|
189
|
+
-o, --output TEXT Output file path
|
|
190
|
+
-d, --dpi INTEGER DPI for saved image [default: 300]
|
|
191
|
+
--latex / --no-latex Enable/disable LaTeX rendering (default: off)
|
|
192
|
+
--help Show this message and exit
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Uses matplotlib's tab10 color palette (10 cycled colors) for distinguishing traces.
|
|
196
|
+
|
|
197
|
+
**Examples:**
|
|
198
|
+
```bash
|
|
199
|
+
gmxplot multi-compare chA/rmsd.xvg chB/rmsd.xvg chC/rmsd.xvg
|
|
200
|
+
gmxplot multi-compare prot3/rmsf_ch*.xvg -o rmsf_multi.png
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### `gmxplot detect`
|
|
204
|
+
|
|
205
|
+
Print the detected plot type and metadata for an XVG file without generating a plot.
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
Usage: gmxplot detect [OPTIONS] FILE
|
|
209
|
+
|
|
210
|
+
Arguments:
|
|
211
|
+
FILE Path to XVG file [required]
|
|
212
|
+
|
|
213
|
+
Options:
|
|
214
|
+
--help Show this message and exit
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Example output:**
|
|
218
|
+
```
|
|
219
|
+
File: tests/fixtures/prot1/energy.xvg
|
|
220
|
+
Type: energy
|
|
221
|
+
Title: GROMACS Energies
|
|
222
|
+
X-axis: Time (ps)
|
|
223
|
+
Y-axis: (kJ/mol), (K), (bar), (kg/m^3)
|
|
224
|
+
Columns: ['Time', 'Potential', 'Temperature', 'Pressure', 'Density']
|
|
225
|
+
Data points: 20001
|
|
226
|
+
Columns count: 5
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `gmxplot batch`
|
|
230
|
+
|
|
231
|
+
Process all XVG files in a directory, generating plots and optionally a statistics CSV.
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
Usage: gmxplot batch [OPTIONS] [INPUT_DIR]
|
|
235
|
+
|
|
236
|
+
Arguments:
|
|
237
|
+
[INPUT_DIR] Input directory with XVG files [default: .]
|
|
238
|
+
|
|
239
|
+
Options:
|
|
240
|
+
-o, --output-dir TEXT Output directory for plots [default: .]
|
|
241
|
+
-r, --roll-avg INTEGER Rolling average window size (auto if not set)
|
|
242
|
+
-d, --dpi INTEGER DPI for saved images [default: 300]
|
|
243
|
+
-e, --ext TEXT Export format (png, pdf, svg, jpg) [default: png]
|
|
244
|
+
--stats / --no-stats Generate statistics CSV [default: True]
|
|
245
|
+
--stats-file TEXT Statistics CSV filename [default: xvg-stats.csv]
|
|
246
|
+
-m, --mean Plot mean lines
|
|
247
|
+
-s, --std Plot mean +/- std lines
|
|
248
|
+
--latex / --no-latex Enable/disable LaTeX rendering (default: off)
|
|
249
|
+
--help Show this message and exit
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Examples:**
|
|
253
|
+
```bash
|
|
254
|
+
gmxplot batch ./simulation/ -o ./plots/
|
|
255
|
+
gmxplot batch ./data/ -o ./output/ --stats --ext pdf
|
|
256
|
+
gmxplot batch ./runs/ --no-stats -m # batch without stats, with mean lines
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### `gmxplot stats`
|
|
260
|
+
|
|
261
|
+
Generate a statistical summary CSV for one or more XVG files, displayed as a Rich table.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Usage: gmxplot stats [OPTIONS] FILES...
|
|
265
|
+
|
|
266
|
+
Arguments:
|
|
267
|
+
FILES... XVG files to analyze [required]
|
|
268
|
+
|
|
269
|
+
Options:
|
|
270
|
+
-o, --output TEXT Output CSV path [default: xvg-stats.csv]
|
|
271
|
+
--help Show this message and exit
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Per-column statistics computed:
|
|
275
|
+
| Field | Description |
|
|
276
|
+
|-------|-------------|
|
|
277
|
+
| dir | Parent directory of the file |
|
|
278
|
+
| file | XVG filename |
|
|
279
|
+
| plot | Column name (e.g., Potential, RMSD, Rg) |
|
|
280
|
+
| mean | Arithmetic mean |
|
|
281
|
+
| std | Standard deviation |
|
|
282
|
+
| min | Minimum value |
|
|
283
|
+
| q10 | 10th percentile |
|
|
284
|
+
| q50 | 50th percentile (median) |
|
|
285
|
+
| q90 | 90th percentile |
|
|
286
|
+
| max | Maximum value |
|
|
287
|
+
|
|
288
|
+
**Example output:**
|
|
289
|
+
```
|
|
290
|
+
XVG Statistics Summary
|
|
291
|
+
โโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโณโโโโโโโโณโโโโโโโโโณโโโโโโโโโณโโโโโโโโณโโโโโโโโโณโโโโโโโโโ
|
|
292
|
+
โ File โ Plot โ Mean โ Std โ Min โ Q10 โ Q50 โ Q90 โ Max โ
|
|
293
|
+
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
|
|
294
|
+
โ rmsdโฆ โ RMSD โ 0.2905โ 0.0323โ 0.0369 โ 0.2544 โ 0.2868โ 0.3324 โ 0.3977 โ
|
|
295
|
+
โ energโฆ โ Potentiโฆ โ-5616.โฆโ1095.5โฆโ-5659.39โ-5639.27โ-5616โฆโ-5601.2โฆโ-5570.โฆโ
|
|
296
|
+
โโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโดโโโโโโโโดโโโโโโโโโดโโโโโโโโโดโโโโโโโโดโโโโโโโโโดโโโโโโโโโ
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Plot Type Detection
|
|
302
|
+
|
|
303
|
+
Plot type is detected automatically from the `@ title "..."` header line in each XVG file, with fallback heuristics based on axis labels and column count when the title is unrecognized.
|
|
304
|
+
|
|
305
|
+
| Plot Type | `@ title` pattern | Column Names | Special Features |
|
|
306
|
+
|-----------|-------------------|--------------|------------------|
|
|
307
|
+
| `energy` | "GROMACS Energies", "Energy", ... | Time, Potential, Temperature, Pressure, Density | Multi-panel grid (2-column), per-component subplots |
|
|
308
|
+
| `gyration` | "Radius of gyration ..." | Time, Rg, RgX, RgY, RgZ | Rg rolling average only (components not shown) |
|
|
309
|
+
| `rmsd` | "RMSD" | Time, RMSD | Rolling average overlay |
|
|
310
|
+
| `rmsf` | "RMS fluctuation", "RMSF" | Residue, RMSF | Per-residue line (no rolling average) |
|
|
311
|
+
| `sasa` | "Solvent Accessible Surface", "Area per residue ..." | Time/Residue, Area, StdDev | Time-series (with RA) or per-residue (without RA) |
|
|
312
|
+
| `pca` | "2D projection of trajectory" | PC1, PC2 | Hexbin density with viridis colormap + colorbar |
|
|
313
|
+
| `xy` | Any unrecognized title | Auto-detected | Generic fallback, legend-based line labels |
|
|
314
|
+
|
|
315
|
+
### Detection priority
|
|
316
|
+
|
|
317
|
+
1. **Title match** (fast, authoritative) โ if `@ title` contains a known keyword, use that type
|
|
318
|
+
2. **Axis label / column count fallback** โ when the title doesn't match, heuristics examine the y-label for units, column count, and axis names
|
|
319
|
+
3. **Default** โ 2+ columns โ `xy`, otherwise `unknown`
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Architecture
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
gmxplot/
|
|
327
|
+
โโโ pyproject.toml # Package config, dependencies, entry point
|
|
328
|
+
โโโ README.md
|
|
329
|
+
โโโ gmxplot/
|
|
330
|
+
โ โโโ __init__.py # Package version
|
|
331
|
+
โ โโโ cli.py # Typer CLI: all 6 commands, figure saving, LaTeX setup
|
|
332
|
+
โ โโโ parser.py # XVG parsing: XVGMetadata, read_xvg(), classify_plot_type()
|
|
333
|
+
โ โโโ plotting.py # Matplotlib figures: plot_energy, plot_rmsd, plot_rmsf, etc.
|
|
334
|
+
โ โโโ comparison.py # Comparison: compare_two(), compare_multi(), type-specific funcs
|
|
335
|
+
โ โโโ stats.py # Statistics: compute_column_stats(), generate_stats_csv()
|
|
336
|
+
โ โโโ escape_codes.py # Escape codes: clean_gromacs_label(), resolve_axis_titles()
|
|
337
|
+
โ โโโ config.py # Defaults: figure sizes, DPI, colors, rolling avg params
|
|
338
|
+
โโโ tests/
|
|
339
|
+
โโโ test_parser.py
|
|
340
|
+
โโโ test_plotting.py
|
|
341
|
+
โโโ test_comparison.py
|
|
342
|
+
โโโ test_stats.py
|
|
343
|
+
โโโ test_escape_codes.py
|
|
344
|
+
โโโ test_cli.py
|
|
345
|
+
โโโ fixtures/ # Sample XVG files for testing
|
|
346
|
+
โโโ prot1/ # energy, gyrate, rmsd, rmsf, sasa, 2dproj
|
|
347
|
+
โโโ prot2/ # Same types (for comparison testing)
|
|
348
|
+
โโโ prot3/ # Chain-specific files (for multi-compare)
|
|
349
|
+
โโโ other_xvg/ # Edge cases (hbnum, resarea, cphmd)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Module relationships
|
|
353
|
+
|
|
354
|
+
```
|
|
355
|
+
cli.py โโโ parser.py (read_xvg, classify_plot_type)
|
|
356
|
+
cli.py โโโ plotting.py (create_plot, calculate_roll_avg)
|
|
357
|
+
cli.py โโโ comparison.py (compare_two, compare_multi)
|
|
358
|
+
cli.py โโโ stats.py (generate_stats_csv, format_stats_table)
|
|
359
|
+
|
|
360
|
+
plotting.py โโโ escape_codes.py (resolve_axis_titles, clean_gromacs_label)
|
|
361
|
+
comparison.py โโโ escape_codes.py
|
|
362
|
+
comparison.py โโโ plotting.py (calculate_roll_avg, _parse_y_units)
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Data flow
|
|
366
|
+
|
|
367
|
+
1. **Parsing**: XVG file โ `read_xvg()` โ `XVGMetadata` (title, labels, legend entries) + `DataFrame` (numeric columns with type-specific names)
|
|
368
|
+
2. **Classification**: `classify_plot_type()` matches title against known patterns โ sets `metadata.plot_type`
|
|
369
|
+
3. **Plotting**: `create_plot()` dispatches to type-specific function โ `Figure` with rolling average overlay
|
|
370
|
+
4. **Output**: `plt.savefig()` โ PNG/PDF/SVG on disk, or `plt.show()` for interactive viewing
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Rolling Average
|
|
375
|
+
|
|
376
|
+
The rolling average window size is calculated as **5% of the data range** (max - min along the x-axis), clamped between **3 and 100**. This provides a reasonable smoothing level for most GROMACS simulation data without over-smoothing.
|
|
377
|
+
|
|
378
|
+
- **Single plot**: Auto-calculated by default; override with `--roll-avg N`
|
|
379
|
+
- **Comparison**: Default 50 (larger window for trend-focused comparison)
|
|
380
|
+
- **RMSF**: No rolling average (per-residue data is not a time series)
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## Color Schemes
|
|
385
|
+
|
|
386
|
+
| Context | Colors | Source |
|
|
387
|
+
|---------|--------|--------|
|
|
388
|
+
| Single plot raw data | `#aec6cf` (pastel blue, 50% alpha) | config.py |
|
|
389
|
+
| Single plot rolling avg | `#1f77b4` (tab10 blue) | config.py |
|
|
390
|
+
| Two-file comparison | `#1f77b4` (blue) vs `#d62728` (red) | `COMPARE_COLORS` |
|
|
391
|
+
| Multi-file comparison | tab10 10-color cycle | `MULTI_COLORS` |
|
|
392
|
+
| PCA density | viridis colormap | matplotlib |
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## GROMACS Escape Code Handling
|
|
397
|
+
|
|
398
|
+
GROMACS XVG files use xmgrace-style formatting codes for axis labels and legends. `gmxplot` converts these to matplotlib-compatible notation:
|
|
399
|
+
|
|
400
|
+
| Escape Code | Meaning | Conversion | Example |
|
|
401
|
+
|-------------|---------|------------|---------|
|
|
402
|
+
| `\S...\N` | Superscript | `$^{...}$` | `nm\S2\N` โ `nm$^{2}$` |
|
|
403
|
+
| `\s...\N` | Subscript | `$_{...}$` | `Rg\sX\N` โ `Rg$_{X}$` |
|
|
404
|
+
| `\f{...}` | Font switch | Removed | `\f{Symbol}alpha` โ `alpha` |
|
|
405
|
+
|
|
406
|
+
Works with matplotlib's built-in mathtext renderer (no LaTeX installation required). If you enable `--latex`, the same notation is handled by LaTeX's math mode.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## References
|
|
411
|
+
|
|
412
|
+
`gmxplot` was inspired by and builds upon ideas from:
|
|
413
|
+
|
|
414
|
+
- **[GMXvg](https://github.com/TheBiomics/GMXvg)** โ Batch-oriented matplotlib plotting for GROMACS XVG files with statistical CSV export.
|
|
415
|
+
- **[xvg_plot](https://github.com/TheBiomics/GMXvg)** โ Interactive Plotly-based XVG visualization with rich type detection and multi-file comparison.
|
|
416
|
+
|
|
417
|
+
Key differences from these tools:
|
|
418
|
+
- **vs GMXvg**: No heavy UtilityLib dependency; cleaner modular architecture; type-specific plot functions with auto-detection; comparison and multi-file support.
|
|
419
|
+
- **vs xvg_plot**: Uses matplotlib instead of Plotly for publication-ready static output; includes statistical summary CSV; uses typer instead of argparse for CLI; supports mean/std overlay lines.
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## License
|
|
424
|
+
|
|
425
|
+
MIT
|
|
426
|
+
|
|
427
|
+
## Todos
|
|
428
|
+
|
|
429
|
+
โ ๏ธ In Chinese
|
|
430
|
+
|
|
431
|
+
- 1. ่พๅบๅๅงxvgๆฐๆฎ
|
|
432
|
+
- 2. ๅฏ่งๅๅ
ถไป้ๆฑ
|