Molecular Interaction Data Structures

Contents

Molecular Interaction Data Structures#

Data structures for representing different types of molecular interactions with comprehensive geometric and chemical information.

Module Overview#

Molecular interaction classes for HBAT analysis.

This module defines the data structures for representing different types of molecular interactions including hydrogen bonds, halogen bonds, π interactions, and cooperativity chains.

This module provides dataclass-based representations for molecular interactions detected in protein and nucleic acid structures. Each interaction type captures specific geometric parameters and provides validation methods.

class hbat.core.interactions.MolecularInteraction[source]#

Bases: ABC

Base class for all molecular interactions.

This abstract base class defines the unified interface for all types of molecular interactions analyzed by HBAT, including hydrogen bonds, halogen bonds, and π interactions.

All interactions have the following core components: - Donor: The electron/proton donor (atom or virtual atom) - Acceptor: The electron/proton acceptor (atom or virtual atom) - Interaction: The mediating atom/point (e.g., hydrogen, π center) - Geometry: Distances and angles defining the interaction - Bonding: The interaction atom must be bonded to the donor atom

Bonding Requirements: - For H-bonds: Hydrogen must be covalently bonded to the donor - For X-bonds: Halogen is covalently bonded to donor carbon - For X-H…π interactions: Hydrogen must be covalently bonded to the donor - For π-π stacking (future): No bonding requirement - uses centroid distances

abstractmethod get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

abstractmethod get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

abstractmethod get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

abstractmethod get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

abstractmethod get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

abstractmethod get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

abstractmethod get_donor_interaction_distance() float[source]#

Get the donor to interaction distance.

Returns:

Distance from donor to interaction point in Angstroms

Return type:

float

abstractmethod get_donor_acceptor_distance() float[source]#

Get the donor to acceptor distance.

Returns:

Distance from donor to acceptor in Angstroms

Return type:

float

abstractmethod get_donor_interaction_acceptor_angle() float[source]#

Get the donor-interaction-acceptor angle.

Returns:

Angle in radians

Return type:

float

abstractmethod is_donor_interaction_bonded() bool[source]#

Check if the interaction atom is bonded to the donor atom.

This is a fundamental requirement for most molecular interactions (except π-π stacking which will be implemented separately).

Returns:

True if donor and interaction atom are bonded

Return type:

bool

property donor: Atom | NPVec3D#

Property accessor for donor.

property acceptor: Atom | NPVec3D#

Property accessor for acceptor.

property interaction: Atom | NPVec3D#

Property accessor for interaction.

property donor_residue: str#

Property accessor for donor residue.

property acceptor_residue: str#

Property accessor for acceptor residue.

property interaction_type: str#

Property accessor for interaction type.

property donor_interaction_distance: float#

Property accessor for donor-interaction distance.

property donor_acceptor_distance: float#

Property accessor for donor-acceptor distance.

property donor_interaction_acceptor_angle: float#

Property accessor for donor-interaction-acceptor angle.

get_donor_atom() Atom | None[source]#

Get the donor atom if it’s an Atom instance.

Returns:

The donor atom if it’s an Atom, None otherwise

Return type:

Optional[Atom]

get_acceptor_atom() Atom | None[source]#

Get the acceptor atom if it’s an Atom instance.

Returns:

The acceptor atom if it’s an Atom, None otherwise

Return type:

Optional[Atom]

property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

class hbat.core.interactions.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: MolecularInteraction

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

__init__(_donor: Atom, hydrogen: Atom, _acceptor: Atom, distance: float, angle: float, _donor_acceptor_distance: float, bond_type: str, _donor_residue: str, _acceptor_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property donor: Atom#

Property accessor for donor atom.

property acceptor: Atom#

Property accessor for acceptor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to hydrogen.

get_donor_acceptor_distance() float[source]#

Distance from donor to acceptor.

get_donor_interaction_acceptor_angle() float[source]#

D-H…A angle.

is_donor_interaction_bonded() bool[source]#

Check if hydrogen is bonded to donor.

For hydrogen bonds, the hydrogen must be covalently bonded to the donor atom. This method assumes the bond has been validated during creation.

Returns:

True (assumes validation was done during creation)

Return type:

bool

property donor_acceptor_properties: str#

Get the donor-acceptor property description.

Returns:

Property description string

Return type:

str

get_backbone_sidechain_interaction() str[source]#

Get simplified backbone/sidechain interaction description.

Returns:

Interaction type (B-B, B-S, S-B, S-S)

Return type:

str

class hbat.core.interactions.HalogenBond(halogen: Atom, _acceptor: Atom, distance: float, angle: float, bond_type: str, _halogen_residue: str, _acceptor_residue: str)[source]#

Bases: MolecularInteraction

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

__init__(halogen: Atom, _acceptor: Atom, distance: float, angle: float, bond_type: str, _halogen_residue: str, _acceptor_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property halogen_residue: str#

Legacy property for halogen residue.

property donor: Atom#

Property accessor for donor atom (halogen).

property acceptor: Atom#

Property accessor for acceptor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to interaction point (0 for halogen bonds).

get_donor_acceptor_distance() float[source]#

Distance from halogen to acceptor.

get_donor_interaction_acceptor_angle() float[source]#

C-X…A angle.

is_donor_interaction_bonded() bool[source]#

Check if halogen is bonded to donor carbon.

For halogen bonds, the halogen atom must be covalently bonded to a carbon atom. The halogen serves as both the donor and interaction point.

Returns:

True (assumes validation was done during creation)

Return type:

bool

class hbat.core.interactions.PiInteraction(_donor: Atom, hydrogen: Atom, pi_center: NPVec3D, distance: float, angle: float, _donor_residue: str, _pi_residue: str)[source]#

Bases: MolecularInteraction

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 (NPVec3D) – 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

__init__(_donor: Atom, hydrogen: Atom, pi_center: NPVec3D, distance: float, angle: float, _donor_residue: str, _pi_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property pi_residue: str#

Legacy property for π residue.

property donor: Atom#

Property accessor for donor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to hydrogen.

get_donor_acceptor_distance() float[source]#

Distance from donor to π center.

get_donor_interaction_acceptor_angle() float[source]#

D-H…π angle.

is_donor_interaction_bonded() bool[source]#

Check if hydrogen is bonded to donor.

For X-H…π interactions, the hydrogen must be covalently bonded to the donor atom.

Returns:

True (assumes validation was done during creation)

Return type:

bool

property donor_acceptor_properties: str#

Get the donor-acceptor property description.

Returns:

Property description string

Return type:

str

get_backbone_sidechain_interaction() str[source]#

Get simplified backbone/sidechain interaction description.

Returns:

Interaction type (B-S, S-S, etc.)

Return type:

str

get_interaction_type_display() str[source]#

Get the interaction type for display purposes.

Returns:

Display format like “D-H…π”

Return type:

str

class hbat.core.interactions.CooperativityChain(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]#

Bases: MolecularInteraction

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

__init__(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]#
get_donor() Atom | NPVec3D[source]#

Get the donor of the first interaction in the chain.

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor of the last interaction in the chain.

get_interaction() Atom | NPVec3D[source]#

Get the center point of the chain (middle interaction point).

get_donor_residue() str[source]#

Get the donor residue of the first interaction.

get_acceptor_residue() str[source]#

Get the acceptor residue of the last interaction.

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Get the distance from chain start to middle interaction.

get_donor_acceptor_distance() float[source]#

Get the distance from chain start to end.

get_donor_interaction_acceptor_angle() float[source]#

Get the angle across the chain (donor-middle-acceptor).

is_donor_interaction_bonded() bool[source]#

Check if interactions in the chain satisfy bonding requirements.

For cooperativity chains, each individual interaction must satisfy its own bonding requirements.

Returns:

True if all interactions in chain are properly bonded

Return type:

bool

Base Classes#

MolecularInteraction#

class hbat.core.interactions.MolecularInteraction[source]#

Bases: ABC

Base class for all molecular interactions.

This abstract base class defines the unified interface for all types of molecular interactions analyzed by HBAT, including hydrogen bonds, halogen bonds, and π interactions.

All interactions have the following core components: - Donor: The electron/proton donor (atom or virtual atom) - Acceptor: The electron/proton acceptor (atom or virtual atom) - Interaction: The mediating atom/point (e.g., hydrogen, π center) - Geometry: Distances and angles defining the interaction - Bonding: The interaction atom must be bonded to the donor atom

Bonding Requirements: - For H-bonds: Hydrogen must be covalently bonded to the donor - For X-bonds: Halogen is covalently bonded to donor carbon - For X-H…π interactions: Hydrogen must be covalently bonded to the donor - For π-π stacking (future): No bonding requirement - uses centroid distances

Abstract base class defining the common interface for all molecular interactions.

Common Properties:

  • Interaction Type: Classification of the interaction

  • Participating Atoms: Atoms involved in the interaction

  • Geometric Parameters: Distance, angle, and orientation measurements

  • Energy Estimation: Approximate interaction strength

  • Validation Methods: Quality assessment and filtering

abstractmethod get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

abstractmethod get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

abstractmethod get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

abstractmethod get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

abstractmethod get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

abstractmethod get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

abstractmethod get_donor_interaction_distance() float[source]#

Get the donor to interaction distance.

Returns:

Distance from donor to interaction point in Angstroms

Return type:

float

abstractmethod get_donor_acceptor_distance() float[source]#

Get the donor to acceptor distance.

Returns:

Distance from donor to acceptor in Angstroms

Return type:

float

abstractmethod get_donor_interaction_acceptor_angle() float[source]#

Get the donor-interaction-acceptor angle.

Returns:

Angle in radians

Return type:

float

abstractmethod is_donor_interaction_bonded() bool[source]#

Check if the interaction atom is bonded to the donor atom.

This is a fundamental requirement for most molecular interactions (except π-π stacking which will be implemented separately).

Returns:

True if donor and interaction atom are bonded

Return type:

bool

property donor: Atom | NPVec3D#

Property accessor for donor.

property acceptor: Atom | NPVec3D#

Property accessor for acceptor.

property interaction: Atom | NPVec3D#

Property accessor for interaction.

property donor_residue: str#

Property accessor for donor residue.

property acceptor_residue: str#

Property accessor for acceptor residue.

property interaction_type: str#

Property accessor for interaction type.

property donor_interaction_distance: float#

Property accessor for donor-interaction distance.

property donor_acceptor_distance: float#

Property accessor for donor-acceptor distance.

property donor_interaction_acceptor_angle: float#

Property accessor for donor-interaction-acceptor angle.

get_donor_atom() Atom | None[source]#

Get the donor atom if it’s an Atom instance.

Returns:

The donor atom if it’s an Atom, None otherwise

Return type:

Optional[Atom]

get_acceptor_atom() Atom | None[source]#

Get the acceptor atom if it’s an Atom instance.

Returns:

The acceptor atom if it’s an Atom, None otherwise

Return type:

Optional[Atom]

property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

Specific Interaction Types#

Hydrogen Bonds#

class hbat.core.interactions.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: MolecularInteraction

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

Represents a hydrogen bond with donor-hydrogen-acceptor geometry.

Geometric Parameters:

  • Distance (D-A): Direct donor to acceptor distance

  • Distance (H-A): Hydrogen to acceptor distance

  • Angle (D-H…A): Donor-hydrogen-acceptor angle

  • Dihedral Angles: Additional geometric descriptors

Chemical Properties:

  • Donor Atom: Electronegative atom covalently bonded to hydrogen

  • Hydrogen Atom: Bridging hydrogen with partial positive charge

  • Acceptor Atom: Electronegative atom with lone electron pairs

  • Residue Context: Protein/nucleic acid environment

Usage Example:

from hbat.core.interactions import HydrogenBond
from hbat.core.pdb_parser import Atom

# Create hydrogen bond representation
hbond = HydrogenBond(
    donor=donor_atom,
    hydrogen=hydrogen_atom,
    acceptor=acceptor_atom,
    distance_da=2.8,
    distance_ha=1.9,
    angle_dha=165.0,
    energy=-2.5
)

# Validate interaction
if hbond.is_valid():
    print(f"Strong hydrogen bond: {hbond.energy:.1f} kcal/mol")
__init__(_donor: Atom, hydrogen: Atom, _acceptor: Atom, distance: float, angle: float, _donor_acceptor_distance: float, bond_type: str, _donor_residue: str, _acceptor_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property donor: Atom#

Property accessor for donor atom.

property acceptor: Atom#

Property accessor for acceptor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to hydrogen.

get_donor_acceptor_distance() float[source]#

Distance from donor to acceptor.

get_donor_interaction_acceptor_angle() float[source]#

D-H…A angle.

is_donor_interaction_bonded() bool[source]#

Check if hydrogen is bonded to donor.

For hydrogen bonds, the hydrogen must be covalently bonded to the donor atom. This method assumes the bond has been validated during creation.

Returns:

True (assumes validation was done during creation)

Return type:

bool

property donor_acceptor_properties: str#

Get the donor-acceptor property description.

Returns:

Property description string

Return type:

str

get_backbone_sidechain_interaction() str[source]#

Get simplified backbone/sidechain interaction description.

Returns:

Interaction type (B-B, B-S, S-B, S-S)

Return type:

str

Halogen Bonds#

class hbat.core.interactions.HalogenBond(halogen: Atom, _acceptor: Atom, distance: float, angle: float, bond_type: str, _halogen_residue: str, _acceptor_residue: str)[source]#

Bases: MolecularInteraction

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

Represents a halogen bond with carbon-halogen-acceptor geometry and σ-hole directionality.

Geometric Parameters:

  • Distance (X…A): Halogen to acceptor distance

  • Angle (C-X…A): Carbon-halogen-acceptor angle

  • σ-hole Direction: Electrostatic potential direction

  • Approach Angle: Acceptor approach to σ-hole

Chemical Properties:

  • Carbon Atom: Atom covalently bonded to halogen

  • Halogen Atom: Electron-deficient halogen (Cl, Br, I, F)

  • Acceptor Atom: Electron-rich acceptor (N, O, S)

  • σ-hole Strength: Depends on halogen polarizability

Usage Example:

from hbat.core.interactions import HalogenBond

# Create halogen bond representation
xbond = HalogenBond(
    carbon=carbon_atom,
    halogen=bromine_atom,
    acceptor=oxygen_atom,
    distance_xa=3.2,
    angle_cxa=172.0,
    sigma_hole_angle=5.0,
    energy=-1.8
)

# Check σ-hole directionality
if xbond.has_good_directionality():
    print(f"Well-directed halogen bond: {xbond.angle_cxa:.1f}°")
__init__(halogen: Atom, _acceptor: Atom, distance: float, angle: float, bond_type: str, _halogen_residue: str, _acceptor_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property halogen_residue: str#

Legacy property for halogen residue.

property donor: Atom#

Property accessor for donor atom (halogen).

property acceptor: Atom#

Property accessor for acceptor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to interaction point (0 for halogen bonds).

get_donor_acceptor_distance() float[source]#

Distance from halogen to acceptor.

get_donor_interaction_acceptor_angle() float[source]#

C-X…A angle.

is_donor_interaction_bonded() bool[source]#

Check if halogen is bonded to donor carbon.

For halogen bonds, the halogen atom must be covalently bonded to a carbon atom. The halogen serves as both the donor and interaction point.

Returns:

True (assumes validation was done during creation)

Return type:

bool

π Interactions#

class hbat.core.interactions.PiInteraction(_donor: Atom, hydrogen: Atom, pi_center: NPVec3D, distance: float, angle: float, _donor_residue: str, _pi_residue: str)[source]#

Bases: MolecularInteraction

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 (NPVec3D) – 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

Represents π interactions including π-π stacking and X-H…π contacts.

Geometric Parameters:

  • Centroid Distance: Distance between aromatic ring centers

  • Ring Angles: Angle between aromatic ring planes

  • Offset Parameters: Lateral displacement measurements

  • Approach Geometry: Face-to-face vs. edge-to-face orientation

Interaction Types:

  • π-π Stacking: Face-to-face aromatic ring interaction

  • T-shaped π-π: Edge-to-face aromatic contact

  • X-H…π: Hydrogen bond donor to π system

  • Cation-π: Positively charged group to π system

Usage Example:

from hbat.core.interactions import PiInteraction

# Create π-π stacking interaction
pi_interaction = PiInteraction(
    ring1_residue=phe_residue,
    ring2_residue=trp_residue,
    ring1_atoms=["CG", "CD1", "CD2", "CE1", "CE2", "CZ"],
    ring2_atoms=["CG", "CD1", "NE1", "CE2", "CD2"],
    centroid_distance=3.8,
    ring_angle=12.0,
    offset=1.2,
    interaction_type="stacking"
)

# Classify interaction geometry
if pi_interaction.is_stacking():
    print("Face-to-face π-π stacking detected")
elif pi_interaction.is_t_shaped():
    print("Edge-to-face T-shaped contact detected")
__init__(_donor: Atom, hydrogen: Atom, pi_center: NPVec3D, distance: float, angle: float, _donor_residue: str, _pi_residue: str)[source]#
property distance: float#

Legacy property for interaction distance.

Returns:

Donor-interaction distance for backward compatibility

Return type:

float

property angle: float#

Legacy property for interaction angle.

Returns:

Donor-interaction-acceptor angle for backward compatibility

Return type:

float

property pi_residue: str#

Legacy property for π residue.

property donor: Atom#

Property accessor for donor atom.

get_donor() Atom | NPVec3D[source]#

Get the donor atom or virtual atom.

Returns:

The donor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor atom or virtual atom.

Returns:

The acceptor atom or virtual atom position

Return type:

Union[Atom, NPVec3D]

get_interaction() Atom | NPVec3D[source]#

Get the interaction mediating atom or point.

Returns:

The mediating atom (e.g., hydrogen) or virtual point (e.g., π center)

Return type:

Union[Atom, NPVec3D]

get_donor_residue() str[source]#

Get the donor residue identifier.

Returns:

String identifier for the donor residue

Return type:

str

get_acceptor_residue() str[source]#

Get the acceptor residue identifier.

Returns:

String identifier for the acceptor residue

Return type:

str

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Distance from donor to hydrogen.

get_donor_acceptor_distance() float[source]#

Distance from donor to π center.

get_donor_interaction_acceptor_angle() float[source]#

D-H…π angle.

is_donor_interaction_bonded() bool[source]#

Check if hydrogen is bonded to donor.

For X-H…π interactions, the hydrogen must be covalently bonded to the donor atom.

Returns:

True (assumes validation was done during creation)

Return type:

bool

property donor_acceptor_properties: str#

Get the donor-acceptor property description.

Returns:

Property description string

Return type:

str

get_backbone_sidechain_interaction() str[source]#

Get simplified backbone/sidechain interaction description.

Returns:

Interaction type (B-S, S-S, etc.)

Return type:

str

get_interaction_type_display() str[source]#

Get the interaction type for display purposes.

Returns:

Display format like “D-H…π”

Return type:

str

Cooperativity Chains#

class hbat.core.interactions.CooperativityChain(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]#

Bases: MolecularInteraction

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

Represents chains of cooperative molecular interactions where the strength of one interaction influences neighboring interactions.

Chain Properties:

  • Sequential Connectivity: Ordered list of connected interactions

  • Chain Length: Number of interactions in the cooperative chain

  • Cumulative Strength: Total interaction energy with cooperativity effects

  • Topology: Linear, branched, or cyclic chain organization

Cooperativity Effects:

  • Enhancement: Neighboring interactions strengthen each other

  • Anti-cooperativity: Interactions compete and weaken each other

  • Resonance Assistance: Shared electron delocalization effects

  • Geometric Constraints: Structural organization influences

Usage Example:

from hbat.core.interactions import CooperativityChain

# Create cooperativity chain
coop_chain = CooperativityChain(
    interactions=[hbond1, hbond2, hbond3],
    chain_type="linear",
    enhancement_factor=1.15,
    total_energy=-8.2
)

# Analyze cooperative effects
individual_energy = sum(i.energy for i in coop_chain.interactions)
cooperative_enhancement = coop_chain.total_energy / individual_energy

print(f"Cooperativity enhancement: {cooperative_enhancement:.2f}x")
__init__(interactions: List[HydrogenBond | HalogenBond | PiInteraction], chain_length: int, chain_type: str)[source]#
get_donor() Atom | NPVec3D[source]#

Get the donor of the first interaction in the chain.

get_acceptor() Atom | NPVec3D[source]#

Get the acceptor of the last interaction in the chain.

get_interaction() Atom | NPVec3D[source]#

Get the center point of the chain (middle interaction point).

get_donor_residue() str[source]#

Get the donor residue of the first interaction.

get_acceptor_residue() str[source]#

Get the acceptor residue of the last interaction.

get_interaction_type() str[source]#

Get the interaction type.

Returns:

String identifier for the interaction type

Return type:

str

get_donor_interaction_distance() float[source]#

Get the distance from chain start to middle interaction.

get_donor_acceptor_distance() float[source]#

Get the distance from chain start to end.

get_donor_interaction_acceptor_angle() float[source]#

Get the angle across the chain (donor-middle-acceptor).

is_donor_interaction_bonded() bool[source]#

Check if interactions in the chain satisfy bonding requirements.

For cooperativity chains, each individual interaction must satisfy its own bonding requirements.

Returns:

True if all interactions in chain are properly bonded

Return type:

bool

Validation and Quality Assessment#

Geometric Validation:

All interaction classes provide validation methods to assess interaction quality:

# Standard validation checks
if interaction.is_valid():
    print("Interaction passes geometric criteria")

if interaction.is_strong():
    print("Interaction has favorable energy")

quality_score = interaction.get_quality_score()
print(f"Interaction quality: {quality_score:.2f}")

Distance Criteria:

  • Hydrogen bonds: 2.5-3.5 Å (donor-acceptor)

  • Halogen bonds: 3.0-4.0 Å (halogen-acceptor)

  • π interactions: 3.5-5.5 Å (centroid-centroid)

Angular Criteria:

  • Hydrogen bonds: >120° (D-H…A angle)

  • Halogen bonds: >150° (C-X…A angle)

  • π interactions: <30° (ring plane angle for stacking)

Energy Estimation#

Energy Models:

Each interaction type uses empirical energy functions based on geometric parameters:

# Hydrogen bond energy (Lippincott-Schroeder)
energy_hb = -2.0 * exp(-distance/2.0) * cos(angle)**2

# Halogen bond energy (empirical)
energy_xb = -1.5 * (R_vdw/distance)**6 * cos(angle)**4

# π interaction energy (Hunter-Sanders)
energy_pi = -2.5 * exp(-distance/3.5) * orientation_factor

Energy Units:

  • All energies reported in kcal/mol

  • Negative values indicate favorable interactions

  • Typical ranges: -0.5 to -5.0 kcal/mol for most interactions

Data Persistence#

Serialization Support:

All interaction classes support JSON serialization for data storage:

import json
from dataclasses import asdict

# Convert interaction to dictionary
interaction_dict = asdict(hydrogen_bond)

# Save to JSON
with open("interactions.json", "w") as f:
    json.dump(interaction_dict, f, indent=2)

Database Integration:

Interaction objects can be easily stored in databases or converted to pandas DataFrames for analysis:

import pandas as pd

# Convert interactions to DataFrame
interaction_data = [asdict(i) for i in interactions]
df = pd.DataFrame(interaction_data)

# Analysis and filtering
strong_hbonds = df[df.energy < -2.0]
print(f"Found {len(strong_hbonds)} strong hydrogen bonds")