diff --git a/package/AUTHORS b/package/AUTHORS index e8e41573d9..ed2a78ad17 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -280,6 +280,7 @@ Chronological list of authors - Amarendra Mohan - Shubham Mittal - Charity Grey + - Tanmay Baranwal External code ------------- diff --git a/package/CHANGELOG b/package/CHANGELOG index fd0b869186..d0d8b4d098 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -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) * `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 diff --git a/package/MDAnalysis/coordinates/TPR.py b/package/MDAnalysis/coordinates/TPR.py index 1940da4c92..b8de4338d7 100644 --- a/package/MDAnalysis/coordinates/TPR.py +++ b/package/MDAnalysis/coordinates/TPR.py @@ -51,6 +51,7 @@ """ +from ..lib.mdamath import triclinic_box from . import base from ..lib import util from .timestep import Timestep @@ -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 + + 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 diff --git a/testsuite/MDAnalysisTests/topology/test_tprparser.py b/testsuite/MDAnalysisTests/topology/test_tprparser.py index 354b41cbed..7e2851240b 100644 --- a/testsuite/MDAnalysisTests/topology/test_tprparser.py +++ b/testsuite/MDAnalysisTests/topology/test_tprparser.py @@ -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: + """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 + + def test_tpr_only_dimensions_shape(self): + import MDAnalysis as mda + from MDAnalysisTests.datafiles import TPR + + u = mda.Universe(TPR) + + assert u.dimensions.shape == (6,)