Installation via pip install molify. For more information please visit the
documentation.
A common use case is to create 3D structures from SMILES strings. This can be
achieved using the molify.rdkit2ase function.
import ase
from rdkit import Chem
from molify import rdkit2ase, ase2rdkit
mol = Chem.MolFromSmiles("O")
atoms: ase.Atoms = rdkit2ase(mol)
mol = ase2rdkit(atoms)Because this is such a common use case, there is a convenience function
molify.smiles2atoms that combines the two steps.
import ase
from molify import smiles2atoms
atoms: ase.Atoms = smiles2atoms("O")
print(atoms)
>>> Atoms(symbols='OH2', pbc=False)Given the molecular units, you can build periodic boxes with a given density
using the molify.pack function.
If you have packmol (at least v20.15.0) you
can use the molify interface as follows:
from molify import pack, smiles2conformers
water = smiles2conformers("O", 2)
ethanol = smiles2conformers("CCO", 5)
density = 1000 # kg/m^3
box = pack([water, ethanol], [7, 5], density)
print(box)
>>> Atoms(symbols='C10H44O12', pbc=True, cell=[8.4, 8.4, 8.4])Many additional features are described in the documentation.