rdkit: Draw.DrawMorganBits(Pyrene) gives error
Configuration:
- RDKit Version: 2019.09.3
- Operating system: Win 10
- Python version (if relevant): 3.7
- Are you using conda? yes
- If you are using conda, which channel did you install the rdkit from?
Description:
If I run
mol = Chem.MolFromSmiles(smiles)
dic = {}
fp = AllChem.GetMorganFingerprintAsBitVect(mol, 2, nBits=5000, bitInfo=dic)
fp_arr = np.zeros(1,)
DataStructs.ConvertToNumpyArray(fp, fp_arr)
fp_arr = np.nonzero(fp_arr)
prints = [(mol_list[num], x, dic) for x in fp.GetOnBits()]
img = Draw.DrawMorganBits(prints, molsPerRow=10, legends=[str(x) for x in fp.GetOnBits()])
img.save('bits.png')
on > 100 different molecules I can extract the finger print bits and visualize the images of them, but once I try to get the fingerprints for a molecule containing a pyrene in it I recieve an error like the one below…
Traceback (most recent call last):
File "C:/Users/computer/PycharmProjects/untitled5/venv/rdkit_test.py", line 42, in <module>
img = Draw.DrawMorganBits(prints, molsPerRow=10, legends=[str(x) for x in fp.GetOnBits()])
File "C:\Users\computer\Anaconda3\envs\my-rdkit-env\lib\site-packages\rdkit\Chem\Draw\IPythonConsole.py", line 248, in DrawMorganBits
return _DrawBit(fn, *args, drawOptions=drawOptions, **kwargs)
File "C:\Users\computer\Anaconda3\envs\my-rdkit-env\lib\site-packages\rdkit\Chem\Draw\IPythonConsole.py", line 206, in _DrawBit
res = fn(*args, **kwargs)
File "C:\Users\computer\Anaconda3\envs\my-rdkit-env\lib\site-packages\rdkit\Chem\Draw\__init__.py", line 600, in DrawMorganBits
return DrawMorganEnvs(envs, **kwargs)
File "C:\Users\computer\Anaconda3\envs\my-rdkit-env\lib\site-packages\rdkit\Chem\Draw\__init__.py", line 724, in DrawMorganEnvs
highlightBondColors=bondColors, highlightAtomRadii=highlightRadii, **kwargs)
rdkit.Chem.rdchem.KekulizeException: Can't kekulize mol. Unkekulized atoms: 0 1 2 3 4 5 6 7 8 9 11 12 13
Your code sample here
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (6 by maintainers)
@jhjensen2 Hi Jan, here’s a monkey patch you can use to avoid the problem: