Convert between Open babel, Pybel, and RDkit to handle mol files

RDkit, Open Babel, and Pybel are indispensable libraries for doing chemoinformatics in Python.All libraries can perform molecular operations and descriptor generation for machine learning, but there are some operations that can only be done with that package or can be implemented more easily.

Basically, various operations are performed starting from converting a compound into a mol object.Of course, the mol object created in each library cannot be read by another library, so it needs to be converted.

Convert from Open Babel to Pybel

There is a dedicated conversion module from Mol of Openbabel to mol of Pybel.

#Create openbabel format mol from Smiles import openbabel obConversion.SetInFormat ("smi") obmol = openbabel.OBMol () obConversion.ReadString (obmol, "C1 = CC = CS1") obmol

>

Convert Openbabel mol to pybel mol with #Molucule () import pybel pybelmol = pybel.Molecule (obmol) pybelmol

Conversion from Open Babel, Pybel to RDkit

Output mol of Open Babel or Pybel as an SDF file, and then read it with RDkit.The reverse route is also via SDF.

from rdkit import Chem pybelmol.write ("sdf", "outputfile.sdf") rdmol = Chem.SDMolSupplier ('outputfile.sdf') rdmol