User 954f1b2ec2
22-08-2014 07:55:05
Dear all,
A newbie question:
How do I calculate the First Zagreb index (the sum of vertex degrees' squares over all vertices of a molecular graph) for a collection of molecules in JChem or in Excel plugin? In fact, a simple function would be enough, which returns the degree of the i-th atom in a given molecule. Is there a standard API function (calculation) for this?
Regards,
Mike
ChemAxon 5fc3e8d7d0
27-08-2014 13:50:57
User 954f1b2ec2
02-09-2014 13:33:04
Dear Laszlo,
Thanks a lot for the advice, I'll try.
I used a simple custom code in Excel Addin as a workaround to calculate the second Zagreb Index and the ABC index. I post the code below, if someone's interested. It works rather solwly, but it solved my problem.
I use degree-based indices as a branchieness metric in my regressions for boiling points and chromatography retention indices.
Public Function JCDegree(Mol As Range, Atom As Integer)
n = JCHeavyAtomCount(Mol)
If Atom < n Then
d = 0
For i = 0 To n - 1
l = JCShortestPath(Mol, Atom, i)
If l = 1 Then
d = d + 1
End If
Next
JCDegree = d
Else
JCDegree = 0
End If
End Function
Public Function JCSecondZagreb(Mol As Range)
n = JCHeavyAtomCount(Mol)
JCSecondZagreb = 0
Dim i As Integer
Dim j As Integer
For i = 0 To n - 1
For j = 0 To n - 1
l = JCShortestPath(Mol, i, j)
If l = 1 Then
JCSecondZagreb = JCSecondZagreb + JCDegree(Mol, i) * JCDegree(Mol, j)
End If
Next
Next
End Function
Public Function JCABCIndex(Mol As Range)
n = JCHeavyAtomCount(Mol)
JCABCIndex = 0
Dim i As Integer
Dim j As Integer
For i = 0 To n - 1
For j = 0 To n - 1
l = JCShortestPath(Mol, i, j)
If l = 1 Then
d1 = JCDegree(Mol, i)
d2 = JCDegree(Mol, j)
JCABCIndex = JCABCIndex + Sqr((d1 + d2 - 2) / (d1 * d2))
End If
Next
Next
End Function
User 954f1b2ec2
02-09-2014 15:33:45
Laszlo,
calculated field with code
def d=0
for (atom in Mol.getNative().getAtomIterator()) {
d=d+Mol.getNative().getLigandCount(atom)**2;
}
return d;
works fine in ChemAxon,
Thnx,
Mike