-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cpp
More file actions
341 lines (303 loc) · 7.39 KB
/
Config.cpp
File metadata and controls
341 lines (303 loc) · 7.39 KB
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
338
339
340
341
#include <iostream>
#include <string>
#include <fstream>
#include "Config.h"
using namespace std;
Config::Config() {
AlignmentType = -1;
InputFile = "";
SlidingWindow = -1;
ReversalStatus = false;
MetricType = -1;
TransformationType = -1;
OutputFile = "";
OutputCoordFile = "";
OutputType = -1;
//Optional Variables
SeedOne = "";
SeedTwo = "";
GenomeSize = -1;
TotalTags = -1;
}
Config::Config(char *input) {
AlignmentType = -1;
InputFile = "";
SlidingWindow = -1;
ReversalStatus = false;
MetricType = -1;
TransformationType = -1;
OutputFile = "";
OutputCoordFile = "";
OutputType = -1;
//Optional Variables
SeedOne = "";
SeedTwo = "";
GenomeSize = -1;
TotalTags = -1;
LoadConfig(input);
}
Config::~Config() {
}
void Config::LoadConfig(char *input) {
ifstream file(input);
while (!file.eof()) {
string temp;
getline(file, temp);
if(!temp.compare("Alignment:")) {
getline(file, temp);
if(!temp.compare("seed")) {
cout<<"Alignment Type: Seed Selection\n";
AlignmentType = 1;
}
else if(!temp.compare("bestpair")) {
cout<<"Alignment Type: BestPair Selection\n";
AlignmentType = 2;
}
else if(!temp.compare("chosen")) {
cout<<"Alignment Type: Chosen Selection\n";
AlignmentType = 3;
}
else {
cout<<"Invalid Alignment Type!!!\n";
exit(0);
}
}
if(!temp.compare("Input File:")) {
getline(file, InputFile);
cout<<"File to be Aligned: "<<InputFile<<endl;
}
if(!temp.compare("Sliding Window:")) {
getline(file, temp);
SlidingWindow = atoi(temp.c_str());
if(SlidingWindow < 1) {
cout<<"Invalid Sliding Window!!!\n";
exit(0);
}
cout<<"Window Size: "<<SlidingWindow<<endl;
}
if(!temp.compare("Reversal Status:")) {
getline(file, temp);
if(!temp.compare("true")) {
cout<<"Reversal Status: true\n";
ReversalStatus = true;
}
else if(!temp.compare("false")) {
cout<<"Reversal Status: false\n";
ReversalStatus = false;
}
else {
cout<<"Invalid Reversal Status!!!\n";
exit(0);
}
}
if(!temp.compare("Alignment Metric:")) {
getline(file, temp);
if(!temp.compare("pearson")) {
cout<<"Metric Selected: pearson\n";
MetricType = 1;
}
else if(!temp.compare("spearman")) {
cout<<"Metric Selected: spearman\n";
MetricType = 2;
}
else if(!temp.compare("euclidean")) {
cout<<"Metric Selected: euclidean\n";
MetricType = 3;
}
else {
cout<<"Invalid Metric Selected!!!\n";
exit(0);
}
}
if(!temp.compare("Transformation:")) {
getline(file, temp);
if(!temp.compare("none")) {
cout<<"Transformation Status: none\n";
TransformationType = 0;
}
else if(!temp.compare("poisson")) {
cout<<"Transformation Status: poisson\n";
TransformationType = 1;
}
else if(!temp.compare("log")) {
cout<<"Transformation Status: log\n";
TransformationType = 2;
}
else if(!temp.compare("squareroot")) {
cout<<"Transformation Status: squareroot\n";
TransformationType = 3;
}
else {
cout<<"Invalid Transformation!!!\n";
exit(0);
}
}
if(!temp.compare("Alignment File Output:")) {
getline(file, OutputFile);
cout<<"Primary Output File: "<<OutputFile<<endl;
}
if(!temp.compare("Alignment Coordinates File Output:")) {
getline(file, OutputCoordFile);
cout<<"Alignment Coordinate Output File: "<<OutputCoordFile<<endl;
}
if(!temp.compare("Genome Size:")) {
getline(file, temp);
GenomeSize = atof(temp.c_str());
cout<<"Genome Size: "<<GenomeSize<<endl;
}
if(!temp.compare("Total Tag Count:")) {
getline(file, temp);
TotalTags = atof(temp.c_str());
cout<<"Total Tags: "<<TotalTags<<endl;
}
if(!temp.compare("Seed One:")) {
getline(file, SeedOne);
cout<<"Primary Seed: "<<SeedOne<<endl;
}
if(!temp.compare("Seed Two:")) {
getline(file, SeedTwo);
cout<<"Secondary Seed: "<<SeedTwo<<endl;
}
if(!temp.compare("Output Type:")) {
getline(file, temp);
if(!temp.compare("standard")) {
cout<<"Output Type: standard\n";
OutputType = 1;
}
else if(!temp.compare("treeview")) {
cout<<"Output Type: treeview\n";
OutputType = 2;
}
else {
cout<<"Invalid Output Type!!!\n";
exit(0);
}
}
if(!file.eof()) {
getline(file, temp);
}
}
file.close();
LoadingCheck();
}
void Config::LoadingCheck() {
if(AlignmentType == -1) {
cout<<"No Alignment Type Selected!!!\n";
exit(0);
}
if(!InputFile.compare("")) {
cout<<"No Input File Selected!!!\n";
exit(0);
}
if(SlidingWindow == -1) {
cout<<"No Window Size Selected!!!\n";
exit(0);
}
if(MetricType == -1) {
cout<<"No Metric Type Selected!!!\n";
exit(0);
}
if(TransformationType == -1) {
cout<<"No Transformation Type Selected!!!\n";
exit(0);
}
if(!OutputFile.compare("")) {
cout<<"No Output File Selected!!!\n";
exit(0);
}
if(!OutputCoordFile.compare("")) {
cout<<"No Output Coordinate File Selected!!!\n";
exit(0);
}
if(OutputType == -1) {
cout<<"No Output Type Selected!!!\n";
exit(0);
}
if(TransformationType != 0 && TransformationType != 3 && (GenomeSize < 1 || TotalTags < 1)) {
cout<<"Genome Size and TotalTag Count are Invalid for Transformation Selected\n";
exit(0);
}
if(AlignmentType == 3 && (!SeedOne.compare("") || !SeedTwo.compare(""))) {
cout<<"Invalid Seeds Selected for Chosen Seed Alignment!!!\n";
exit(0);
}
}
int Config::getAlignmentType() {
return AlignmentType;
}
string Config::getInputFile() {
return InputFile;
}
int Config::getSlidingWindow() {
return SlidingWindow;
}
bool Config::getReversalStatus() {
return ReversalStatus;
}
int Config::getMetricType() {
return MetricType;
}
int Config::getTransformationType() {
return TransformationType;
}
string Config::getOutputFile() {
return OutputFile;
}
string Config::getOutputCoordFile() {
return OutputCoordFile;
}
int Config::getOutputType() {
return OutputType;
}
void Config::setAlignmentType(int type) {
AlignmentType = type;
}
void Config::setInputFile(string file) {
InputFile = file;
}
void Config::setSlidingWindow(int window) {
SlidingWindow = window;
}
void Config::setReversalStatus(bool status) {
ReversalStatus = status;
}
void Config::setMetricType(int metric) {
MetricType = metric;
}
void Config::setTransformationType(int transformation) {
TransformationType = transformation;
}
void Config::setOutputFile(string outfile) {
OutputFile = outfile;
}
void Config::setOutputCoordFile(string outcoordfile) {
OutputCoordFile = outcoordfile;
}
void Config::setOutputType(int out) {
OutputType = out;
}
//Optional Variables
string Config::getSeedOne() {
return SeedOne;
}
string Config::getSeedTwo() {
return SeedTwo;
}
double Config::getGenomeSize() {
return GenomeSize;
}
double Config::getTotalTags() {
return TotalTags;
}
void Config::setSeedOne(string one) {
SeedOne = one;
}
void Config::setSeedTwo(string two) {
SeedTwo = two;
}
void Config::setGenomeSize(double size) {
GenomeSize = size;
}
void Config::setTotalTags(double tags) {
TotalTags = tags;
}