Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
First Zagreb index with JChem or Excel Plugin
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message
Mikhail

Joined: 21 May 2014
Posts: 3

View user's profile

Back to top
Link to postPosted: Fri Aug 22, 2014 8:55 amPost subject: First Zagreb index with JChem or Excel Plugin Reply with quote

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

László
ChemAxon personnel
Joined: 14 Jan 2011
Posts: 78

View user's profile

Back to top
Link to postPosted: Wed Aug 27, 2014 2:50 pmPost subject: Reply with quote

Dear Mike,

Yes, there is: Molecule.getLigandCount(MolAtom)
Could you share with us why you would like to calculate the Zagreb index?

BR,
Laszlo

Mikhail

Joined: 21 May 2014
Posts: 3

View user's profile

Back to top
Link to postPosted: Tue Sep 02, 2014 2:33 pmPost subject: Reply with quote

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

Mikhail

Joined: 21 May 2014
Posts: 3

View user's profile

Back to top
Link to postPosted: Tue Sep 02, 2014 4:33 pmPost subject: Reply with quote

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

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1


To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum