Skip to content

Commit

Permalink
ENH: support tpx 134 (GMX 2024.4)
Browse files Browse the repository at this point in the history
* Fixes gh-4855.

* Add support for reading topology data from `.tpr` files
produced by GROMACS 2024.4, corresponding to tpx version
`134`.

* My approach was similar to the one I used in gh-4523, except
for two things: 1) I retrieved the current generation (`28`) from
a `print` in our own binary parser rather than rebuilding
GMX from source with added `printf`, and more importantly 2) I
had to add some shims because the `.tpr` format has changed.

* With regard to the additional field data now stored in the
`.tpr` format, I was involved in reviewing it upstream at:
https://gitlab.com/gromacs/gromacs/-/merge_requests/4544.
You can see that the changes related to the MARTINI functional
form made it into the `v2024.4` tag i.e., here:
https://gitlab.com/gromacs/gromacs/-/blob/v2024.4/src/gromacs/gmxpreprocess/convparm.cpp?ref_type=tags#L372
  • Loading branch information
tylerjereddy committed Dec 26, 2024
1 parent c08cb79 commit 55354e2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 7 deletions.
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ The rules for this file:


-------------------------------------------------------------------------------
??/??/?? IAlibay, ChiahsinChu, RMeli, tanishy7777, talagayev
??/??/?? IAlibay, ChiahsinChu, RMeli, tanishy7777, talagayev,
tyler.je.reddy

* 2.9.0

