Conformer ensembles and diversity
embed_diverse runs several independent embeddings with consecutive seeds and keeps one representative per Butina RMSD cluster. It is the cheapest way to answer "what conformers exist?" without a full force-field search.
Pipeline
flowchart LR
A[SMILES] --> B[Seed base..base+n-1]
B --> C[N independent embeddings]
C --> D{Any success?}
D -- no --> E[Return error records]
D -- yes --> F[Pairwise Kabsch RMSD]
F --> G[Butina neighbour lists]
G --> H[Cluster centroids]
H --> I[Diverse ensemble]
Seeds and attempts
n_conformers is the number of attempts, not a promise of that many output conformers. Seeds are base_seed .. base_seed + n_conformers - 1, so the same (smiles, n_conformers, rmsd_cutoff, base_seed) is reproducible.
If every attempt fails (invalid SMILES, unsupported element), the error records are returned instead of an empty vector. The CLI turns an all-error result into exit code 1.
Butina clustering
- Compute the Kabsch RMSD between every pair of successful conformers.
- Build each conformer's neighbour list with
RMSD <= cutoff(self included). - Select the conformer with the most neighbours as a centroid, remove its neighbours, and repeat.
- Return the centroid coordinates in cluster order.
The cutoff is a real distance in Å and must be finite and positive. 0 would make every conformer its own singleton cluster; it is rejected by the CLI and by the checked Python/WASM clustering wrappers. Every conformer must be a non-empty finite 3N array with the same atom count for all members.
UFF conformer search
search_conformers_with_uff is the force-field-ranked search, distinct from the cheap embed_diverse ensemble. It generates up to n_samples embeddings with consecutive seeds, preconditions each with Monte Carlo torsion sampling and a greedy rotatable-bond pass, scores it with UFF, sorts by energy, and collapses structures whose Kabsch RMSD is below rmsd_threshold.
flowchart LR
A[SMILES] --> B[n_samples embeddings]
B --> C[MC torsion sampling]
C --> D[Greedy torsion refinement]
D --> E[UFF energy]
E --> F[Sort by energy]
F --> G[Kabsch RMSD dedup]
G --> H[Clusters + representatives]
let result = sci_form::search_conformers_with_uff("CCCC", 10, 42, 0.2)?;
println!("{} generated, {} unique, {} rotatable bonds",
result.generated, result.unique, result.rotatable_bonds);
for conformer in &result.conformers {
println!("seed {} {:.3} kcal/mol", conformer.seed, conformer.energy_kcal_mol);
}| Surface | Entry point |
|---|---|
| Rust | search_conformers_with_uff(smiles, n_samples, seed, rmsd_threshold) |
| Python | search_conformers_with_uff(...) (deprecated search_conformers) |
| WASM | search_conformers_with_uff[_seed64] |
| CLI | not exposed |
n_samples ≥ 1 and rmsd_threshold must be finite and > 0; otherwise the call is rejected. The threshold is in Å and is applied to the aligned RMSD. generated counts successful embeddings before deduplication, unique is the number of retained representatives, and clusters maps every representative to its member seeds. Energies are UFF kcal/mol and are only comparable within one molecule.
Limitations: UFF is a classical force field, the search is stochastic (the seed controls reproducibility), and no quantum refinement or Boltzmann weighting is applied. A large threshold intentionally collapses all structures into one cluster; that is useful as a test but not as a conformer search.
Surfaces
| Surface | Entry point |
|---|---|
| CLI | sci-form embed-diverse "<SMILES>" --n-conformers 10 --rmsd-cutoff 1.0 --base-seed 42 |
| CLI | sci-form filter-diverse '<coords-json>' --rmsd-cutoff 1.0 |
| Rust | sci_form::embed_diverse(smiles, n, cutoff, seed) |
| Python | sci_form.embed_diverse(smiles, n_conformers, rmsd_cutoff, base_seed) |
| WASM | embed_diverse(smiles, n_conformers, rmsd_cutoff, base_seed) |
Validation
- Same base seed reproduces the same coordinates; a different base seed changes them.
- Ethanol with two attempts returns one or two centroids, each with nine atoms and no error.
- An invalid SMILES returns one error record per attempt; the CLI exits 1.
n_conformers = 0and non-positive cutoffs are rejected by the CLI.