Commit 4ffcc6aa authored by Haowen Zhang's avatar Haowen Zhang Committed by swiftgenomics
Browse files

Rename a minimizer position as a hit.

parent 2f4c02c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include "temp_mapping.h"
#include "utils.h"

#define CHROMAP_VERSION "0.2.3-r429"
#define CHROMAP_VERSION "0.2.3-r430"

namespace chromap {

+3 −3
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ void Index::Construct(uint32_t num_sequences, const SequenceBatch &reference) {
      break;
    }

    occurrence_table_.push_back(minimizers[ti].GetMinimizer());
    occurrence_table_.push_back(minimizers[ti].GetHit());
    previous_key = current_key;
  }

@@ -225,13 +225,13 @@ void Index::CheckIndex(uint32_t num_sequences,
    uint64_t key = kh_key(lookup_table_, khash_iterator);
    uint64_t value = kh_value(lookup_table_, khash_iterator);
    if (key & 1) {  // singleton
      assert(minimizers[i].GetMinimizer() == value);
      assert(minimizers[i].GetHit() == value);
      count = 0;
    } else {
      uint32_t offset = value >> 32;
      uint32_t num_occ = value;
      uint64_t value_in_index = occurrence_table_[offset + count];
      assert(value_in_index == minimizers[i].GetMinimizer());
      assert(value_in_index == minimizers[i].GetHit());
      ++count;
      if (count == num_occ) {
        count = 0;
+11 −12
Original line number Diff line number Diff line
@@ -12,23 +12,22 @@ class Minimizer {
  Minimizer() = delete;

  Minimizer(std::pair<uint64_t, uint64_t> minimizer)
      : hash_key_(minimizer.first), minimizer_(minimizer.second) {}
      : hash_key_(minimizer.first), hit_(minimizer.second) {}

  Minimizer(uint64_t hash_key, uint64_t minimizer)
      : hash_key_(hash_key), minimizer_(minimizer) {}
  Minimizer(uint64_t hash_key, uint64_t hit) : hash_key_(hash_key), hit_(hit) {}

  ~Minimizer() = default;

  inline uint64_t GetHashKey() const { return hash_key_; }

  inline uint64_t GetMinimizer() const { return minimizer_; }
  inline uint64_t GetHit() const { return hit_; }

  inline uint32_t GetSequenceIndex() const { return (minimizer_ >> 33); }
  inline uint32_t GetSequenceIndex() const { return (hit_ >> 33); }

  inline uint32_t GetSequencePosition() const { return (minimizer_ >> 1); }
  inline uint32_t GetSequencePosition() const { return (hit_ >> 1); }

  inline Strand GetSequenceStrand() const {
    if ((minimizer_ & 1) == 0) {
    if ((hit_ & 1) == 0) {
      return kPositive;
    }
    return kNegative;
@@ -39,7 +38,7 @@ class Minimizer {
      return true;
    }

    if (hash_key_ == m.hash_key_ && minimizer_ < m.minimizer_) {
    if (hash_key_ == m.hash_key_ && hit_ < m.hit_) {
      return true;
    }

@@ -50,10 +49,10 @@ class Minimizer {
  // The hash value of the kmer.
  uint64_t hash_key_ = 0;

  // The high 31 bits save the reference sequence index in the reference
  // sequence batch. The following 32 bits save the reference position on that
  // sequence. And the lowest bit encodes the strand (0 for positive).
  uint64_t minimizer_ = 0;
  // The high 31 bits save the sequence index in the sequence batch. The
  // following 32 bits save the end position on that sequence. And the lowest
  // bit encodes the strand (0 for positive).
  uint64_t hit_ = 0;
};

}  // namespace chromap
+3 −3
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class mm_cache {
    int direction = 0;
    for (i = 0; i < size; ++i) {
      if (cache.minimizers[i] != minimizers[i].GetHashKey() ||
          (minimizers[i].GetMinimizer() & 1) != cache.strands[i])
          (minimizers[i].GetHit() & 1) != cache.strands[i])
        break;
    }
    if (i >= size) {
@@ -58,7 +58,7 @@ class mm_cache {

    for (i = 0, j = size - 1; i < size; ++i, --j) {
      if (cache.minimizers[i] != minimizers[j].GetHashKey() ||
          (minimizers[j].GetMinimizer() & 1) == cache.strands[i])
          (minimizers[j].GetHit() & 1) == cache.strands[i])
        break;
    }
    if (i >= size) {
@@ -263,7 +263,7 @@ if (cache[hidx].finger_print_cnt_sum <= 5)
      cache[hidx].strands.resize(msize);
      for (i = 0; i < msize; ++i) {
        cache[hidx].minimizers[i] = minimizers[i].GetHashKey();
        cache[hidx].strands[i] = (minimizers[i].GetMinimizer() & 1);
        cache[hidx].strands[i] = (minimizers[i].GetHit() & 1);
      }
      for (i = 0; i < msize - 1; ++i) {
        cache[hidx].offsets[i] =