smiles_writer
SMILES string generation from molecular graphs.
Generates canonical SMILES strings using DFS traversal with support for: - Ring closures - Aromaticity - Stereochemistry (R/S, E/Z) - Charges and isotopes
smiles_from_molecule(molecule, canonical=True)
Generate SMILES from a Molecule object.
Convenience function that creates a MolecularGraph and generates SMILES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
molecule
|
A Molecule object from chmpy. |
required | |
canonical
|
bool
|
If True, generate canonical SMILES (default True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
SMILES string. |
Source code in chmpy/graph/smiles_writer.py
to_smiles(graph, canonical=True, explicit_h=False, guess_charges=False)
Generate a SMILES string from a molecular graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph instance. |
required |
canonical
|
bool
|
If True, generate canonical SMILES (default True). |
True
|
explicit_h
|
bool
|
If True, include explicit hydrogens (default False). |
False
|
guess_charges
|
bool
|
If True, automatically detect and assign formal charges for common functional groups (nitro, carboxylate, etc.). |
False
|
Returns:
| Type | Description |
|---|---|
str
|
SMILES string representation of the molecule. |