diff --git a/package/MDAnalysis/topology/tpr/utils.py b/package/MDAnalysis/topology/tpr/utils.py index a6158333de..e959d71677 100644 --- a/package/MDAnalysis/topology/tpr/utils.py +++ b/package/MDAnalysis/topology/tpr/utils.py @@ -826,7 +826,7 @@ def do_moltype(data, symtab, fver): bonds += list(ik_obj.process(ias)) elif ik_obj.name in ['ANGLES', 'G96ANGLES', 'CROSS_BOND_BOND', 'CROSS_BOND_ANGLE', 'UREY_BRADLEY', 'QANGLES', - 'RESTRANGLES', 'TABANGLES']: + 'RESTRANGLES', 'TABANGLES', 'LINEAR_ANGLES']: angles += list(ik_obj.process(ias)) elif ik_obj.name in ['PDIHS', 'RBDIHS', 'RESTRDIHS', 'CBTDIHS', 'FOURDIHS', 'TABDIHS']: diff --git a/testsuite/MDAnalysisTests/coordinates/test_tpr.py b/testsuite/MDAnalysisTests/coordinates/test_tpr.py index 8f27c3fdea..a12b08c392 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_tpr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_tpr.py @@ -68,6 +68,7 @@ TPR2020B2, INPCRD, TPR_gh_5145, + TPR_linear_angle, ) import MDAnalysis as mda @@ -80,6 +81,15 @@ @pytest.mark.parametrize( "tpr_file, exp_first_atom, exp_last_atom, exp_shape, exp_vel_first_atom, exp_vel_last_atom", [ + # see gh-5361 for CO2/linear angle: + ( + TPR_linear_angle, + [1.250, 1.250, 1.250], + [1.250, 1.260, 1.136], + (3, 3), + [0, 0, 0], + [0, 0, 0], + ), # this case is an alanine dipeptide # with neural network potential active # and nonzero velocities diff --git a/testsuite/MDAnalysisTests/data/tprs/Linear_Angle.tpr b/testsuite/MDAnalysisTests/data/tprs/Linear_Angle.tpr new file mode 100644 index 0000000000..28fb043689 Binary files /dev/null and b/testsuite/MDAnalysisTests/data/tprs/Linear_Angle.tpr differ diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 7083c10e30..0289d64aed 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -137,6 +137,7 @@ "TPR2024_4", "TPR2025_0", "TPR2026_0", + "TPR_linear_angle", "TPR510_bonded", "TPR2016_bonded", "TPR2018_bonded", @@ -574,6 +575,7 @@ TPR2024_4 = (_data_ref / "tprs/2lyz_gmx_2024_4.tpr").as_posix() TPR2025_0 = (_data_ref / "tprs/2lyz_gmx_2025_0.tpr").as_posix() TPR2026_0 = (_data_ref / "tprs/2lyz_gmx_2026_0.tpr").as_posix() +TPR_linear_angle = (_data_ref / "tprs/Linear_Angle.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() diff --git a/testsuite/MDAnalysisTests/topology/test_tprparser.py b/testsuite/MDAnalysisTests/topology/test_tprparser.py index 354b41cbed..c53241b52d 100644 --- a/testsuite/MDAnalysisTests/topology/test_tprparser.py +++ b/testsuite/MDAnalysisTests/topology/test_tprparser.py @@ -51,7 +51,8 @@ TPR2023_bonded, TPR2024_4_bonded, TPR2025_0_bonded, TPR2024_bonded, TPR2026_0_bonded, - TPR_NNPOT_2025_0, TPR_NNPOT_2026_0) + TPR_NNPOT_2025_0, TPR_NNPOT_2026_0, + TPR_linear_angle) from numpy.testing import assert_equal # fmt: on @@ -438,3 +439,12 @@ def test_resids(resid_from_one, resid_addition): resids, err_msg="tpr_resid_from_one kwarg not switching resids", ) + + +def test_gh_5361(): + # GROMACS linear angle potential handling with CO2 example + u = mda.Universe(TPR_linear_angle) + actual = u.angles.to_indices() + expected = [[1, 0, 2]] + assert_equal(u.atoms.names, ["C", "O1", "O2"]) + assert_equal(actual, expected)