Open Babel optimizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os | |
from openbabel import pybel | |
# read through multiple files on command-line | |
for argument in sys.argv[1:]: | |
filename, extension = os.path.splitext(argument) | |
# read the molecule from the supplied file | |
for mol in pybel.readfile(extension[1:], argument): | |
ff = pybel._forcefields["mmff94"] | |
success = ff.Setup(mol.OBMol) | |
if not success: | |
ff = pybel._forcefields["uff"] | |
success = ff.Setup(mol.OBMol) | |
if not success: | |
sys.exit("Cannot set up forcefield") | |
ff.ConjugateGradients(100, 1.0e-3) | |
ff.WeightedRotorSearch(100, 25) | |
ff.ConjugateGradients(250, 1.0e-4) | |
ff.GetCoordinates(mol.OBMol) | |
mol.write("sdf", "test.sdf", overwrite=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment