mols2grid
10 minutes of fame: mols2grid ¶
Author: Paul Czodrowski
Date: 02.09.2021
http://www.czodrowskilab.org/ | http://twitter.com/czodrowskipaul |
---|---|
http://www.czodrowskilab.org/music | http://github.com/czodrowskilab |
Inspired by Pat Walter's (https://github.com/PatWalters/chem_tutorial, https://twitter.com/wpwalters) recent talk (recorded: https://youtu.be/2ZjerAGS_IQ)
Pat gave a talk (slides: https://github.com/PatWalters/chem_tutorial/blob/main/2021_08_19_Chem_Tutorial.pdf; code: https://github.com/PatWalters/chem_tutorial) as part of the RSC CICAG Open Chemical Sciences workshop series.
As an interesting matter of fact Pat is using binder (www.mybinder.org) for direct access and execution of his notebooks (https://mybinder.org/v2/gh/PatWalters/chem_tutorial/HEAD): this is awesome!
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
from rdkit.Chem import rdDepictor
IPythonConsole.ipython_useSVG = True
rdDepictor.SetPreferCoordGen(True)
import mols2grid
mols = [x for x in Chem.SDMolSupplier("example_compounds.sdf")]
Here comes the cool thing: mols2grid for a neat display of a list of molecules¶
mols2grid (https://github.com/cbouy/mols2grid) is developed by Cédric Bouysset (https://twitter.com/cedricbouysset, https://cedric.bouysset.net/) and can be simply installed via conda
mols2grid.display(mols)
mols2grid.selection
Now a few more tricks I found on Cedric'c Colab notebook (https://colab.research.google.com/github/cbouy/mols2grid/blob/master/demo.ipynb):
# example dataframe
import pandas as pd
smiles = ["CCO", "c1ccccc1", "N", "CO", "O=S(=O)(-O)(-O)", "CCC", "CCC=O"]
df = pd.DataFrame({"smi": smiles,
"id": range(1, len(smiles) + 1)})
# setup the grid
mg = mols2grid.MolGrid(df, smiles_col="smi", size=(110, 90))
mg.display(subset=["id", "img"], n_cols=7)