Commit 266c513a authored by Haowen Zhang's avatar Haowen Zhang Committed by Li Song
Browse files

Remove unused parameters for index construction.

parent ae75498b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1143,8 +1143,7 @@ void Chromap<MappingRecord>::MapPairedEndReads() {
  }

  // Load index
  Index index(min_num_seeds_required_for_mapping_, max_seed_frequencies_,
              index_file_path_);
  Index index(index_file_path_);
  index.Load();
  kmer_size_ = index.GetKmerSize();
  window_size_ = index.GetWindowSize();
@@ -2587,8 +2586,7 @@ void Chromap<MappingRecord>::MapSingleEndReads() {
    reference.ReorderSequences(custom_rid_rank_);
  }

  Index index(min_num_seeds_required_for_mapping_, max_seed_frequencies_,
              index_file_path_);
  Index index(index_file_path_);
  index.Load();
  kmer_size_ = index.GetKmerSize();
  window_size_ = index.GetWindowSize();
+0 −113
Original line number Diff line number Diff line
@@ -334,67 +334,6 @@ void Index::Load() {
            << Chromap<>::GetRealTime() - real_start_time << "s.\n";
}

// void Index::GenerateCandidatesOnOneDirection(
//    int error_threshold, int num_seeds_required, uint32_t num_minimizers,
//    std::vector<uint64_t> &hits, std::vector<Candidate> &candidates) const {
//  hits.emplace_back(UINT64_MAX);
//  if (hits.size() > 0) {
//    int minimizer_count = 1;
//    // The number of seeds with the exact same reference position.
//    int equal_count = 1;
//    int best_equal_count = 1;
//    uint64_t previous_hit = hits[0];
//    uint32_t previous_reference_id = previous_hit >> 32;
//    uint32_t previous_reference_position = previous_hit;
//    uint64_t best_local_hit = hits[0];
//    for (uint32_t pi = 1; pi < hits.size(); ++pi) {
//      uint32_t current_reference_id = hits[pi] >> 32;
//      uint32_t current_reference_position = hits[pi];
//#ifdef LI_DEBUG
//      printf("%s: %d %d\n", __func__, current_reference_id,
//             current_reference_position);
//#endif
//      if (current_reference_id != previous_reference_id ||
//          current_reference_position >
//              previous_reference_position + error_threshold ||
//          ((uint32_t)minimizer_count >= num_minimizers &&
//           current_reference_position >
//               (uint32_t)best_local_hit + error_threshold)) {
//        if (minimizer_count >= num_seeds_required) {
//          Candidate candidate;
//          candidate.position = best_local_hit;
//          candidate.count = best_equal_count;
//          candidates.push_back(candidate);
//        }
//
//        minimizer_count = 1;
//        equal_count = 1;
//        best_equal_count = 1;
//        best_local_hit = hits[pi];
//      } else {
//        if (hits[pi] == best_local_hit) {
//          ++equal_count;
//          ++best_equal_count;
//        } else if (hits[pi] == previous_hit) {
//          ++equal_count;
//          if (equal_count > best_equal_count) {
//            best_local_hit = previous_hit;
//            best_equal_count = equal_count;
//          }
//        } else {
//          equal_count = 1;
//        }
//
//        ++minimizer_count;
//      }
//
//      previous_hit = hits[pi];
//      previous_reference_id = current_reference_id;
//      previous_reference_position = current_reference_position;
//    }
//  }
//}

