Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ The rules for this file:
* 2.11.0

Fixes
* Fixes the error message for short peptide stretches inside dssp.py,
and showing minimum value is 6 (Issue #5046, PR #5163)
* Fixes the verbose=False in EinsteinMSD, and only shows progress bar when
verbose=True (Issue #5144, PR #5153)
* Fix incorrect assignment of topology_format to format (and vice versa)
Expand All @@ -34,6 +36,8 @@ Enhancements
(Issue #4679, PR #4745)

Changes
* Inside the DSSP class of dssp.py file, a value error is raised for
value less than 6 (Issue #5046, PR #5163)
* The msd.py inside analysis is changed, and ProgressBar is implemented inside
_conclude_simple and _conclude_fft functions instead of tqdm (Issue #5144, PR #5153)

Expand Down
8 changes: 8 additions & 0 deletions package/MDAnalysis/analysis/dssp/dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class DSSP(AnalysisBase):

Raises
------
ValueError
If fewer than 6 residues are provided in the selection.
ValueError
if ``guess_hydrogens`` is True but some non-PRO hydrogens are missing.

Expand Down Expand Up @@ -357,6 +359,12 @@ def __init__(
)
)

if len(ag.residues) < 6:
raise ValueError(
"DSSP requires at least 6 residues for secondary structure analysis, "
f"but only {len(ag.residues)} residue(s) were provided in the selection."
)

def _prepare(self):
self.results.dssp_ndarray = []

Expand Down
21 changes: 21 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_dssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,24 @@ def test_exception_raises_with_atom_index(pdb_filename, client_DSSP):
match="Residue <Residue SER, 298> contains*",
):
DSSP(u, guess_hydrogens=False).run(**client_DSSP)


def test_insufficient_residues_raises_error(client_DSSP):
"""Test that DSSP raises clear error for insufficient residues."""
u = mda.Universe(TPR, XTC)

protein = u.select_atoms("protein")
resids = protein.residues.resids

with pytest.raises(ValueError, match="DSSP requires at least 6 residues"):
res2 = u.select_atoms(f"protein and resid {resids[0]}-{resids[1]}")
DSSP(res2)

with pytest.raises(ValueError, match="DSSP requires at least 6 residues"):
res4 = u.select_atoms(f"protein and resid {resids[0]}-{resids[3]}")
DSSP(res4)

res6 = u.select_atoms(f"protein and resid {resids[0]}-{resids[5]}")
dssp = DSSP(res6)
result = dssp.run(**client_DSSP, stop=1)
assert result.results.dssp.shape[1] == 6
Loading