File: connectivityDescriptors.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (96 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: connectivityDescriptors.C,v 1.1.28.1 2007/03/16 00:06:46 bertsch Exp $
// 

#include <BALL/QSAR/connectivityDescriptors.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/bondIterator.h>
#include <BALL/KERNEL/atomIterator.h>
#include <BALL/KERNEL/PTE.h>
#include <BALL/KERNEL/fragment.h>

namespace BALL
{

	//////////////////
	// Zagreb index
	//////////////////
	ZagrebIndex::ZagrebIndex()
  	: ConnectivityBase("ZagrebIndex", "")
	{
	}

	ZagrebIndex::ZagrebIndex(const ZagrebIndex& zi)
		:	ConnectivityBase(zi)
	{
	}

	ZagrebIndex::~ZagrebIndex()
	{
	}

	ZagrebIndex& ZagrebIndex::operator = (const ZagrebIndex& zi)
	{
		this->setName(zi.getName());
		this->setUnit(zi.getUnit());
		return *this;
	}

	double ZagrebIndex::compute(AtomContainer& ac)
	{
		//if (!isValid_(ac))
		//{
		// do nothing...
		//}
		double sum = 0;
		AtomConstIterator atom_it = ac.beginAtom();
		BALL_FOREACH_ATOM (ac, atom_it)
		{
			if (atom_it->getElement() != PTE[Element::H])
			{
				Atom::BondConstIterator bond_it;
				int delta = 0; // heavy degree
				for (bond_it = atom_it->beginBond(); bond_it != atom_it->endBond(); bond_it++)
				{
					if (bond_it->getBoundAtom(*atom_it)->getElement() != PTE[Element::H])
					{
						delta++;
					}
				}
				sum += delta*delta;
			}
		}
		//ac.setProperty("ZagrebIndex", sum);
		return sum;
	}


	/////////////////////
	// Balabans index j
	////////////////////
	BalabanIndexJ::BalabanIndexJ()
		:	ConnectivityBase("BalabanIndexJ", "")
	{
	}

	BalabanIndexJ::BalabanIndexJ(const BalabanIndexJ& bij)
		:	ConnectivityBase(bij)
	{
	}

	BalabanIndexJ::~BalabanIndexJ()
	{
	}

	BalabanIndexJ& BalabanIndexJ::operator = (const BalabanIndexJ& bij)
	{
		this->setName(bij.getName());
		this->setUnit(bij.getUnit());
		return *this;
	}

} //namespace BALL