1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use fmt;
use Molecule;
use BondDescriptor;
/// A stochastic fragment: one `[bd]SMILES[bd]` unit inside a stochastic object.
///
/// Each fragment represents one possible repeat unit (before `;`) or end group (after `;`).
///
/// # Example
///
/// For the input `[$]CC(C)[$]` (polypropylene repeat unit):
/// - `left` = `[$]` (NonDirectional, no index)
/// - `smiles_raw` = `"CC(C)"` (original string, preserved verbatim for display)
/// - `molecule` = propane (3 C atoms, 2 bonds)
/// - `left_atom` = 0 (first written C connects to the left BD)
/// - `right_atom` = 1 (second written C connects to the right BD; the branch C is at index 2)
/// - `right` = `[$]` (NonDirectional, no index)
///
/// # Connection atoms
///
/// In BigSMILES the atom ordering within the SMILES string is semantically significant:
/// - The **left** bond descriptor always connects to the **first written atom** (index 0).
/// - The **right** bond descriptor connects to the **last atom on the main chain** —
/// i.e., the last atom encountered at parenthesis depth 0.
///
/// Re-canonicalising the SMILES (e.g. `CC(C)` → `CCC`) would silently change which
/// atoms bear the descriptors, turning polypropylene into polypropane. `smiles_raw`
/// preserves the original notation; the parsed `molecule` and `{left,right}_atom` are
/// kept for structural analysis and future polymer-chain generation.