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.
| Molecule | TPSA (Ų) |
|---|---|
| Ethanol | 20.23 |
| Benzene | 0.00 |
| Acetic acid | 37.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]
| Field | Meaning |
|---|---|
molecular_weight, n_heavy_atoms, n_hydrogens, n_bonds | Composition and graph size |
n_rotatable_bonds | Single heavy-atom bonds, not in rings |
n_hbd, n_hba | N-H/O-H donors and N/O acceptors |
fsp3 | Fraction of four-coordinate carbons |
total_abs_charge, max_charge, min_charge | Gasteiger charge summaries |
wiener_index | Sum of graph shortest-path distances |
n_rings, n_aromatic | Cycle count and aromatic atoms |
balaban_j | Bond-order weighted Balaban index |
sum_electronegativity, sum_polarizability | Atomic-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:
| Molecule | MW | n_aromatic | total_abs_charge | Balaban J |
|---|---|---|---|---|
ethanol CCO | 46.06900000000002 | 0 | 0.8770485170010166 | 4.1447263667447585 |
benzene c1ccccc1 | 78.11399999999996 | 6 | 0.7473192980309791 | 3.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
| Capability | CLI | Rust / Python |
|---|---|---|
| Charges | sci-form charges "<SMILES>" | compute_charges |
| Configured charges | sci-form charges-configured "<SMILES>" --max-iter N | compute_charges_configured |
| TPSA | sci-form tpsa "<SMILES>" | compute_tpsa |
| ECFP | sci-form ecfp "<SMILES>" -r 2 -n 2048 | compute_ecfp |
| ECFP batch | sci-form ecfp-batch '["CCO","c1ccccc1"]' | compute_ecfp_batch |
| Tanimoto | sci-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_configuredrequires an integermax_iter >= 1and finiteinitial_dampingin(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_ecfpandcompute_ecfp_batchrequire0 <= radius <= 100and64 <= n_bits <= 1,048,576; empty/whitespace SMILES are parse errors.compute_ecfp_batchpreserves 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 withValueError/{"error": ...}; the legacy Rustcompute_tanimotokeeps the raw Jaccard value for compatibility, andrings::ecfp::try_compute_tanimotois the checked variant. - RMSD/Kabsch alignment is documented separately in molecular alignment.