|
1 | 1 | from MDAnalysisTests.datafiles import (TPR2024_4_bonded,
|
2 | 2 | TPR_EXTRA_2024_4,
|
3 |
| - TPR2024_4) |
| 3 | + TPR2024_4, |
| 4 | + TPR2024) |
4 | 5 | import MDAnalysis as mda
|
5 | 6 |
|
6 | 7 |
|
7 | 8 | import pytest
|
| 9 | +import numpy as np |
8 | 10 | from numpy.testing import assert_allclose, assert_equal
|
9 | 11 |
|
10 | 12 |
|
11 |
| -@pytest.mark.parametrize("tpr_file, exp_first_atom, exp_last_atom, exp_shape", [ |
12 |
| - (TPR2024_4_bonded, |
| 13 | +@pytest.mark.parametrize("tpr_file, exp_first_atom, exp_last_atom, exp_shape, exp_vel_first_atom, exp_vel_last_atom", [ |
| 14 | + (TPR2024_4_bonded, # tpx 134 |
13 | 15 | [4.446, 4.659, 2.384],
|
14 | 16 | [4.446, 4.659, 2.384],
|
15 | 17 | (14, 3),
|
| 18 | + np.zeros(3), |
| 19 | + np.zeros(3), |
16 | 20 | ),
|
17 | 21 | # same coordinates, different shape
|
18 |
| - (TPR_EXTRA_2024_4, |
| 22 | + (TPR_EXTRA_2024_4, # tpx 134 |
19 | 23 | [4.446, 4.659, 2.384],
|
20 | 24 | [4.446, 4.659, 2.384],
|
21 | 25 | (18, 3),
|
| 26 | + np.zeros(3), |
| 27 | + np.zeros(3), |
22 | 28 | ),
|
23 | 29 | # different coordinates and different shape
|
24 |
| - (TPR2024_4, |
| 30 | + (TPR2024_4, # tpx 134 |
25 | 31 | [3.25000e-01, 1.00400e+00, 1.03800e+00],
|
26 | 32 | [-2.56000e-01, 1.37300e+00, 3.59800e+00],
|
27 | 33 | (2263, 3),
|
| 34 | + np.zeros(3), |
| 35 | + np.zeros(3), |
| 36 | + ), |
| 37 | + (TPR2024, # tpx 133 |
| 38 | + [3.25000e-01, 1.00400e+00, 1.03800e+00], |
| 39 | + [-2.56000e-01, 1.37300e+00, 3.59800e+00], |
| 40 | + (2263, 3), |
| 41 | + np.zeros(3), |
| 42 | + np.zeros(3), |
28 | 43 | ),
|
29 | 44 | ])
|
30 |
| -def test_basic_read_tpr(tpr_file, exp_first_atom, exp_last_atom, exp_shape): |
| 45 | +def test_basic_read_tpr(tpr_file, |
| 46 | + exp_first_atom, |
| 47 | + exp_last_atom, |
| 48 | + exp_shape, |
| 49 | + exp_vel_first_atom, |
| 50 | + exp_vel_last_atom): |
| 51 | + # verify basic ability to read positions and |
| 52 | + # velocities from GMX .tpr files |
| 53 | + # expected values are from gmx dump |
31 | 54 | u = mda.Universe(tpr_file)
|
32 | 55 | assert_allclose(u.atoms.positions[0, ...], exp_first_atom)
|
33 | 56 | assert_allclose(u.atoms.positions[-1, ...], exp_last_atom)
|
34 | 57 | assert_equal(u.atoms.positions.shape, exp_shape)
|
| 58 | + assert_allclose(u.atoms.velocities[0, ...], exp_vel_first_atom) |
| 59 | + assert_allclose(u.atoms.velocities[-1, ...], exp_vel_last_atom) |
| 60 | + assert_equal(u.atoms.velocities.shape, exp_shape) |
0 commit comments