pymatgen.io.babel module

class BabelMolAdaptor(mol)[source]

Bases: object

Adaptor serves as a bridge between OpenBabel’s Molecule and pymatgen’s Molecule.

Initializes with pymatgen Molecule or OpenBabel”s OBMol.

Parameters:mol – pymatgen’s Molecule or OpenBabel OBMol
static from_file(filename, file_format='xyz')[source]

Uses OpenBabel to read a molecule from a file in all supported formats.

Parameters:
  • filename – Filename of input file
  • file_format – String specifying any OpenBabel supported formats.
Returns:

BabelMolAdaptor object

static from_string(string_data, file_format='xyz')[source]

Uses OpenBabel to read a molecule from a string in all supported formats.

Parameters:
  • string_data – String containing molecule data.
  • file_format – String specifying any OpenBabel supported formats.
Returns:

BabelMolAdaptor object

localopt(forcefield='mmff94', steps=500)[source]

A wrapper to pybel’s localopt method to optimize a Molecule.

Parameters:
  • forcefield – Default is mmff94. Options are ‘gaff’, ‘ghemical’, ‘mmff94’, ‘mmff94s’, and ‘uff’.
  • steps – Default is 500.
openbabel_mol

Returns OpenBabel’s OBMol.

pybel_mol

Returns Pybel’s Molecule object.

pymatgen_mol

Returns pymatgen Molecule object.

write_file(filename, file_format='xyz')[source]

Uses OpenBabel to output all supported formats.

Parameters:
  • filename – Filename of file to output
  • file_format – String specifying any OpenBabel supported formats.