Commit 9295f811 authored by Cyprien Borée's avatar Cyprien Borée

add parameter and fix bugs

For more informations see #3393.
parent 663aff89
Pipeline #34879 failed with stages
in 2 minutes and 46 seconds
......@@ -21,7 +21,8 @@ void BinReadStorage::init(size_t nb_bins, size_t max_score, const VirtualReadSco
if (inited)
return;
this->nb_bins = nb_bins;
this->nb_bins = 1;
this->max_bins = nb_bins;
this->max_score = max_score;
if (no_list)
bins = NULL;
......@@ -37,6 +38,7 @@ void BinReadStorage::init(size_t nb_bins, size_t max_score, const VirtualReadSco
void BinReadStorage::reallocate(){
auto tmp_bin = bins;
nb_bins = max_bins;
if(bins){
delete [] bins;
......@@ -86,6 +88,8 @@ void BinReadStorage::addScore(size_t bin, float score) {
void BinReadStorage::add(Sequence &s) {
float score = scorer->getScore(s);
size_t bin = scoreToBin(score);
addScore(bin, score);
all_read_lengths += s.sequence.length();
if (nb_stored < getMaxNbReadsStored()) {
bins[bin].push_back(s);
nb_stored++;
......@@ -94,7 +98,10 @@ void BinReadStorage::add(Sequence &s) {
} else {
// We don't have space left.
// Either we don't insert that sequence or it replaces another one
reallocate();
if(nb_inserted >= nb_stored){
reallocate();
nb_stored *= nb_bins;
}
if (bin > smallest_bin_not_empty) {
bins[smallest_bin_not_empty].erase(bins[smallest_bin_not_empty].begin());
if (bins[smallest_bin_not_empty].size() == 0)
......
......@@ -68,6 +68,7 @@ class VirtualReadStorage {
*/
class BinReadStorage: public VirtualReadStorage {
private:
size_t max_bins;
size_t nb_bins;
list<Sequence> *bins;
double *score_bins;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment