15
15
from pymatgen .core .structure import IMolecule , Molecule
16
16
17
17
try :
18
- from openbabel import openbabel
19
- from openbabel import pybel as pb
18
+ from openbabel import openbabel , pybel
20
19
except Exception :
21
20
openbabel = None
22
21
@@ -75,7 +74,7 @@ def __init__(self, mol):
75
74
self ._obmol = ob_mol
76
75
elif isinstance (mol , openbabel .OBMol ):
77
76
self ._obmol = mol
78
- elif isinstance (mol , pb .Molecule ):
77
+ elif isinstance (mol , pybel .Molecule ):
79
78
self ._obmol = mol .OBMol
80
79
81
80
@property
@@ -102,9 +101,9 @@ def localopt(self, forcefield="mmff94", steps=500):
102
101
'mmff94', 'mmff94s', and 'uff'.
103
102
steps: Default is 500.
104
103
"""
105
- pbmol = pb .Molecule (self ._obmol )
106
- pbmol .localopt (forcefield = forcefield , steps = steps )
107
- self ._obmol = pbmol .OBMol
104
+ pybelmol = pybel .Molecule (self ._obmol )
105
+ pybelmol .localopt (forcefield = forcefield , steps = steps )
106
+ self ._obmol = pybelmol .OBMol
108
107
109
108
def make3d (self , forcefield = "mmff94" , steps = 50 ):
110
109
"""
@@ -125,9 +124,9 @@ def make3d(self, forcefield="mmff94", steps=50):
125
124
'mmff94', 'mmff94s', and 'uff'.
126
125
steps: Default is 50.
127
126
"""
128
- pbmol = pb .Molecule (self ._obmol )
129
- pbmol .make3D (forcefield = forcefield , steps = steps )
130
- self ._obmol = pbmol .OBMol
127
+ pybelmol = pybel .Molecule (self ._obmol )
128
+ pybelmol .make3D (forcefield = forcefield , steps = steps )
129
+ self ._obmol = pybelmol .OBMol
131
130
132
131
def add_hydrogen (self ):
133
132
"""Add hydrogens (make all hydrogen explicit)."""
@@ -288,7 +287,7 @@ def confab_conformers(
288
287
@property
289
288
def pybel_mol (self ):
290
289
"""Returns Pybel's Molecule object."""
291
- return pb .Molecule (self ._obmol )
290
+ return pybel .Molecule (self ._obmol )
292
291
293
292
def write_file (self , filename , file_format = "xyz" ):
294
293
"""
@@ -298,7 +297,7 @@ def write_file(self, filename, file_format="xyz"):
298
297
filename: Filename of file to output
299
298
file_format: String specifying any OpenBabel supported formats.
300
299
"""
301
- mol = pb .Molecule (self ._obmol )
300
+ mol = pybel .Molecule (self ._obmol )
302
301
return mol .write (file_format , filename , overwrite = True )
303
302
304
303
@staticmethod
@@ -316,7 +315,7 @@ def from_file(filename, file_format="xyz", return_all_molecules=False):
316
315
Returns:
317
316
BabelMolAdaptor object or list thereof
318
317
"""
319
- mols = pb .readfile (str (file_format ), str (filename ))
318
+ mols = pybel .readfile (str (file_format ), str (filename ))
320
319
if return_all_molecules :
321
320
return [BabelMolAdaptor (mol .OBMol ) for mol in mols ]
322
321
@@ -348,5 +347,5 @@ def from_string(string_data, file_format="xyz"):
348
347
Returns:
349
348
BabelMolAdaptor object
350
349
"""
351
- mols = pb .readstring (str (file_format ), str (string_data ))
350
+ mols = pybel .readstring (str (file_format ), str (string_data ))
352
351
return BabelMolAdaptor (mols .OBMol )
0 commit comments