Commit 8806e956 authored by Li's avatar Li Committed by Haowen Zhang
Browse files

Fix a problem of underflow causing wrong hit order

parent 450e04df
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -449,7 +449,7 @@ int Index::CollectSeedHits(
      if (mm_positive_hits[mi].size() == 0) continue;
      // only the positive part may have the underflow issue
      if (heap_resort)
        std::sort(mm_positive_hits[mi].begin(), mm_positive_hits[mi].end());
        std::sort(mm_positive_hits[mi].begin(), mm_positive_hits[mi].end(), CompSortHits);
      struct mmHit nh;
      nh.mi = mi;
      nh.position = mm_positive_hits[mi][0];
@@ -495,7 +495,7 @@ int Index::CollectSeedHits(
    delete[] mm_negative_hits;
    delete[] mm_pos;
  } else {
    std::sort(positive_hits.begin(), positive_hits.end());
    std::sort(positive_hits.begin(), positive_hits.end(), CompSortHits);
    std::sort(negative_hits.begin(), negative_hits.end());
  }
  /*for (uint32_t mi = 0 ; mi < positive_hits->size() ; ++mi)
+7 −0
Original line number Diff line number Diff line
@@ -93,6 +93,13 @@ class Index {
    return key;
  }

  inline static bool CompSortHits(const uint64_t &a, const uint64_t &b) {
    if (int(a>>32) != int(b>>32))
      return a < b;
    else
      return (int)a < int(b);
  }

 protected:
  int kmer_size_;
  int window_size_;
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,14 @@ class MappingMetadata {
    repetitive_seed_length_ = 0;
  }

  inline void PrintCandidates(FILE *fp) {
    uint32_t i ;
    for (i = 0 ; i < positive_candidates_.size() ; ++i)
      fprintf(fp, "+ %d %d %d %d\n", i, (int)(positive_candidates_[i].position>>32), (int)(positive_candidates_[i].position), positive_candidates_[i].count) ;
    for (i = 0 ; i < negative_candidates_.size() ; ++i)
      fprintf(fp, "- %d %d %d %d\n", i, (int)(negative_candidates_[i].position>>32), (int)(negative_candidates_[i].position), negative_candidates_[i].count) ;
  }

  inline size_t GetNumCandidates() const {
    return positive_candidates_.size() + negative_candidates_.size();
  }
+5 −1
Original line number Diff line number Diff line
@@ -48,7 +48,11 @@ struct mmHit {

  bool operator<(const mmHit &h) const {
    // the inversed direction is to make a min-heap
    //return position > h.position;
    if (int(position>>32) != int(h.position>>32))
      return position > h.position;
    else
      return (int)position > (int)h.position;
  }
};