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

The 4n+2 rule #1

Open
matteoferla opened this issue Aug 3, 2022 · 0 comments
Open

The 4n+2 rule #1

matteoferla opened this issue Aug 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@matteoferla
Copy link
Owner

There are too many ad hoc cases that are meant to catch generic errors but mainly happen due to violations of the 4n+2 rule for aromaticity.

From a simplistic point of view, this would detect if a set of bonds composing a ring and its substituent is aromatic:

def obeys_4n2(mol: Chem.Mol, bonds: Sequence[Chem.Bond]):
    # 4N+2 rule
    is_aromatic_bond = lambda bond: bond.GetBondType() in (Chem.BondType.AROMATIC, Chem.BondType.DOUBLE)
    pis = len(tuple(filter(is_aromatic_bond, bonds)))
    return (pis - 2) % 4 == 0

The double bond in there for substituents is for xanthine and friends.
Expanding the list of bonds to include the substituents is easy:

bonds: List[Chem.Bond] = list(map(mol.GetBondWithIdx, bond_idxs))
exbond_idxs: Set[int] = set()
for bond in bonds:
    for atom in (bond.GetBeginAtom(), bond.GetEndAtom()):
        exbond_idxs.update(map(Chem.Bond.GetIdx, atom.GetBonds()))
exbonds: List[Chem.Bond] = list(map(mol.GetBondWithIdx, exbond_idxs))

But this does not include other rings, so the bonds should include all in the conjugation system. Think cyanine dyes... That is too complicated.
Plus charged/protonated atoms are not considered (e.g. indole). This is currently done in a rather random manner.

Ideally, were this module to be perfect this would need to be considered. For now this will not be done.

@matteoferla matteoferla added the enhancement New feature or request label Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant