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
61
62
63
64
65
66
/// Batch SMILES canonicalization using RENKIN's own canonicalizer
/// (`chem_env::to_canonical`), the same function `propose_one_step`/
/// `merge_into_candidates` use to produce `precursor_smiles` strings in the
/// candidate pool. Ground-truth label sources (e.g. raw reaction datasets)
/// must be canonicalized through this exact path -- not a third-party
/// toolkit's canonical form -- or exact-string label matching in
/// `train_reranker.py::label_and_split_rows` will silently mismatch.
///
/// Reads SMILES from stdin (one per line), writes canonical SMILES to
/// stdout (one line per input line, same order). Outputs "ERR" for
/// unparseable input so line-alignment with the input is always preserved.
///
/// `--clear-atom-maps`: structurally clear each atom's atom-map number
/// (`chem_env::clear_atom_maps`) before canonicalizing -- input SMILES may
/// be atom-mapped (`[CH3:1]O`). Never strip atom maps by regex/string
/// manipulation on SMILES text upstream of this binary: `:` is also SMILES
/// bond syntax, so a text-level strip can corrupt a ring-closure digit that
/// happens to follow an explicit bond symbol (see
/// `chem_env::clear_atom_maps_tests::explicit_colon_bond_with_ring_closure_digit_is_not_corrupted`
/// for a concrete case). Without this flag, atom maps in the input are
/// preserved in the output canonical SMILES, unchanged from prior behavior.
///
/// Usage:
/// cargo build --release --bin renkin-canonicalize
/// echo "CC(=O)Oc1ccccc1C(=O)O" | ./target/release/renkin-canonicalize
/// echo "[CH3:1]O" | ./target/release/renkin-canonicalize --clear-atom-maps