cbouy / mols2grid

Interactive molecule viewer for 2D structures

Home Page:https://mols2grid.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: is there a way to label atoms?

aced125 opened this issue · comments

This currently doesn't work for me. Example:

import mols2grid
from rdkit import Chem

mol = Chem.MolFromSmiles("c1ccncc1")

for i, atom in enumerate(mol.GetAtoms()):
    atom.SetProp("molAtomMapNumber", str(atom.GetIdx()+1))
    atom.SetProp("atomNote", "hi")

mols2grid.display([mol])
Screenshot 2023-08-11 at 23 34 02

You need to prerender images in order to do that:

mols2grid.display([mol], prerender=True)

Without this mols2grid will just use the SMILES string (which includes the atom map number in your example) to do the rendering browser-side which is faster.

Feel free to reopen the issue if you have another related question.

Cheers,
Cédric

thanks, appreciate that!