-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstColMilestones.cpp
More file actions
50 lines (40 loc) · 1.5 KB
/
firstColMilestones.cpp
File metadata and controls
50 lines (40 loc) · 1.5 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
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<sstream>
// Program 4
using std::cout; using std::string; using std::vector; using std::stringstream; using std::fstream; using std::ios; using std::endl; using std::flush;
#define DELTA 3
#define ull unsigned long long
string firstColFilename = "data/dataset1/chrX_map.txt";
string mapMilestoneFilename = "chrX_map_milestone.txt";
int main(int argc, char const *argv[]){
fstream firstColFile(firstColFilename, ios::in);
fstream mapMilestoneFile(mapMilestoneFilename, ios::out|ios::trunc);
if(!firstColFile.is_open()){
cout<<"| Unable to open "<<firstColFilename<<" to read from it. Program terminated.\n";
return EXIT_FAILURE;
}
if(!mapMilestoneFile.is_open()){
cout<<"| Unable to open "<<mapMilestoneFilename<<" to write into it. Program terminated.\n";
return EXIT_FAILURE;
}
string readIndex;
ull index, iter = 0;
vector<ull>milestoneIndices;
cout<<"Parsing..."<<flush;
while (getline(firstColFile, readIndex)){
index = stoull(readIndex);
if (!(iter%DELTA)) milestoneIndices.push_back(index);
iter++;
}
cout<<"\rParsed.\n";
cout<<"Writing to file..."<<flush;
for (ull i = 0; i < milestoneIndices.size(); i++){
mapMilestoneFile<<milestoneIndices[i]<<"\n";
}
cout<<"\rWritten to file.\n";
if(firstColFile.is_open()) firstColFile.close();
if(mapMilestoneFile.is_open()) mapMilestoneFile.close();
}