-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCleaning up HSAEN files.cpp
More file actions
73 lines (63 loc) · 1.29 KB
/
Cleaning up HSAEN files.cpp
File metadata and controls
73 lines (63 loc) · 1.29 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
// Cleaning up HSAEN files.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "linkedlist.h"
bool Find(vector <string> vecint, string num)
{
for (int i = 0; i < vecint.size(); i++)
{
if (vecint[i] == num)
{
return true;
}
}
return false;
}
void RemoveDuplicates(vector <string>& vecstr)
{
vector <string> holder;
for (int i = 0; i < vecstr.size(); i++)
{
if (!Find(holder, vecstr[i]))
{
holder.push_back(vecstr[i]);
}
}
vecstr.clear();
for (int i = 0; i < holder.size(); i++)
{
vecstr.push_back(holder[i]);
}
holder.clear();
}
int main()
{
string str;
string hold;
int count = 0;
vector <string> PathwayGenes;
//input data from all hsa files
for (int n = 10; n <= 5300; n++)
{
PathwayGenes.clear();
str = "Pathways_HSA_" + to_string(n) + ".txt";
ifstream Pathways(str);
if (Pathways.is_open())
{
while (getline(Pathways, hold))
{
PathwayGenes.push_back(hold);
}
//delete duplicates
RemoveDuplicates(PathwayGenes);
cout << str << endl;
//insert data back into text file
ofstream myfile(str);
for (int i = 0; i < PathwayGenes.size(); i++)
{
myfile << PathwayGenes[i] << endl;
}
Pathways.close();
}
}
return 0;
}