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.
- 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:
objectRepresents a chemical bond between two atoms.
This class stores information about atomic bonds, including the atoms involved and bond type/origin.
- Parameters:
atom1_serial (int) β Serial number of first atom
atom2_serial (int) β Serial number of second atom
bond_type (str) β Type of bond (βcovalentβ, βexplicitβ, etc.)
distance (Optional[float]) β Distance between bonded atoms in Angstroms
detection_method (str) β Method used to detect this bond
- __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:
atom1_serial (int) β Serial number of first atom
atom2_serial (int) β Serial number of second atom
bond_type (str) β Type of bond (βcovalentβ, βexplicitβ, etc.)
distance (Optional[float]) β Distance between bonded atoms in Angstroms
detection_method (str) β Method used to detect this bond
- __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:
objectRepresents 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)
residue_type (str) β Residue type classification (P=Protein, D=DNA, R=RNA, L=Ligand)
backbone_sidechain (str) β Backbone/sidechain classification (B=Backbone, S=Sidechain)
aromatic (str) β Aromatic classification (A=Aromatic, N=Non-aromatic)
- __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)
residue_type (str) β Residue type classification (P=Protein, D=DNA, R=RNA, L=Ligand)
backbone_sidechain (str) β Backbone/sidechain classification (B=Backbone, S=Sidechain)
aromatic (str) β Aromatic classification (A=Aromatic, N=Non-aromatic)
- 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:
objectRepresents 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]