Fixes
* Add support for TPR files produced by GROMACS 2024.4
* Fixes invalid default unit from Angstrom to Angstrom^{-3} for convert_density() function. (Issue #4829)
* Fixes deprecation warning Array to scalar convertion. Replaced atan2() with np.arctan2() (Issue #4339)
* Replaced mutable defaults with None and initialized them within
Expand Down
1 change: 1 addition & 0 deletions package/MDAnalysis/topology/TPRParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
127 28 2022 yes
129 28 2023 yes
133 28 2024.1 yes
134 28 2024.4 yes
========== ============== ==================== =====
.. [*] Files generated by the beta versions of Gromacs 2020 are NOT supported.
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/topology/tpr/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"""

#: Gromacs TPR file format versions that can be read by the TPRParser.
SUPPORTED_VERSIONS = (58, 73, 83, 100, 103, 110, 112, 116, 119, 122, 127, 129, 133)
SUPPORTED_VERSIONS = (58, 73, 83, 100, 103, 110, 112,
116, 119, 122, 127, 129, 133, 134)

# Some constants
STRLEN = 4096
Expand Down
9 changes: 9 additions & 0 deletions package/MDAnalysis/topology/tpr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ def do_iparams(data, functypes, fver):
elif i in [setting.F_RESTRANGLES]:
data.unpack_real() # harmonic.rA
data.unpack_real() # harmonic.krA
if fver >= 134:
data.unpack_real() # harmonic.rB
data.unpack_real() # harmonic.krB

elif i in [setting.F_LINEAR_ANGLES]:
data.unpack_real() # linangle.klinA
data.unpack_real() # linangle.aA
Expand Down Expand Up @@ -598,6 +602,9 @@ def do_iparams(data, functypes, fver):
elif i in [setting.F_RESTRDIHS]:
data.unpack_real() # pdihs.phiA
data.unpack_real() # pdihs.cpA
if fver >= 134:
data.unpack_real() # pdihs.phiB
data.unpack_real() # pdihs.cpB
elif i in [setting.F_DISRES]:
data.unpack_int() # disres.label
data.unpack_int() # disres.type
Expand Down Expand Up @@ -640,6 +647,8 @@ def do_iparams(data, functypes, fver):

elif i in [setting.F_CBTDIHS]:
ndo_real(data, setting.NR_CBTDIHS) # cbtdihs.cbtcA
if fver >= 134:
ndo_real(data, setting.NR_CBTDIHS) # cbtdihs.cbtcB

elif i in [setting.F_RBDIHS]:
ndo_real(data, setting.NR_RBDIHS) # iparams_rbdihs_rbcA
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@
"TPR460", "TPR461", "TPR502", "TPR504", "TPR505", "TPR510", "TPR2016",
"TPR2018", "TPR2019B3", "TPR2020B2", "TPR2020", "TPR2020Double",
"TPR2021", "TPR2021Double", "TPR2022RC1", "TPR2023", "TPR2024",
"TPR2024_4",
"TPR510_bonded", "TPR2016_bonded", "TPR2018_bonded", "TPR2019B3_bonded",
"TPR2020B2_bonded", "TPR2020_bonded", "TPR2020_double_bonded",
"TPR2021_bonded", "TPR2021_double_bonded", "TPR2022RC1_bonded",
"TPR334_bonded", "TPR2023_bonded", "TPR2024_bonded",
"TPR2024_4_bonded",
"TPR_EXTRA_2021", "TPR_EXTRA_2020", "TPR_EXTRA_2018",
"TPR_EXTRA_2016", "TPR_EXTRA_407", "TPR_EXTRA_2022RC1",
"TPR_EXTRA_2023", "TPR_EXTRA_2024",
"TPR_EXTRA_2023", "TPR_EXTRA_2024", "TPR_EXTRA_2024_4",
"PDB_sub_sol", "PDB_sub_dry", # TRRReader sub selection
"TRR_sub_sol",
"XTC_sub_sol",
Expand Down Expand Up @@ -407,6 +409,7 @@
TPR2022RC1 = (_data_ref / 'tprs/2lyz_gmx_2022-rc1.tpr').as_posix()
TPR2023 = (_data_ref / 'tprs/2lyz_gmx_2023.tpr').as_posix()
TPR2024 = (_data_ref / 'tprs/2lyz_gmx_2024.tpr').as_posix()
TPR2024_4 = (_data_ref / 'tprs/2lyz_gmx_2024_4.tpr').as_posix()
# double precision
TPR455Double = (_data_ref / 'tprs/drew_gmx_4.5.5.double.tpr').as_posix()
TPR460 = (_data_ref / 'tprs/ab42_gmx_4.6.tpr').as_posix()
Expand All @@ -427,7 +430,9 @@
TPR2022RC1_bonded = (_data_ref / 'tprs/all_bonded/dummy_2022-rc1.tpr').as_posix()
TPR2023_bonded = (_data_ref / 'tprs/all_bonded/dummy_2023.tpr').as_posix()
TPR2024_bonded = (_data_ref / 'tprs/all_bonded/dummy_2024.tpr').as_posix()
TPR2024_4_bonded = (_data_ref / 'tprs/all_bonded/dummy_2024_4.tpr').as_posix()
# all interactions
TPR_EXTRA_2024_4 = (_data_ref / 'tprs/virtual_sites/extra-interactions-2024_4.tpr').as_posix()
TPR_EXTRA_2024 = (_data_ref / 'tprs/virtual_sites/extra-interactions-2024.tpr').as_posix()
TPR_EXTRA_2023 = (_data_ref / 'tprs/virtual_sites/extra-interactions-2023.tpr').as_posix()
TPR_EXTRA_2022RC1 = (_data_ref / 'tprs/virtual_sites/extra-interactions-2022-rc1.tpr').as_posix()
Expand Down
11 changes: 7 additions & 4 deletions testsuite/MDAnalysisTests/topology/test_tprparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
TPR450, TPR451, TPR452, TPR453, TPR454, TPR455, TPR455Double,
TPR460, TPR461, TPR502, TPR504, TPR505, TPR510, TPR510_bonded,
TPR2016, TPR2018, TPR2019B3, TPR2020B2, TPR2020, TPR2020Double,
TPR2021, TPR2021Double, TPR2022RC1, TPR2023, TPR2024,
TPR2021, TPR2021Double, TPR2022RC1, TPR2023, TPR2024, TPR2024_4,
TPR2016_bonded, TPR2018_bonded, TPR2019B3_bonded,
TPR2020B2_bonded, TPR2020_bonded, TPR2020_double_bonded,
TPR2021_bonded, TPR2021_double_bonded, TPR334_bonded,
TPR2022RC1_bonded, TPR2023_bonded, TPR2024_bonded,
TPR2024_4_bonded,
TPR_EXTRA_2021, TPR_EXTRA_2020, TPR_EXTRA_2018,
TPR_EXTRA_2016, TPR_EXTRA_407, TPR_EXTRA_2022RC1,
TPR_EXTRA_2023, TPR_EXTRA_2024,
TPR_EXTRA_2023, TPR_EXTRA_2024, TPR_EXTRA_2024_4,
XTC,
)
from MDAnalysisTests.topology.base import ParserBase
Expand All @@ -58,6 +59,8 @@
TPR2022RC1_bonded,
TPR2023_bonded,
TPR2024_bonded,
TPR2024_4_bonded,
TPR_EXTRA_2024_4,
TPR_EXTRA_2024,
TPR_EXTRA_2023,
TPR_EXTRA_2022RC1,
Expand Down Expand Up @@ -135,7 +138,7 @@ class TestTPRGromacsVersions(TPRAttrs):
TPR455, TPR502, TPR504, TPR505, TPR510, TPR2016,
TPR2018, TPR2019B3, TPR2020, TPR2020Double,
TPR2021, TPR2021Double, TPR2022RC1, TPR2023,
TPR2024])
TPR2024, TPR2024_4])
def filename(self, request):
return request.param

Expand Down Expand Up @@ -262,7 +265,7 @@ def test_all_impropers(topology, impr):
@pytest.fixture(params=(
TPR400, TPR402, TPR403, TPR404, TPR405, TPR406, TPR407, TPR450, TPR451,
TPR452, TPR453, TPR454, TPR502, TPR504, TPR505, TPR510, TPR2016, TPR2018,
TPR2023, TPR2024,
TPR2023, TPR2024, TPR2024_4,
))
def bonds_water(request):
parser = MDAnalysis.topology.TPRParser.TPRParser(request.param).parse()
Expand Down

0 comments on commit 55354e2

Please sign in to comment.