Skip to content

Commit

Permalink
fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed Mar 27, 2024
1 parent 3b38028 commit f71fd79
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion include/buckets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct buckets {
m_clear = false;
m_read_kmer.drop_char();
m_last_char = m_bv_it.get_next_char();
read_kmer.kth_char_or(m_k - 1, m_last_char);
m_read_kmer.kth_char_or(m_k - 1, m_last_char);
++m_begin_kmer_id;
++m_offset;
return m_ret;
Expand Down
6 changes: 3 additions & 3 deletions include/kmer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ constexpr char nucleotides[] = "ACTG";
#endif

template <typename Kmer>
struct dna_uint_kmer_t : alpha_kmer_t<Kmer, 2, dna_alphabet> {
using base = alpha_kmer_t<Kmer, 2, dna_alphabet>;
struct dna_uint_kmer_t : alpha_kmer_t<Kmer, 2, nucleotides> {
using base = alpha_kmer_t<Kmer, 2, nucleotides>;
using base::uint_kmer_bits;
using base::bits_per_char;
using base::max_k;
Expand Down Expand Up @@ -149,7 +149,7 @@ struct dna_uint_kmer_t : alpha_kmer_t<Kmer, 2, dna_alphabet> {
g 103 01100111 -> 10
t 116 01110100 -> 11
*/
static inline uint64_t char_to_uint(char c) { return (((c >> 1) ^ (c >> 2)) & 3); }
static uint64_t char_to_uint(char c) { return (((c >> 1) ^ (c >> 2)) & 3); }
#else
/*
char decimal binary
Expand Down
3 changes: 2 additions & 1 deletion src/check_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ bool check_correctness_kmer_iterator(dictionary<kmer_t> const& dict) {
return true;
}

bool check_correctness_contig_iterator(dictionary const& dict) {
template<class kmer_t>
bool check_correctness_contig_iterator(dictionary<kmer_t> const& dict) {
std::cout << "checking correctness of contig iterator..." << std::endl;
std::string expected_kmer(dict.k(), 0);
for (uint64_t contig_id = 0; contig_id != dict.num_contigs(); ++contig_id) {
Expand Down
44 changes: 22 additions & 22 deletions test/test_alphabet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ int main(int argc, char** argv) {
return 1;
}
uint64_t k = std::stoull(argv[1]);
if (k > constants::max_k) {
std::cerr << "k must be less <= " << constants::max_k << " but got k = " << k << '\n';
if (k > kmer_t::max_k) {
std::cerr << "k must be less <= " << kmer_t::max_k << " but got k = " << k << '\n';
return 1;
}
std::string read(
Expand Down Expand Up @@ -54,23 +54,23 @@ int main(int argc, char** argv) {
/****/

#ifdef SSHASH_USE_TRADITIONAL_NUCLEOTIDE_ENCODING
expect(kmer_t::char_to_int('A'), kmer_t(0));
expect(kmer_t::char_to_int('a'), kmer_t(0));
expect(kmer_t::char_to_int('C'), kmer_t(1));
expect(kmer_t::char_to_int('c'), kmer_t(1));
expect(kmer_t::char_to_int('G'), kmer_t(2));
expect(kmer_t::char_to_int('g'), kmer_t(2));
expect(kmer_t::char_to_int('T'), kmer_t(3));
expect(kmer_t::char_to_int('t'), kmer_t(3));
expect(kmer_t::char_to_uint('A'), 0);
expect(kmer_t::char_to_uint('a'), 0);
expect(kmer_t::char_to_uint('C'), 1);
expect(kmer_t::char_to_uint('c'), 1);
expect(kmer_t::char_to_uint('G'), 2);
expect(kmer_t::char_to_uint('g'), 2);
expect(kmer_t::char_to_uint('T'), 3);
expect(kmer_t::char_to_uint('t'), 3);
#else
expect(kmer_t::char_to_int('A'), kmer_t(0));
expect(kmer_t::char_to_int('a'), kmer_t(0));
expect(kmer_t::char_to_int('C'), kmer_t(1));
expect(kmer_t::char_to_int('c'), kmer_t(1));
expect(kmer_t::char_to_int('T'), kmer_t(2));
expect(kmer_t::char_to_int('t'), kmer_t(2));
expect(kmer_t::char_to_int('G'), kmer_t(3));
expect(kmer_t::char_to_int('g'), kmer_t(3));
expect(kmer_t::char_to_uint('A'), 0);
expect(kmer_t::char_to_uint('a'), 0);
expect(kmer_t::char_to_uint('C'), 1);
expect(kmer_t::char_to_uint('c'), 1);
expect(kmer_t::char_to_uint('T'), 2);
expect(kmer_t::char_to_uint('t'), 2);
expect(kmer_t::char_to_uint('G'), 3);
expect(kmer_t::char_to_uint('g'), 3);
#endif

for (uint64_t kmer_len = 1; kmer_len <= k; ++kmer_len) {
Expand All @@ -80,10 +80,10 @@ int main(int argc, char** argv) {
for (uint64_t i = 0; i != 1000; ++i) {
// generate a random kmer of length kmer_len
random_kmer(kmer.data(), kmer_len);
kmer_t::compute_reverse_complement(kmer.data(), rc.data(), kmer_len);
kmer_t uint_kmer = kmer_t::string_to_uint_kmer(kmer.data(), kmer_len);
uint_kmer = kmer_t::compute_reverse_complement(uint_kmer, kmer_len);
expect(kmer_t::uint_kmer_to_string(uint_kmer, kmer_len), rc);
util::compute_reverse_complement(kmer.data(), rc.data(), kmer_len);
kmer_t uint_kmer = util::string_to_uint_kmer<kmer_t>(kmer.data(), kmer_len);
uint_kmer = uint_kmer.reverse_complement(kmer_len);
expect(util::uint_kmer_to_string(uint_kmer, kmer_len), rc);
}
}

Expand Down

0 comments on commit f71fd79

Please sign in to comment.