Rings and stereochemistry
Two graph analyses sit next to each other because both answer structural questions without requiring 3D coordinates for their topology stage.
SSSR
The Smallest Set of Smallest Rings is a minimum-weight cycle basis. The implementation removes each edge in turn, finds the shortest alternative path between its endpoints and keeps a linearly independent set of the shortest cycles.
flowchart LR
A[Molecular graph] --> B[Adjacency list]
B --> C[For each edge: remove it]
C --> D[Shortest path between endpoints]
D --> E[Cycle candidate]
E --> F[Minimum-weight independent basis]
F --> G[Rings + atom membership + histogram]
For naphthalene the result is two six-membered rings; the two fused carbons belong to both rings. Acyclic molecules return an empty ring list. Empty or malformed SMILES are errors (ValueError in Python, {"error": ...} in WASM).
| Surface | Entry point |
|---|---|
| CLI | sci-form sssr "<SMILES>" |
| Rust | sci_form::compute_sssr(smiles) |
| Python | sci_form.compute_sssr(smiles) |
Stereochemistry
analyze_stereo combines four detectors:
- Tetrahedral centres with CIP priorities obtained from the substituent trees.
- Double bonds with E/Z from the highest-priority substituent on each side.
- Atropisomeric axes for hindered biaryls.
- Prochiral centres and helical chirality descriptors.
The topology stage reports the centre, its substituents and CIP priorities but leaves configuration empty. R/S requires 3D coordinates; the sign of the tetrahedron formed by substituents 1–2–3 with the lowest-priority group pointing away gives the configuration.
flowchart LR
A[SMILES graph] --> B[Tetrahedral centre detection]
B --> C[CIP priority trees]
A --> D[Double-bond detection]
D --> E[E/Z priority comparison]
C --> F{3D coordinates?}
F -- yes --> G[Signed tetrahedron: R/S]
F -- no --> H[Topology only]
E --> I[Stereo analysis]
G --> I
H --> I
| Surface | Entry point |
|---|---|
| CLI | sci-form stereo "<SMILES>" [--coords "<flat-json>"] |
| Rust | sci_form::analyze_stereo(smiles, &positions) |
| Python | sci_form.analyze_stereo(smiles, coords) |
Graph feature analysis
analyze_graph_features is the corpus-level companion to analyze_stereo. It returns:
aromatic_atomsandaromatic_bonds(indices include explicit hydrogens);tagged_tetrahedral_centersfrom@/@@tags;inferred_tetrahedral_centersfrom CIP substituent trees.
The inferred list uses the same four-distinct-substituent test as find_stereocenters, not an element-count heuristic. For example, C(F)(Cl)(Cl)Br has three element types but two identical chlorine substituents, so it is not a tetrahedral centre; C(F)(Cl)(Br)I is.
let features = sci_form::analyze_graph_features("C(F)(Cl)(Br)I")?;
assert_eq!(features.aromaticity.aromatic_bonds.len(), 0);
assert_eq!(features.stereocenters.inferred_tetrahedral_centers, vec![0]);features = sci_form.analyze_graph_features("c1ccccc1")
print(features.aromatic_atoms.count(True), features.aromatic_bonds)| Surface | Entry point |
|---|---|
| Rust | sci_form::analyze_graph_features(smiles) |
| Python | sci_form.analyze_graph_features(smiles) (alias graph_features) |
| WASM | analyze_graph_features(smiles) |
There is no dedicated CLI command. Empty or malformed SMILES are rejected.
Validation
- Benzene: one six-membered ring; naphthalene: two six-membered rings.
CCOhas no rings.C(F)(Cl)(Br)Ihas one tetrahedral centre with CIP priorities I > Br > Cl > F; topology-only reports no configuration, and a tetrahedral coordinate set reportsS.C[C@H](F)Clfrom the embedded geometry reports centre 1 asS.- The coordinate slice is either empty (topology only) or exactly
3Nfinite values. Truncated, extra or non-finite coordinates are rejected instead of producing a partial configuration or panicking.ValueErroris raised in Python and{"error": ...}is returned by WASM.