Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on SDMolSupplier when kekulize is False #1880

Open
jaechanglim opened this issue May 29, 2018 · 1 comment
Open

error on SDMolSupplier when kekulize is False #1880

jaechanglim opened this issue May 29, 2018 · 1 comment

Comments

@jaechanglim
Copy link

Description:

  • RDKit Version: '2018.03.1'
  • Platform: linux centos

when I ran the following code, the error occured. The error message is as follow

File "check2.py", line 7, in
print (Chem.MolToSmiles(m))
Boost.Python.ArgumentError: Python argument types in
rdkit.Chem.rdmolfiles.MolToSmiles(NoneType)
did not match C++ signature:
MolToSmiles(RDKit::ROMol mol, bool isomericSmiles=True, bool kekuleSmiles=False, int rootedAtAtom=-1, bool canonical=True, bool allBondsExplicit=False, bool allHsExplicit=False)

If I remove 'rdmolfiles.SDWriter.SetKekulize(w, False)', there's no problem (For some reason the molecule should not be keulized when writing sdf file)

My code is

from rdkit import Chem
from rdkit.Chem import rdmolfiles
w = Chem.SDWriter('tmp.sdf')
rdmolfiles.SDWriter.SetKekulize(w, False)
w.write(Chem.MolFromSmiles('CC(c1cc(=O)[nH]c(n1)N1CCN(CC1)c1ccccc1)C'))
m = Chem.SDMolSupplier('tmp.sdf')[0]
print (Chem.MolToSmiles(m))

Anyone knows the reason or solution?

Thank you

@greglandrum
Copy link
Member

Here is the underlying cause of the problem:

In [2]: m = Chem.MolFromSmiles('CC(c1cc(=O)[nH]c(n1)N1CCN(CC1)c1ccccc1)C')

In [3]: mb = Chem.MolToMolBlock(m,kekulize=False)

In [4]: nm =Chem.MolFromMolBlock(mb)
[05:09:07] Can't kekulize mol.  Unkekulized atoms: 2 3 6 7 8

and the simplest form:

In [5]: m = Chem.MolFromSmiles('c1ccc[nH]1')

In [6]: mb = Chem.MolToMolBlock(m,kekulize=False)

In [7]: nm =Chem.MolFromMolBlock(mb)
[05:11:37] Can't kekulize mol.  Unkekulized atoms: 0 1 2 3 4

Though I don't see this as a very urgent problem (according to the MDL documentation, aromatic bonds are only supposed to be in Mol files for queries, and you wouldn't sanitize a query), it probably should still be fixed.

@jaechanglim : why do you need the aromatic bonds in the SD file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants