Skip to main content

add_hydrogens

Function add_hydrogens 

Source
pub fn add_hydrogens(
    structure: &mut Structure,
    config: &HydroConfig,
) -> Result<(), Error>
Expand description

Adds hydrogens to all standard residues in-place, updating protonation states when needed.

This function implements a multi-phase pipeline:

  1. Disulfide detection — Identifies CYS pairs forming S-S bonds and relabels to CYX.
  2. Non-HIS protonation — Applies pKa-based titration to ASP, GLU, LYS, ARG, CYS, TYR (only when target_ph is specified).
  3. HIS protonation — Determines HIS state via pH thresholds, salt bridge detection, and tautomer strategy.
  4. Hydrogen construction — Builds hydrogens according to template geometry and terminal-specific rules.

§Arguments

  • structure - Mutable structure whose residues will be protonated and hydrated.
  • config - Hydrogenation configuration controlling pH, strategy, and options.

§Returns

Ok(()) when hydrogenation succeeds.

§Errors

Returns Error::MissingInternalTemplate when no template is found or Error::IncompleteResidueForHydro when required anchor atoms are missing.