Skip to main content

Module organic_chemistry

Module organic_chemistry 

Source
Expand description

Organic Chemistry Engine.

Pure-Rust implementations of core organic-chemistry primitives:

  • SMILES parsing & molecular graph building
  • Molecular formula, exact weight, and isotope-aware mass
  • Lipinski Rule-of-Five, Veber, Ghose, Egan drug-likeness filters
  • LogP (Crippen–Wildman atomic contributions, 25 atom types)
  • TPSA (Ertl 2000 atomic contributions)
  • H-bond donors / acceptors, rotatable bonds, aromatic ring count
  • Functional group detection (20 groups via SMARTS-inspired pattern matching)
  • Chiral centre enumeration
  • Morgan circular fingerprint generation
  • Thermochemistry: Arrhenius, Gibbs–Helmholtz, van’t Hoff, Henderson–Hasselbalch
  • Green chemistry: atom economy, E-factor, PMI, RME, yield-adjusted AE
  • pKa estimation (functional-group based)
  • SMILES structural validation
  • InChI / InChIKey format validation

SHACL constraint name → function: qualia:validateSmilesvalidate_smiles() qualia:validateInchivalidate_inchi() qualia:computeMolecularWeightexact_molecular_weight() qualia:computeLogPcompute_logp() qualia:computeTPSAcompute_tpsa() qualia:evaluateLipinskievaluate_lipinski() qualia:evaluateVeberevaluate_veber() qualia:evaluateGhoseevaluate_ghose() qualia:evaluateEganevaluate_egan() qualia:detectFunctionalGroupsdetect_functional_groups() qualia:computePkaestimate_pka() qualia:computeChiralCenterscount_chiral_centers() qualia:generateCircularFingerprintcircular_fingerprint() qualia:computeArrheniusRatearrhenius_rate() qualia:computeGibbsEnergygibbs_free_energy() qualia:computeEquilibriumequilibrium_constant() qualia:computeHendersonHasselbalchhenderson_hasselbalch() qualia:computeAtomEconomyatom_economy() qualia:computeEFactore_factor() qualia:computeGreenMetricsgreen_metrics()

Structs§

Atom
BbbPermeationResult
Bond
EganResult
GhoseResult
GreenMetrics
InchiValidation
IsotopeDistribution
LipinskiResult
MolecularDescriptors
Molecule
PkaEstimate
SmilesValidation
VeberResult

Enums§

BondOrder
FunctionalGroup

Constants§

R_J_MOL_K
Universal gas constant J / (mol·K)

Functions§

arrhenius_rate
Arrhenius rate constant k at temperature T (K). k = A × exp(−Ea / (R × T)) activation_energy_j_mol: Ea in J/mol
arrhenius_ratio
Temperature dependence of k using the Arrhenius equation. Returns (k_t1, k_t2).
atom_economy
Simplified atom economy (Trost): single product vs all reactants.
catalyst_activity
Catalyst activity at time t under first-order deactivation: a(t) = a₀·exp(−k_d·t). Models the degradation that limits sustained yield on small decentralized nodes.
circular_fingerprint
Morgan algorithm: radius-r circular fingerprint as sorted Vec identifiers.
compute_descriptors
Compute all Lipinski/Veber/Ghose descriptors from a parsed molecule.
compute_logp
Per-atom LogP contributions mapped by (element, aromaticity, polar_neighbour). Derived from Wildman & Crippen 1999, Table 1 (25 of 68 atom types).
compute_tpsa
Topological polar surface area in Ų.
conversion_under_variable_temperature
Total fractional conversion of a first-order reaction under a variable temperature profile — e.g. fluctuating off-grid power driving a fluctuating reactor temperature. Integrates dX/dt = k(T)·(1−X) across temp_profile_k (k from the Arrhenius rate, explicit-Euler steps of dt_s), returning the final conversion X ∈ [0,1]. Zero-heap (the profile is a caller slice).
count_chiral_centers
Count sp3 carbon atoms with 4 distinct substituents (simplified: sp3 C with degree 4).
deactivated_reaction_rate
Effective reaction rate accounting for catalyst decay: r_eff = r_base · a(t)/a₀.
detect_functional_groups
Detect functional groups in a molecule. Returns unique set.
e_factor
E-factor (Sheldon): waste_kg / product_kg. Fine chemicals < 50; bulk < 5; pharma 25–100.
equilibrium_constant
Equilibrium constant from ΔG°: K = exp(−ΔG° / (R × T))
estimate_pka
Estimate pKa values from functional group type (literature reference values).
evaluate_egan
evaluate_ghose
evaluate_lipinski
evaluate_veber
exact_molecular_weight
Exact monoisotopic molecular weight (Da).
formula_string
Hill-order formula string (C first, H second, then others alphabetically).
gibbs_free_energy
Gibbs free energy ΔG = ΔH − T × ΔS (all in J/mol or kJ/mol consistently).
gibbs_from_equilibrium
ΔG° from equilibrium constant K: ΔG° = −R × T × ln(K)
gibbs_helmholtz
Gibbs–Helmholtz: ΔG(T2) from ΔG(T1).
green_metrics
henderson_hasselbalch
Henderson–Hasselbalch: pH = pKa + log10([A-] / [HA])
ionisation_fraction
Degree of ionisation α at a given pH for a monoprotic acid.
isotope_mass_distribution
Computes the theoretical M, M+1, M+2 isotopic distribution based on the number of Carbon, Nitrogen, Oxygen, Sulfur, Chlorine, and Bromine atoms.
ligand_efficiency
Computes Ligand Efficiency (LE): pIC50 / Heavy Atom Count (HAC). Standard target is LE >= 0.3.
lipophilic_ligand_efficiency
Computes Lipophilic Ligand Efficiency (LLE): pIC50 - LogP. Standard target is LLE >= 5.0.
molecular_formula
Atom counts by element symbol.
parse_smiles
Parse a SMILES string into a Molecule.
predict_bbb_permeation
Evaluates Blood-Brain Barrier (BBB) permeation probability using Clark’s rules (Molecular Weight, LogP, PSA, HBD).
urea_equilibrium_extent
Equilibrium extent ξ of the Bosch–Meiser urea synthesis 2 NH₃ + CO₂ ⇌ (NH₂)₂CO + H₂O, solved from the equilibrium constant (via the caller-supplied ΔG° at temp_k) and the initial NH₃/CO₂ partial pressures, by bisection on the reaction quotient Q(ξ) = ξ² / ((p_NH₃−2ξ)²·(p_CO₂−ξ)) (strictly increasing in ξ). Returns ξ in the same units as the input pressures. Simplified gas-phase model (industrial urea is liquid-phase/high-P — that shifts the numbers, not the method). Demonstrates Le Chatelier: higher reactant pressure ⇒ higher ξ.
validate_inchi
validate_smiles
vant_hoff_enthalpy
van’t Hoff enthalpy estimate from two equilibrium constants at two temperatures.