-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenbs.cpp
More file actions
84 lines (63 loc) · 1.47 KB
/
Copy pathgenbs.cpp
File metadata and controls
84 lines (63 loc) · 1.47 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
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include "bkgsub.h"
using namespace std;
int main()
{
srand((unsigned)time(NULL));
// Input node gene list.
cout << "Input node gene list file: ";
string node;
cin >> node;
vector<string> nlst;
if(get1stcol(node, nlst) < 0)
return 1;
// Input bkg gene list.
cout << "Input bkg gene list file: ";
string bkg;
cin >> bkg;
vector<string> blst;
if(get1stcol(bkg, blst) < 0)
return 1;
cout << "Input number of bootstrap samples: ";
int bsn;
cin >> bsn;
// Do 10 bootstrap sampling.
for(int bs = 0; bs < bsn; bs++)
{
ostringstream strmo;
strmo << node << bs+1;
ofstream o(strmo.str().data());
vector<string> rlst;
for(size_t i = 0; i < nlst.size(); i++)
{
int idx = (int)floor(((double)rand()-1)/RAND_MAX*nlst.size());
rlst.push_back(nlst[idx]);
}
for(size_t i = 0; i < rlst.size(); i++)
o << rlst[i] << endl;
o.close();
}
for(int bs = 0; bs < bsn; bs++)
{
ostringstream strmo;
strmo << bkg << bs+1;
ofstream o(strmo.str().data());
vector<string> rlst;
for(size_t i = 0; i < blst.size(); i++)
{
int idx = (int)floor(((double)rand()-1)/RAND_MAX*blst.size());
rlst.push_back(blst[idx]);
}
for(size_t i = 0; i < rlst.size(); i++)
o << rlst[i] << endl;
o.close();
}
return 0;
}