1 |
/********************************************************************** |
2 |
* Copyright (C) 2002-2003 by Gezelter's Group
|
3 |
*This program is free software; you can redistribute it and/or modify
|
4 |
*it under the terms of the GNU General Public License as published by
|
5 |
*the Free Software Foundation version 2 of the License.
|
6 |
*
|
7 |
*This program is distributed in the hope that it will be useful,
|
8 |
*but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9 |
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10 |
*GNU General Public License for more details.
|
11 |
*
|
12 |
************************************************************************ |
13 |
*Author: Teng Lin Email: tlin@nd.edu |
14 |
*Date: 08/13/2002 Version: 1.0 |
15 |
* |
16 |
************************************************************************ |
17 |
*Description: |
18 |
* |
19 |
***********************************************************************/ |
20 |
#include <iostream> |
21 |
#include <vector> |
22 |
#include "fasatom.h" |
23 |
|
24 |
using namespace std; |
25 |
|
26 |
/*********************************************************************** |
27 |
* Class TFASAtom |
28 |
***********************************************************************/ |
29 |
void TFASAtom::Clear() |
30 |
{ |
31 |
_index = 0; |
32 |
_frameIndex = 0; |
33 |
_atomicNum = 0; |
34 |
_nameIndex = 0; |
35 |
_typeIndex = 0; |
36 |
_resid = 0; |
37 |
_residIndex = 0; |
38 |
_resnameIndex = 0; |
39 |
_chainIndex = 0; |
40 |
_segnameIndex = 0; |
41 |
_atomProp = TAtomProp::apNormal; |
42 |
_mass = 0; |
43 |
_charge = 0; |
44 |
_covRadius = 0; |
45 |
_vdwRadius = 0; |
46 |
_maxBonds = 0; |
47 |
_pcharge = 0; |
48 |
_hyb = 0; |
49 |
_impval = 0; |
50 |
_pseudo = false; |
51 |
_residue = NULL; |
52 |
_mol = NULL; |
53 |
_model = NULL; |
54 |
_bondList.clear(); |
55 |
|
56 |
} |
57 |
|
58 |
TFASAtom::TFASAtom() |
59 |
{ |
60 |
Clear(); |
61 |
} |
62 |
|
63 |
TFASAtom::TFASAtom(int index) |
64 |
{ |
65 |
Clear(); |
66 |
_index = index; |
67 |
_frameIndex = (index - 1) * 3; |
68 |
} |
69 |
|
70 |
TFASAtom::TFASAtom(const TFASAtom &src) |
71 |
{ |
72 |
|
73 |
} |
74 |
|
75 |
TFASAtom::~TFASAtom() |
76 |
{ |
77 |
Clear(); |
78 |
} |
79 |
|
80 |
// |
81 |
unsigned int TFASAtom::GetHvyValence() |
82 |
{ |
83 |
unsigned int count; |
84 |
vector<TFASBond *>::iterator i; |
85 |
TFASAtom *atom; |
86 |
count=0; |
87 |
|
88 |
for(atom = BeginNbrAtom(i); atom != NULL; atom = NextNbrAtom(i)) |
89 |
if(!atom->IsHydrogen()) count++; |
90 |
|
91 |
return count; |
92 |
} |
93 |
|
94 |
//Get Coordinate & Velocity |
95 |
/* |
96 |
float TFASAtom::GetRX(int frameNum) |
97 |
{ |
98 |
if (_model != NULL) |
99 |
{ |
100 |
return _model->GetRX(_frameIndex, frameNum); |
101 |
} |
102 |
else |
103 |
{ |
104 |
|
105 |
} |
106 |
} |
107 |
|
108 |
float TFASAtom::GetRY(int frameNum) |
109 |
{ |
110 |
if (_model != NULL) |
111 |
{ |
112 |
return _model->GetRY(_frameIndex+1, frameNum); |
113 |
} |
114 |
else |
115 |
{ |
116 |
|
117 |
} |
118 |
|
119 |
} |
120 |
|
121 |
float TFASAtom::GetRZ(int frameNum) |
122 |
{ |
123 |
if (_model != NULL) |
124 |
{ |
125 |
return _model->GetRZ(_frameIndex+2, frameNum); |
126 |
} |
127 |
else |
128 |
{ |
129 |
|
130 |
} |
131 |
|
132 |
} |
133 |
|
134 |
float TFASAtom::GetVX(int frameNum) |
135 |
{ |
136 |
if (_model != NULL) |
137 |
{ |
138 |
return _model->GetVX(_frameIndex, frameNum); |
139 |
} |
140 |
else |
141 |
{ |
142 |
|
143 |
} |
144 |
|
145 |
} |
146 |
|
147 |
float TFASAtom::GetVY(int frameNum) |
148 |
{ |
149 |
if (_model != NULL) |
150 |
{ |
151 |
return _model->GetVY(_frameIndex+1, frameNum); |
152 |
} |
153 |
else |
154 |
{ |
155 |
|
156 |
} |
157 |
|
158 |
} |
159 |
|
160 |
float TFASAtom::GetVZ(int frameNum) |
161 |
{ |
162 |
if (_model != NULL) |
163 |
{ |
164 |
return _model->GetVZ(_frameIndex+2, frameNum); |
165 |
} |
166 |
else |
167 |
{ |
168 |
|
169 |
} |
170 |
|
171 |
} |
172 |
*/ |
173 |
void TFASAtom::AddBond(TFASBond * bond) |
174 |
{ |
175 |
if (bond==NULL) |
176 |
{ |
177 |
|
178 |
} |
179 |
else |
180 |
{ |
181 |
_bondList.push_back(bond); |
182 |
} |
183 |
} |
184 |
|
185 |
void TFASAtom::DeleteBond(TFASBond *bond) |
186 |
{ |
187 |
vector<TFASBond *>::iterator i; |
188 |
i = find(_bondList.begin(), _bondList.end(), bond); |
189 |
if (i != _bondList.end()) |
190 |
{ |
191 |
_bondList.erase(i); |
192 |
} |
193 |
else |
194 |
{ |
195 |
|
196 |
} |
197 |
} |
198 |
|
199 |
TFASBond * TFASAtom::GetBond(TFASAtom *nbrAtom) |
200 |
{ |
201 |
TFASBond *bond; |
202 |
vector<TFASBond *>::iterator i; |
203 |
if(nbrAtom == NULL) |
204 |
{ |
205 |
|
206 |
} |
207 |
else |
208 |
{ |
209 |
|
210 |
for(bond = BeginBond(i); bond != NULL; bond = NextBond(i)) |
211 |
{ |
212 |
if (bond->GetNbrAtom(this) == nbrAtom) return bond; |
213 |
} |
214 |
return NULL; |
215 |
} |
216 |
} |
217 |
|
218 |
TFASBond * TFASAtom::BeginBond(vector<TFASBond *>::iterator &i) |
219 |
{ |
220 |
i = _bondList.begin(); |
221 |
return (i == _bondList.end()) ? NULL : *i; |
222 |
} |
223 |
|
224 |
TFASBond * TFASAtom::NextBond(vector<TFASBond *>::iterator &i) |
225 |
{ |
226 |
i++; |
227 |
return (i == _bondList.end()) ? NULL : *i; |
228 |
} |
229 |
|
230 |
TFASAtom * TFASAtom::BeginNbrAtom(vector<TFASBond *>::iterator &i) |
231 |
{ |
232 |
TFASBond * bond = BeginBond(i); |
233 |
|
234 |
if(bond != NULL) |
235 |
{ |
236 |
return bond->GetNbrAtom(this); |
237 |
} |
238 |
else |
239 |
{ |
240 |
|
241 |
} |
242 |
} |
243 |
|
244 |
TFASAtom * TFASAtom::NextNbrAtom(vector<TFASBond *>::iterator &i) |
245 |
{ |
246 |
TFASBond * bond = NextBond(i); |
247 |
|
248 |
if(bond != NULL) |
249 |
{ |
250 |
return bond->GetNbrAtom(this); |
251 |
} |
252 |
else |
253 |
{ |
254 |
|
255 |
} |
256 |
} |
257 |
|
258 |
bool TFASAtom::IsConnected(TFASAtom *atom) |
259 |
{ |
260 |
vector<TFASBond *>::iterator i; |
261 |
TFASAtom *nbrAtom; |
262 |
|
263 |
for(nbrAtom = BeginNbrAtom(i); nbrAtom != NULL; nbrAtom = NextNbrAtom(i)) |
264 |
{ |
265 |
if (atom == nbrAtom) |
266 |
{ |
267 |
return true; |
268 |
} |
269 |
} |
270 |
|
271 |
return false; |
272 |
} |
273 |
|
274 |
bool TFASAtom::IsOneThree(TFASAtom *atom) |
275 |
{ |
276 |
TFASAtom *thisNbr; |
277 |
TFASAtom *atomNbr; |
278 |
vector<TFASBond *>::iterator i; |
279 |
vector<TFASBond *>::iterator j; |
280 |
|
281 |
for(thisNbr = this->BeginNbrAtom(i); thisNbr != NULL; thisNbr = this->NextNbrAtom(i)) |
282 |
for(atomNbr = atom->BeginNbrAtom(j); thisNbr != NULL; atomNbr = atom->NextNbrAtom(j)) |
283 |
if (atomNbr == thisNbr) return true; |
284 |
|
285 |
return false; |
286 |
|
287 |
} |
288 |
|
289 |
bool TFASAtom::IsOneFour(TFASAtom *atom) |
290 |
{ |
291 |
TFASAtom *thisNbr; |
292 |
TFASAtom *atomNbr; |
293 |
vector<TFASBond *>::iterator i; |
294 |
vector<TFASBond *>::iterator j; |
295 |
|
296 |
for(thisNbr = this->BeginNbrAtom(i); thisNbr != NULL; thisNbr = this->NextNbrAtom(i)) |
297 |
for(atomNbr = atom->BeginNbrAtom(j); atomNbr != NULL; atomNbr = atom->NextNbrAtom(j)) |
298 |
if (thisNbr->IsConnected(atomNbr)) return true; |
299 |
|
300 |
return false; |
301 |
|
302 |
} |
303 |
|
304 |
bool TFASAtom::IsCarboxylOxygen() |
305 |
{ |
306 |
if (!IsOxygen()) return false; |
307 |
if (GetHvyValence() != 1) return false; |
308 |
|
309 |
TFASAtom *atom; |
310 |
vector<TFASBond *>::iterator i; |
311 |
|
312 |
for(atom=BeginNbrAtom(i); atom != NULL; atom = NextNbrAtom(i)) |
313 |
if (atom->IsCarbon()) break; |
314 |
|
315 |
if (atom == NULL) return false; |
316 |
|
317 |
|
318 |
} |
319 |
|
320 |
bool TFASAtom::IsPhosphateOxygen() |
321 |
{ |
322 |
if (!IsOxygen()) return false; |
323 |
|
324 |
|
325 |
} |
326 |
|
327 |
bool TFASAtom::IsSulfateOxygen() |
328 |
{ |
329 |
|
330 |
} |
331 |
|
332 |
bool TFASAtom::IsNitroOxygen() |
333 |
{ |
334 |
|
335 |
} |
336 |
|
337 |
bool TFASAtom::IsAmideNitrogen() |
338 |
{ |
339 |
|
340 |
} |
341 |
|
342 |
bool TFASAtom::IsPolarHydrogen() |
343 |
{ |
344 |
|
345 |
} |
346 |
|
347 |
bool TFASAtom::IsNonPolarHydrogen() |
348 |
{ |
349 |
|
350 |
} |
351 |
|
352 |
bool TFASAtom::IsInRing() |
353 |
{ |
354 |
|
355 |
} |
356 |
|
357 |
bool TFASAtom::IsInRingSize(int ringSize) |
358 |
{ |
359 |
|
360 |
} |
361 |
|
362 |
bool TFASAtom::IsAromatic() |
363 |
{ |
364 |
|
365 |
} |
366 |
|
367 |
bool TFASAtom::IsAromaticNOxide() |
368 |
{ |
369 |
|
370 |
} |
371 |
|
372 |
bool TFASAtom::IsChiral() |
373 |
{ |
374 |
|
375 |
} |
376 |
|
377 |
bool TFASAtom::IsAxial() |
378 |
{ |
379 |
|
380 |
} |
381 |
|
382 |
bool TFASAtom::HasAlphaBetaUnsat(bool includePandS) |
383 |
{ |
384 |
|
385 |
} |
386 |
|
387 |
bool TFASAtom::HasBondOfOrder(int order) |
388 |
{ |
389 |
|
390 |
} |
391 |
|
392 |
int TFASAtom::CountBondsOfOrder(int order) |
393 |
{ |
394 |
|
395 |
} |
396 |
|