Skip to content

Fix #5505: Incorrect masking of hydrogen bond donors in DSSP - #5506

Open
BradyAJohnston wants to merge 6 commits into
enh-dssp-constructionfrom
fix-dssp-multi-chain
Open

BradyAJohnston wants to merge 6 commits into
enh-dssp-constructionfrom
fix-dssp-multi-chain

Conversation

@BradyAJohnston

@BradyAJohnston BradyAJohnston commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Fixes #5505, stacked on #5504

This doesn't change how MDA behaves compared to pydssp for any of our existing test data, but that's only because we don't have multiple chains or a gap in the backbone. pydssp expects only a single chain, and already fails to assign secondary structure across periodic boundaries which we now account for. Something that isn't done here is that the original DSSP doesn't assign SS across a break in the backbone but we still technically allow it if the other boxes are ticked.

Changes made in this Pull Request:

  • Updates to the masking of hydrogen donors. If there are multiple chains guess_hydrogens no longer fails and if there is a break in the chain the first residues for each segment are masked as not being donors.
  • additional tests that include artificial systems with multiple chains and gaps in the backbone

LLM / AI generated code disclosure

LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)
  • I have read and understand the current AI Policy
  • LLM/AI disclosure was updated.

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.

@read-the-docs-community

read-the-docs-community Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

@BradyAJohnston BradyAJohnston added this to the 2.12 milestone Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.92%. Comparing base (7289187) to head (59b50f0).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           enh-dssp-construction    #5506   +/-   ##
======================================================
  Coverage                  93.92%   93.92%           
======================================================
  Files                        184      184           
  Lines                      22673    22678    +5     
  Branches                    3222     3222           
======================================================
+ Hits                       21295    21301    +6     
  Misses                       917      917           
+ Partials                     461      460    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just changelog

Comment thread package/CHANGELOG Outdated
residue more than 2.5 Å from the C atom of the residue before it: another
chain or a gap) as DSSP does: they are no hydrogen bond donors and are
not checked for a single hydrogen with ``guess_hydrogens=False``, which
rejected every system with more than one chain (Issue #XXXX, PR #XXXX)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fill in PR/issue and move to 2.12.0 section

is_pro = calphas.resnames[1:n] == "PRO"
counts = n_hydrogens[1:n]
wrong = np.flatnonzero(np.where(is_pro, counts != 0, counts != 1))
is_pro = calphas.resnames[:n] == "PRO"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With definition of self._chain_start it makes sense to now not exclude the initial residue anymore. ✅

Comment on lines +247 to +248
np.testing.assert_equal(result[:, :n_residues], expected)
np.testing.assert_equal(result[:, n_residues:], expected)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this test that both copies give the same results fail before this fix?

@orbeckst

Copy link
Copy Markdown
Member

@BradyAJohnston apologies, I pressed a button on GH "rebase stack" and hoped it would "just be fine" or at least that I could quickly fix up any conflicts but it turns out one has to use gh and that was a bit too much for me as I haven't worked with stacked PRs. Sorry – could you please fix your PRs and then we might be able to get them merged fairly quickly? #5504 is done.

@orbeckst orbeckst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With CHANGELOG/release number edits, lgtm.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DSSP: multi-chain systems fail with guess_hydrogens=False, and residues after a gap form spurious H-bonds

2 participants