from_smiles
¶
Converts a SMILES string to a GraphData,
with the featurization of PyG's from_smiles (see from_rdmol()).
An invalid SMILES string gives an empty molecule (no atoms), as in PyG.
Requires rdkit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
smiles
|
str
|
The SMILES string. |
required |
with_hydrogen
|
bool
|
Whether to add the hydrogens to the graph.
Default: |
False
|
kekulize
|
bool
|
Whether to convert the aromatic bonds to single and double
bonds. Default: |
False
|
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph, with |
GraphData
|
9] |
GraphData
|
SMILES string in its |
Example:
from mlx_graphs.utils import from_smiles, to_smiles
graph = from_smiles("CCO")
>>> GraphData(
edge_index(shape=(2, 4), int32)
node_features(shape=(3, 9), int32)
edge_features(shape=(4, 3), int32)
smiles=CCO)
to_smiles(graph)
>>> 'CCO'
Source code in mlx_graphs/utils/smiles.py
from mlx_graphs.utils import from_smiles · mlx_graphs/utils/smiles.py