1 |
tim |
86 |
/********************************************************************** |
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 |
tim |
66 |
#ifndef FASMOL_H |
21 |
|
|
#define FASMOL_H |
22 |
|
|
|
23 |
|
|
#include <iostream> |
24 |
|
|
#include <vector> |
25 |
|
|
#include <string> |
26 |
tim |
86 |
#include "keylist.h" |
27 |
|
|
#include "animation.h" |
28 |
tim |
66 |
using namespace std; |
29 |
|
|
|
30 |
|
|
class TFASAtom; |
31 |
|
|
class TFASResidue; |
32 |
|
|
class TFASBond; |
33 |
|
|
class TFASMolecule; |
34 |
|
|
|
35 |
tim |
88 |
/******************************************************************************* |
36 |
|
|
In next version,I would like to declare TFASModel as template using class |
37 |
|
|
partial specialization.So if you want to derived a class from TAnimation,( the |
38 |
|
|
reason we want to do this is that if the trajectory file is too huge, we can |
39 |
|
|
not load all the frames to memory at one time, we would like to load part of |
40 |
|
|
it,and then we can doing the job of swapping as OS by ourself) and then we |
41 |
|
|
can derive TFASmodel from the new Animation class easily. |
42 |
|
|
|
43 |
|
|
declaration: |
44 |
|
|
|
45 |
|
|
class TMyAnimation : public TAnimation |
46 |
|
|
{ |
47 |
|
|
public: |
48 |
|
|
vector<TFrames *> _frames |
49 |
|
|
int _activeFrame; |
50 |
|
|
int _totalFrames; |
51 |
|
|
int _numFrames; |
52 |
|
|
void SwapFromDisk(); |
53 |
|
|
void SwapToDisk(); |
54 |
|
|
GetCoor(int frameIndex, int frameNum) |
55 |
|
|
{ |
56 |
|
|
if (frameNum = -1) |
57 |
|
|
frameNum = _activeFrame; |
58 |
|
|
if (framNum > frameNum && frameNum <totalNum) |
59 |
|
|
{ |
60 |
|
|
//here we know that the frame we want to acces is not now in memory |
61 |
|
|
//so we trigger a exception, and the exception handler will swap some |
62 |
|
|
//frames in and some out or we can just hard code here |
63 |
|
|
throw exception |
64 |
|
|
|
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
template<class T> class TFASModel : public T |
71 |
|
|
{ |
72 |
|
|
public: |
73 |
|
|
vector<TFASAtom<T> *> _atomList; |
74 |
|
|
|
75 |
|
|
}; |
76 |
|
|
|
77 |
|
|
template<class T> class TFASAtom |
78 |
|
|
{ |
79 |
|
|
public: |
80 |
|
|
TFASModel<T> _parent; |
81 |
|
|
GetRX(int frameNum = -1) |
82 |
|
|
{ |
83 |
|
|
_parent.GetCoor(frameIndex, frameNum); |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
so what we only need to do is |
89 |
|
|
|
90 |
|
|
TFASModel<TMyAnimation> fasModel; |
91 |
|
|
TFASAtom<TMyAnimation> fasAtom; |
92 |
|
|
and then build up the structure of model |
93 |
|
|
so if you want to get the coordinate of an atom,you can use below |
94 |
|
|
|
95 |
|
|
fasAtom.GetRX(); |
96 |
|
|
|
97 |
|
|
Actually, we can declare the TFASModel without deriving from TAnimation, just |
98 |
|
|
delegate the operation about coordinate to TAnimation. |
99 |
|
|
|
100 |
|
|
|
101 |
|
|
*******************************************************************************/ |
102 |
tim |
86 |
class TFASModel : public TAnimation |
103 |
tim |
66 |
{ |
104 |
|
|
protected: |
105 |
|
|
string _modelName; |
106 |
|
|
unsigned int _natoms; |
107 |
|
|
unsigned int _nbonds; |
108 |
|
|
unsigned int _nresidues; |
109 |
|
|
unsigned int _nmols; |
110 |
tim |
88 |
|
111 |
tim |
66 |
vector<TFASAtom *> _atomList; |
112 |
|
|
vector<TFASResidue *> _resList; |
113 |
|
|
vector<TFASBond *> _bondList; |
114 |
|
|
vector<TFASMolecule *> _molList; |
115 |
tim |
88 |
|
116 |
tim |
86 |
TNameList _atomNames; |
117 |
|
|
TNameList _atomTypes; |
118 |
|
|
TNameList _resNames; |
119 |
|
|
TNameList _resIds; |
120 |
|
|
TNameList _chainNames; |
121 |
|
|
TNameList _segNames; |
122 |
|
|
|
123 |
tim |
66 |
public: |
124 |
tim |
86 |
|
125 |
tim |
66 |
TFASModel(); |
126 |
|
|
~TFASModel(); |
127 |
tim |
86 |
|
128 |
tim |
66 |
string GetModelName() { return _modelName;} |
129 |
|
|
void SetModelName(string modelName) { _modelName = modelName;} |
130 |
tim |
86 |
void SetModelName(char * modelName) {_modelName = modelName;} |
131 |
tim |
88 |
|
132 |
tim |
66 |
void FindMolecules(); |
133 |
|
|
}; |
134 |
|
|
|
135 |
|
|
|
136 |
|
|
#endif |