4 |
|
#include <vector> |
5 |
|
#include "forcerCmd.h" |
6 |
|
#include "PDBReader.hpp" |
7 |
+ |
#include "RigidBody.hpp" |
8 |
+ |
#include "GridBuilder.hpp" |
9 |
|
|
10 |
|
#define MK_STR(s) # s |
11 |
|
#define STR_DEFINE(t, s) t = MK_STR(s) |
49 |
|
vector<Atype*> vdwAtypes; |
50 |
|
vector<Atype*>::iterator i; |
51 |
|
Atype* at; |
52 |
+ |
RigidBody* rb; |
53 |
|
vector<VDWAtom*> theAtoms; |
54 |
|
vector<VDWAtom*>::iterator j; |
55 |
|
VDWAtom* atom; |
56 |
< |
|
56 |
> |
GridBuilder* gb; |
57 |
> |
vector<double> sigmaGrid; |
58 |
> |
vector<double> epsGrid; |
59 |
> |
vector<double> sGrid; |
60 |
> |
|
61 |
|
double mass, rpar, eps; |
62 |
+ |
double xyz3[3]; |
63 |
|
string fileName; |
64 |
|
char vdwFileName[2002]; |
65 |
|
char structureFileName[2002]; |
66 |
|
char temp[200]; |
67 |
|
char readLine[500]; |
68 |
+ |
char xyzFile[200]; |
69 |
|
FILE *vdwFile, *structureFile; |
70 |
|
char* ffPath_env = "VDW_PATH"; |
71 |
|
char* ffPath; |
73 |
|
char* foo; |
74 |
|
char* myType; |
75 |
|
char* vType; |
76 |
+ |
char *token; |
77 |
+ |
const char *file; |
78 |
+ |
const char *period = "."; |
79 |
+ |
int k; |
80 |
|
int lineNum; |
81 |
|
int nTokens; |
82 |
|
int FF; |
83 |
+ |
int bandwidth; |
84 |
|
short int gotMatch; |
85 |
|
|
86 |
|
//parse the command line options |
95 |
|
exit(1); |
96 |
|
} |
97 |
|
|
98 |
+ |
file = fileName.c_str(); |
99 |
+ |
strcpy(xyzFile, file); |
100 |
+ |
token = strtok(xyzFile, period); |
101 |
+ |
strcpy(xyzFile, token); |
102 |
+ |
strcat(xyzFile, "ref.xyz"); |
103 |
+ |
ofstream xfiles(xyzFile); |
104 |
+ |
|
105 |
+ |
//the bandwidth has a default value (default=16), so it is always given |
106 |
+ |
bandwidth = args_info.bandwidth_arg; |
107 |
+ |
|
108 |
|
if (args_info.charmm_given) { |
109 |
|
FF=CHARMM; |
110 |
|
strcpy(vdwFileName, "charmm27.vdw"); |
130 |
|
strcpy(vdwFileName, "oplsaal.vdw"); |
131 |
|
} |
132 |
|
|
133 |
+ |
|
134 |
+ |
printf ("opening %s\n", vdwFileName); |
135 |
|
vdwFile = fopen( vdwFileName, "r" ); |
136 |
|
|
137 |
|
if( vdwFile == NULL ){ |
148 |
|
strcat( temp, vdwFileName ); |
149 |
|
strcpy( vdwFileName, temp ); |
150 |
|
|
151 |
+ |
printf ("opening %s\n", vdwFileName); |
152 |
|
vdwFile = fopen( vdwFileName, "r" ); |
153 |
|
|
154 |
|
if( vdwFile == NULL ){ |
159 |
|
vdwFileName ); |
160 |
|
exit(-1); |
161 |
|
} |
162 |
< |
printf( "VDW file %s opened sucessfully.\n", vdwFileName ); |
163 |
< |
lineNum = 0; |
164 |
< |
|
162 |
> |
} |
163 |
> |
printf( "VDW file %s opened sucessfully.\n", vdwFileName ); |
164 |
> |
lineNum = 0; |
165 |
> |
|
166 |
> |
eof_test = fgets( readLine, sizeof(readLine), vdwFile ); |
167 |
> |
lineNum++; |
168 |
> |
|
169 |
> |
if( eof_test == NULL ){ |
170 |
> |
printf("Error in reading Atoms from force file at line %d.\n", |
171 |
> |
lineNum ); |
172 |
> |
exit(-1); |
173 |
> |
} |
174 |
> |
|
175 |
> |
while( eof_test != NULL ){ |
176 |
> |
// toss comment lines |
177 |
> |
if( readLine[0] != '!' && readLine[0] != '#' ){ |
178 |
> |
|
179 |
> |
nTokens = count_tokens(readLine, " ,;\t"); |
180 |
> |
if (nTokens < 4) { |
181 |
> |
printf("Not enough tokens on line %d.\n", lineNum); |
182 |
> |
exit(-1); |
183 |
> |
} |
184 |
> |
|
185 |
> |
at = new Atype(); |
186 |
> |
foo = strtok(readLine, " ,;\t"); |
187 |
> |
at->setType(foo); |
188 |
> |
foo = strtok(NULL, " ,;\t"); |
189 |
> |
mass = atof(foo); |
190 |
> |
at->setMass(mass); |
191 |
> |
foo = strtok(NULL, " ,;\t"); |
192 |
> |
rpar = atof(foo); |
193 |
> |
at->setRpar(rpar); |
194 |
> |
foo = strtok(NULL, " ,;\t"); |
195 |
> |
eps = atof(foo); |
196 |
> |
at->setEps(eps); |
197 |
> |
vdwAtypes.push_back(at); |
198 |
> |
} |
199 |
|
eof_test = fgets( readLine, sizeof(readLine), vdwFile ); |
200 |
|
lineNum++; |
201 |
< |
|
202 |
< |
if( eof_test == NULL ){ |
203 |
< |
printf("Error in reading Atoms from force file at line %d.\n", |
204 |
< |
lineNum ); |
144 |
< |
exit(-1); |
145 |
< |
} |
146 |
< |
|
147 |
< |
while( eof_test != NULL ){ |
148 |
< |
// toss comment lines |
149 |
< |
if( readLine[0] != '!' && readLine[0] != '#' ){ |
150 |
< |
|
151 |
< |
nTokens = count_tokens(readLine, " ,;\t"); |
152 |
< |
if (nTokens < 4) { |
153 |
< |
printf("Not enough tokens on line %d.\n", lineNum); |
154 |
< |
exit(-1); |
155 |
< |
} |
156 |
< |
|
157 |
< |
at = new Atype(); |
158 |
< |
foo = strtok(readLine, " ,;\t"); |
159 |
< |
at->setType(foo); |
160 |
< |
foo = strtok(NULL, " ,;\t"); |
161 |
< |
mass = atof(foo); |
162 |
< |
at->setMass(mass); |
163 |
< |
foo = strtok(NULL, " ,;\t"); |
164 |
< |
rpar = atof(foo); |
165 |
< |
at->setRpar(rpar); |
166 |
< |
foo = strtok(NULL, " ,;\t"); |
167 |
< |
eps = atof(foo); |
168 |
< |
at->setEps(eps); |
169 |
< |
vdwAtypes.push_back(at); |
170 |
< |
} |
171 |
< |
eof_test = fgets( readLine, sizeof(readLine), vdwFile ); |
172 |
< |
lineNum++; |
173 |
< |
} |
174 |
< |
|
175 |
< |
fclose( vdwFile ); |
176 |
< |
} |
201 |
> |
} |
202 |
> |
|
203 |
> |
fclose( vdwFile ); |
204 |
> |
|
205 |
|
printf("%d Atom Types read from VDW file\n", vdwAtypes.size()); |
206 |
|
|
207 |
|
// Now, open and parse the input file! |
250 |
|
} |
251 |
|
} |
252 |
|
|
253 |
< |
//GridBuilder gb = new GridBuilder(); |
254 |
< |
//gb->findAxesAndOrigin(theAtoms); |
255 |
< |
//gb->launchProbe(FF, sigmaGrid, sGrid, epsGrid); |
256 |
< |
|
253 |
> |
rb = new RigidBody(); |
254 |
> |
for( j = theAtoms.begin(); j != theAtoms.end(); ++j){ |
255 |
> |
rb->addAtom(*j); |
256 |
> |
} |
257 |
|
|
258 |
+ |
rb->calcRefCoords(); |
259 |
+ |
|
260 |
+ |
//print a reference coordinate xyz file |
261 |
+ |
xfiles << rb->getNumAtoms() << "\n\n"; |
262 |
+ |
for (k=0; k<rb->getNumAtoms(); k++){ |
263 |
+ |
rb->getAtomRefCoor(xyz3, k); |
264 |
+ |
xfiles << rb->getAtomType(k) << "\t" << |
265 |
+ |
xyz3[0] << "\t" << xyz3[1] << "\t" << |
266 |
+ |
xyz3[2] << "\n"; |
267 |
+ |
} |
268 |
+ |
|
269 |
+ |
gb = new GridBuilder(rb, bandwidth*2); |
270 |
+ |
|
271 |
+ |
cout << "Doing GridBuilder calculations...\n"; |
272 |
+ |
gb->launchProbe(FF, sigmaGrid, sGrid, epsGrid); |
273 |
+ |
|
274 |
+ |
//write out the grid files |
275 |
|
} |
276 |
|
|
277 |
|
int count_tokens(char *line, char *delimiters) { |