Skip to content

Commit 1bb9db2

Browse files
authored
Merge branch 'develop' into fix-msd-nojump-doc
2 parents 66d7f12 + a029dcd commit 1bb9db2

10 files changed

Lines changed: 51 additions & 17 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ Changes made in this Pull Request:
88
<!-- Describe the changes that this PR makes. If applicable, use the following bullet list. -->
99
-
1010

11+
## LLM / AI generated code disclosure
12+
<!-- Please update this disclosure to reflect if you did or did not use LLMs / AI to generate code -->
13+
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes / no
14+
1115
## PR Checklist
1216
<!-- Please use the following checklist to ensure the PR is ready to be reviewed/merged. -->
1317
- [ ] Issue raised/referenced?
1418
- [ ] Tests updated/added?
1519
- [ ] Documentation updated/added?
1620
- [ ] `package/CHANGELOG` file updated?
1721
- [ ] Is your name in `package/AUTHORS`? (If it is not, add it!)
22+
- [ ] LLM/AI disclosure was updated.
1823

1924
## Developers Certificate of Origin
2025
<!--

.github/workflows/linters.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ jobs:
9393
micromamba: true
9494
full-deps: true
9595
numpy: numpy=1.26.0
96-
rdkit: rdkit=2023.09.3
9796

9897
- name: install
9998
run: |

azure-pipelines.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ jobs:
2525
PYTHON_VERSION: '3.11'
2626
PYTHON_ARCH: 'x64'
2727
BUILD_TYPE: 'normal'
28-
imageName: 'windows-2019'
28+
imageName: 'windows-latest'
2929
Win-Python313-64bit-full:
3030
PYTHON_VERSION: '3.13'
3131
PYTHON_ARCH: 'x64'
3232
BUILD_TYPE: 'normal'
33-
imageName: 'windows-2019'
33+
imageName: 'windows-latest'
3434
Win-Python313-64bit-full-wheel:
3535
PYTHON_VERSION: '3.13'
3636
PYTHON_ARCH: 'x64'
3737
BUILD_TYPE: 'wheel'
3838
NUMPY_MIN: '2.1.0'
39-
imageName: 'windows-2019'
39+
imageName: 'windows-latest'
4040
Win-Python311-64bit-full-wheel:
4141
PYTHON_VERSION: '3.11'
4242
PYTHON_ARCH: 'x64'
4343
BUILD_TYPE: 'wheel'
4444
NUMPY_MIN: '1.26.0'
45-
imageName: 'windows-2019'
45+
imageName: 'windows-latest'
4646
Linux-Python313-64bit-full-wheel:
4747
PYTHON_VERSION: '3.13'
4848
PYTHON_ARCH: 'x64'

package/AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Chronological list of authors
265265
- Raúl Lois-Cuns
266266
- Pranay Pelapkar
267267
- Shreejan Dolai
268-
- Tanisha Dubey
268+
- Tanisha Dubey
269269

270270
External code
271271
-------------

package/CHANGELOG

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ The rules for this file:
1515

1616
-------------------------------------------------------------------------------
1717
??/??/?? IAlibay, orbeckst, marinegor, tylerjereddy, ljwoods2, marinegor,
18-
spyke7, talagayev
18+
spyke7, talagayev, tanii1125
1919

2020
* 2.11.0
2121

