Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoes committed Jul 1, 2022
1 parent bd54584 commit 71cf2cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion alignmcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse, sys, rdkit, collections
from rdkit.Chem import AllChem as Chem
from rdkit.Chem import rdMolAlign
from rdkit.Chem.rdShape import Align
from rdkit.Chem.rdMolAlign import AlignMol
from rdkit.Chem import rdMolAlign
from rdkit.Chem import rdFMCS
Expand Down
2 changes: 1 addition & 1 deletion rdconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def getRMS(mol, c1,c2):
converged = not Chem.UFFOptimizeMolecule(mol,confId=conf)
cenergy.append(Chem.UFFGetMoleculeForceField(mol,confId=conf).CalcEnergy())
if options.verbose:
print("Convergence of conformer",conf,converged)
print("Convergence of conformer",conf,converged,cenergy[-1])

mol = Chem.RemoveHs(mol)
sortedcids = sorted(cids,key = lambda cid: cenergy[cid])
Expand Down
19 changes: 11 additions & 8 deletions uffminimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
parser = OptionParser(usage="Usage: %prog [options] <input>.sdf <output>.sdf")
parser.add_option("-v","--verbose", dest="verbose",action="store_true",default=False,
help="verbose output")

parser.add_option("-a","--add_hydrogens", dest="addh",action="store_true",default=False,
help="add hydrogens")


(options, args) = parser.parse_args()
Expand All @@ -18,31 +19,33 @@

inmols = Chem.SDMolSupplier(input)
if inmols is None:
print "Could not open ".input
print("Could not open ".input)
sys.exit(-1)

sdwriter = Chem.SDWriter(output)
if sdwriter is None:
print "Could not open ".output
print("Could not open ".output)
sys.exit(-1)

for mol in inmols:
if mol is not None:
try:
if options.addh:
mol = Chem.AddHs(mol,addCoords=True)
orig = Chem.UFFGetMoleculeForceField(mol).CalcEnergy()
a=Chem.UFFOptimizeMolecule(mol)

#sometimes the UFF Optimization does not converge (returns a 1 instead of 0)
if a==1:
a=Chem.UFFOptimizeMolecule(mol, maxIter=1000)
a=Chem.UFFOptimizeMolecule(mol, maxIters=1000)

if options.verbose:
e = Chem.UFFGetMoleculeForceField(mol).CalcEnergy()
print mol.GetProp('_Name'),orig,"->",e
print(mol.GetProp('_Name'),orig,"->",e)
sdwriter.write(mol)
except (KeyboardInterrupt, SystemExit):
raise
except:
print "Exception occurred",mol.GetProp('_Name')
except:
print("Exception occurred",mol.GetProp('_Name'))
else:
print "ERROR"
print("ERROR")

0 comments on commit 71cf2cc

Please sign in to comment.