Skip to content

Detect

This module provides functionality to detect protonation sites in molecules using substructure matching with comprehensive error handling and validation.

ProtonationSiteDetectionError

Bases: Exception

Raised when protonation site detection encounters an error.

ProtonationSiteDetector(validate_sites=True, max_sites_per_molecule=50)

Robust detector for finding protonation sites in molecules.

Uses substructure matching to identify potential protonation sites based on known pKa patterns. Handles atom protection to prevent overlapping matches.

Initialize the detector with explicit configuration.

PARAMETER DESCRIPTION
validate_sites

Whether to validate detected sites (explicit, not default)

TYPE: bool DEFAULT: True

max_sites_per_molecule

Maximum sites to detect per molecule (bounded)

TYPE: int DEFAULT: 50

max_sites_per_molecule = max_sites_per_molecule

pka_data = PKaData()

validate_sites = validate_sites

find_sites(mol_record)

Find protonation sites in a molecule. This is the main entry point.

PARAMETER DESCRIPTION
mol_record

MoleculeRecord to analyze

TYPE: MoleculeRecord

RETURNS DESCRIPTION
tuple[MoleculeRecord, list[ProtonationSite]]

Tuple of (updated_mol_record, list_of_protonation_sites)

RAISES DESCRIPTION
ProtonationSiteDetectionError

If detection fails critically

get_stats()

Get detection statistics.

RETURNS DESCRIPTION
dict[str, int]

Dictionary of detection statistics

reset_stats()

Reset all detection statistics to zero.

canonicalize_smiles_list(mols, original_smiles='')

Generate canonical SMILES from molecule objects.

PARAMETER DESCRIPTION
mols

List of RDKit mol objects to convert

TYPE: list[Mol]

original_smiles

Original SMILES for logging context

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
list[str]

List of unique canonical SMILES strings

find(mol_record, validate_sites=True, max_sites_per_molecule=50)

Convenience function for finding protonation sites with default settings.

PARAMETER DESCRIPTION
mol_record

MoleculeRecord to analyze

TYPE: MoleculeRecord

RETURNS DESCRIPTION
tuple[MoleculeRecord, list[ProtonationSite]]

Tuple of (updated_mol_record, list_of_protonation_sites)