-
Notifications
You must be signed in to change notification settings - Fork 7
/
InputManager.cpp
117 lines (99 loc) · 2.53 KB
/
InputManager.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
// InputManager.cpp: manages input
#include "InputManager.h"
#include "PEDIndividualsExtractor.h"
#include "HMIndividualsExtractor.h"
#include <iostream>
#include <cmath>
using namespace std;
// InputManager(): default constructor
InputManager::InputManager()
{
// get map of genetic distance
string choice;
choice = "1" ; // 1-> Indicates PED/PLink Data
/*normalPrompt();
cin >> choice;
while (!validChoice(choice))
{
invalidChoiceMessage();
normalPrompt();
cin >> choice;
}*/
setFileFormat(choice);
instantiatePie();
}
InputManager::~InputManager()
{
delete pie;
}
bool InputManager::getPhased()
{
string s; bool phase;
cout << "Please indicate if the phase is known" << endl
<< '\t' << "Enter 1 for phased" << endl
<< '\t' << "Enter 2 for unphased" << endl;
cin >> s;
if(s[0] == '1') phase = true;
else phase = false;
pie->setPhased(phase);
return phase;
}
// getIndividuals(): extracts individuals using pie
void InputManager::getIndividuals(string map, string ped)
{
pie->getInput(map, ped);
}
// normalPrompt():issues prompt asking user which file format
// will be used for individuals
void InputManager::normalPrompt()
{
cout << "Please indicate which file format you'll be using for individuals" << endl
<< " Enter 1 for PED / Plink" << endl
<< " Enter 2 for PHASE / HapMap" << endl;
}
string InputManager::getOutput()
{
string s;
cout << "Please indicate output file location: " << endl;
cin >> s;
return s;
}
// validChoice(): determines if a string is valid input for file format
bool InputManager::validChoice(string choice)
{
if (choice[0] == '1' || choice[0] == '2')
return true;
else
return false;
}
PolymorphicIndividualsExtractor* InputManager::getPie()
{
return pie;
}
// invalidChoiceMessage(): gives message saying format is not valid
void InputManager::invalidChoiceMessage()
{
cerr << "That choice is not recognized." << endl;
}
// setFileFormat(): sets file format using information from normalPrompt()
void InputManager::setFileFormat(string choice)
{
if (choice[0] == '1')
format = PED;
else if (choice[0] == '2')
format = HM;
else
{
cerr << "WARNING: InputManager::setFileFormat(): invalid file format choice"
<< endl;
}
}
// instantiatePie(): instantiates appropriate pie
void InputManager::instantiatePie()
{
if (format == PED)
pie = new PEDIndividualsExtractor();
else if (format == HM)
pie = new HMIndividualsExtractor();
}
// end InputManager.cpp