Skip to content

Commit

Permalink
fix discretization abundance bug when abundance >= 50000
Browse files Browse the repository at this point in the history
  • Loading branch information
rizkg committed May 13, 2019
1 parent 626b5b5 commit f58d96b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 15 additions & 10 deletions gatb-core/src/gatb/kmer/impl/MPHFAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,22 @@ void MPHFAlgorithm<span,Abundance_t,NodeState_t>::populate ()
/** We get the abundance of the current kmer. */
int abundance = itKmers->item().abundance;

if (abundance > max_abundance_discrete)
{
_nb_abundances_above_precision++;
//std::cout << "found abundance larger than discrete: " << abundance << std::endl;
abundance = max_abundance_discrete;
}

int idx ;
if (abundance >= max_abundance_discrete)
{
_nb_abundances_above_precision++;
//std::cout << "found abundance larger than discrete: " << abundance << std::endl;
idx = _abundanceDiscretization.size() -2 ;
}
else
{
//get first cell strictly greater than abundance
std::vector<int>::iterator up = std::upper_bound(_abundanceDiscretization.begin(), _abundanceDiscretization.end(), abundance);
up--; // get previous cell
idx = up- _abundanceDiscretization.begin() ;
}

//get first cell strictly greater than abundance
std::vector<int>::iterator up = std::upper_bound(_abundanceDiscretization.begin(), _abundanceDiscretization.end(), abundance);
up--; // get previous cell
int idx = up- _abundanceDiscretization.begin() ;
/** We set the abundance of the current kmer. */
_abundanceMap->at (h) = idx;

Expand Down
4 changes: 2 additions & 2 deletions gatb-core/src/gatb/tools/collections/impl/MapMPHF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ namespace gatb {



_abundanceDiscretization[256] = UINT_MAX;
_abundanceDiscretization[256] = total;




Expand Down

0 comments on commit f58d96b

Please sign in to comment.