-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
230 lines (144 loc) · 4.58 KB
/
main.cpp
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#include <iostream>
#include "FF/readff.h"
#include "FF/readinput.h"
#include "FF/csortpotential.h"
#include "FF/cffstream.h"
#include "topo/csystem.h"
#include "topo/cdatareader.h"
#include "topo/cdatawriter.h"
#include "commandlineparser.h"
#include "topo/cpdbreader.h"
#include "topo/csystemsorter.h"
#include "topo/cxmlwriter.h"
int main(int argc,char *argv[])
{
/* Pure files must be the last to be loaded
* Added pure functionallity .pure. files are not included
* Mixing updated mixGeo perform geometric mixing LJ if style LJAB vs LJ LJAB is default.
*
* -opls keyword added, (adds bond between outer atoms in dihederals
* -body writes out bodies
*
* hoomd is now default, for lammps use -lmp
*
* Added read several pdb files
*
* Added mixing for group names, .i.e teg teg and so on.
*
* FIXES:
* Need fail proof pdb reader,almost done!
* Need fix for dihederal not found if wrapped coords
*
*/
commandLineParser parse;
string inFile, dataFile,pdbFile;
parse.addSearchString(".in");
parse.addSearchString(".pdb");
parse.addSearchString("data.");
parse.addArguments(argc,argv);
parse.search();
parse.printArguments();
if (parse.has(".in"))
{
inFile=parse.getString(".in");
}else
{
cout <<"No inputFile! "<<endl;
return 0;
}
try
{
readInput inputData(inFile);
readFF ffFiles(inputData.getFiles());
csystem sys;
if (parse.has("data."))
{
dataFile=parse.getString("data.");
cdataReader readData(&sys,dataFile,&inputData);
cSystemSorter sorter(&sys);
sorter.findMolecules();
}
bool opls=false;
if (parse.has("-opls"))
{
opls=true;
}
bool hoomd=true;
if (parse.has("-lmp"))
{
hoomd=false;
}
cSortPotential potential;
potential.sortData(inputData,ffFiles,opls,hoomd);
if (parse.has(".pdb"))
{
cout<<"Number of pdb files "<<parse.getNValues(".pdb")<<endl;
for (int i =0;i <parse.getNValues(".pdb");i++)
{
pdbFile=parse.getString(".pdb",i);
cpdbReader readPdb(&sys,pdbFile);
}
cSystemSorter sorter(&sys);
sorter.sortOnDistance(&potential);
sorter.findMolecules();
sorter.updateAngles();
}
if(parse.has(".pdb") || parse.has("data."))
{
sys.printSummary();
sys.setParameters(&potential);
if(!potential.getVecRmBond().empty() ||!potential.getVecRmAngle().empty() ||!potential.getVecRmImproper().empty() )
{
cout <<"\nStarting remove request! \n\n";
sys.removeBonds(potential.getVecRmBond());
sys.removeAngle(potential.getVecRmAngle());
sys.removeImproper(potential.getVecRmImproper());
sys.printSummary();
potential.removePot();
sys.setParameters(&potential);
}
vector<pair<int,int>> vecSwapImDi=potential.getVecSwapImDi();
if(!vecSwapImDi.empty())
{
cout <<"\nStarting moving Impropers into diherals! \n\n";
sys.swapImproperDihedral(vecSwapImDi);
sys.setParameters(&potential);
}
//Must be last, calling setParameters after adding addOPLS() can add bonds that should not be there
if(opls)
{
sys.addOPLS();
sys.update();
}
sys.printSummary();
}
//Potential is set up, now write the wanted files
cffStream ffStream(potential);
size_t found = inFile.find_last_of(".");
string outFile=inFile.substr(0,found);
if (parse.has("-latex"))
{
ffStream.writeLatex(outFile);
} else if(parse.has("-lmp"))
{
ffStream.writeLammps(outFile);
cdatawriter dataWriter;
dataWriter.write(&sys,outFile);
}else
{
cxmlwriter xml;
ffStream.writeHoomd(outFile);
if (parse.has("-body"))
{
xml.write(&sys,outFile,true);
}else
{
xml.write(&sys,outFile,false);
}
}
}catch(exception & e)
{
std::cerr << "Error : " << e.what() << '\n';
}
return 0;
}