Hi Tim,

after you are done removing the atoms you can do loop through remaining
ring atoms and bonds and clear aromatic flags, e.g.

from rdkit import Chem

rwmol = Chem.RWMol(Chem.MolFromSmiles("c1ccccc1"))
rwmol.RemoveAtom(0)

for a in rwmol.GetAtoms():
    if (not a.IsInRing()) and a.GetIsAromatic():
        a.SetIsAromatic(False)
for b in rwmol.GetBonds():
    if (not b.IsInRing()) and b.GetIsAromatic():
        b.SetIsAromatic(False)

Chem.SanitizeMol(rwmol)
rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE

rwmol
[image: image.png]

However, this will still leave you with not particularly useful AROMATIC
bond types.
Probably a better option is to kekulize the molecule and clear aromatic
flags before starting to remove atoms, then sanitize:

rwmol = Chem.RWMol(Chem.MolFromSmiles("c1ccccc1"))
Chem.Kekulize(rwmol, clearAromaticFlags=True)
rwmol.RemoveAtom(0)

Chem.SanitizeMol(rwmol)
rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE

rwmol
[image: image.png]

Cheers,
p.

On Mon, Feb 14, 2022 at 11:55 AM Tim Dudgeon <tdudgeon...@gmail.com> wrote:

> I'm using mol.RemoveAtom(atom) to remove atoms from a molecule, and then
> calling Chem.SanitizeMol(mol) at the end to clean up the molecule. Mostly
> this works fine.
> But when I delete atoms in an aromatic ring but leave a single ring atom
> remaining in the molecule then the sanitize function fails:
>
> rdkit.Chem.rdchem.AtomKekulizeException: non-ring atom 0 marked aromatic
>
> I'm using SanitizeMol() with default options so SanitizeFlags.SANITIZE_ALL
> should be in place.
> What do I need to do to have sanitize to fix the atom type in the general
> case?
>
> Tim
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to