Skip to content

fix inclusion of PRO in secondary structure #5065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

orbeckst
Copy link
Member

@orbeckst orbeckst commented Jun 12, 2025

Fixes #4913

Changes made in this Pull Request:

  • ported fix from PyDSSP 0.9.1 by @ShintaroMinami to analysis.dssp.DSSP (see also Wrong assignment or prolines? ShintaroMinami/PyDSSP#2)
  • new kwarg ignore_proline_donor=True for DSSP (the new default changes the behavior and implements the fix, False recovers old behavior); the kwarg also exists in PyDSSP
  • updated docs
  • minimal regression tests
  • updated CHANGELOG

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!)

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.


📚 Documentation preview 📚: https://mdanalysis--5065.org.readthedocs.build/en/5065/

- fix #4913
- ported fix from PyDSSP 0.9.1 by @ShintaroMinami to analysis.dssp.DSSP
  (see also ShintaroMinami/PyDSSP#2)
- new kwarg ignore_proline_donor=True for DSSP (the new default changes the behavior
  and implements the fix, False recovers old behavior); the kwarg also exists in
  PyDSSP
- updated docs
- minimal regression tests
- updated CHANGELOG
@orbeckst orbeckst force-pushed the update-dssp-proline-fix branch from b38e9db to 005100f Compare June 12, 2025 00:23
Copy link
Member Author

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

This is a quick draft. I'd be more than happy if someone continued and completed it.

Comment on lines +332 to +334
self._donor_mask: Optional[np.ndarray] = (
ag.residues.resnames != "PRO" if ignore_proline_donor else None
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This may not be correct. The code runs ... but I am not sure if I should be masking corresponding atoms.

Comment on lines +135 to +136
Mask out any hydrogens that should not be considered (in particular HN
in PRO). If ``None`` then all H will be used (behavior up to 2.9.0).
Copy link
Member Author

Choose a reason for hiding this comment

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

These docs should be more specific and state the shape. I just quickly guessed the shape from https://github.com/ShintaroMinami/PyDSSP/blob/e251a43ff8622fe0a555313b1567edce45e789e8/scripts/pydssp#L30

donor_mask = sequence != 'PRO' if args.ignore_proline_donor else None

if donor_mask is not None
else np.ones(n_atoms, dtype=float)
)
donor_mask = np.tile(donor_mask[:, np.newaxis], (1, n_atoms))
Copy link
Member Author

Choose a reason for hiding this comment

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

Is the donor_mask (one element for each residue) really correct for this tiling????

# hydrogen bond map (continuous value extension of original definition)
hbond_map = np.clip(cutoff - margin - e, a_min=-margin, a_max=margin)
hbond_map = (np.sin(hbond_map / margin * np.pi / 2) + 1.0) / 2
hbond_map = hbond_map * local_mask
hbond_map *= local_mask
hbond_map *= donor_mask
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this correct? The original code uses https://github.com/ShintaroMinami/PyDSSP/blob/e251a43ff8622fe0a555313b1567edce45e789e8/pydssp/pydssp_numpy.py#L72

hbond_map = hbond_map * repeat(donor_mask, 'l1 l2 -> b l1 l2', b=b)

(with einops.repeat()). Note that we create our donor_mask with tile so it may already be the right size and shape.

@@ -13,15 +13,52 @@
"pdb_filename", glob.glob(f"{DSSP_FOLDER}/?????.pdb.gz")
)
def test_file_guess_hydrogens(pdb_filename, client_DSSP):
# run 2.9.0 tests (which include PRO)
# ignore_proline_donor=False
# TODO: update reference data for ignore_proline_donor=True
Copy link
Member Author

Choose a reason for hiding this comment

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

We should really have correct reference data. About half of the files do not show a difference between ignore_proline_donor=True and ignore_proline_donor=False.

Comment on lines -35 to -36
protein = mda.Universe(TPR, XTC).select_atoms("protein")
run = DSSP(protein).run(**client_DSSP, stop=10)
Copy link
Member Author

Choose a reason for hiding this comment

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

These lines seemed superfluous as the atomgroup approach is tested separately.

Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.63%. Comparing base (d412c9a) to head (87810eb).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5065   +/-   ##
========================================
  Coverage    93.63%   93.63%           
========================================
  Files          177      177           
  Lines        22033    22037    +4     
  Branches      3115     3115           
========================================
+ Hits         20631    20635    +4     
  Misses         948      948           
  Partials       454      454           

☔ View full report in Codecov by Sentry.
📢 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.

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.

Update secondary structure assignment in DSSP after an upstream fix
1 participant