File: atomBondModelBaseProcessor.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 (174 lines) | stat: -rw-r--r-- 4,097 bytes parent folder | download | duplicates (4)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: atomBondModelBaseProcessor.C,v 1.15.18.1 2007/03/25 22:02:28 oliver Exp $
//

#include <BALL/VIEW/MODELS/atomBondModelBaseProcessor.h>
#include <BALL/KERNEL/forEach.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/residue.h>

#include <BALL/QSAR/ringPerceptionProcessor.h>

using namespace std;

namespace BALL
{
	namespace VIEW
	{

		AtomBondModelBaseProcessor::AtomBondModelBaseProcessor()
			:	ModelProcessor(),
			  used_atoms_(),
				atom_set_()
		{
		}

		AtomBondModelBaseProcessor::AtomBondModelBaseProcessor(const AtomBondModelBaseProcessor& processor)
			:	ModelProcessor(processor),
				used_atoms_(),
				atom_set_()
		{
		}

		AtomBondModelBaseProcessor::~AtomBondModelBaseProcessor()
		{
			#ifdef BALL_VIEW_DEBUG
				Log.info() << "Destructing object " << this << " of class AtomBondModelBaseProcessor" << std::endl;
			#endif 
		}

		void AtomBondModelBaseProcessor::clear()
		{
			ModelProcessor::clear();
			atom_set_.clear();
			used_atoms_.clear();
			rings_.clear();
			ring_atoms_.clear();
		}

		void AtomBondModelBaseProcessor::set(const AtomBondModelBaseProcessor& processor)
		{
			clear();
			ModelProcessor::set(processor);
		}

		const AtomBondModelBaseProcessor& AtomBondModelBaseProcessor::operator = (const AtomBondModelBaseProcessor& processor)
		{
			set(processor);
			return *this;
		}

		void AtomBondModelBaseProcessor::clearComposites()
		{
			atom_set_.clear();
			used_atoms_.clear();
		}
				
		void AtomBondModelBaseProcessor::dump(ostream& s, Size depth) const
		{
			BALL_DUMP_STREAM_PREFIX(s);
			
			BALL_DUMP_DEPTH(s, depth);
			BALL_DUMP_HEADER(s, this, this);

			ModelProcessor::dump(s, depth + 1);

			BALL_DUMP_DEPTH(s, depth);
			s << "used atoms: " << used_atoms_.size() << endl;

			BALL_DUMP_STREAM_SUFFIX(s);
		}

		void AtomBondModelBaseProcessor::buildBondModels_()
    {
			// generate bond primitive
			const Atom* second_atom_ptr = 0;
			AtomBondConstIterator bond_it;
			list<const Atom*>::const_iterator atom_it;

			// for all used atoms
			for (atom_it  = getAtomList_().begin();
					 atom_it != getAtomList_().end(); ++atom_it)
			{
				// for all bonds connected from first- to second atom
				BALL_FOREACH_ATOM_BOND(**atom_it, bond_it)
				{
					if (*atom_it != bond_it->getSecondAtom())
					{
						second_atom_ptr = bond_it->getSecondAtom();
					}
					else
					{
						second_atom_ptr = bond_it->getFirstAtom();
					}

					// use only atoms with greater handles than first atom
					// or
					// second atom not a used atom, but smaller as the first atom
					// process bond between them		
					if (**atom_it < *second_atom_ptr && getAtomSet_().has(second_atom_ptr))
					{
						visualiseBond_(*bond_it);
					}
				}
			}
    }

		void AtomBondModelBaseProcessor::visualiseBond_(const Bond& /*bond*/)
		{
		}

		bool AtomBondModelBaseProcessor::createGeometricObjects()
		{
			ring_atoms_.clear();

			vector<vector<Atom*> >::iterator it = rings_.begin();
			for(; it != rings_.end(); it++)
			{
				vector<Atom*>& ring = *it;
				if (ring.size() != 5 && ring.size() != 6) continue;

				vector<Atom*>::iterator ait = ring.begin();

				for (; ait != ring.end(); ait++)
				{
					ring_atoms_.insert(*ait);
				}
			}

			buildBondModels_();
			visualiseRings_();
			rings_.clear();
			return true;
		}

		Processor::Result AtomBondModelBaseProcessor::operator () (Composite& composite)
		{
			Fragment* residue = dynamic_cast<Fragment*>(&composite);
			if (residue == 0) 
			{
				return Processor::CONTINUE;
			}

			RingPerceptionProcessor rpp;
			try
			{
				rpp.calculateSSSR(rings_, *residue);
			}
			catch (Exception::GeneralException e)
			{
				Log.warn() << "Exception of type " << e.getName() << " occurred in line "
					         << e.getLine() << " of " << e.getFile() << endl;
				Log.warn() << "Error message: " << e.getMessage() << endl;
			}
			return Processor::CONTINUE;
		}

#		ifdef BALL_NO_INLINE_FUNCTIONS
#			include <BALL/VIEW/MODELS/atomBondModelBaseProcessor.iC>
#		endif

	} // namespace VIEW
} // namespace BALL