Calculate 0, 1st, 2nd order Molecular Connectivity Indices (MCIs) using openbabel/pybel

Molecular Connectivity Indices (MCIs), also known as Kier-Hall connectivity indices were useful molecular descriptors for predicting properties for chemicals.

To calculate these MCIs, the connectivity count for each atom needs to be obtained. This is easily facilitated by openbabel module, to give the atom.valence info: from pybel import * from openbabel import * mol = readstring("smi","c(ccc(c1)Cl)(c1)C(c(ccc(c2)Cl)c2)C(Cl)(Cl)Cl") # p,p'-DDT for atom in mol.atoms: print(atom.valence)
 * 1) take the p,p'-DDT as an input SMILES

actually we use atom.idx to match the index and the valence (connectivity) of the current atom for atom in mol.atoms: print(atom.idx) For later convenience, a dictionary could be created for the idx and valence info idx_valDict = dict for atom in mol.atoms: idx_valDict[atom.idx] = atom.valence The zero order MCI (MCI0) only considers each atom itself, therefore MCI0 = 0 for atom in mol.atoms: MCI0 = MCI0 + atom.valence ** (-0.5) print(MCI0) The first order MCI (MCI1) considers bonded atoms, therefore we need to firstly find out all bonds.

Without using the lower-level OBMol, we can use SMARTS code: bonds = Smarts("*~*").findall(mol) MCI1 = 0 for bond in bonds: MCI1 = MCI1 + (idx_valDict[bond[0]]*idx_valDict[bond[1]]) ** (-0.5) print(MCI1) The spirit of second order MCI would be similar: it considers atoms within an angle.
 * 1) get bonds info of mol, SMARTS: *~*
 * 1) the previously defined dictionary would be useful here ^_^

Therefore, we could use angle SMARTS to match all triple tuples. I'll leave this to the readers for exercise.