Core Analysis Engine
The core module contains the main analysis algorithms and data structures.
Analysis Module
Core analysis engine for hydrogen bond and molecular interaction analysis.
This module implements the main computational logic for detecting and analyzing molecular interactions including hydrogen bonds, halogen bonds, and X-H…π interactions.
- class hbat.core.analysis.MolecularInteraction[source]
Bases:
ABC
Base class for all molecular interactions.
This abstract base class defines the interface for all types of molecular interactions analyzed by HBAT, including hydrogen bonds, halogen bonds, and π interactions.
- abstractmethod get_donor_atom() Atom | None [source]
Get the donor atom if applicable.
- Returns:
The donor atom in the interaction, or None if not applicable
- Return type:
Optional[Atom]
- abstractmethod get_acceptor_atom() Atom | None [source]
Get the acceptor atom if applicable.
- Returns:
The acceptor atom in the interaction, or None if not applicable
- Return type:
Optional[Atom]
- abstractmethod get_donor_residue() str [source]
Get the donor residue identifier.
- Returns:
String identifier for the donor residue
- Return type:
- abstractmethod get_acceptor_residue() str [source]
Get the acceptor residue identifier.
- Returns:
String identifier for the acceptor residue
- Return type:
- abstract property distance: float
Get the interaction distance.
- Returns:
Distance between interacting atoms in Angstroms
- Return type:
- class hbat.core.analysis.HydrogenBond(donor: Atom, hydrogen: Atom, acceptor: Atom, distance: float, angle: float, donor_acceptor_distance: float, bond_type: str, donor_residue: str, acceptor_residue: str)[source]
Bases:
object
Represents a hydrogen bond interaction.
This class stores all information about a detected hydrogen bond, including the participating atoms, geometric parameters, and classification information.
- Parameters:
donor (Atom) – The hydrogen bond donor atom
hydrogen (Atom) – The hydrogen atom in the bond
acceptor (Atom) – The hydrogen bond acceptor atom
distance (float) – H…A distance in Angstroms
angle (float) – D-H…A angle in radians
donor_acceptor_distance (float) – D…A distance in Angstroms
bond_type (str) – Classification of the hydrogen bond type
donor_residue (str) – Identifier for donor residue
acceptor_residue (str) – Identifier for acceptor residue
- class hbat.core.analysis.HalogenBond(halogen: Atom, acceptor: Atom, distance: float, angle: float, bond_type: str, halogen_residue: str, acceptor_residue: str)[source]
Bases:
object
Represents a halogen bond interaction.
This class stores information about a detected halogen bond, where a halogen atom acts as an electron acceptor.
- Parameters:
halogen (Atom) – The halogen atom (F, Cl, Br, I)
acceptor (Atom) – The electron donor/acceptor atom
distance (float) – X…A distance in Angstroms
angle (float) – C-X…A angle in radians
bond_type (str) – Classification of the halogen bond type
halogen_residue (str) – Identifier for halogen-containing residue
acceptor_residue (str) – Identifier for acceptor residue
- class hbat.core.analysis.PiInteraction(donor: Atom, hydrogen: Atom, pi_center: Vec3D, distance: float, angle: float, donor_residue: str, pi_residue: str)[source]
Bases:
object
Represents an X-H…π interaction.
This class stores information about a detected X-H…π interaction, where a hydrogen bond donor interacts with an aromatic π system.
- Parameters:
donor (Atom) – The hydrogen bond donor atom
hydrogen (Atom) – The hydrogen atom
pi_center (Vec3D) – Center of the aromatic π system
distance (float) – H…π distance in Angstroms
angle (float) – D-H…π angle in radians
donor_residue (str) – Identifier for donor residue
pi_residue (str) – Identifier for π-containing residue
- class hbat.core.analysis.CooperativityChain(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]
Bases:
object
Represents a chain of cooperative molecular interactions.
This class represents a series of linked molecular interactions where the acceptor of one interaction acts as the donor of the next, creating cooperative effects.
- Parameters:
interactions (List[Union[HydrogenBond, HalogenBond, PiInteraction]]) – List of interactions in the chain
chain_length (int) – Number of interactions in the chain
chain_type (str) – Description of the interaction types in the chain
- interactions: List[HydrogenBond | HalogenBond | PiInteraction]
- __init__(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str) None
- class hbat.core.analysis.AnalysisParameters(hb_distance_cutoff: float = 3.5, hb_angle_cutoff: float = 120.0, hb_donor_acceptor_cutoff: float = 4.0, xb_distance_cutoff: float = 4.0, xb_angle_cutoff: float = 120.0, pi_distance_cutoff: float = 4.5, pi_angle_cutoff: float = 90.0, covalent_cutoff_factor: float = 1.2, analysis_mode: str = 'complete')[source]
Bases:
object
Parameters for molecular interaction analysis.
This class contains all configurable parameters used during molecular interaction analysis, including distance cutoffs, angle thresholds, and analysis modes.
- Parameters:
hb_distance_cutoff (float) – Maximum H…A distance for hydrogen bonds (Å)
hb_angle_cutoff (float) – Minimum D-H…A angle for hydrogen bonds (degrees)
hb_donor_acceptor_cutoff (float) – Maximum D…A distance for hydrogen bonds (Å)
xb_distance_cutoff (float) – Maximum X…A distance for halogen bonds (Å)
xb_angle_cutoff (float) – Minimum C-X…A angle for halogen bonds (degrees)
pi_distance_cutoff (float) – Maximum H…π distance for π interactions (Å)
pi_angle_cutoff (float) – Minimum D-H…π angle for π interactions (degrees)
covalent_cutoff_factor (float) – Factor for covalent bond detection
analysis_mode (str) – Analysis mode (‘local’ or ‘global’)
- __init__(hb_distance_cutoff: float = 3.5, hb_angle_cutoff: float = 120.0, hb_donor_acceptor_cutoff: float = 4.0, xb_distance_cutoff: float = 4.0, xb_angle_cutoff: float = 120.0, pi_distance_cutoff: float = 4.5, pi_angle_cutoff: float = 90.0, covalent_cutoff_factor: float = 1.2, analysis_mode: str = 'complete') None
- class hbat.core.analysis.HBondAnalyzer(parameters: AnalysisParameters | None = None)[source]
Bases:
object
Main analyzer for molecular interactions.
This is the primary class for analyzing molecular interactions in protein structures. It detects hydrogen bonds, halogen bonds, π interactions, and cooperative interaction chains.
- Parameters:
parameters (Optional[AnalysisParameters]) – Analysis parameters to use
- __init__(parameters: AnalysisParameters | None = None)[source]
Initialize analyzer with parameters.
- Parameters:
parameters (Optional[AnalysisParameters]) – Analysis parameters, defaults to standard parameters if None
- analyze_file(pdb_file: str) bool [source]
Analyze a PDB file for molecular interactions.
This method parses a PDB file and analyzes it for all types of molecular interactions supported by HBAT. Results are stored in the analyzer instance for later retrieval.
Classes
- class hbat.core.analysis.HBondAnalyzer(parameters: AnalysisParameters | None = None)[source]
Bases:
object
Main analyzer for molecular interactions.
This is the primary class for analyzing molecular interactions in protein structures. It detects hydrogen bonds, halogen bonds, π interactions, and cooperative interaction chains.
- Parameters:
parameters (Optional[AnalysisParameters]) – Analysis parameters to use
- __init__(parameters: AnalysisParameters | None = None)[source]
Initialize analyzer with parameters.
- Parameters:
parameters (Optional[AnalysisParameters]) – Analysis parameters, defaults to standard parameters if None
- analyze_file(pdb_file: str) bool [source]
Analyze a PDB file for molecular interactions.
This method parses a PDB file and analyzes it for all types of molecular interactions supported by HBAT. Results are stored in the analyzer instance for later retrieval.
- class hbat.core.analysis.AnalysisParameters(hb_distance_cutoff: float = 3.5, hb_angle_cutoff: float = 120.0, hb_donor_acceptor_cutoff: float = 4.0, xb_distance_cutoff: float = 4.0, xb_angle_cutoff: float = 120.0, pi_distance_cutoff: float = 4.5, pi_angle_cutoff: float = 90.0, covalent_cutoff_factor: float = 1.2, analysis_mode: str = 'complete')[source]
Bases:
object
Parameters for molecular interaction analysis.
This class contains all configurable parameters used during molecular interaction analysis, including distance cutoffs, angle thresholds, and analysis modes.
- Parameters:
hb_distance_cutoff (float) – Maximum H…A distance for hydrogen bonds (Å)
hb_angle_cutoff (float) – Minimum D-H…A angle for hydrogen bonds (degrees)
hb_donor_acceptor_cutoff (float) – Maximum D…A distance for hydrogen bonds (Å)
xb_distance_cutoff (float) – Maximum X…A distance for halogen bonds (Å)
xb_angle_cutoff (float) – Minimum C-X…A angle for halogen bonds (degrees)
pi_distance_cutoff (float) – Maximum H…π distance for π interactions (Å)
pi_angle_cutoff (float) – Minimum D-H…π angle for π interactions (degrees)
covalent_cutoff_factor (float) – Factor for covalent bond detection
analysis_mode (str) – Analysis mode (‘local’ or ‘global’)
- __init__(hb_distance_cutoff: float = 3.5, hb_angle_cutoff: float = 120.0, hb_donor_acceptor_cutoff: float = 4.0, xb_distance_cutoff: float = 4.0, xb_angle_cutoff: float = 120.0, pi_distance_cutoff: float = 4.5, pi_angle_cutoff: float = 90.0, covalent_cutoff_factor: float = 1.2, analysis_mode: str = 'complete') None
Interaction Classes
- class hbat.core.analysis.MolecularInteraction[source]
Bases:
ABC
Base class for all molecular interactions.
This abstract base class defines the interface for all types of molecular interactions analyzed by HBAT, including hydrogen bonds, halogen bonds, and π interactions.
- abstractmethod get_donor_atom() Atom | None [source]
Get the donor atom if applicable.
- Returns:
The donor atom in the interaction, or None if not applicable
- Return type:
Optional[Atom]
- abstractmethod get_acceptor_atom() Atom | None [source]
Get the acceptor atom if applicable.
- Returns:
The acceptor atom in the interaction, or None if not applicable
- Return type:
Optional[Atom]
- abstractmethod get_donor_residue() str [source]
Get the donor residue identifier.
- Returns:
String identifier for the donor residue
- Return type:
- abstractmethod get_acceptor_residue() str [source]
Get the acceptor residue identifier.
- Returns:
String identifier for the acceptor residue
- Return type:
- abstract property distance: float
Get the interaction distance.
- Returns:
Distance between interacting atoms in Angstroms
- Return type:
- class hbat.core.analysis.HydrogenBond(donor: Atom, hydrogen: Atom, acceptor: Atom, distance: float, angle: float, donor_acceptor_distance: float, bond_type: str, donor_residue: str, acceptor_residue: str)[source]
Bases:
object
Represents a hydrogen bond interaction.
This class stores all information about a detected hydrogen bond, including the participating atoms, geometric parameters, and classification information.
- Parameters:
donor (Atom) – The hydrogen bond donor atom
hydrogen (Atom) – The hydrogen atom in the bond
acceptor (Atom) – The hydrogen bond acceptor atom
distance (float) – H…A distance in Angstroms
angle (float) – D-H…A angle in radians
donor_acceptor_distance (float) – D…A distance in Angstroms
bond_type (str) – Classification of the hydrogen bond type
donor_residue (str) – Identifier for donor residue
acceptor_residue (str) – Identifier for acceptor residue
- class hbat.core.analysis.HalogenBond(halogen: Atom, acceptor: Atom, distance: float, angle: float, bond_type: str, halogen_residue: str, acceptor_residue: str)[source]
Bases:
object
Represents a halogen bond interaction.
This class stores information about a detected halogen bond, where a halogen atom acts as an electron acceptor.
- Parameters:
halogen (Atom) – The halogen atom (F, Cl, Br, I)
acceptor (Atom) – The electron donor/acceptor atom
distance (float) – X…A distance in Angstroms
angle (float) – C-X…A angle in radians
bond_type (str) – Classification of the halogen bond type
halogen_residue (str) – Identifier for halogen-containing residue
acceptor_residue (str) – Identifier for acceptor residue
- class hbat.core.analysis.PiInteraction(donor: Atom, hydrogen: Atom, pi_center: Vec3D, distance: float, angle: float, donor_residue: str, pi_residue: str)[source]
Bases:
object
Represents an X-H…π interaction.
This class stores information about a detected X-H…π interaction, where a hydrogen bond donor interacts with an aromatic π system.
- Parameters:
donor (Atom) – The hydrogen bond donor atom
hydrogen (Atom) – The hydrogen atom
pi_center (Vec3D) – Center of the aromatic π system
distance (float) – H…π distance in Angstroms
angle (float) – D-H…π angle in radians
donor_residue (str) – Identifier for donor residue
pi_residue (str) – Identifier for π-containing residue
- class hbat.core.analysis.CooperativityChain(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]
Bases:
object
Represents a chain of cooperative molecular interactions.
This class represents a series of linked molecular interactions where the acceptor of one interaction acts as the donor of the next, creating cooperative effects.
- Parameters:
interactions (List[Union[HydrogenBond, HalogenBond, PiInteraction]]) – List of interactions in the chain
chain_length (int) – Number of interactions in the chain
chain_type (str) – Description of the interaction types in the chain
- interactions: List[HydrogenBond | HalogenBond | PiInteraction]
- __init__(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str) None
PDB Parser Module
PDB file parser for molecular structure analysis using pdbreader.
This module provides functionality to parse PDB (Protein Data Bank) files and extract atomic coordinates and molecular information using the pdbreader library.
- class hbat.core.pdb_parser.Atom(serial: int, name: str, alt_loc: str, res_name: str, chain_id: str, res_seq: int, i_code: str, coords: Vec3D, occupancy: float, temp_factor: float, element: str, charge: str, record_type: str)[source]
Bases:
object
Represents an atom from a PDB file.
This class stores all atomic information parsed from PDB format including coordinates, properties, and residue information.
- Parameters:
serial (int) – Atom serial number
name (str) – Atom name
alt_loc (str) – Alternate location indicator
res_name (str) – Residue name
chain_id (str) – Chain identifier
res_seq (int) – Residue sequence number
i_code (str) – Insertion code
coords (Vec3D) – 3D coordinates
occupancy (float) – Occupancy factor
temp_factor (float) – Temperature factor
element (str) – Element symbol
charge (str) – Formal charge
record_type (str) – PDB record type (ATOM or HETATM)
- is_hydrogen() bool [source]
Check if atom is hydrogen.
- Returns:
True if atom is hydrogen or deuterium
- Return type:
- class hbat.core.pdb_parser.Residue(name: str, chain_id: str, seq_num: int, i_code: str, atoms: List[Atom])[source]
Bases:
object
Represents a residue containing multiple atoms.
This class groups atoms belonging to the same residue and provides methods for accessing and analyzing residue-level information.
- Parameters:
- class hbat.core.pdb_parser.PDBParser[source]
Bases:
object
Parser for PDB format files using pdbreader.
This class handles parsing of PDB (Protein Data Bank) format files and converts them into HBAT’s internal atom and residue representations. Uses the pdbreader library for robust PDB format handling.
- __init__() None [source]
Initialize PDB parser.
Creates a new parser instance with empty atom and residue lists.
- parse_file(filename: str) bool [source]
Parse a PDB file.
Reads and parses a PDB format file, extracting all ATOM and HETATM records and converting them to HBAT’s internal representation.
- parse_lines(lines: List[str]) bool [source]
Parse PDB format lines.
Parses PDB format content provided as a list of strings, useful for processing in-memory PDB data.
- get_atoms_by_residue(res_name: str) List[Atom] [source]
Get all atoms from residues with specific name.
- get_hydrogen_atoms() List[Atom] [source]
Get all hydrogen atoms.
- Returns:
List of all hydrogen and deuterium atoms
- Return type:
List[Atom]
- has_hydrogens() bool [source]
Check if structure contains hydrogen atoms.
Determines if the structure has a reasonable number of hydrogen atoms compared to heavy atoms, indicating explicit hydrogen modeling.
- Returns:
True if structure appears to contain explicit hydrogens
- Return type:
- get_residue_list() List[Residue] [source]
Get list of all residues.
- Returns:
List of all residues in the structure
- Return type:
List[Residue]
Classes
- class hbat.core.pdb_parser.PDBParser[source]
Bases:
object
Parser for PDB format files using pdbreader.
This class handles parsing of PDB (Protein Data Bank) format files and converts them into HBAT’s internal atom and residue representations. Uses the pdbreader library for robust PDB format handling.
- __init__() None [source]
Initialize PDB parser.
Creates a new parser instance with empty atom and residue lists.
- parse_file(filename: str) bool [source]
Parse a PDB file.
Reads and parses a PDB format file, extracting all ATOM and HETATM records and converting them to HBAT’s internal representation.
- parse_lines(lines: List[str]) bool [source]
Parse PDB format lines.
Parses PDB format content provided as a list of strings, useful for processing in-memory PDB data.
- get_atoms_by_residue(res_name: str) List[Atom] [source]
Get all atoms from residues with specific name.
- get_hydrogen_atoms() List[Atom] [source]
Get all hydrogen atoms.
- Returns:
List of all hydrogen and deuterium atoms
- Return type:
List[Atom]
- has_hydrogens() bool [source]
Check if structure contains hydrogen atoms.
Determines if the structure has a reasonable number of hydrogen atoms compared to heavy atoms, indicating explicit hydrogen modeling.
- Returns:
True if structure appears to contain explicit hydrogens
- Return type:
- get_residue_list() List[Residue] [source]
Get list of all residues.
- Returns:
List of all residues in the structure
- Return type:
List[Residue]
- class hbat.core.pdb_parser.Atom(serial: int, name: str, alt_loc: str, res_name: str, chain_id: str, res_seq: int, i_code: str, coords: Vec3D, occupancy: float, temp_factor: float, element: str, charge: str, record_type: str)[source]
Bases:
object
Represents an atom from a PDB file.
This class stores all atomic information parsed from PDB format including coordinates, properties, and residue information.
- Parameters:
serial (int) – Atom serial number
name (str) – Atom name
alt_loc (str) – Alternate location indicator
res_name (str) – Residue name
chain_id (str) – Chain identifier
res_seq (int) – Residue sequence number
i_code (str) – Insertion code
coords (Vec3D) – 3D coordinates
occupancy (float) – Occupancy factor
temp_factor (float) – Temperature factor
element (str) – Element symbol
charge (str) – Formal charge
record_type (str) – PDB record type (ATOM or HETATM)
- is_hydrogen() bool [source]
Check if atom is hydrogen.
- Returns:
True if atom is hydrogen or deuterium
- Return type:
- class hbat.core.pdb_parser.Residue(name: str, chain_id: str, seq_num: int, i_code: str, atoms: List[Atom])[source]
Bases:
object
Represents a residue containing multiple atoms.
This class groups atoms belonging to the same residue and provides methods for accessing and analyzing residue-level information.
- Parameters:
Vector Mathematics Module
3D Vector mathematics for molecular analysis.
This module provides Vec3D class for 3D vector operations used in molecular geometry calculations.
- class hbat.core.vector.Vec3D(x: float = 0.0, y: float = 0.0, z: float = 0.0)[source]
Bases:
object
3D vector class for molecular calculations.
This class provides comprehensive 3D vector operations used in molecular geometry calculations, including distance measurements, angle calculations, and coordinate transformations.
- Parameters:
- __setitem__(index: int, value: float) None [source]
Set component by index (0=x, 1=y, 2=z).
- Parameters:
- Raises:
IndexError – If index is out of range (not 0, 1, or 2)
- Returns:
None
- Return type:
None
- length() float [source]
Calculate vector length/magnitude.
- Returns:
Euclidean length of the vector
- Return type:
- magnitude() float [source]
Alias for length().
- Returns:
Euclidean magnitude of the vector
- Return type:
- normalize() Vec3D [source]
Return normalized unit vector.
- Returns:
Unit vector in the same direction
- Return type:
- unit_vector() Vec3D [source]
Alias for normalize().
- Returns:
Unit vector in the same direction
- Return type:
- to_list() List[float] [source]
Convert to list [x, y, z].
- Returns:
Vector components as a list
- Return type:
List[float]
- hbat.core.vector.unit_vector_between(a: Vec3D, b: Vec3D) Vec3D [source]
Return unit vector pointing from a to b.
- hbat.core.vector.angle_between_vectors(a: Vec3D, b: Vec3D, c: Vec3D | None = None) float [source]
Calculate angle between vectors.
If c is provided: Calculate angle ABC where B is the vertex. If c is None: Calculate angle between vectors a and b.
- hbat.core.vector.dihedral_angle(a: Vec3D, b: Vec3D, c: Vec3D, d: Vec3D) float [source]
Calculate dihedral angle between planes ABC and BCD.
Classes
- class hbat.core.vector.Vec3D(x: float = 0.0, y: float = 0.0, z: float = 0.0)[source]
Bases:
object
3D vector class for molecular calculations.
This class provides comprehensive 3D vector operations used in molecular geometry calculations, including distance measurements, angle calculations, and coordinate transformations.
- Parameters:
- __setitem__(index: int, value: float) None [source]
Set component by index (0=x, 1=y, 2=z).
- Parameters:
- Raises:
IndexError – If index is out of range (not 0, 1, or 2)
- Returns:
None
- Return type:
None
- length() float [source]
Calculate vector length/magnitude.
- Returns:
Euclidean length of the vector
- Return type:
- magnitude() float [source]
Alias for length().
- Returns:
Euclidean magnitude of the vector
- Return type:
- normalize() Vec3D [source]
Return normalized unit vector.
- Returns:
Unit vector in the same direction
- Return type:
- unit_vector() Vec3D [source]
Alias for normalize().
- Returns:
Unit vector in the same direction
- Return type:
- to_list() List[float] [source]
Convert to list [x, y, z].
- Returns:
Vector components as a list
- Return type:
List[float]
Functions
- hbat.core.vector.unit_vector_between(a: Vec3D, b: Vec3D) Vec3D [source]
Return unit vector pointing from a to b.
- hbat.core.vector.angle_between_vectors(a: Vec3D, b: Vec3D, c: Vec3D | None = None) float [source]
Calculate angle between vectors.
If c is provided: Calculate angle ABC where B is the vertex. If c is None: Calculate angle between vectors a and b.