Core Data Structures#
Molecular structure classes for HBAT.
This module contains the core data structures representing molecular entities including atoms, bonds, and residues from PDB files.
Classes#
- class hbat.core.structure.Bond(atom1_serial: int, atom2_serial: int, bond_type: str = 'covalent', distance: float | None = None, detection_method: str = 'distance_based')[source]#
Bases:
object
Represents a chemical bond between two atoms.
This class stores information about atomic bonds, including the atoms involved and bond type/origin.
- Parameters:
- __init__(atom1_serial: int, atom2_serial: int, bond_type: str = 'covalent', distance: float | None = None, detection_method: str = 'distance_based') None [source]#
Initialize a Bond object.
- Parameters:
- __iter__() Iterator[Tuple[str, Any]] [source]#
Iterate over bond attributes as (name, value) pairs.
- Returns:
Iterator of (attribute_name, value) tuples
- Return type:
Iterator[Tuple[str, Any]]
- to_dict() Dict[str, Any] [source]#
Convert bond to dictionary.
- Returns:
Dictionary representation of the bond
- Return type:
Dict[str, Any]
- class hbat.core.structure.Atom(serial: int, name: str, alt_loc: str, res_name: str, chain_id: str, res_seq: int, i_code: str, coords: NPVec3D, occupancy: float, temp_factor: float, element: str, charge: str, record_type: str, residue_type: str = 'L', backbone_sidechain: str = 'S', aromatic: str = 'N')[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 (NPVec3D) – 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)
- __init__(serial: int, name: str, alt_loc: str, res_name: str, chain_id: str, res_seq: int, i_code: str, coords: NPVec3D, occupancy: float, temp_factor: float, element: str, charge: str, record_type: str, residue_type: str = 'L', backbone_sidechain: str = 'S', aromatic: str = 'N') None [source]#
Initialize an Atom object.
- 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 (NPVec3D) – 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:
- is_metal() bool [source]#
Check if atom is a metal.
- Returns:
True if atom is a common metal ion
- Return type:
- __iter__() Iterator[Tuple[str, Any]] [source]#
Iterate over atom attributes as (name, value) pairs.
- Returns:
Iterator of (attribute_name, value) tuples
- Return type:
Iterator[Tuple[str, Any]]
- to_dict() Dict[str, Any] [source]#
Convert atom to dictionary.
- Returns:
Dictionary representation of the atom
- Return type:
Dict[str, Any]
- class hbat.core.structure.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:
- __init__(name: str, chain_id: str, seq_num: int, i_code: str, atoms: List[Atom]) None [source]#
Initialize a Residue object.
- center_of_mass() NPVec3D [source]#
Calculate center of mass of residue.
Computes the mass-weighted centroid of all atoms in the residue.
- Returns:
Center of mass coordinates
- Return type:
- get_aromatic_center() NPVec3D | None [source]#
Calculate aromatic ring center if residue is aromatic.
For aromatic residues (PHE, TYR, TRP, HIS), calculates the geometric center of the aromatic ring atoms.
- Returns:
Center coordinates of aromatic ring, None if not aromatic
- Return type:
Optional[NPVec3D]
- __iter__() Iterator[Tuple[str, Any]] [source]#
Iterate over residue attributes as (name, value) pairs.
- Returns:
Iterator of (attribute_name, value) tuples
- Return type:
Iterator[Tuple[str, Any]]
- to_dict() Dict[str, Any] [source]#
Convert residue to dictionary.
- Returns:
Dictionary representation of the residue
- Return type:
Dict[str, Any]