NetworkX InterfaceΒΆ
[1]:
import networkx as nx
import rdkit2ase
[2]:
water = rdkit2ase.smiles2conformers("O", numConfs=10)
etoh = rdkit2ase.smiles2conformers("CCO", numConfs=10)
box = rdkit2ase.pack(
data=[water, etoh], counts=[5, 5], density=800, packmol="packmol.jl"
)
[3]:
graph = rdkit2ase.ase2networkx(box)
print(f"Graph with {len(graph)} atoms and {len(graph.edges())} bonds.")
Graph with 60 atoms and 50 bonds.
[4]:
molecules = len(list(nx.connected_components(graph)))
print(f"Found {molecules} molecules")
Found 10 molecules
[5]:
rdkit2ase.networkx2rdkit(graph)
[5]:

Some information, like pbc
and box
size are silently lost.
[6]:
rdkit2ase.networkx2ase(graph)
[6]:
Atoms(symbols='OH2OH2OH2OH2OH2C2OH6C2OH6C2OH6C2OH6C2OH6', pbc=True, cell=[8.728901107040366, 8.728901107040366, 8.728901107040366], initial_charges=...)