Skip to content

Charges, TPSA and fingerprints ​

This page covers the fast 2D descriptors that share only the molecular graph: Gasteiger–Marsili charges, topological polar surface area (TPSA) and ECFP fingerprints with Tanimoto similarity.

Gasteiger–Marsili charges ​

Each atom starts with its formal charge and an electronegativity polynomial χ(q) = a + b q + c q². Every iteration transfers charge along each bond towards the more electronegative atom, damped by a factor that halves each step. The loop stops when the largest transfer falls below the convergence threshold (default 1e-10) or after the iteration cap (default 100).

flowchart LR
    A[Molecular graph] --> B[Formal charges]
    B --> C[Electronegativity polynomials]
    C --> D[Bond charge transfer]
    D --> E[Apply damping]
    E --> F{max transfer < tol?}
    F -- no --> C
    F -- yes --> G[Converged charges]

For ethanol the result sums to zero, the oxygen carries about −0.397 e and the hydroxyl hydrogen about +0.210 e. charges uses the converging default; charges-configured --max-iter N exposes the cap for experiments.

TPSA ​

TPSA sums tabulated polar-fragment contributions (Ertl et al.) over N, O, P and S atoms and their attached hydrogens. It is reported in Ų and needs no 3D coordinates.

MoleculeTPSA (Ų)
Ethanol20.23
Benzene0.00
Acetic acid37.30
Methanethiol (CS)38.80
Phosphoric acid (OP(=O)(O)O)87.57

compute_tpsa_from_smiles rejects empty/whitespace or malformed SMILES. The raw Rust compute_tpsa(elements, bonds) is the tolerant low-level helper; compute_tpsa_checked validates non-empty elements (1..=118), bond indices, self-bonds and bond orders 1..=4.

ML descriptors and proxy properties ​

compute_ml_descriptors(smiles) builds the graph-only descriptor vector used by the property proxies. Charges are Gasteiger–Marsili and aromatic atoms are derived from aromatic bonds, so the charge and aromatic fields are populated even when the caller only supplies a SMILES.

flowchart LR
    A[SMILES] --> B[Molecular graph]
    B --> C[Gasteiger charges]
    B --> D[Aromatic bonds]
    B --> E[Topology: rings, Wiener, Balaban]
    C --> F[MolecularDescriptors]
    D --> F
    E --> F
    F --> G[predict_ml_properties]
FieldMeaning
molecular_weight, n_heavy_atoms, n_hydrogens, n_bondsComposition and graph size
n_rotatable_bondsSingle heavy-atom bonds, not in rings
n_hbd, n_hbaN-H/O-H donors and N/O acceptors
fsp3Fraction of four-coordinate carbons
total_abs_charge, max_charge, min_chargeGasteiger charge summaries
wiener_indexSum of graph shortest-path distances
n_rings, n_aromaticCycle count and aromatic atoms
balaban_jBond-order weighted Balaban index
sum_electronegativity, sum_polarizabilityAtomic-property sums

Gasteiger parameters do not cover every element. For a molecule containing an element without parameters (for example [Fe]), the charge summaries are reported as zero while the topology descriptors remain available; this is a documented fallback, not a silent failure of the whole descriptor call.

Measured values:

MoleculeMWn_aromatictotal_abs_chargeBalaban J
ethanol CCO46.0690000000000200.87704851700101664.1447263667447585
benzene c1ccccc178.1139999999999660.74731929803097913.6035674514745475

predict_ml_properties(smiles) applies the proxy models to those descriptors. For benzene the aromatic correction gives logP 1.24057 and molar refractivity 42.929232; treating the six aromatic atoms as zero would understate both. The models are Additive proxies, not trained GNNs or publication-grade predictors.

ECFP and Tanimoto ​

The Extended-Connectivity Fingerprint hashes Morgan-style atom environments:

flowchart LR
    A[Molecular graph] --> B[Initial atom invariants]
    B --> C[Neighbourhood refinement]
    C --> D[Hash each environment]
    D --> E[Set bits modulo n_bits]
    E --> F[ECFP fingerprint]
    F --> G["Tanimoto: |A∩B| / |A∪B|"]

Radius 2 is ECFP4 and radius 3 is ECFP6. Hashes are deterministic and the output keeps the raw feature hashes alongside the on-bit indices. Tanimoto is dimensionless in [0, 1]: identical fingerprints give 1, disjoint fingerprints give 0, and the metric is symmetric.

Surfaces ​

CapabilityCLIRust / Python
Chargessci-form charges "<SMILES>"compute_charges
Configured chargessci-form charges-configured "<SMILES>" --max-iter Ncompute_charges_configured
TPSAsci-form tpsa "<SMILES>"compute_tpsa
ECFPsci-form ecfp "<SMILES>" -r 2 -n 2048compute_ecfp
ECFP batchsci-form ecfp-batch '["CCO","c1ccccc1"]'compute_ecfp_batch
Tanimotosci-form tanimoto "CCO" "CCN"compute_tanimoto

Validation ​

  • Gasteiger charges sum to zero and match the RDKit fixture (F21). Empty/whitespace SMILES are parse errors; compute_charges_configured requires an integer max_iter >= 1 and finite initial_damping in (0, 1].
  • TPSA reproduces the Ertl fragment values above for N, O, P and S. Empty/malformed SMILES are errors; the raw Rust helper is tolerant and the checked variant rejects invalid elements/bonds.
  • ECFP is deterministic for a fixed radius and bit width; Tanimoto is 1 for identical molecules and 0 for disjoint fingerprints.
  • compute_ecfp and compute_ecfp_batch require 0 <= radius <= 100 and 64 <= n_bits <= 1,048,576; empty/whitespace SMILES are parse errors. compute_ecfp_batch preserves input order and matches the single-molecule fingerprints. An empty list returns an empty list; any invalid SMILES rejects the whole batch.
  • Tanimoto requires both fingerprints to use the same radius and n_bits. Python/WASM reject mismatched or malformed fingerprints with ValueError / {"error": ...}; the legacy Rust compute_tanimoto keeps the raw Jaccard value for compatibility, and rings::ecfp::try_compute_tanimoto is the checked variant.
  • RMSD/Kabsch alignment is documented separately in molecular alignment.

Released under the MIT License.