Skip to content

Add annotate_dssp() - #967

Closed
padix-key wants to merge 2 commits into
biotite-dev:v2from
padix-key:dssp
Closed

padix-key wants to merge 2 commits into
biotite-dev:v2from
padix-key:dssp

Conversation

@padix-key

Copy link
Copy Markdown
Member

This PR adds annotate_dssp() to biotite.structure, a pure Python/NumPy implementation of the DSSP secondary structure assignment in its most recent version (DSSP 4, Hekkelman et al. 2025, based on Kabsch & Sander 1983). This includes the polyproline II helix and the preference of π-helices over α-helices.

The implementation is split into two parts:

  1. _find_dssp_hbonds(): Find the backbone hydrogen bonds based on the DSSP electrostatic energy criterion. Candidate residue pairs are found via a CellList and the energies are computed in a vectorized manner. As in DSSP, only the two strongest bonds per N-H donor are kept.
  2. _assign_dssp_elements(): Assign the secondary structure elements from these hydrogen bonds and the backbone geometry. n-turns, helices, turns, bends and PPII helices are assigned via vectorized shifted masks. Only joining bridges to ladders and merging ladders across β-bulges uses loops, as this logic is inherently sequential (over bridges/ladders, not residues).

Changes to DsspElement

As annotate_dssp() returns DsspElement values and biotite.structure must not depend on biotite.application, DsspElement is moved from biotite.application.dssp to biotite.structure. As DsspElement was introduced in v2, this does not break any released API.
Analogous to PSeaElement, it obtains a NONE member (symbol '') for residues that are not amino acids or lack one of the backbone atoms N, CA, C or O.

Validation

  • The new test_dssp_consistency requires an exact match with DsspApp (DSSP 4.6) for all structures in tests/structure/data/pdb, covering multiple chains, chain gaps and non-canonical amino acids (9940 residues, no differences).
  • In addition, 20 further PDB entries (e.g. GroEL, SARS-CoV-2 spike) were compared manually: 16858 residues, no differences.
  • annotate_dssp() takes 1-18 ms for the test structures compared to ~1.4 s for DsspApp, and ~0.13 s for a ribosome (4V6X).

Deviation from the original software

In DSSP the amide hydrogen of the first residue after a chain break is placed based on the C=O of the residue before the gap (or even of the previous chain). Here such residues cannot act as hydrogen bond donor instead, as the hydrogen position is undefined. This did not lead to any difference in the tested structures and is documented in the docstring.

Implement the DSSP 4 secondary structure assignment in `biotite.structure`.
The function is split into the detection of backbone hydrogen bonds via
the DSSP energy criterion and the assignment of the secondary structure
elements based on these hydrogen bonds.
The results are identical to the original DSSP software for all test
structures.

`DsspElement` is moved from `biotite.application.dssp` into
`biotite.structure` and obtains a `NONE` member for residues that are not
amino acids or have an incomplete backbone.
@padix-key
padix-key deleted the branch biotite-dev:v2 October 16, 2026 10:58
@padix-key padix-key closed this Oct 16, 2026
@codspeed

codspeed Bot commented Oct 16, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.34%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 106 untouched benchmarks
⏩ 14 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ benchmark_match_kmer_selection[KmerTable-11*11*1*1***111] 276.7 µs 244.7 µs +13.07%
⚡ benchmark_match[KmerTable-None] 327.6 µs 295.4 µs +10.92%
⚡ benchmark_match_kmer_selection[BucketKmerTable(10000)-11*11*1*1***111] 353.5 µs 321.2 µs +10.05%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing padix-key:dssp (137abd5) with v2 (9c84779)

Open in CodSpeed

Footnotes

  1. 14 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch was successfully deployed

1 active deployment
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.

1 participant