-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileReader.h
337 lines (282 loc) · 9.14 KB
/
FileReader.h
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/**
* @file FileReader.h
* @author Donal Evans
* @date 03 Jun 2016
* @see Atom.h
* @see Residue.h
* @brief This class opens and reads .gro and .xtc files and stores them.
*
* Detailed description goes here.
*/
#ifndef FILEREADER_H
#define FILEREADER_H
#include "Atom.h"
#include "Residue.h"
#include <QObject>
#include <QVector3D>
#include <limits>
class FileReader : public QObject
{
Q_OBJECT
public:
/**
* @brief Getter for the Atom pointer vector.
* @return A QVector of Atom pointers.
*/
QVector<Atom*>& GetAtomVectorRef();
/**
* @brief Getter for the maximum path curvature value among the atoms
* in the atom vector.
* @return The value of the maximum path curvature, as a float.
*/
float GetMaxPathCurvature();
/**
* @brief Getter for the maximum path length value among the atoms
* in the atom vector.
* @return The value of the maximum path length, as a float.
*/
float GetMaxPathLength();
/**
* @brief Getter for the maximum velocity value among the atoms
* in the atom vector.
* @return The value of the maximum velocity, as a float.
*/
float GetMaxVelocity();
/**
* @brief Getter for the minimum path curvature value among the atoms
* in the atom vector.
* @return The value of the minimum path curvature, as a float.
*/
float GetMinPathCurvature();
/**
* @brief Getter for the minimum path length value among the atoms
* in the atom vector.
* @return The value of the minimum path length, as a float.
*/
float GetMinPathLength();
/**
* @brief Getter for the minimum velocity value among the atoms
* in the atom vector.
* @return The value of the minimum velocity, as a float.
*/
float GetMinVelocity();
/**
* @brief Getter for the vector containing the Residue pointers from
* the .gro file.
* @return QVector of Residue pointers.
*/
QVector<Residue*>& GetResidueVectorRef();
/**
* @brief Setter for the vector containing Residue pointers.
* @param residueVector A QVector of Residue objects.
*/
void SetResidueVector(QVector<Residue*> residueVector);
/**
* @brief Getter for the 3D vector containing the dimensions of the
* simulation box.
* @return QVector3D containing x, y and z dimensions.
*/
QVector3D& GetSimBoxRef();
/**
* @brief Constructor
*/
FileReader();
/**
* @brief Calculates the path curvature for every @Atom in the atom vector.
*/
void CalculatePathCurvature();
/**
* @brief Calculates the path length for every @Atom in the atom vector.
*/
void CalculatePathLength();
/**
* @brief Calculates the velocity for every @Atom in the atom vector.
*/
void CalculateVelocity();
/**
* @brief Reads data from .gro and .xtc files and stores it.
* @param groFilePath The file path of the .gro file.
* @param xtcFilePath The file path of the .xtc file.
* @return true if the data was loaded successfully, false otherwise.
*/
bool LoadData(const QString& groFilePath,
const QString& xtcFilePath);
signals:
/**
* @brief Used to output messages from the class.
* @param output The string to be output.
* @param duration The duration in ms that the message will be displayed
* on a QStatusBar.
*/
void consoleOutput(QString output, int duration);
private:
/**
* @brief Setter for the Atom pointer vector.
* @param atomVector A QVector of Atom pointers.
*/
void setAtomVector(QVector<Atom*> atomVector);
/**
* @brief Getter for the list of Strings in the .gro file.
* @return A list of Strings.
*/
QStringList getGroList();
/**
* @brief Setter for the list of Strings in the .gro file.
* @param groList A list of Strings.
*/
void setGroList(QStringList& groList);
/**
* @brief Getter for the number of unique Residues in the .gro file.
* @return An integer.
*/
int getNumOfResidues();
/**
* @brief etter for the number of unique Residues in the .gro file.
* @param NumOfResidues An integer value.
*/
void setNumOfResidues(int numOfResidues);
/**
* @brief Setter for the 3D vector containing the dimensions of the
* simulation box.
* @param x The size of the simulation box in the X dimension.
* @param y The size of the simulation box in the Y dimension.
* @param z The size of the simulation box in the Z dimension.
*/
void setSimBox(float x, float y, float z);
/**
* @brief Adds a Residue @e residue to the Residue vector at index @e index.
* @param residue The Residue to be added to the Residue vector.
* @param index The index at which the Residue will be added.
*/
void addResidue(Residue* residue, int index);
/**
* @brief Removes all Atoms from the Atom vector.
*/
void clearAtomVector();
/**
* @brief Removes all Residues from the Residue vector.
*/
void clearResidueVector();
/**
* @brief Creates an Atom for each line of the .gro file data and adds
* it to the Atom vector.
*/
void createAtomVector();
/**
* @brief Stores a list of all the lines of data in the .gro file.
*
* Takes a String containing the entire contents of the .gro file, splits
* it up by line and discards the first two lines and the last line, which
* do not contain atom information.
* @param groFileData The contents of the .gro file.
*/
void createGroList(QString groFileData);
/**
* @brief Creates a vector of the residues in the .gro file.
*
* For each unique residue in the .gro file, creates a Residue object and
* populates it with Atom objects for each atom belonging to that residue.
*/
void createResidueVector();
/**
* @brief Reads data from the .gro file and stores it.
* @param groFilePath The file path of the .gro file.
* @return true if the data was fetched successfully, false otherwise.
*/
bool fetchGroData(const QString& groFilePath);
/**
* @brief Reads data from the .xtc file and adds it to the data from
* the .gro file.
* @param xtcFilePath The file path of the .xtc file.
* @return true if the data was fetched successfully, false otherwise.
*/
bool fetchXtcData(const QString& xtcFilePath);
/**
* @brief A QVector of pointers to all the Atoms in the .gro file.
*/
QVector<Atom*> m_AtomVector;
/**
* @brief A list of Strings containing each line of the .gro file.
*/
QStringList m_GroList;
/**
* @brief The value of the maximum path curvature value among the atoms
* in the atom vector, as a float.
*/
float m_MaxPathCurvature = -INFINITY;
/**
* @brief The value of the maximum path length value among the atoms
* in the atom vector, as a float.
*/
float m_MaxPathLength = -INFINITY;
/**
* @brief The value of the maximum velocity value among the atoms
* in the atom vector, as a float.
*/
float m_MaxVelocity = -INFINITY;
/**
* @brief The value of the minimum path curvature value among the atoms
* in the atom vector, as a float.
*/
float m_MinPathCurvature = INFINITY;
/**
* @brief The value of the minimum path length value among the atoms
* in the atom vector, as a float.
*/
float m_MinPathLength = INFINITY;
/**
* @brief The value of the minimum velocity value among the atoms
* in the atom vector, as a float.
*/
float m_MinVelocity = INFINITY;
/**
* @brief The number of unique Residues in the .gro file.
*/
int m_NumOfResidues;
/**
* @brief Flag signifying if the path curvature has already been calculated for
* the atoms in the atom vector or not.
*/
bool m_PathCurvature;
/**
* @brief Flag signifying if the path length has already been calculated for
* the atoms in the atom vector or not.
*/
bool m_PathLength;
/**
* @brief A vector of all the Residues in the .gro file.
*/
QVector<Residue*> m_ResidueVector;
/**
* @brief The dimensions of the computational box in which the Atoms exist.
*/
QVector3D m_SimBox;
/**
* @brief Flag signifying if the velocity has already been calculated for
* the atoms in the atom vector or not.
*/
bool m_Velocity;
/**
* @brief Xtc position data is stored in reduced precision. This scaling
* factor allows original precision to be restored.
*/
float XTC_PREC = 1000.0;
/**
* @brief The index of the x coordinate in position vectors.
*/
const int X_POSITION = 0;
/**
* @brief The index of the y coordinate in position vectors.
*/
const int Y_POSITION = 1;
/**
* @brief The index of the z coordinate in position vectors.
*/
const int Z_POSITION = 2;
/**
* @brief Allows printing of Strings to console.
* @param output The String to be printed.
*/
void print(QString output);
};
#endif // FILEREADER_H