Skip to content
Snippets Groups Projects
Commit 2cf1abc1 authored by Veronique Legrand's avatar Veronique Legrand
Browse files

bugfix : now increment the counter for only the biggest hash value obtained...

bugfix : now increment the counter for only the biggest hash value obtained for a k-mer and its reverse complement. Before, I incemented both counters and it is not what we want.
parent eb952327
No related branches found
No related tags found
No related merge requests found
...@@ -61,17 +61,17 @@ const int CountMinSketch::Pi_js[500]={2147469629, 2147469637, 2147469659, 214746 ...@@ -61,17 +61,17 @@ const int CountMinSketch::Pi_js[500]={2147469629, 2147469637, 2147469659, 214746
void CountMinSketch::addKMer(unsigned long val) { void CountMinSketch::addKMer(const unsigned long& val1,const unsigned long& val2) {
int h,j; int h1,h2,h,j;
// short cnt; // short cnt;
unsigned char cnt; unsigned char cnt;
//unsigned short min=ushortmask; //unsigned short min=ushortmask;
for (j=0;j<lambda;j++) { for (j=0;j<lambda;j++) {
h=hash64to32(val,j); h1=hash64to32(val1,j);
h2=hash64to32(val2,j);
(h1>h2)?h=h1:h=h2;
cnt=cms_lambda_array[j] [h]; cnt=cms_lambda_array[j] [h];
cnt++; cnt++;
//if (cnt<min) min=cnt;
// cms_lambda_array[j] [h]=(cnt & ushortmask);
cms_lambda_array[j] [h]=(cnt & ubytemask); cms_lambda_array[j] [h]=(cnt & ubytemask);
} }
} }
...@@ -102,7 +102,8 @@ int CountMinSketch::addRead(const readNumericValues& read_val) { ...@@ -102,7 +102,8 @@ int CountMinSketch::addRead(const readNumericValues& read_val) {
if (keep_r) { if (keep_r) {
readNumericValues::const_iterator it; readNumericValues::const_iterator it;
for (it=read_val.begin();it!=read_val.end();it++) { for (it=read_val.begin();it!=read_val.end();it++) {
addKMer(*it); /* Here, note that k-mer go by pair : 1rst 1 is k_mer and next one is its reverse complement*/
addKMer(*it,*(++it));
} }
} }
return keep_r; return keep_r;
......
...@@ -64,7 +64,7 @@ class CountMinSketch { ...@@ -64,7 +64,7 @@ class CountMinSketch {
// std::map<int,int> getIthArray(int); // utility method provided for testing only. // std::map<int,int> getIthArray(int); // utility method provided for testing only.
void addKMer(unsigned long); // inline? TODO: see later if it can help us gain time. void addKMer(const unsigned long&,const unsigned long&); // inline? TODO: see later if it can help us gain time.
int isRCovBelowThres(const readNumericValues& read_val, const int& threshold); int isRCovBelowThres(const readNumericValues& read_val, const int& threshold);
......
...@@ -36,7 +36,7 @@ void test_CMS(int lambda,int kappa,int kappa_prime) { ...@@ -36,7 +36,7 @@ void test_CMS(int lambda,int kappa,int kappa_prime) {
int rej_expected=0; int rej_expected=0;
int ret; int ret;
for (i=0;i<num;i++) { for (i=0;i<num;i++) {
cms.addKMer(num); cms.addKMer(num,num-1);
} }
// Now, check that our k-mer is present in the CMS. // Now, check that our k-mer is present in the CMS.
int min=cms.getEstimatedNbOcc(num); int min=cms.getEstimatedNbOcc(num);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment