Skip to content

fix(ops): Correct N-Terminal Proline Hydrogen Geometry#41

Merged
TKanX merged 4 commits into
mainfrom
bugfix/40-n-terminal-proline-receives-wrong-sp-secondary-amine-hybridization
Mar 28, 2026
Merged

fix(ops): Correct N-Terminal Proline Hydrogen Geometry#41
TKanX merged 4 commits into
mainfrom
bugfix/40-n-terminal-proline-receives-wrong-sp-secondary-amine-hybridization

Conversation

@TKanX
Copy link
Copy Markdown
Owner

@TKanX TKanX commented Mar 28, 2026

Summary:

Fixed a bug where N-terminal Proline residues were incorrectly assigned three hydrogens (H1, H2, H3) with a standard primary amine sp³ geometry. Proline has a secondary amine due to its pyrrolidine ring, so its N-terminus should only receive two hydrogens (H2, H3) when protonated, and one (H2) when deprotonated. The geometry calculation has been updated to correctly place these hydrogens based on the angle bisector of the CA-N-CD bonds, respecting the ring structure.

Changes:

  • Updated construct_n_term_hydrogens in ops/hydro.rs:

    • Added a specific branch for StandardResidue::PRO.
    • For N-terminal Proline, the code now calculates the direction for H2 and H3 using the bisector and perpendicular vectors of the N-CA and N-CD bonds.
    • H1 is never added to Proline.
    • H3 is only added if the terminus is protonated (pH < 8.0).
  • Added Validation Tests:

    • Introduced n_terminal_pro_residue helper for generating test cases.
    • Added tests to verify correct protonation states for N-term PRO with and without specified pH (pro_n_terminal_defaults_to_protonated_without_ph, pro_n_terminal_remains_protonated_below_pka, pro_n_terminal_deprotonates_above_pka).
    • Added geometric validation tests (pro_n_terminal_h_has_tetrahedral_bond_lengths, pro_n_terminal_h_has_tetrahedral_bond_angles) to ensure the newly placed hydrogens satisfy the expected 1.01 Å bond length and ~109.5° tetrahedral angles relative to the CA and CD atoms.

@TKanX TKanX self-assigned this Mar 28, 2026
@TKanX TKanX added the bug 🐛 Something isn't working label Mar 28, 2026
@TKanX TKanX linked an issue Mar 28, 2026 that may be closed by this pull request
3 tasks
Copilot AI review requested due to automatic review settings March 28, 2026 02:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes N-terminal Proline hydrogen reconstruction so PRO (secondary amine) no longer receives an invalid third N–H and uses ring-aware geometry for placed hydrogens.

Changes:

  • Added a PRO-specific branch in construct_n_term_hydrogens to place only H2 (neutral) or H2+H3 (protonated), never H1.
  • Updated N-terminal hydrogen placement for PRO to use CA–N–CD bisector/perpendicular directions rather than the generic sp³ frame.
  • Added targeted tests covering PRO N-terminus protonation behavior and geometric sanity checks (bond lengths/angles).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/bio-forge/src/ops/hydro.rs
Comment thread crates/bio-forge/src/ops/hydro.rs
@TKanX TKanX merged commit e019c51 into main Mar 28, 2026
8 checks passed
@TKanX TKanX deleted the bugfix/40-n-terminal-proline-receives-wrong-sp-secondary-amine-hybridization branch March 28, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N-terminal Proline Receives Wrong sp³ Secondary Amine Hybridization

2 participants