From be0a9552bf9d86f1f33e575039b062edfb6d0240 Mon Sep 17 00:00:00 2001 From: Oleksandr Kulkov Date: Wed, 27 Mar 2024 14:49:21 +0100 Subject: [PATCH] use kmer_t::bits_per_char instead of const 2 --- include/buckets.hpp | 20 ++++++++++---------- include/builder/build_skew_index.hpp | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/buckets.hpp b/include/buckets.hpp index 44d92bd..a4e4768 100644 --- a/include/buckets.hpp +++ b/include/buckets.hpp @@ -57,14 +57,14 @@ struct buckets { kmer_t contig_prefix(uint64_t contig_id, uint64_t k) const { uint64_t contig_begin = pieces.access(contig_id); - bit_vector_iterator bv_it(strings, 2 * contig_begin); - return bv_it.read(2 * (k - 1)); + bit_vector_iterator bv_it(strings, kmer_t::bits_per_char * contig_begin); + return bv_it.read(kmer_t::bits_per_char * (k - 1)); } kmer_t contig_suffix(uint64_t contig_id, uint64_t k) const { uint64_t contig_end = pieces.access(contig_id + 1); - bit_vector_iterator bv_it(strings, 2 * (contig_end - k + 1)); - return bv_it.read(2 * (k - 1)); + bit_vector_iterator bv_it(strings, kmer_t::bits_per_char * (contig_end - k + 1)); + return bv_it.read(kmer_t::bits_per_char * (k - 1)); } std::pair locate_bucket(uint64_t bucket_id) const { @@ -95,7 +95,7 @@ struct buckets { uint64_t m) const { uint64_t offset = offsets.access(super_kmer_id); auto [res, contig_end] = offset_to_id(offset, k); - bit_vector_iterator bv_it(strings, 2 * offset); + bit_vector_iterator bv_it(strings, kmer_t::bits_per_char * offset); uint64_t window_size = std::min(k - m + 1, contig_end - offset - k + 1); for (uint64_t w = 0; w != window_size; ++w) { kmer_t read_kmer = bv_it.read_and_advance_by_char(kmer_t::bits_per_char * k); @@ -120,7 +120,7 @@ struct buckets { for (uint64_t super_kmer_id = begin; super_kmer_id != end; ++super_kmer_id) { uint64_t offset = offsets.access(super_kmer_id); auto [res, contig_end] = offset_to_id(offset, k); - bit_vector_iterator bv_it(strings, 2 * offset); + bit_vector_iterator bv_it(strings, kmer_t::bits_per_char * offset); uint64_t window_size = std::min(k - m + 1, contig_end - offset - k + 1); for (uint64_t w = 0; w != window_size; ++w) { kmer_t read_kmer = bv_it.read_and_advance_by_char(kmer_t::bits_per_char * k); @@ -171,8 +171,8 @@ struct buckets { void access(uint64_t kmer_id, char* string_kmer, uint64_t k) const { uint64_t offset = id_to_offset(kmer_id, k); - bit_vector_iterator bv_it(strings, 2 * offset); - kmer_t read_kmer = bv_it.read(2 * k); + bit_vector_iterator bv_it(strings, kmer_t::bits_per_char * offset); + kmer_t read_kmer = bv_it.read(kmer_t::bits_per_char * k); util::uint_kmer_to_string(read_kmer, string_kmer, k); } @@ -239,10 +239,10 @@ struct buckets { bool m_clear; void next_piece() { - m_bv_it.at(2 * m_offset); + m_bv_it.at(kmer_t::bits_per_char * m_offset); m_next_offset = m_pieces_it.next(); assert(m_next_offset > m_offset); - m_read_kmer = m_bv_it.take(2 * m_k); + m_read_kmer = m_bv_it.take(kmer_t::bits_per_char * m_k); m_clear = true; } }; diff --git a/include/builder/build_skew_index.hpp b/include/builder/build_skew_index.hpp index 38753a2..f9e6600 100644 --- a/include/builder/build_skew_index.hpp +++ b/include/builder/build_skew_index.hpp @@ -216,12 +216,12 @@ void build_skew_index(skew_index& m_skew_index, parse_data& data assert(lists[i].size() > lower and lists[i].size() <= upper); uint64_t super_kmer_id = 0; for (auto [offset, num_kmers_in_super_kmer] : lists[i]) { - bit_vector_iterator bv_it(m_buckets.strings, 2 * offset); + bit_vector_iterator bv_it(m_buckets.strings, kmer_t::bits_per_char * offset); for (uint64_t i = 0; i != num_kmers_in_super_kmer; ++i) { - kmer_t kmer = bv_it.read(2 * build_config.k); + kmer_t kmer = bv_it.read(kmer_t::bits_per_char * build_config.k); keys_in_partition.push_back(kmer); super_kmer_ids_in_partition.push_back(super_kmer_id); - bv_it.eat(2); + bv_it.eat(kmer_t::bits_per_char); } assert(super_kmer_id < (1ULL << cvb_positions.width())); ++super_kmer_id;