Commit 6eb7b958 authored by Swift Genomics's avatar Swift Genomics Committed by swiftgenomics
Browse files

Use encapsulated Minimizer funcs.

parent 1c23c7e6
Loading
Loading
Loading
Loading
+12 −15
Original line number Original line Diff line number Diff line
@@ -48,9 +48,8 @@ class mm_cache {
    }
    }
    if (i >= size) {
    if (i >= size) {
      for (i = 0; i < size - 1; ++i) {
      for (i = 0; i < size - 1; ++i) {
        if (cache.offsets[i] !=
        if (cache.offsets[i] != ((int)minimizers[i + 1].GetSequencePosition() -
            ((int)GenerateSequencePosition(minimizers[i + 1].GetHit()) -
                                 (int)minimizers[i].GetSequencePosition()))
             (int)GenerateSequencePosition(minimizers[i].GetHit())))
          break;
          break;
      }
      }
      if (i >= size - 1) direction = 1;
      if (i >= size - 1) direction = 1;
@@ -66,8 +65,8 @@ class mm_cache {
    if (i >= size) {
    if (i >= size) {
      for (i = 0, j = size - 1; i < size - 1; ++i, --j) {
      for (i = 0, j = size - 1; i < size - 1; ++i, --j) {
        if (cache.offsets[i] !=
        if (cache.offsets[i] !=
            ((int)GenerateSequencePosition(minimizers[j].GetHit())) -
            ((int)minimizers[j].GetSequencePosition()) -
                ((int)GenerateSequencePosition(minimizers[j - 1].GetHit())))
                ((int)minimizers[j - 1].GetSequencePosition()))
          break;
          break;
      }
      }


@@ -134,7 +133,7 @@ class mm_cache {
      neg_candidates = cache[hidx].negative_candidates;
      neg_candidates = cache[hidx].negative_candidates;
      repetitive_seed_length = cache[hidx].repetitive_seed_length;
      repetitive_seed_length = cache[hidx].repetitive_seed_length;
      int size = pos_candidates.size();
      int size = pos_candidates.size();
      int shift = (int)GenerateSequencePosition(minimizers[0].GetHit());
      int shift = (int)minimizers[0].GetSequencePosition();
      for (i = 0; i < size; ++i) {
      for (i = 0; i < size; ++i) {
        uint64_t rid = pos_candidates[i].position >> 32;
        uint64_t rid = pos_candidates[i].position >> 32;
        int rpos = (int)pos_candidates[i].position;
        int rpos = (int)pos_candidates[i].position;
@@ -148,9 +147,8 @@ class mm_cache {
      int size = cache[hidx].negative_candidates.size();
      int size = cache[hidx].negative_candidates.size();
      // Start position of the last minimizer shoud equal the first minimizer's
      // Start position of the last minimizer shoud equal the first minimizer's
      // end position in rc "read".
      // end position in rc "read".
      int shift =
      int shift = read_len -
          read_len -
                  ((int)minimizers[msize - 1].GetSequencePosition()) - 1 +
          ((int)GenerateSequencePosition(minimizers[msize - 1].GetHit())) - 1 +
                  kmer_length - 1;
                  kmer_length - 1;


      pos_candidates = cache[hidx].negative_candidates;
      pos_candidates = cache[hidx].negative_candidates;
@@ -243,7 +241,7 @@ if (cache[hidx].finger_print_cnt_sum <= 5)
        return;
        return;
      }
      }
      int size = pos_candidates.size();
      int size = pos_candidates.size();
      int shift = (int)GenerateSequencePosition(minimizers[0].GetHit());
      int shift = (int)minimizers[0].GetSequencePosition();
      // Do not cache if it is too near the start.
      // Do not cache if it is too near the start.
      for (i = 0; i < size; ++i)
      for (i = 0; i < size; ++i)
        if ((int)pos_candidates[i].position < kmer_length + shift) {
        if ((int)pos_candidates[i].position < kmer_length + shift) {
@@ -255,8 +253,7 @@ if (cache[hidx].finger_print_cnt_sum <= 5)
      size = neg_candidates.size();
      size = neg_candidates.size();
      for (i = 0; i < size; ++i)
      for (i = 0; i < size; ++i)
        if ((int)neg_candidates[i].position -
        if ((int)neg_candidates[i].position -
                ((int)GenerateSequencePosition(
                ((int)minimizers[msize - 1].GetSequencePosition()) <
                    minimizers[msize - 1].GetHit())) <
            kmer_length + shift) {
            kmer_length + shift) {
          cache[hidx].offsets.clear();
          cache[hidx].offsets.clear();
          cache[hidx].strands.clear();
          cache[hidx].strands.clear();
@@ -271,8 +268,8 @@ if (cache[hidx].finger_print_cnt_sum <= 5)
      }
      }
      for (i = 0; i < msize - 1; ++i) {
      for (i = 0; i < msize - 1; ++i) {
        cache[hidx].offsets[i] =
        cache[hidx].offsets[i] =
            ((int)GenerateSequencePosition(minimizers[i + 1].GetHit())) -
            ((int)minimizers[i + 1].GetSequencePosition()) -
            ((int)GenerateSequencePosition(minimizers[i].GetHit()));
            ((int)minimizers[i].GetSequencePosition());
      }
      }
      std::vector<Candidate>().swap(cache[hidx].positive_candidates);
      std::vector<Candidate>().swap(cache[hidx].positive_candidates);
      std::vector<Candidate>().swap(cache[hidx].negative_candidates);
      std::vector<Candidate>().swap(cache[hidx].negative_candidates);