Convert¶
| Function | Description |
|---|---|
to_networkx() |
Converts a mlx_graphs.data.GraphData instance to a a directed networkx.DiGraph otherwise. |
from_networkx() |
Converts a networkx.Graph or networkx.DiGraph to a mlx_graphs.data.GraphData instance. |
| Function | Description |
|---|---|
from_pyg() |
Converts a torch_geometric.data.Data object to a mlx_graphs.data.GraphData. |
to_pyg() |
Converts a mlx_graphs.data.GraphData to a torch_geometric.data.Data object. |
Molecules¶
Conversions between molecules (RDKit molecules or SMILES strings) and
GraphData, with the featurization of PyG.
RDKit is an optional dependency, imported only when one of these functions is
called (pip install rdkit).
| Function | Description |
|---|---|
from_smiles() |
Converts a SMILES string to a GraphData, with the featurization of PyG's from_smiles (see from_rdmol()). |
to_smiles() |
Converts a GraphData with the features of from_smiles() to a (canonical, isomeric) SMILES string, as PyG's to_smiles. |
from_rdmol() |
Converts an RDKit molecule (rdkit.Chem.Mol) to a GraphData, with the features of PyG's from_rdmol. |
to_rdmol() |
Converts a GraphData with the features of from_rdmol() back to an RDKit molecule, as PyG's to_rdmol. |
The node features of from_smiles are, for each atom, the indices of its
properties in the lists of mlx_graphs.utils.x_map, and the edge features the
indices of the bond properties in mlx_graphs.utils.e_map (the same tables as
PyG's torch_geometric.utils.smiles):
| Map | Features, in column order |
|---|---|
x_map |
atomic_num, chirality, degree, formal_charge, num_hs, num_radical_electrons, hybridization, is_aromatic, is_in_ring |
e_map |
bond_type, stereo, is_conjugated |