-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueryValidation.cpp
109 lines (97 loc) · 2.05 KB
/
queryValidation.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
#include <string>
#include <cstdlib>
#include <iostream>
#include "queryValidation.h"
#include "myStructs.h"
using namespace std;
void setInputType(const string& parameter, InputType& input)
{
if (!parameter.compare("ged"))
{
input.raw = 1;
input.corr = 0;
input.unfiltered = 0;
}
else if (!parameter.compare("corr"))
{
input.raw = 0;
input.corr = 1;
input.unfiltered = 0;
}
else if (!parameter.compare("csd"))
{
input.raw = 0;
input.corr = 0;
input.unfiltered = 1;
}
else
{
cout << "Error: Unknown argument for input.\n";
exit(1);
}
}
void setOutput(const string& parameter, Output& o)
{
if (!parameter.compare("corr"))
{
o.corr = 1;
}
else if (!parameter.compare("csd"))
{
o.unfiltered = 1;
}
else if (!parameter.compare("network"))
{
o.filtered = 1;
}
else if (!parameter.compare("all"))
{
o.all = 1;
}
else
{
cout << "Error: Unknown argument for output.\n";
exit(1);
}
}
void setCorrMethod(const string& parameter, string& c)
{
if (!parameter.compare("pearson"))
{
c = parameter;
}
else if (!parameter.compare("spearman"))
{
c = parameter;
}
else
{
cout << "Error: Unknown argument for correlation method.\n";
exit(1);
}
}
void setFormat(const string& parameter, bool& vertical)
{
if (!parameter.compare("horizontal")) vertical = 0;
else if (!parameter.compare("vertical")) vertical = 1;
else
{
cout << "Error: Unknown argument for data format given. Expected either\n"
<< "\"horizontal\" or \"vertical\"\n";
exit(1);
}
}
void validateJob(const InputType& input, const Output& o)
{
if ((input.corr && o.corr) || (input.unfiltered && o.unfiltered))
{
cout << "Error: Input type = Output type.\n";
exit(1);
}
if (input.unfiltered && o.corr)
{
cout << "Error: Cannot calculate correlation coefficients with unfiltered\n"
<< "CSD-scores as input.";
exit(1);
}
}