Repository navigation
Expand file tree
/
Copy pathInputManager.cpp
More file actions
98 lines (81 loc) · 1.9 KB
/
Copy pathInputManager.cpp
File metadata and controls
98 lines (81 loc) · 1.9 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
// 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()
{
string choice;
if ( ped_file == "" || map_file == "" || out_file == "" ) {
normalPrompt();
cin >> choice;
while (!validChoice(choice))
{
invalidChoiceMessage();
normalPrompt();
cin >> choice;
}
}
setFileFormat("1");
instantiatePie();
}
InputManager::~InputManager()
{
delete pie;
}
// getIndividuals(): extracts individuals using pie
void InputManager::getIndividuals()
{
pie->getInput();
}
// 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;
}
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
{
cerr << "WARNING: InputManager::setFileFormat(): invalid file format choice"
<< endl;
}
}
// instantiatePie(): instantiates appropriate pie
void InputManager::instantiatePie()
{
pie = new PEDIndividualsExtractor();
}
// end InputManager.cpp