Hi Goutam,

The RDKit doesn't have an implementation of the Wiener index[1]

I don't seem to have copies of all those old papers anymore, but assuming
that the wikipedia page about the Wiener index has the definition correct (
https://en.wikipedia.org/wiki/Wiener_index), here's a crude implementation
that should give you an idea of how to do the calculation:

In [8]: def wiener_index(m):
   ...:     res = 0
   ...:     amat = Chem.GetDistanceMatrix(m)
   ...:     for i in range(m.GetNumAtoms()):
   ...:         for j in range(i+1,m.GetNumAtoms()):
   ...:             res += amat[i][j]
   ...:     return res
   ...:


In [18]: butane = Chem.MolFromSmiles('CCCC')



In [19]: wiener_index(butane)


Out[19]: 10.0

In [20]: isobutane = Chem.MolFromSmiles('CC(C)C')



In [21]: wiener_index(isobutane)


Out[21]: 9.0

I hope this helps
-greg
[1] which is kind of odd, because I think I remember implementing it years
and years ago, but it doesn't seem to be in the code now.


On Wed, Nov 6, 2019 at 3:17 PM Goutam Mukherjee <cyz078...@gmail.com> wrote:

> Dear Members,
>
> I want to calculate Wiener Index for my molecule.
> Could you help me how do I calculate the same using rdKit command.
>
> Thanks and Best Regards,
> Goutam
> _______________________________________________
> 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