forked from oukenteikan/Microbe-Dataset-Division
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration.cpp
59 lines (57 loc) · 1.23 KB
/
integration.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
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#define N 1000000
#define M 3
//每一类的uniquedata获得了一个唯一的编号,然后输出为All*。
using namespace std;
int main()
{
FILE *f[M];
ofstream fout[M];
string s[M] = {"genecompress.data","genomecompress.data","proteincompress.data"};
for (int i = 0 ; i < M ; i ++)
{
f[i] = fopen((string("../Compress/") + s[i]).c_str(), "r");
if (f[i] == NULL)
{
cout << "Fail to open" << s[i] << endl;
return 0;
}
fout[i].open((string("All")+s[i]).c_str(),ios::out);
if (!fout[i])
{
cout << "Fail to open" << endl;
return 0;
}
}
cout << "Successful open" << endl;
char str[N];
map<string, long> m[M];
long cnt = 0;
for (int i = 0 ; i < M ; i ++)
{
while (fgets(str, N, f[i])!=NULL)
{
m[i].insert(pair<string, long>(str, cnt ++));
if (cnt % N == 0) cout << cnt << endl;
}
for (map<string, long>::iterator p = m[i].begin() ; p != m[i].end() ; p ++)
fout[i] << (*p).second << " " << (*p).first;
}
for (int i = 0 ; i < M ; i ++)
{
fout[i].close();
fclose(f[i]);
}
return 0;
}