Skip to content

Commit 58f9a53

Browse files
committed
Fix PersistenceLength normalization for sliced run (Issue #5453)
PersistenceLength._conclude() normalized bond_autocorrelation using the total number of frames in the trajectory instead of the number of frames actually analyzed. This gave wrong results whenever run() was called with start, stop, or step. Now uses self.n_frames, which AnalysisBase already tracks for this purpose. Added a regression test comparing full trajectory and sliced runs against manually computed normalization values.
1 parent c882e5c commit 58f9a53

4 files changed

Lines changed: 86 additions & 2 deletions

File tree

package/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ Chronological list of authors
284284
- Sai Udayagiri
285285
- Apoorva Verma
286286
- Aryaman Chaudhri
287+
- Srikar JY
287288

288289
External code
289290
-------------

package/CHANGELOG

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ The rules for this file:
1818
spyke7, talagayev, tanii1125, BradyAJohnston, hejamu, jeremyleung521,
1919
harshitgajjela-droid, kunjsinha, aygarwal, jauy123, Dreamstick9,
2020
ollyfutur, Amarendra22, charity-g, ParthUppal523, apoorva-01, RMeli,
21-
raulloiscuns, Aryaman-Chaudhri
21+
raulloiscuns, Aryaman-Chaudhri, srikarjy
2222

2323
* 2.11.0
2424

2525
Fixes
26+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
2627
* `AtomGroup.rotate()` and the `rotateby` trajectory transformation now
2728
also rotate velocities and forces besides positions. This also affects
2829
`MDAnalysis.analysis.align.alignto()` and `AlignTraj`, since they
@@ -120,6 +121,7 @@ Deprecations
120121
* 2.10.0
121122

122123
Fixes
124+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
123125
* Fix incorrect conversion factors for speed units A/fs, A/us, A/ms
124126
in MDAnalysis.units (Issue #5051, PR #5053)
125127
* `analysis.polymer.sort_backbone` is now working for discontinuous polymers
@@ -212,6 +214,7 @@ Deprecations
212214
* 2.9.0
213215

214216
Fixes
217+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
215218
* Add support for TPR files produced by GROMACS 2024.4 and GROMACS 2025.0
216219
* Fixes invalid default unit from Angstrom to Angstrom^{-3} for
217220
convert_density() function. (Issue #4829)
@@ -254,6 +257,7 @@ Changes
254257
* 2.8.0
255258

256259
Fixes
260+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
257261
* Fix `test_imd.py` test failures after imdclient 0.2.4
258262
increased default timeout by ensuring EOF sent (Issue #5442, PR #5443)
259263
* Allows bond/angle/dihedral connectivity to be guessed additively with
@@ -389,6 +393,7 @@ Deprecations
389393
* 2.7.0
390394

391395
Fixes
396+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
392397
* Fix doctest errors of lib/transformations.py (Issue #3925, PR #4370)
393398
* Fix documentation building errors due to `html_static_path` and unindented
394399
block of code (Issue #4362, PR #4365)
@@ -458,6 +463,7 @@ Deprecations
458463
* 2.6.1
459464

460465
Fixes
466+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
461467
* Fix Atom type guessing error (PR #4168, Issue #4167)
462468

463469
Enhancements
@@ -482,6 +488,7 @@ Deprecations
482488
* 2.6.0
483489

484490
Fixes
491+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
485492
* Fix AtomGroup.center_of_charge(..., unwrap=True) giving
486493
inconsistent (but scientifically correct) results on Intel macOS
487494
(Issue #4211)
@@ -541,6 +548,7 @@ Deprecations
541548
* 2.5.0
542549

543550
Fixes
551+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
544552
* Fixed using 'rb' mode inside GSDReader to avoid FutureWarning from GSDFile (Issue #4152)
545553
* Fixed ChainReader performing transformations correctly across boundaries in the individual trajectories
546554
(Issue #3657 #4008 PR #3906)
@@ -631,6 +639,7 @@ Changes
631639
* 2.4.3
632640

633641
Fixes
642+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
634643
* Fixed DCD reading for large (>2Gb) files (Issue #4039). This was broken
635644
for versions 2.4.0, 2.4.1 and 2.4.2
636645
* Fix element parsing from PSF files tests read via Parmed (Issue #4015)
@@ -641,6 +650,7 @@ Fixes
641650
* 2.4.2
642651

643652
Fixes
653+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
644654
* np.histogramdd calls in :class:`DensityAnalysis` now pass the `density`
645655
argument rather than the NumPy 1.24 removed `normed` (PR #3976)
646656
* visualization.streamlines_3D and visualization.streamlines no longer
@@ -653,6 +663,7 @@ Fixes
653663
* 2.4.1
654664

655665
Fixes
666+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
656667
* Fixes pyproject.toml minimum pin for biopython
657668

658669

@@ -662,6 +673,7 @@ Fixes
662673
* 2.4.0
663674

664675
Fixes
676+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
665677
* Update hbond analysis doc string to use exclusive bound language
666678
(Issue #3847)
667679
* XTC and TRR readers now fail with IOError when a status except EOK (=0) is
@@ -755,6 +767,7 @@ Deprecations
755767
* 2.3.0
756768

757769
Fixes
770+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
758771
* Fixes awk call in deploy.yaml tests for macos runners (Issue #3693)
759772
* add a 0.5 for correct midpoints in hole analysis (Issue #3715)
760773
* Fix reading error when PDB CONECT records are corrupt. (Issue #988)
@@ -798,6 +811,7 @@ Deprecations
798811
* 2.2.0
799812

800813
Fixes
814+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
801815
* Fixed issue where Reader.copy() did not preserve optional arguments
802816
and kwargs passed to the original class (Issue #3664, PR #3685)
803817
* Iterating a SingleFrameReaderBase trajectory now rewinds the
@@ -895,6 +909,7 @@ Deprecations
895909
* 2.1.0
896910

897911
Fixes
912+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
898913
* Use uint64_t loop counters in C level distance functions to avoid overflow
899914
for large arrays (Issue #3512, PR #3513).
900915
* Prevents attempts to close an already closed NamedStream (Issue #3386)
@@ -946,6 +961,7 @@ Deprecations
946961
* 2.0.0
947962

948963
Fixes
964+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
949965
* Added an `rdkit_kwargs` parameter to pass arguments to the RDKitConverter
950966
from the `select_atoms` method (Issue #3319, PR #3324)
951967
* Fixes AtomGroup.unique, ResidueGroup.unique, SegmentGroup.unique not
@@ -1309,6 +1325,7 @@ Deprecations
13091325
* 1.1.1
13101326

13111327
Fixes
1328+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
13121329
* Remove absolute paths from package upload to pypi.
13131330

13141331

@@ -1318,6 +1335,7 @@ Fixes
13181335
* 1.1.0
13191336

13201337
Fixes
1338+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
13211339
* Removes use of absolute paths in setup.py to avoid Windows installation
13221340
failures (Issue #3129)
13231341
* Adds test for crashes caused by small box NSGrid searches (Issue #2670)
@@ -1361,6 +1379,7 @@ Enhancements
13611379
* 1.0.1
13621380

13631381
Fixes
1382+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
13641383
* Due to issues with the reliability/accuracy of `nsgrid`, this method is
13651384
currently not recommended for use. It has also been removed as an option
13661385
from lib.capped_distance and lib.self_capped_distance. Please use PKDTree
@@ -1423,6 +1442,7 @@ Deprecations
14231442
* 1.0.0
14241443

14251444
Fixes
1445+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
14261446
* MOL2Writer now accepts both Universes and AtomgGroups (Issue #2717)
14271447
* Use user-provided `remark` in `XYZWriter` (Issue #2692)
14281448
* Added more informative error messages about topology attributes
@@ -1625,6 +1645,7 @@ Deprecations
16251645
* 0.20.1
16261646

16271647
Fixes
1648+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
16281649
* The NetCDF writer now writes `cell_angle` units as `degree` instead of
16291650
`degrees` in accordance with the AMBER NetCDF convention (Issue #2327).
16301651
* Fixed installation without Cython (Issue #2337)
@@ -1698,6 +1719,7 @@ Changes
16981719
* changed the water bridge analysis output format (PR #2087)
16991720

17001721
Fixes
1722+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
17011723
* fixed ChainReader setting format with format keyword (Issue #2334)
17021724
* fixed lack of check for scaling of NCDFReader velocities (Issue #2323)
17031725
* fixed PDBReader and PDBWriter newlines for PDB header (Issue #2324)
@@ -1769,6 +1791,7 @@ Changes
17691791
* 0.19.1
17701792

17711793
Fixes
1794+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
17721795
* limit output of Chainreader __repr__ (#2109)
17731796
* added missing docs for lib.pkdtree (#2104)
17741797
* Added sphinx markup for FrameIterator (#2106)
@@ -1857,6 +1880,7 @@ Enhancements
18571880
(where possible) (Issue #1041 PR #2080)
18581881

18591882
Fixes
1883+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
18601884
* Rewind in the SingleFrameReader now reads the frame from the file (Issue #1929)
18611885
* Fixed order of indices in Angle/Dihedral/Improper repr
18621886
* coordinates.memory.MemoryReader now takes np.ndarray only (Issue #1685)
@@ -1956,6 +1980,7 @@ Enhancements
19561980
* Added AtomGroup, ResidueGroup and SegmentGroup to the top module namespace
19571981

19581982
Fixes
1983+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
19591984
* Fixed MPI fork() warning when importing MDAnalysis in an Infiniband-enabled
19601985
MPI environment (PR #1794)
19611986
* Fixed waterdynamics SurvivalProbability ignoring the t0 start time
@@ -2034,6 +2059,7 @@ Deprecations
20342059
* timeseries keyword format is replaced by order. The format keyword is marked for deprecation in 1.0
20352060

20362061
Fixes
2062+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
20372063
* Fixed analysis.psa.dist_mat_to_vec not returning int values (Issue #1507)
20382064
* Fixed triclinic PBC transform for a- and b- axes (Issue #1697)
20392065
* Fixed nuclinfo.tors() not converting delta (Issue #1572)
@@ -2098,6 +2124,7 @@ Deprecations
20982124
* deprecated the core.flag registry for 1.0 (Issue #782)
20992125

21002126
Fixes
2127+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
21012128
* fixed GROWriter truncating long resids from the wrong end (Issue #1395)
21022129
* Fixed dtype of numpy arrays to accomodate 32 bit architectures (Issue #1362)
21032130
* Groups are hashable on python 3 (Issue #1397)
@@ -2129,6 +2156,7 @@ Enhancements
21292156
* made online docs responsive with the Alabaster Sphinx theme (#378)
21302157

21312158
Fixes
2159+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
21322160
* In Universe.transfer_to_memory(): dt is now adjusted with step (Issue #1310)
21332161
* Various documentation sphinx errors (PR #1312)
21342162
* Bugfix in confdistmatrix.get_distance_matrix; now works on all trajectory types.
@@ -2222,6 +2250,7 @@ Enhancements
22222250
weights="size") by about 5x (partially Issue #1191)
22232251

22242252
Fixes
2253+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
22252254
* Trajectory slicing made completely Pythonic (Issue #918 PR #1195)
22262255
* Argument validation of dist_mat_to_vec is fixed (#597 PR #1183)
22272256
* Give correct error when the topology file format is not recognized (Issue #982)
@@ -2357,6 +2386,7 @@ Enhancements
23572386
* Iteration and seeking in PDB files made faster (Issue #848)
23582387

23592388
Fixes
2389+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
23602390
* Fixed TypeError in PSAnalysis heatmap-dendrogram plotting (Issue #1018)
23612391
* ENT file format added to PDB Readers/Writers/Parsers (Issue #834)
23622392
* rmsd now returns proper value when given array of weights (Issue #814)
@@ -2451,6 +2481,7 @@ Changes
24512481
before trying to deduce the format from file extension. (Issue #712)
24522482

24532483
Fixes
2484+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
24542485

24552486
* Syntax error corrected in psa.py (Issue #738)
24562487
* XDR file seeking and telling working again for large files (Issue #677).
@@ -2530,6 +2561,7 @@ Changes
25302561
* MOL2Writer.write now only writes a single frame (Issue #521)
25312562

25322563
Fixes
2564+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
25332565

25342566
* Fixed select_atoms requiring a trajectory be loaded (Issue #270)
25352567
* AtomGroup timesteps no longer cached (Issue #606)
@@ -2577,6 +2609,7 @@ Enhancements
25772609
Changes
25782610

25792611
Fixes
2612+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
25802613
* Fixed OpenMP detection on Linux/OSX #459
25812614
* Fixed reading of LAMMPS trajectory times: default unit ought
25822615
to be fs and not ps
@@ -2631,6 +2664,7 @@ Changes
26312664
* To build with debug-symbols use 'MDA_DEBUG_CFLAGS' instead of 'MDA_DEBUG_CFLAGS'
26322665

26332666
Fixes
2667+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
26342668
* Fixed minor issue in lib.mdamath.make_whole where if all bonds
26352669
were correctly sized, it wouldn't notice that multiple fragments
26362670
had been given. (Issue #445)
@@ -3227,6 +3261,7 @@ Testsuite
32273261
* 0.7.5.1
32283262

32293263
Fixes
3264+
* `PersistenceLength._conclude()` now normalizes `results.bond_autocorrelation` using the number of frames actually analyzed instead of the total trajectory frame count, fixing incorrect results when `run()` is called with `start`/`stop`/`step` (Issue #5453).
32303265
* added: missing files (Issue 95)
32313266
* removed: unused delaunay-related files
32323267

package/MDAnalysis/analysis/polymer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def fit(self):
317317

318318
def _conclude(self):
319319
norm = np.linspace(self.chainlength - 1, 1, self.chainlength - 1)
320-
norm *= len(self._atomgroups) * self._trajectory.n_frames
320+
norm *= len(self._atomgroups) * self.n_frames
321321
self.results.bond_autocorrelation = (
322322
self.results.raw_bond_autocorr / norm
323323
)

0 commit comments

Comments
 (0)