Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Chronological list of authors
- Amarendra Mohan
- Shubham Mittal
- Charity Grey
- Tanmay Baranwal

External code
-------------
Expand Down
5 changes: 4 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ The rules for this file:
spyke7, talagayev, tanii1125, BradyAJohnston, hejamu, jeremyleung521,
harshitgajjela-droid, kunjsinha, aygarwal, jauy123, Dreamstick9,
ollyfutur, Amarendra22, charity-g, ParthUppal523

* 2.11.0

Fixes
* TPRReader now exposes box dimensions when loading TPR files
as coordinates-only Universes, fixing missing `Universe.dimensions`
values. (Issue #5375, PR #5377)
* `MDAnalysis.analysis.nucleicacids.WatsonCrickDist`, `MinorPairDist`,
and `MajorPairDist` now match residue names against the full resname
instead of only the first character, fixing incorrect behaviour with
Expand Down
11 changes: 10 additions & 1 deletion package/MDAnalysis/coordinates/TPR.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

"""

from ..lib.mdamath import triclinic_box
from . import base
from ..lib import util
from .timestep import Timestep
Expand Down Expand Up @@ -110,7 +111,15 @@ def _read_first_frame(self):

state_ngtc = th.ngtc # done init_state() in src/gmxlib/tpxio.c
if th.bBox:
tpr_utils.extract_box_info(data, th.fver)
box_info = tpr_utils.extract_box_info(data, th.fver)
# box vectors are stored in nm
box_angstrom = np.array(box_info.size) * 10.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unit handling needs some discussion/consideration, per Irfan's comments at: #5374 (comment)

I think I may open yet another issue about this, because the matter is actually a bit complex/confusing at the moment

Copy link
Copy Markdown
Author

@iamtanmaybaranwal iamtanmaybaranwal May 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the discussion in #5374. The conversion * 10.0 from nm to Angstroms follows the standard MDAnalysis convention where dimensions are always in Angstroms. Happy to update if the team decides on a different approach in the new issue you mentioned.


ts.dimensions = triclinic_box(
box_angstrom[0],
box_angstrom[1],
box_angstrom[2],
)

if state_ngtc > 0:
if th.fver < 69: # redundancy due to different versions
Expand Down
33 changes: 33 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_tpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import pytest
import numpy as np
from numpy.testing import assert_allclose, assert_equal
from MDAnalysisTests.datafiles import TPR


@pytest.mark.parametrize(
Expand Down Expand Up @@ -494,3 +495,35 @@ def test_different_versions():
assert_allclose(u.atoms.velocities[-1, ...], exp_vel)
assert_equal(u.atoms.positions.shape, exp_shape)
assert_equal(u.atoms.velocities.shape, exp_shape)


class TestTPRDimensions:
"""Tests for TPR coordinate box dimensions."""

@pytest.mark.parametrize(
"tpr_file, expected_dims",
[
# cubic box - adk oplsaa system (tpx 58)
(
TPR,
[80.017006, 80.017006, 80.017, 60.0, 60.0, 90.0],
),
# cubic box - same system different gromacs versions
(
TPR2024_4,
[79.1, 79.1, 37.9, 90.0, 90.0, 90.0],
),
(
TPR2016,
[79.1, 79.1, 37.9, 90.0, 90.0, 90.0],
),
# different box shape
(
TPR455Double,
[43.7388, 43.7388, 107.9261, 90.0, 90.0, 90.0],
),
],
)
def test_tpr_dimensions_values(self, tpr_file, expected_dims):
u = mda.Universe(tpr_file)
assert_allclose(u.dimensions, expected_dims, rtol=1e-3)
1 change: 1 addition & 0 deletions testsuite/MDAnalysisTests/topology/test_tprparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import functools

import MDAnalysis as mda
from numpy.testing import assert_allclose
import MDAnalysis.topology.TPRParser
import numpy as np
import pytest
Expand Down
Loading