Skip to content

Commit ab3b11f

Browse files
author
Nina Baumgarten
committed
current sample file
1 parent 01d6bc7 commit ab3b11f

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

src/sampleRandomRsIDs2.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include "sampleRandomRsIDs2.hpp"
22
#include <stdio.h>
33
#include <algorithm>
4-
//own classes
5-
#include "callBashCommand.hpp"
6-
74

85
string getToken(string& line, char delim){
96
int pos = 0;
@@ -34,8 +31,6 @@ void determineMAFsForSNPs(string bedFile, vector<double>& MAF){
3431
}
3532
return;
3633
}
37-
38-
3934
int main(){
4035

4136
BashCommand bc("/home/nbaumgarten/hg38.fa");
@@ -51,7 +46,7 @@ int main(){
5146
cout << "after constructor" << endl;
5247
unordered_map<double,int> MAF_counter = s.splitMAFinBins(); // split original MAF distribution in bins
5348
cout << "after maf_counter" << endl;
54-
s.determineRandomSNPs(MAF_counter, "testDir", 100, 20, ".", 1);
49+
s.determineRandomSNPs(MAF_counter, "testDir", 100, 20, 1);
5550

5651

5752

src/sampleRandomRsIDs2.hpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//own classes
2020
#include "callBashCommand.hpp"
2121

22-
int MAXIMAL_ROUNDS = 1000;
22+
int MAXIMAL_ROUNDS = 1500;
2323

2424
using namespace std;
2525

@@ -36,7 +36,8 @@ class rsIDsampler{
3636

3737
unordered_map<double, int> splitMAFinBins();
3838
string getToken(string& line, char delim);
39-
vector<string> determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, string sourceDir, int seed);
39+
//vector<string> determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, string sourceDir, int seed);
40+
vector<string> determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, int seed);
4041
void sampleSNPs(int counter, string outputFile, vector<string>& SNPs, int seed, int size, string histogramFile);
4142
// void determineRandomSamples(unordered_map<double,int>& MAF_counter, string outputFile, unordered_map<double, vector<string>>& dbSNPs, int seed, string histogram, vector<double>& keys);
4243
// unordered_map<double, vector<string>> storeDbSNPs();
@@ -75,7 +76,8 @@ rsIDsampler::~rsIDsampler()
7576
/*
7677
// reads SNPs bin per bin from the dbSNP file and determines random SNPs for the given rounds per bin
7778
*/
78-
vector<string> rsIDsampler::determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, string sourceDir, int seed){
79+
//vector<string> rsIDsampler::determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, string sourceDir, int seed){
80+
vector<string> rsIDsampler::determineRandomSNPs(unordered_map<double,int>& MAF_counter, string outputDir, int rounds, int numThreads, int seed){
7981

8082
double bin = -1.0, currentMAF = 0.0;
8183
int counter = 0, size = 0; //alternative 53330
@@ -90,11 +92,11 @@ vector<string> rsIDsampler::determineRandomSNPs(unordered_map<double,int>& MAF_c
9092
for(int r = 0; r < rounds; ++r){
9193
num = to_string(r);
9294
SNP_files[r] = outputDir + "/randomSNPs_" + num + ".txt";
93-
histogram_files[r] = outputDir + "/histogram_" + num + ".txt";
95+
//histogram_files[r] = outputDir + "/histogram_" + num + ".txt";
9496
//write header of the histogram file
95-
h.open(histogram_files[r]);
96-
h << "SNP\tMAF\n";
97-
h.close();
97+
//h.open(histogram_files[r]);
98+
//h << "SNP\tMAF\n";
99+
//h.close();
98100
}
99101

100102
ifstream inputFile(dbSNPFile); //open dbSNPFile
@@ -110,6 +112,7 @@ vector<string> rsIDsampler::determineRandomSNPs(unordered_map<double,int>& MAF_c
110112
size = currentSNPs.size();
111113
//cout << "bin " << bin << endl;
112114
for(int r = 0; r < rounds; ++r){
115+
//cout << r << endl;
113116
sampleSNPs(counter, SNP_files[r] , currentSNPs, seed + r, size, histogram_files[r]);
114117
}
115118
}
@@ -177,9 +180,9 @@ void rsIDsampler::sampleSNPs(int counter, string outputFile, vector<string>& SNP
177180
output << currentSNPs;
178181
output.close();
179182
ofstream h;
180-
h.open(histogramFile, std::ofstream::app);
181-
h << helper;
182-
h.close();
183+
// h.open(histogramFile, std::ofstream::app);
184+
// h << helper;
185+
// h.close();
183186
}
184187

185188
/*

0 commit comments

Comments
 (0)