-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Expand `TPRReader()` support to include velocity handling, and add tests/functionality for an additional tpx version (`133`). [ci skip] [skip azp]
- Loading branch information
1 parent
4af047d
commit 7583a2e
Showing
3 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,60 @@ | ||
from MDAnalysisTests.datafiles import (TPR2024_4_bonded, | ||
TPR_EXTRA_2024_4, | ||
TPR2024_4) | ||
TPR2024_4, | ||
TPR2024) | ||
import MDAnalysis as mda | ||
|
||
|
||
import pytest | ||
import numpy as np | ||
from numpy.testing import assert_allclose, assert_equal | ||
|
||
|
||
@pytest.mark.parametrize("tpr_file, exp_first_atom, exp_last_atom, exp_shape", [ | ||
(TPR2024_4_bonded, | ||
@pytest.mark.parametrize("tpr_file, exp_first_atom, exp_last_atom, exp_shape, exp_vel_first_atom, exp_vel_last_atom", [ | ||
(TPR2024_4_bonded, # tpx 134 | ||
[4.446, 4.659, 2.384], | ||
[4.446, 4.659, 2.384], | ||
(14, 3), | ||
np.zeros(3), | ||
np.zeros(3), | ||
), | ||
# same coordinates, different shape | ||
(TPR_EXTRA_2024_4, | ||
(TPR_EXTRA_2024_4, # tpx 134 | ||
[4.446, 4.659, 2.384], | ||
[4.446, 4.659, 2.384], | ||
(18, 3), | ||
np.zeros(3), | ||
np.zeros(3), | ||
), | ||
# different coordinates and different shape | ||
(TPR2024_4, | ||
(TPR2024_4, # tpx 134 | ||
[3.25000e-01, 1.00400e+00, 1.03800e+00], | ||
[-2.56000e-01, 1.37300e+00, 3.59800e+00], | ||
(2263, 3), | ||
np.zeros(3), | ||
np.zeros(3), | ||
), | ||
(TPR2024, # tpx 133 | ||
[3.25000e-01, 1.00400e+00, 1.03800e+00], | ||
[-2.56000e-01, 1.37300e+00, 3.59800e+00], | ||
(2263, 3), | ||
np.zeros(3), | ||
np.zeros(3), | ||
), | ||
]) | ||
def test_basic_read_tpr(tpr_file, exp_first_atom, exp_last_atom, exp_shape): | ||
def test_basic_read_tpr(tpr_file, | ||
exp_first_atom, | ||
exp_last_atom, | ||
exp_shape, | ||
exp_vel_first_atom, | ||
exp_vel_last_atom): | ||
# verify basic ability to read positions and | ||
# velocities from GMX .tpr files | ||
# expected values are from gmx dump | ||
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) | ||
assert_allclose(u.atoms.velocities[0, ...], exp_vel_first_atom) | ||
assert_allclose(u.atoms.velocities[-1, ...], exp_vel_last_atom) | ||
assert_equal(u.atoms.velocities.shape, exp_shape) |