import pandas as pd
import mols2grid
smiles = ["CCO", "c1ccccc1", "N", "CO", "O=S(=O)(-O)(-O)", "CCC", "CCC=O"]
df = pd.DataFrame({"smi": smiles,
"id": range(1, len(smiles) + 1)})
mg = mols2grid.MolGrid(df, smiles_col="smi", size=(110, 90))
mg.display(subset=["id", "img"], n_cols=7)
I was trying to visualize a list of SMILES, as shown in your colab. But I got the following error message.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-26-cbf1ce952db4> in <module>
7 "id": range(1, len(smiles) + 1)})
8 # setup the grid
----> 9 mg = mols2grid.MolGrid(df, smiles_col="smi", size=(110, 90))
10 mg.display(subset=["id", "img"], n_cols=7)
~/anaconda3/lib/python3.7/site-packages/mols2grid/molgrid.py in __init__(self, df, smiles_col, mol_col, coordGen, useSVG, mapping, **kwargs)
74 dataframe.dropna(axis=0, subset=[mol_col], inplace=True)
75 # generate drawings
---> 76 dataframe["img"] = dataframe[mol_col].apply(self.mol_to_img, **kwargs)
77 self.dataframe = dataframe
78 self.mol_col = mol_col
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
4133 else:
4134 values = self.astype(object)._values
-> 4135 mapped = lib.map_infer(values, f, convert=convert_dtype)
4136
4137 if len(mapped) and isinstance(mapped[0], Series):
pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in f(x)
4118
4119 def f(x):
-> 4120 return func(x, *args, **kwds)
4121
4122 else:
~/anaconda3/lib/python3.7/site-packages/mols2grid/molgrid.py in mol_to_img(self, mol, **kwargs)
170 """Convert an RDKit mol to an HTML img tag containing a drawing of the
171 molecule"""
--> 172 img = self.draw_mol(mol, **kwargs)
173 if self.useSVG:
174 return img
~/anaconda3/lib/python3.7/site-packages/mols2grid/molgrid.py in draw_mol(self, mol, size, use_coords, MolDrawOptions, **kwargs)
158 for key, value in kwargs.items():
159 setattr(MolDrawOptions, key, value)
--> 160 d2d.SetDrawOptions(MolDrawOptions)
161 if not use_coords:
162 mol = deepcopy(mol)
AttributeError: 'MolDraw2DSVG' object has no attribute 'SetDrawOptions'