Alsallam alaykom. I am using rdkit and py3dmol in pycharm, where I faced problem in making drawings visible.

it gives me for rdkit drawings:

and for py3dmol drawings gives nothing.

In jupyter everthing is going OK

the full code is provided below

import py3Dmol import copy from rdkit import Chem from rdkit.Chem import Draw from rdkit.Chem.Draw import IPythonConsole from rdkit.Chem import AllChem from rdkit.Chem import rdBase from rdkit.Chem import rdMolAlign from rdkit.Chem import rdMolDescriptors import numpy as np import streamlit as st p=AllChem.ETKDGv3() p.verbose=True mols=[m for m in Chem.SDMolSupplier('cdk2.sdf') if m !=None] [:2] for mol in mols: mol.RemoveAllConformers() hmols_1=[Chem.AddHs(m) for m in mols] hmols_2=copy.deepcopy(hmols_1) #generate 100 conformers per molcule for mol in hmols_1: AllChem.EmbedMultipleConfs(mol,100,p) for mol in hmols_2: AllChem.EmbedMultipleConfs(mol,100,p) writer=Chem.SDWriter('hmols_1.sdf') for mol in hmols_1: writer.write(mol) #import matplotlib.pyplot as plt #import PIL as pl #Draw.MolsToGridImage(mols) #fig.show() #from IPython.display import display, Image Draw.MolsToGridImage(mols) #IPythonConsole.display.display(fig) #fig.show() #.MolsToGridImage(mols) #st.image(Draw._drawerToImage().show()) # %% ### assignign force field scores crippen_contribs=[rdMolDescriptors._CalcCrippenContribs(mol) for mol in hmols_1] crippen_ref_contrib=crippen_contribs[0] crippen_prob_contribs=crippen_contribs[1:] ref_mol1=hmols_1[0] prob_mols_1=hmols_1[1:] mmff_params=[AllChem.MMFFGetMoleculeProperties(mol) for mol in hmols_2] mmff_ref_param=mmff_params[0] mmff_prob_params=mmff_params[1:] ref_mol2=hmols_2[0] prob_mols_2=hmols_2[1:] # %% ## allign using forcefield p_crippen=py3Dmol.view(width=600, height=400) p_crippen.addModel(Chem.MolToMolBlock(ref_mol1),'sdf') crippen_score=[] for idx, mol in enumerate(prob_mols_1): tempscore=[] for cid in range (100): crippenO3A=rdMolAlign.GetCrippenO3A(mol,ref_mol1,crippen_prob_contribs[idx],crippen_ref_contrib,cid,0) crippenO3A.Align() tempscore.append(crippenO3A.Score()) best=np.argmax(tempscore) p_crippen.addModel (Chem.MolToMolBlock(mol,confId=int(best)),'sdf') crippen_score.append(tempscore[best]) #p_crippen.setStyle({'stick': {}}) p_crippen.render() p_crippen p_crippen.show()

More Mohammed Nooraldeen Al-Qattan's questions See All
Similar questions and discussions