Skip to content

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).

SurfaceEntry point
CLIsci-form sssr "<SMILES>"
Rustsci_form::compute_sssr(smiles)
Pythonsci_form.compute_sssr(smiles)

Stereochemistry ​

analyze_stereo combines four detectors:

  1. Tetrahedral centres with CIP priorities obtained from the substituent trees.
  2. Double bonds with E/Z from the highest-priority substituent on each side.
  3. Atropisomeric axes for hindered biaryls.
  4. 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
SurfaceEntry point
CLIsci-form stereo "<SMILES>" [--coords "<flat-json>"]
Rustsci_form::analyze_stereo(smiles, &positions)
Pythonsci_form.analyze_stereo(smiles, coords)

Graph feature analysis ​

analyze_graph_features is the corpus-level companion to analyze_stereo. It returns:

  • aromatic_atoms and aromatic_bonds (indices include explicit hydrogens);
  • tagged_tetrahedral_centers from @/@@ tags;
  • inferred_tetrahedral_centers from 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.

rust
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]);
python
features = sci_form.analyze_graph_features("c1ccccc1")
print(features.aromatic_atoms.count(True), features.aromatic_bonds)
SurfaceEntry point
Rustsci_form::analyze_graph_features(smiles)
Pythonsci_form.analyze_graph_features(smiles) (alias graph_features)
WASManalyze_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.
  • CCO has no rings.
  • C(F)(Cl)(Br)I has one tetrahedral centre with CIP priorities I > Br > Cl > F; topology-only reports no configuration, and a tetrahedral coordinate set reports S.
  • C[C@H](F)Cl from the embedded geometry reports centre 1 as S.
  • The coordinate slice is either empty (topology only) or exactly 3N finite values. Truncated, extra or non-finite coordinates are rejected instead of producing a partial configuration or panicking. ValueError is raised in Python and {"error": ...} is returned by WASM.

Released under the MIT License.