Skip to content

Commit

Permalink
Add option to skip 3D generation in getOBMol()
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf-meyer committed Mar 7, 2024
1 parent 35714b8 commit 6b78b7f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions molSimplify/Classes/mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,9 +1440,9 @@ def findsubMol(self, atom0, atomN, smart=False):
return subm

@classmethod
def from_smiles(cls, smiles):
def from_smiles(cls, smiles, gen3d: bool = True):
mol = cls()
mol.getOBMol(smiles, "smistring")
mol.getOBMol(smiles, "smistring", gen3d=gen3d)

elem = globalvars().elementsbynum()
# Add atoms
Expand Down Expand Up @@ -2291,7 +2291,7 @@ def getAngle(self, idx0, idx1, idx2):
angle = vecangle(v1, v2)
return angle

def getOBMol(self, fst, convtype, ffclean=False):
def getOBMol(self, fst, convtype, ffclean=False, gen3d=True):
"""
Get OBMol object from a file or SMILES string. If you have a mol3D,
then use convert2OBMol instead.
Expand All @@ -2304,6 +2304,8 @@ def getOBMol(self, fst, convtype, ffclean=False):
Input filetype (xyz,mol,smi).
ffclean : bool, optional
Flag for forcefield cleanup of structure. Default is False.
gen3d: bool, optional
Flag for 3D structure generation using openbabel.OBBuilder
Returns
-------
Expand All @@ -2321,8 +2323,9 @@ def getOBMol(self, fst, convtype, ffclean=False):
obConversion.ReadFile(OBMol, fst)
if 'smi' in convtype:
OBMol.AddHydrogens()
b = openbabel.OBBuilder()
b.Build(OBMol)
if gen3d:
b = openbabel.OBBuilder()
b.Build(OBMol)
if ffclean:
forcefield = openbabel.OBForceField.FindForceField('mmff94')
forcefield.Setup(OBMol)
Expand Down

0 comments on commit 6b78b7f

Please sign in to comment.