// Return the number of repetitive seeds.
int Index::CollectSeedHits(
    int max_seed_frequency, int repetitive_seed_frequency,
@@ -751,56 +690,4 @@ int Index::CollectSeedHitsFromRepetitiveReadWithMateInfo(
  return max_minimizer_count;
}

// void Index::GenerateCandidates(int error_threshold,
//                               MappingMetadata &mapping_metadata) const {
//  const std::vector<std::pair<uint64_t, uint64_t> > &minimizers =
//      mapping_metadata.minimizers_;
//  std::vector<uint64_t> &positive_hits = mapping_metadata.positive_hits_;
//  std::vector<uint64_t> &negative_hits = mapping_metadata.negative_hits_;
//  std::vector<Candidate> &positive_candidates =
//      mapping_metadata.positive_candidates_;
//  std::vector<Candidate> &negative_candidates =
//      mapping_metadata.negative_candidates_;
//  uint32_t &repetitive_seed_length = mapping_metadata.repetitive_seed_length_;
//
//  repetitive_seed_length = 0;
//  int repetitive_seed_count = CollectSeedHits(
//      max_seed_frequencies_[0], max_seed_frequencies_[0], minimizers,
//      repetitive_seed_length, positive_hits, negative_hits, false);
//
//  bool use_high_frequency_minimizers = false;
//  if (positive_hits.size() + negative_hits.size() == 0) {
//    positive_hits.clear();
//    negative_hits.clear();
//    repetitive_seed_length = 0;
//    repetitive_seed_count = CollectSeedHits(
//        max_seed_frequencies_[1], max_seed_frequencies_[0], minimizers,
//        repetitive_seed_length, positive_hits, negative_hits, true);
//    use_high_frequency_minimizers = true;
//    if (positive_hits.size() == 0 || negative_hits.size() == 0) {
//      use_high_frequency_minimizers = false;
//    }
//  }
//
//  int num_required_seeds = minimizers.size() - repetitive_seed_count;
//  num_required_seeds = num_required_seeds > 1 ? num_required_seeds : 1;
//  num_required_seeds = num_required_seeds >
//  min_num_seeds_required_for_mapping_
//                           ? min_num_seeds_required_for_mapping_
//                           : num_required_seeds;
//  if (use_high_frequency_minimizers) {
//    num_required_seeds = min_num_seeds_required_for_mapping_;
//  }
//
//  // std::cerr << "Normal positive gen on one dir\n";
//  GenerateCandidatesOnOneDirection(error_threshold, num_required_seeds,
//                                   minimizers.size(), positive_hits,
//                                   positive_candidates);
//  // std::cerr << "Normal negative gen on one dir\n";
//  GenerateCandidatesOnOneDirection(error_threshold, num_required_seeds,
//                                   minimizers.size(), negative_hits,
//                                   negative_candidates);
//  // fprintf(stderr, "p+n: %d\n", positive_candidates->size() +
//  // negative_candidates->size()) ;
//}
}  // namespace chromap
+5 −18
Original line number Diff line number Diff line
@@ -31,19 +31,19 @@ struct mmHit {

class Index {
 public:
  Index(int min_num_seeds_required_for_mapping,
        const std::vector<int> &max_seed_frequencies,
        const std::string &index_file_path)
      : index_file_path_(index_file_path) {  // for read mapping
  // For read mapping.
  Index(const std::string &index_file_path)
      : index_file_path_(index_file_path) {
    lookup_table_ = kh_init(k64);
  }

  // For index construction.
  Index(int kmer_size, int window_size, int num_threads,
        const std::string &index_file_path)
      : kmer_size_(kmer_size),
        window_size_(window_size),
        num_threads_(num_threads),
        index_file_path_(index_file_path) {  // for index construction
        index_file_path_(index_file_path) {
    lookup_table_ = kh_init(k64);
  }

@@ -93,13 +93,6 @@ class Index {
      const SequenceBatch &sequence_batch, uint32_t sequence_index,
      std::vector<std::pair<uint64_t, uint64_t> > &minimizers) const;

  // void GenerateCandidatesOnOneDirection(
  //    int error_threshold, int num_seeds_required, uint32_t num_minimizers,
  //    std::vector<uint64_t> &hits, std::vector<Candidate> &candidates) const;

  // void GenerateCandidates(int error_threshold,
  //                        MappingMetadata &mapping_metadata) const;

  inline static uint64_t Hash64(uint64_t key, const uint64_t mask) {
    key = (~key + (key << 21)) & mask;  // key = (key << 21) - key - 1;
    key = key ^ key >> 24;
@@ -114,12 +107,6 @@ class Index {
 protected:
  int kmer_size_;
  int window_size_;
  // int min_num_seeds_required_for_mapping_;
  // Vector of size 2. The first element is the frequency threshold, and the
  // second element is the frequency threshold to run rescue. The second element
  // should always larger than the first one.
  // TODO(Haowen): add an error check.
  // std::vector<int> max_seed_frequencies_;
  // Number of threads to build the index, which is not used right now.
  int num_threads_;
  const std::string index_file_path_;