Calculate descriptors with RDkit

4.3k views Asked by At

I am trying to calculate all the descriptors (both 2D/3D) for a list of molecules with RDkit in python. When I run:

MolecularDescriptorCalculator.CalcDescriptors(mol, simplelist) 

it returns:

AttributeError: 'Mol' object has no attribute 'simpleList'
2

There are 2 answers

0
Oliver Scott On

Looks like you are using the API slightly wrong, you need to initialize the MolecularDescriptorCalculator class first with the list of descriptors you require.

simplelist = ['TPSA']  # In the list add the names of the descriptors required
calculator = MolecularDescriptorCalculator(simplelist)
descriptors = calculator.CalcDescriptors(mol)
print(descriptors)

[Out]:
(21.259999999999998,)
1
Gashaw M Goshu On

To calculate all the rdkit descriptors, you can use the following code:

descriptor_names = list(rdMolDescriptors.Properties.GetAvailableProperties())

get_descriptors = rdMolDescriptors.Properties(descriptor_names)

Calculate descriptors using smile strings

def smi_to_descriptors(smile):
    mol = Chem.MolFromSmiles(smile)
    descriptors = []
    if mol:
        descriptors = np.array(get_descriptors.ComputeProperties(mol))
    return descriptors

if the the smiles are in pandas dataframe

dataset['descriptors'] = dataset.SMILES.apply(smi_to_descriptors)