Re: [Rdkit-discuss] Delete atoms can leave dangling aromaticity
Thanks Paolo, that does the trick. Tim On Mon, Feb 14, 2022 at 11:23 AM Paolo Tosco wrote: > 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("c1c1")) > 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("c1c1")) > 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 > 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
Re: [Rdkit-discuss] Delete atoms can leave dangling aromaticity
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("c1c1")) 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("c1c1")) 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 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
[Rdkit-discuss] Delete atoms can leave dangling aromaticity
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