PDB Structure Fixer#
PDB structure fixing module for adding missing hydrogen atoms.
This module provides functionality to add missing hydrogen atoms to PDB structures using either OpenBabel or PDBFixer tools. It integrates with HBAT’s internal data structures and provides a clean interface for structure enhancement.
- exception hbat.core.pdb_fixer.PDBFixerError[source]#
Bases:
ExceptionException raised when PDB fixing operations fail.
- class hbat.core.pdb_fixer.PDBFixer[source]#
Bases:
objectFix PDB structures by adding missing hydrogen atoms.
This class provides methods to add missing hydrogen atoms to protein structures using either OpenBabel or PDBFixer with OpenMM. It works with HBAT’s internal atom and residue data structures.
- add_missing_hydrogens(atoms: List[Atom], method: str = 'openbabel', pH: float = 7.0, **kwargs: Any) List[Atom][source]#
Add missing hydrogen atoms to a list of atoms.
Takes a list of HBAT Atom objects and returns a new list with missing hydrogen atoms added using the specified method.
- Parameters:
- Returns:
List of atoms with hydrogens added
- Return type:
List[Atom]
- Raises:
PDBFixerError if fixing fails
- add_missing_heavy_atoms(atoms: List[Atom], method: str = 'pdbfixer', **kwargs: Any) List[Atom][source]#
Add missing heavy atoms to a structure.
Uses PDBFixer to identify and add missing heavy atoms in residues. This is particularly useful for structures with incomplete side chains.
- convert_nonstandard_residues(atoms: List[Atom], custom_replacements: Dict[str, str] | None = None) List[Atom][source]#
Convert non-standard residues to their standard equivalents using PDBFixer.
This method uses PDBFixer’s built-in findNonstandardResidues() and replaceNonstandardResidues() methods to properly handle non-standard residues.
- remove_heterogens(atoms: List[Atom], keep_water: bool = True) List[Atom][source]#
Remove unwanted heterogens from the structure using PDBFixer.
Uses PDBFixer’s built-in removeHeterogens() method to properly handle heterogen removal with the option to keep water molecules.
- fix_structure_file(input_path: str, output_path: str | None = None, method: str = 'openbabel', pH: float = 7.0, overwrite: bool = False, **kwargs: Any) str[source]#
Fix a PDB file by adding missing hydrogen atoms.
- Parameters:
input_path (str) – Path to input PDB file
output_path (Optional[str]) – Path for output file (optional)
method (str) – Method to use (‘openbabel’ or ‘pdbfixer’)
pH (float) – pH value for protonation (pdbfixer only)
overwrite (bool) – Whether to overwrite existing output file
kwargs (Any) – Additional parameters for the fixing method
- Returns:
Path to the output file
- Return type:
- Raises:
PDBFixerError if fixing fails
- fix_pdb_file_to_file(input_pdb_path: str, output_pdb_path: str, method: str = 'openbabel', add_hydrogens: bool = True, add_heavy_atoms: bool = False, convert_nonstandard: bool = False, remove_heterogens: bool = False, keep_water: bool = True, pH: float = 7.0, **kwargs: Any) bool[source]#
Fix a PDB file and save the result to another file.
This method processes the original PDB file directly and saves the fixed structure to a new file, preserving proper PDB formatting.
- Parameters:
input_pdb_path (str) – Path to the original PDB file
output_pdb_path (str) – Path where the fixed PDB should be saved
method (str) – Method to use (‘openbabel’ or ‘pdbfixer’)
add_hydrogens (bool) – Whether to add missing hydrogen atoms
add_heavy_atoms (bool) – Whether to add missing heavy atoms (pdbfixer only)
convert_nonstandard (bool) – Whether to convert nonstandard residues (pdbfixer only)
remove_heterogens (bool) – Whether to remove heterogens (pdbfixer only)
keep_water (bool) – Whether to keep water molecules when removing heterogens
pH (float) – pH value for protonation (pdbfixer only)
kwargs (Any) – Additional parameters
- Returns:
True if fixing succeeded, False otherwise
- Return type:
- Raises:
PDBFixerError if fixing fails
- hbat.core.pdb_fixer.add_missing_hydrogens(atoms: List[Atom], method: str = 'openbabel', pH: float = 7.0, **kwargs: Any) List[Atom][source]#
Convenience function to add missing hydrogen atoms.
- hbat.core.pdb_fixer.fix_pdb_file(input_path: str, output_path: str | None = None, method: str = 'openbabel', pH: float = 7.0, overwrite: bool = False, **kwargs: Any) str[source]#
Convenience function to fix a PDB file.
- Parameters:
input_path (str) – Path to input PDB file
output_path (Optional[str]) – Path for output file (optional)
method (str) – Method to use (‘openbabel’ or ‘pdbfixer’)
pH (float) – pH value for protonation (pdbfixer only)
overwrite (bool) – Whether to overwrite existing output file
kwargs (Any) – Additional parameters for the fixing method
- Returns:
Path to the output file
- Return type:
- hbat.core.pdb_fixer.add_missing_heavy_atoms(atoms: List[Atom], method: str = 'pdbfixer', **kwargs: Any) List[Atom][source]#
Convenience function to add missing heavy atoms.
- hbat.core.pdb_fixer.convert_nonstandard_residues(atoms: List[Atom], custom_replacements: Dict[str, str] | None = None) List[Atom][source]#
Convenience function to convert non-standard residues using PDBFixer.
Uses PDBFixer’s built-in findNonstandardResidues() and replaceNonstandardResidues() methods to properly handle non-standard residue conversion.