-
Notifications
You must be signed in to change notification settings - Fork 716
ENH: add TPR position and velocity read support #4873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Hello @tylerjereddy! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-12-31 17:39:01 UTC |
@@ -0,0 +1,73 @@ | |||
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- | |||
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
header needs expanding to full version
im_excl_grp_size = data.unpack_int() | ||
ndo_int(data, im_excl_grp_size) | ||
# TODO: why is this needed? | ||
data.unpack_int() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above can probably be cleaned up a bit.. probably has some unused vars, etc.
It was produced by careful printf
-ing the GMX source as you might expect. Expanding to support other tpx
versions may not be too bad, although this was fairly time consuming to draft.
# api/legacy/include/gromacs/topology/topology_enums.h | ||
# worst case scenario we hard code it based on | ||
# tpx/GMX version? | ||
SimulationAtomGroupType_size = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On latest GMX main
branch, this is the data structure in question:
enum class SimulationAtomGroupType : int
{
TemperatureCoupling,
EnergyOutput,
Acceleration,
Freeze,
User1,
User2,
MassCenterVelocityRemoval,
CompressedPositionOutput,
OrientationRestraintsFit,
QuantumMechanics,
Count
};
u = mda.Universe(tpr_file) | ||
assert_allclose(u.atoms.positions[0, ...], exp_first_atom) | ||
assert_allclose(u.atoms.positions[-1, ...], exp_last_atom) | ||
assert_equal(u.atoms.positions.shape, exp_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have specific conventions for coordinate reader testing, but for now this is where I've started. Should be easy to expand to include velocities as well.
Cases with only positions and no velocities (etc.) may also be sensible to add, on top of older tpx
files...
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4873 +/- ##
===========================================
- Coverage 93.62% 93.57% -0.06%
===========================================
Files 177 178 +1
Lines 21995 22087 +92
Branches 3112 3141 +29
===========================================
+ Hits 20593 20668 +75
- Misses 947 957 +10
- Partials 455 462 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@tylerjereddy since this PR is composed of two new files, and the modifications are all in one place, would you mind if I go ahead with #4849? I don't think there would be significant conflicts. |
ok |
Thanks @tylerjereddy. It is now merged. |
d67bccb
to
7583a2e
Compare
I drafted in support/testing for handling velocities as well, plus support/testing for reading positions/velocities from one more Need to poke around the |
I was able to extend support and testing for I also modernized an old TPR file we had with non-zero velocities (and a large number of atoms) for cobrotoxin via |
* Add support for reading positions from GMX `.tpr` files at `tpx` version `134`.
* Expand `TPRReader()` support to include velocity handling, and add tests/functionality for an additional tpx version (`133`). [ci skip] [skip azp]
* Add `.tpr` position/velocity reading support back to GMX 2023 (tpx version 129), and associated testing. * Add a `.tpr` position/velocity reading test case that has non-zero velocities and many more atoms. This test case currently passes for position retrieval but not for velocity retrieval. [ci skip] [skip azp] [azp skip] [skip ci]
1e01bb6
to
1009386
Compare
* Fixed an issue where `TPRReader` used `ts._velocities` instead of `ts.velocities` to assign the velocity array * Needed to improve the precision of the expected velocity values in `test_basic_read_tpr` after the above fix. * `TPR_xvf_2024_4` was missing from `__all__`, causing a test failure
1009386
to
e2cda7d
Compare
This test case for non-zero velocities should be passing now, as should other tests, apart from the linter, after some more bug fixes. The outstanding items here would likely be:
|
* Add preliminary support for tpx version 137 (GROMACS 2025.0). This required additional bit unpacking based on empirical observations on the `TPR_NNPOT_2025_0` test file. A regression test for position and velocity reads from that test file was added, with expected values from `gmx dump -s ala_nnpot_gmx_2025_0.tpr`. * Fix up formatting complaints from `black` that were causing CI failures.
Updates from work today:
|
* Add support and testing for `tpx` version 127 (GROMACS 2022), including two regression tests for that `.tpr` format. Supporting this file version required careful analysis of relative binary file offsets.
Added support for Next up from our support table should probably be |
* Add support for velocity and coordinate reading from `.tpr` files that are in tpx generation `122` (GROMACS 2021). Includes two regression tests.
For today, I added support for For tomorrow, I'll see if I can add support for |
* Add support for position and velocity data reading from `.tpr` files that correspond to `tpx` version 119 (GROMACS `2020`). Two regression tests for `.tpr` files at this version of GMX were added.
Today, added support for For tomorrow, I'll aim to extend backward to |
* Add support for reading positions and velocities from `.tpr` files at `tpx` version 116 (GROMACS `2019`). Likewise for `tpx` version 112 (GROMACS `2018`). * Add regression tests for the above improvements.
Today, support was added for tpx 116 (GMX 2019) and tpx 112 (GMX 2018). The latter required some non-trivial byte-stride analysis on the binary files. For tomorrow, I'll take aim at tpx 110 (GMX 2016) if I can. |
* Add support for position and velocity reading from `.tpr` files that correspond to `tpx` version 110 (GROMACS `2016`). Likewise for `tpx` version 103 (GROMACS `5.1`). * Add regression tests for the above improvements.
Today, added support for I'll try to check |
* Add position and velocity reading support for `.tpr` files at `tpx` version 100 (for GROMACS `5.x` before `5.1`), including regression tests.
Today, added support for Next up is |
* Add support for reading positions and velocities from `.tpr` files at `tpx` version 83 (GMX `4.6.0`, `4.6.1`). Likewise for `tpx` versions 73 (GMX `4.5.x`) and 58 (GMX `4.0.x`). Also added some shims for improved double precision support. * Add regression tests for the above improvements.
@@ -74,6 +74,8 @@ | |||
Impropers, | |||
) | |||
|
|||
global_precision = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestions for tracking TPR file precision in a way that doesn't use a global
are appreciated
Ok, this weekend I added position and velocity reading support for all remaining I think this is ready for review now--I've updated the original comment above with some notes for reviewers. The linter will currently fail because I'm using a Suggestions for fixing that and anything else you find are appreciated. |
Fixes gh-464.
.tpr
files over the full range oftpx
versions supported by regular.tpr
topology parsing (58
through137
). We've had an issue open to add this capability for almost a decade now.Notes for reviewers:
global
to track TPR file precision are appreciated..tpr
reading performance is atrocious anyway and my attempts to fix at WIP, ENH: faster TPR topology building for large systems #4098 have stalled for more than a year, so I suggest we defer performance (and probably even duplication) considerations until after the capability and tests are cemented in.CHANGELOG
and docs changes when it looks like we're close to ready to merge, but I still appreciate suggestions on i.e., locations where doc changes will be needed.PR Checklist
Developers certificate of origin
📚 Documentation preview 📚: https://mdanalysis--4873.org.readthedocs.build/en/4873/