Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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 #27)
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.

what is PR 27?

* `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
20 changes: 20 additions & 0 deletions testsuite/MDAnalysisTests/topology/test_tprparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,23 @@ def test_resids(resid_from_one, resid_addition):
resids,
err_msg="tpr_resid_from_one kwarg not switching resids",
)


class TestTPRBoxVectors:
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.

shouldn't this testing live in the coordinate namespace since the "coordinates-only Universe" is emphasized and the changes are made in package/MDAnalysis/coordinates/TPR.py?

"""Tests for TPRParser box vector support."""

def test_tpr_only_dimensions_not_none(self):
import MDAnalysis as mda
from MDAnalysisTests.datafiles import TPR

u = mda.Universe(TPR)

assert u.dimensions is not None
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.

This test case is not well thought out -- it serves no value whatsoever alongside the one below, since they use the same TPR and this just checks that the attribute is not None...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated — removed the redundant None and shape-only checks. Tests are now parametrized across multiple TPR files (TPR, TPR2024_4, TPR2016, TPR455Double) with actual dimension values verified via gmx dump / mda.Universe.


def test_tpr_only_dimensions_shape(self):
import MDAnalysis as mda
from MDAnalysisTests.datafiles import TPR
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.

This pattern of scoping imports inside functions like this is a hallmark of LLM/AI usage, and not really checking the work very carefully.

We do generally expect contributions to review work carefully, whether they use an LLM or not.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed — removed the scoped imports from inside test functions. All imports are now at the top of the file.


u = mda.Universe(TPR)

assert u.dimensions.shape == (6,)
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.

We expect testing to be a bit more thorough than this:

  1. check the actual values make sense--could easily break things while retaining the correct shape
  2. probably check some different TPR files/box types in a parametrized test

Loading