Hi Shani,

I'm not aware of an rdkit function that gets the degree of carbocations.
If you define the degree of a carbocation as the number of carbon atoms
directly attached to it, the following function (although probably not very
efficient) can achieve this:

def GetCarboCatDegree(mol):
    for atom in mol.GetAtoms():
        if (atom.GetFormalCharge() == 1) and (atom.GetSymbol() == 'C'):
            Degree = 0
            for Neighbor in atom.GetNeighbors():
                if Neighbor.GetSymbol() == 'C': Degree +=1
            return Degree

As for grouping, if you want, you can use a default dictionary with degrees
as the keys and lists of the corresponding molecules as the values:

from collections import defaultdict
Degrees_Mols_Dict = defaultdict(list)
for mol in mols:
    Degree = GetCarboCationDegree(mol)
    Degrees_Mols_Dict[Degree].append(mol)

I hope this works for you.
Best regards,
Omar

On Tue, Mar 17, 2020 at 12:08 PM Shani Levi <levishan...@gmail.com> wrote:

> Hi everyone,
> I'm looking for a way to categorize different types of carbocations
> (primary, secondary and tertiary) using RDKit.
> my input is a smile string, and each smile has a formal charge of +1 (only
> one carbon is charged), so my goal is categorizing the carbocations to
> groups according to their type.
>
> I tried using GetDegree and GetExplicitValence, but I couldn't figure out
> how to use them
>
> For example:
> C=C1C=C2[C@H](CC1)[C@@H](C)CC[C@@H]2[C@@H](C)CC[CH+]C(C)C
> This smile is a secondary carbocation. how can RDKit get this
> information for me?
>
> thanks a lot!
> Shani
> _______________________________________________
> 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