ChemPlot icon indicating copy to clipboard operation
ChemPlot copied to clipboard

Hide hydrogens when using interactive_plot to render 2D image of molecules

Open shkao opened this issue 3 years ago • 3 comments

Hi mcsorkun,

Thanks a lot for the great tool. Just wondering, what would be the best way to hide all the hydrogens when using the interactive_plot? I tried to preprocess the smiles by rdkit.Chem.rdmolops.RemoveHs, but in the bokeh HTML the 2D images rendered by interactive_plot are still with hydrogens, for example: image

Would be great to have an option in interactive_plot to do this.

shkao avatar Apr 12 '22 14:04 shkao

Hi @shkao, Apologizes for the late reply! Currently each Plotter object keep track of the rdkit Mol objects within an attribute __mols. The latter is used by interactive_plot() in order to draw the molecules. Therefore currently in order to remove the hydrogens you will need to modify this attribute before calling interactive_plot() with, for example, the following line:

plotter_instance._Plotter__mols = [Chem.RemoveHs(mol) for mol in plotter_instance._Plotter__mols]

Thank you for the suggestion! We discuss adding an option to remove hydrogens in interactive_plot() for the next sub-release!

dajtmullaj avatar May 06 '22 16:05 dajtmullaj

Hi @dajtmullaj,

Thank you, works like a charm now! And I also found it integrated perfectly with Streamlit. A very nice package, thanks again! :-) Do you want me to close this issue now, or wait until the enhancement feature is done?

shkao avatar May 09 '22 04:05 shkao

@shkao I'll prefer to leave it open for now! We will soon start development on small enhancement features as the one we just discussed and I will close it then as you suggested :) I am glad you are enjoying the package :) Don't hesitate to let us know future suggestions!

dajtmullaj avatar May 10 '22 15:05 dajtmullaj