rxn.chemutils.miscellaneous.canonicalize_any
- rxn.chemutils.miscellaneous.canonicalize_any(any_smiles, check_valence=True, sort_molecules=False, fallback_value=None)[source]
Canonicalize any SMILES string (molecule SMILES, multicomponent SMILES, reaction SMILES).
In the case of reaction SMILES, the format is kept.
- Parameters
any_smiles (
str
) – any kind of SMILES string.check_valence (
bool
, default:True
) – if False, will not do any valence check.sort_molecules (
bool
, default:False
) – whether to sort the compounds alphabetically at the same time.fallback_value (
Optional
[str
], default:None
) – what value to returns when the canonicalization is unsuccessful. Default: no fallback, will propagate the exception.
- Raises
Exception – different kinds of exception may be raised during parsing.
InvalidSmiles – for canonicalization errors.
- Return type
str
- Returns
the canonical (molecule, multicomponent, or reaction) SMILES string.