2222
Fixes
23+
* DSSP now explicitly checks for a minimum of 6 residues and raises a clear
24+
error message, unlike the previous behavior where it would fail with an
25+
incomprehensible broadcasting error at execution time (Issue #5046, PR #5163)
2326
* Fixes the verbose=False in EinsteinMSD, and only shows progress bar when
2427
verbose=True (Issue #5144, PR #5153)
2528
* Fix incorrect assignment of topology_format to format (and vice versa)

package/MDAnalysis/analysis/dssp/dssp.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class DSSP(AnalysisBase):
210210
Parameters
211211
----------
212212
atoms : Union[Universe, AtomGroup]
213-
input Universe or AtomGroup. In both cases, only protein residues will
213+
input Universe or AtomGroup with at least 6 protein residues. In both cases, only protein residues will
214214
be chosen prior to the analysis via `select_atoms('protein')`.
215215
Heavy atoms of the protein are then selected by name
216216
`heavyatom_names`, and hydrogens are selected by name
@@ -239,6 +239,8 @@ class DSSP(AnalysisBase):
239239
240240
Raises
241241
------
242+
ValueError
243+
If fewer than 6 residues are provided in the selection.
242244
ValueError
243245
if ``guess_hydrogens`` is True but some non-PRO hydrogens are missing.
244246
@@ -357,6 +359,12 @@ def __init__(
357359
)
358360
)
359361

362+
if len(ag.residues) < 6:
363+
raise ValueError(
364+
"DSSP requires at least 6 residues for secondary structure analysis, "
365+
f"but only {len(ag.residues)} residue(s) were provided in the selection."
366+
)
367+
360368
def _prepare(self):
361369
self.results.dssp_ndarray = []
362370

package/MDAnalysis/analysis/msd.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,11 @@ def _parse_msd_type(self):
406406
"xyz": [0, 1, 2],
407407
}
408408

409-
self.msd_type = self.msd_type.lower()
410-
411409
try:
412-
self._dim = keys[self.msd_type]
413-
except KeyError:
410+
self._dim = keys[self.msd_type.lower()]
411+
except (AttributeError, KeyError):
414412
raise ValueError(
415-
"invalid msd_type: {} specified, please specify one of xyz, "
416-
"xy, xz, yz, x, y, z".format(self.msd_type)
413+
f"Invalid msd_type {self.msd_type}, must be a string and one of: xyz, xy, xz, yz, x, y, z"
417414
)
418415

419416
self.dim_fac = len(self._dim)

package/MDAnalysis/lib/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
import errno
203203
import functools
204204
import gzip
205-
import importlib
205+
import importlib.util
206206
import inspect
207207
import io
208208
import itertools

testsuite/MDAnalysisTests/analysis/test_dssp.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,23 @@ def test_exception_raises_with_atom_index(pdb_filename, client_DSSP):
8989
match="Residue <Residue SER, 298> contains*",
9090
):
9191
DSSP(u, guess_hydrogens=False).run(**client_DSSP)
92+
93+
94+
def test_insufficient_residues_raises_error(client_DSSP):
95+
"""Test that DSSP raises clear error for insufficient residues."""
96+
u = mda.Universe(TPR, XTC)
97+
98+
protein = u.select_atoms("protein")
99+
100+
with pytest.raises(ValueError, match="DSSP requires at least 6 residues"):
101+
res2 = protein.residues[:2].atoms
102+
DSSP(res2)
103+
104+
with pytest.raises(ValueError, match="DSSP requires at least 6 residues"):
105+
res4 = protein.residues[:4].atoms
106+
DSSP(res4)
107+
108+
res6 = protein.residues[:6].atoms
109+
dssp = DSSP(res6)
110+
result = dssp.run(**client_DSSP, stop=1)
111+
assert result.results.dssp.shape[1] == 6

testsuite/MDAnalysisTests/analysis/test_msd.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ def test_updating_ag_rejected(self, u):
117117
with pytest.raises(TypeError, match=errmsg):
118118
m = MSD(updating_ag, msd_type="xyz", fft=False)
119119

120-
@pytest.mark.parametrize("msdtype", ["foo", "bar", "yx", "zyx"])
120+
@pytest.mark.parametrize(
121+
"msdtype", ["foo", "bar", "yx", "zyx", 123, "", " xy "]
122+
)
121123
def test_msdtype_error(self, u, SELECTION, msdtype):
122-
errmsg = f"invalid msd_type: {msdtype}"
124+
errmsg = f"Invalid msd_type {msdtype}, must be a string and one of: xyz, xy, xz, yz, x, y, z"
123125
with pytest.raises(ValueError, match=errmsg):
124126
m = MSD(u, SELECTION, msd_type=msdtype)
125127

0 commit comments

Comments
 (0)