Skip to content

Commit

Permalink
Fix missed fialed embedding check bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jessbade committed Feb 23, 2024
1 parent 8233598 commit 26bf720
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions isicle/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def __init__(self, **kwargs):
self.__dict__.update(dict.fromkeys(self._defaults, self._default_value))
self.__dict__.update(kwargs)

def _is_embedded(self):
def _is_embedded(self, mol):
"""
Check if molecule has embedded 3D coordinates.
Expand All @@ -311,7 +311,7 @@ def _is_embedded(self):
"""

try:
self.mol.GetConformers()
mol.GetConformer().Is3D()
return True
except:
return False
Expand Down Expand Up @@ -386,17 +386,17 @@ def _forcefield_selector(forcefield, mw):
# Embed molecule 3D coordinates
if embed is True:
# Attempt embedding
try:
Chem.AllChem.EmbedMolecule(mol)

# Use random coordinates
except:
Chem.AllChem.EmbedMolecule(mol, useRandomCoords=True)
res = Chem.AllChem.EmbedMolecule(mol)
if res == -1:
# Use random coordinates
res = Chem.AllChem.EmbedMolecule(mol, useRandomCoords=True)
if res == -1:
raise ValueError("Embedding failure.")

# Optimize according to supplied forcefield
if forcefield is not None:
# Check if embedded
if self._is_embedded():
if self._is_embedded(mol):
# Forcefield selection
if "mmff94s" in forcefield.lower():
_forcefield_selector(forcefield, mol)(
Expand Down

0 comments on commit 26bf720

Please sign in to comment.