Structural descriptor parity
Reference: RDKit 2025.09.6, default sanitization/aromaticity model with
SmilesParserParams.removeHs = False. The 21 SQL functions introduced in
f428ef1 are exercised through their exported Rust C ABI functions.
Measured contract
- 4,510 distinct SMILES inputs, 21 outputs each: 94,710 comparisons.
- Integers must match exactly. Fractions, heavy atom mass and mean degree must be finite and within 1e-9 absolute error; no percentage tolerance.
- Corpus: the existing curated organic/drug-like set, deterministic randomized and Kekule spellings, explicit H, radicals, fused/bridged/large rings, and all 118 elements and all nonzero isotope masses exposed by the reference table for mass numbers 1-350. These are not 4,510 independent drug molecules; a large part of the corpus is isolated element/isotope coverage.
- Expected values are generated independently by RDKit and checked into
crates/smiles/tests/data/rdkit_profile.tsv. Rust tests need no RDKit install.
Hydrogen atoms in the input are retained on both sides. Explicit H is the
number of H vertices plus the sum of RDKit atom GetNumExplicitHs() values
on non-H atoms. Implicit H sums GetNumImplicitHs() on non-H atoms. RDKit
sanitization promotes pyrrolic N/P hydrogen to explicit H even when the input
was written in unbracketed Kekule form. Total H is their sum.
Bond counts include explicit H bonds, so comparing against RDKit's default
H-removing parser is not the same contract. Ring size uses the perceived
symmetrized SSSR, not the largest possible graph cycle. Mean degree is
2 * heavy-heavy edges / heavy atoms, not the degree including hydrogen.
Fractions and mean degree return zero when there are no heavy atoms.
Heavy atom mass uses the pinned RDKit average weights for unlabelled atoms
and isotope masses for labelled atoms, excluding all H isotopes. Numerical
periodic-table data are generated by scripts/gen_profile_weights.py; no
RDKit code or library is required at runtime. Other mass APIs are unchanged.
Reproduce
uv run --python 3.12 --with rdkit==2025.9.6 python scripts/gen_profile_fixtures.py
uv run --python 3.12 --with rdkit==2025.9.6 python scripts/gen_profile_weights.py
CARGO_TARGET_DIR=/private/tmp/rusta-ducksmiles-parity-target cargo test -p ducksmiles_smiles --test profile_parity
CARGO_TARGET_DIR=/private/tmp/rusta-ducksmiles-parity-target cargo test --workspace
The generator fixes the reference version and random seeds. It does not fetch
an external molecular database or discard mismatches. The full source corpus
and reference formulas are available in scripts/gen_profile_fixtures.py.
Corrected discrepancies
- Atomic-weight rounding differences (e.g. sulfur and chlorine), missing elements and ignored isotope labels in heavy atom mass.
- Explicit/implicit partition of pyrrolic H after aromatic perception.
- Aromatic macrocycles beyond eight atoms.
- Fused systems whose aromatic atoms share a non-aromatic fusion bond.
- Neutral nitrogen radicals incorrectly treated as aromatic lone-pair donors.
- Lone-pair contributions when a fused system is already partly aromatic.
Limits
Passing this finite corpus does not prove equivalence on every molecule. Full RDKit sanitization, exotic valences, coordination/dative bonds, arbitrary radical/charged aromatic systems, unsupported notation and arbitrary complex ring topologies remain outside the parity guarantee. Invalid-input acceptance is not claimed to match RDKit. The parser must not be used as a substitute for RDKit chemical validation. No broad PubChem/ChEMBL benchmark or experimental property-prediction accuracy is claimed.
Validation here covers the Rust implementation and C ABI. The DuckDB extension binary/community release must be rebuilt separately; pushing this branch does not update an already installed extension. Workspace tests include the older descriptor, canonicalization, ring and fingerprint regression suites. General repository formatting/Clippy checks also expose unrelated existing formatting and raw-pointer FFI lint issues; they are not represented as clean checks.
References: RDKit aromaticity, atom API, HeavyAtomMolWt.