From 8498e366a203f8548acff4b0c78b79da84d31fe0 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:25:19 -0800 Subject: [PATCH 01/13] src/falco_word.hpp: eliminating the fw_encode function because letters are now already encoded as appropriate numbers --- src/falco_word.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/falco_word.hpp b/src/falco_word.hpp index f4218fa..157fc38 100644 --- a/src/falco_word.hpp +++ b/src/falco_word.hpp @@ -19,7 +19,7 @@ // T (84)10 = (1010100)2 => 001 struct falco_word { - static constexpr std::span extended_bases = "GTCAN"; + static constexpr std::span extended_bases = "ACTGN"; static constexpr auto extended_alpha_size = 5; static constexpr auto shift_for_width_bits = 56u; static constexpr auto width_bits_removal_mask = 0xffffffffffffff; @@ -32,12 +32,9 @@ struct falco_word { operator<=>(const falco_word &) const = default; falco_word(auto b, std::uint64_t w) { - static constexpr auto fw_encode = [](const auto c) { - return ((c >> 1) & 7) ^ 3; // NOLINT(*-avoid-magic-numbers) - }; static const auto enc_shift = [&](auto &x, auto &c) { // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound) - x = (x * extended_alpha_size) + fw_encode(*c++); + x = (x * extended_alpha_size) + *c++; }; w = w < max_hi_lim ? w : max_hi_lim; const auto lo_lim = b + (w > max_lo_lim ? max_lo_lim : w); From 0c73447f42003202717d1a34719d4921b8daa9f1 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:26:08 -0800 Subject: [PATCH 02/13] src/samrec.cpp: updating the base-to-number mapping for early encoding as ACGTN = 01324 --- src/samrec.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/samrec.cpp b/src/samrec.cpp index a79ac55..a3fac52 100644 --- a/src/samrec.cpp +++ b/src/samrec.cpp @@ -38,12 +38,24 @@ samrec::to_string() const -> std::string { samrec::get_next(samrec::pos_t &cursor, const samrec::pos_t end_itr, samrec &rec) -> bool { + // ADS: number of SAM fields to skip after the flag column and before the read + // sequence column static constexpr auto n_fields_to_skip = 7; - const auto iupac = [](const auto c) -> char { - return "NANCNNNGNNNNNNNNNNNNTNNNNNNNNNNN"[c & 31]; // NOLINT + static constexpr auto base_to_idx = [](const auto c) -> char { + static constexpr auto mask = 31; + static constexpr auto to_acgtn = std::array{ + 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + }; + return to_acgtn[c & mask]; // NOLINT }; - const auto iupac_cmpl = [](const auto c) -> char { - return "NTNGNNNCNNNNNNNNNNNNANNNNNNNNNNN"[c & 31]; // NOLINT + static constexpr auto base_to_idx_cmpl = [](const auto c) -> char { + static constexpr auto mask = 31; + static constexpr auto to_acgtn_cmpl = std::array{ + 4, 2, 4, 3, 4, 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + }; + return to_acgtn_cmpl[c & mask]; // NOLINT }; static constexpr auto bam_is_rev = [](const auto flag) -> bool { static constexpr auto BAM_FREVERSE = 16; @@ -110,14 +122,15 @@ samrec::get_next(samrec::pos_t &cursor, if (bam_is_rev(flag)) { std::reverse_copy(seq_itr, seq_itr + seq_len, out_seq_itr); - std::transform(out_seq_itr, out_seq_itr + seq_len, out_seq_itr, iupac_cmpl); + std::transform(out_seq_itr, out_seq_itr + seq_len, out_seq_itr, + base_to_idx_cmpl); if (*qual_itr != qual_missing_code) std::reverse_copy(qual_itr, qual_itr + seq_len, out_qual_itr); else *out_qual_itr = qual_missing_code; } else { - std::transform(seq_itr, seq_itr + seq_len, out_seq_itr, iupac); + std::transform(seq_itr, seq_itr + seq_len, out_seq_itr, base_to_idx); if (*qual_itr != qual_missing_code) std::copy(qual_itr, qual_itr + seq_len, out_qual_itr); else From c742d085c76196c8044908762660ced793bd3d73 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:30:32 -0800 Subject: [PATCH 03/13] data/test_data/md5sum.txt: updates reflecting different sorted order of identified contaminants with tied scores --- data/test_data/md5sum.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/test_data/md5sum.txt b/data/test_data/md5sum.txt index 0a062fb..49b53d9 100644 --- a/data/test_data/md5sum.txt +++ b/data/test_data/md5sum.txt @@ -7,7 +7,7 @@ bcf8363f788e54d38a5ec758042959ce ./fastq_plain_out/fastq_1/fastqc_data.txt 39a5df25471d6f250de7b31a03325254 ./fastq_bgzf_mult_out/fastq_bgzip_2/fastqc_data.txt 55d98514eda63c2cf4b900a0fb7b074b ./fastq_bgzf_out/fastq_bgzip_1/fastqc_data.txt 41a799d28bdc2e35e17546fe2af146cb ./bam_mult_out/bam_1/fastqc_data.txt -fbbf6f4d0607abf18425699197fb9e7f ./bam_mult_out/bam_2/fastqc_data.txt +953dddfc5bf8d0f045ddc04419c604f8 ./bam_mult_out/bam_2/fastqc_data.txt 0e0d6a2d5523f50cb2374ef49e498036 ./fastq_stdin_out/fastq_stdin/fastqc_data.txt bab943eb8b778badeccb51045c8365b0 ./fastq_gz_out/fastq_gz_1/fastqc_data.txt 41a799d28bdc2e35e17546fe2af146cb ./bam_orig_dups_out/bam_1/fastqc_data.txt From 0bb2ee7991a333a7aa289499dba700d02e81b535 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:34:17 -0800 Subject: [PATCH 04/13] src/bamrec.cpp: updating the base-to-number mapping for early encoding as ACGTN = 01324 --- src/bamrec.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/bamrec.cpp b/src/bamrec.cpp index 8a7f164..327377a 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -37,23 +37,29 @@ bamrec::to_string() const -> std::string { template static inline constexpr output_itr_t assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr std::span seq_nt16_str_complem = "NTGNCNNNANNNNNNN"; - constexpr auto bam_seqi = [](const auto s, const auto i) -> int { + static constexpr std::array seq_nt16_str_cmpl = { + 4, 2, 3, 4, 1, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, + }; + static constexpr auto bam_seqi = [](const auto s, const auto i) { constexpr auto low_nibble_on = 0xf; return s[i >> 1] >> ((~i & 1) << 2) & low_nibble_on; }; - for (auto j = last; j != 0; ++d_first) - *d_first = seq_nt16_str_complem[bam_seqi(first, --j)]; + auto j = last; + while (j != 0) + *d_first++ = seq_nt16_str_cmpl[bam_seqi(first, --j)]; return d_first; } template static inline constexpr output_itr_t assign_sequence(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr std::span seq_nt16_str = "NACNGNNNTNNNNNNN"; - constexpr auto bam_seqi = [](const auto s, const auto i) -> int { + static constexpr auto n_possible_symbols = 16; + static constexpr auto seq_nt16_str = std::array{ + 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, + }; + static constexpr auto bam_seqi = [](const auto s, const auto i) { constexpr auto low_nibble_on = 0xf; - return s[i >> 1] >> ((~i & 1) << 2) & low_nibble_on; + return (s[i >> 1] >> ((~i & 1) << 2)) & low_nibble_on; }; for (auto j = 0U; j != last; ++j) *d_first++ = seq_nt16_str[bam_seqi(first, j)]; From 3ce2a9c985d3b199545844afbfd954a11119c860 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:36:50 -0800 Subject: [PATCH 05/13] src/bamrec.cpp: cleanup --- src/bamrec.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/bamrec.cpp b/src/bamrec.cpp index 327377a..ab7977f 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -37,7 +37,7 @@ bamrec::to_string() const -> std::string { template static inline constexpr output_itr_t assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr std::array seq_nt16_str_cmpl = { + static constexpr auto seq_nt16_str_cmpl = std::array{ 4, 2, 3, 4, 1, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, }; static constexpr auto bam_seqi = [](const auto s, const auto i) { @@ -53,8 +53,7 @@ assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { template static inline constexpr output_itr_t assign_sequence(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr auto n_possible_symbols = 16; - static constexpr auto seq_nt16_str = std::array{ + static constexpr auto seq_nt16_str = std::array{ 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, }; static constexpr auto bam_seqi = [](const auto s, const auto i) { From 85351ac3033e93ac8766aadaa31698127bf9b493 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:37:22 -0800 Subject: [PATCH 06/13] src/fqrec.hpp: changes for alphabet encoded numerically immediately --- src/fqrec.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fqrec.hpp b/src/fqrec.hpp index 7018539..e53291d 100644 --- a/src/fqrec.hpp +++ b/src/fqrec.hpp @@ -74,8 +74,13 @@ struct fq_gz_task_t { [[nodiscard]] inline auto get_next(fqrec::pos_t &cursor, const fqrec::pos_t end_itr) -> fqrec { - const auto iupac = [](auto &c) { - c = "NANCNNNGNNNNNNNNNNNNTNNNNNNNNNNN"[c & 31]; // NOLINT + const auto to_acgtn = [](auto &c) { + static constexpr auto mask = 31; + static constexpr auto x = std::array{ + 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + }; + c = x[c & mask]; // NOLINT }; // ADS: need to make sure cursor < end_itr or we will move past const auto n = cursor; @@ -92,7 +97,7 @@ get_next(fqrec::pos_t &cursor, const fqrec::pos_t end_itr) -> fqrec { const auto r = itr; while (itr != end_itr && *itr != '\n') - iupac(*itr++); + to_acgtn(*itr++); if (itr++ == end_itr) return {}; const auto o = itr; From 29c61331929c92428924669e143cec44eee4b526 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:53:42 -0800 Subject: [PATCH 07/13] src/original_duplicates.cpp: updating the base-to-number mapping for encoding as ACGTN = 03124 --- src/original_duplicates.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/original_duplicates.cpp b/src/original_duplicates.cpp index 44629d5..5ab432a 100644 --- a/src/original_duplicates.cpp +++ b/src/original_duplicates.cpp @@ -35,12 +35,17 @@ init_orig_dups_bam(const std::string &filename, const std::uint64_t n_unique) // the target, so try to overshoot. static constexpr auto n_unique_multiplier = 10; static constexpr auto complem = [](char &x) { - assert(x >= 'A' && x <= 'T'); - x = "TNGNNNCNNNNNNNNNNNNA"[x - 'A']; + static constexpr auto complement_mapping = std::array{ + 2, 3, 0, 1, 4, // (A, C, T, G) -> (T, G, A, C) + }; + assert(x >= 0 && x <= 4); + x = complement_mapping[x]; }; static constexpr auto to_acgtn = [](const char x) { - static constexpr char mask = 15; - static constexpr std::span seq_nt16_str_acgtn = "NACNGNNNTNNNNNNN"; + static constexpr auto mask = 15; + static constexpr auto seq_nt16_str_acgtn = std::array{ + 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, + }; return seq_nt16_str_acgtn[x & mask]; }; const std::unique_ptr in( @@ -88,10 +93,15 @@ init_orig_dups_fq(const std::string &filename, const std::uint64_t n_unique) // the n_unique that is the target; impossible to know how many needed to hit // the target, so try to overshoot. static constexpr auto n_unique_multiplier = 10; + static constexpr auto n_lines_per_record = 4; + static constexpr auto record_line_index = 1; static constexpr auto to_acgtn = [](const auto c) { static constexpr auto mask = 31; - static constexpr std::span to_acgtn_sp = "NANCNNNGNNNNNNNNNNNNTNNNNNNNNNNN"; - return to_acgtn_sp[c & mask]; + static constexpr auto to_acgtn_a = std::array{ + 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + }; + return to_acgtn_a[c & mask]; }; const std::unique_ptr in( bgzf_open(std::data(filename), "r"), &bgzf_close); @@ -106,7 +116,7 @@ init_orig_dups_fq(const std::string &filename, const std::uint64_t n_unique) const auto max_n_reads = n_unique_multiplier * n_unique; while (n_reads < max_n_reads && std::size(dups) < n_unique && (r = bgzf_getline(in.get(), '\n', &s)) >= 0) { - if (n_lines % 4 == 1) { + if (n_lines % n_lines_per_record == record_line_index) { const auto l_qseq = ks_len(&s); std::ranges::transform(std::span(s.s, l_qseq), s.s, to_acgtn); const auto seq = ks_c_str(&s); From ebf5e10935c0951ffd78fe434f319e576ca1ab76 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:54:53 -0800 Subject: [PATCH 08/13] src/adapter_matcher.cpp: updating the base-to-number encoding to happen here with all non ACGT mapped to N, and all encoded as ACGTN = 03124 --- src/adapter_matcher.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/adapter_matcher.cpp b/src/adapter_matcher.cpp index bc0ea1e..df3c46d 100644 --- a/src/adapter_matcher.cpp +++ b/src/adapter_matcher.cpp @@ -26,11 +26,20 @@ #include adapter_matcher::adapter_matcher() { + [[maybe_unused]] // ADS: false positive compiler warning + static constexpr auto base_to_idx = [](const auto c) -> char { + static constexpr auto mask = 31; + static constexpr auto to_acgtn = std::array{ + 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + }; + return to_acgtn[c & mask]; // NOLINT + }; static constexpr auto shift_plus = [&](const auto r, const auto c) { - return (r << nibble_size) + encode_nibble(c); + return (r << nibble_size) + encode_nibble(base_to_idx(c)); }; static constexpr auto do_encoding = [&](const auto &a) { - return std::accumulate(std::cbegin(a), std::cend(a), 0ul, shift_plus); + return std::accumulate(std::cbegin(a), std::cend(a), 0LU, shift_plus); }; if (const auto &as = adapter_set::instance(); !as.adapters.empty()) { n_adapters = adapter_set::n_adapters(); From 4ae8d869094b213bee501d4ed7e1a621d49c8200 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 15:55:50 -0800 Subject: [PATCH 09/13] src/falco_utils.hpp: updating the base-to-number encoding as ACGTN = 03124 --- src/falco_utils.hpp | 99 ++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/src/falco_utils.hpp b/src/falco_utils.hpp index b19b673..b920997 100644 --- a/src/falco_utils.hpp +++ b/src/falco_utils.hpp @@ -30,6 +30,12 @@ // G (71)10 = (1000111)2 => 11 => 3 // T (84)10 = (1010100)2 => 10 => 2 +// N => 100 => 4 +// A => 000 => 0 +// C => 001 => 1 +// G => 011 => 3 +// T => 010 => 2 + static constexpr auto adenine_index = 0; static constexpr auto cytosine_index = 1; static constexpr auto thymine_index = 2; @@ -37,10 +43,56 @@ static constexpr auto guanine_index = 3; static constexpr std::span bases = "ACTG"; // ADS: index this with vars above static constexpr auto alphabet_size = 4; -static constexpr auto unknown_base_index = 3; +static constexpr auto unknown_base_index = 0; +static constexpr auto N_encoding = 4; static constexpr auto nibble_size = 4; +[[nodiscard]] inline constexpr auto +encode(const char c) -> char { + static constexpr auto two_bit_mask = 3; + return c & two_bit_mask; // Ns are counted as G so must be subtracted +} + +[[nodiscard]] inline constexpr auto +is_gc(const char c) -> bool { + return c & 1; +} + +[[nodiscard]] inline constexpr auto +encode_nibble(const char c) -> char { + static constexpr auto four_bit_mask = 15; // ADS: 15 is to keep 4 bits + return c & four_bit_mask; // N gets separate encoding +} + +inline constexpr auto +count_nucs(auto seq_itr, + const auto seq_end, + auto &tab) { // cppcheck-suppress constParameterReference + auto out_itr = std::begin(tab); + while (seq_itr != seq_end) + ++(*out_itr++)[encode(*seq_itr++)]; +} + +inline constexpr auto +count_ns(auto seq_itr, + const auto seq_end, + auto &tab) { // cppcheck-suppress constParameterReference + auto out_itr = std::begin(tab); + while (seq_itr != seq_end) + *out_itr++ += (*seq_itr++ == N_encoding); +} + +[[nodiscard]] inline auto +count_gc(auto seq_itr, const auto seq_end) { + auto gc = 0; + while (seq_itr != seq_end) { + gc += (*seq_itr != N_encoding) && is_gc(*seq_itr); + ++seq_itr; + } + return gc; +} + namespace falco { static constexpr auto base_permutation_for_report_impl = { guanine_index, @@ -141,23 +193,6 @@ get_run_duration(const auto start_time) { inline constexpr auto end_module_tag = ">>END_MODULE\n"; -[[nodiscard]] inline constexpr auto -encode(const char c) { - static constexpr auto two_bit_mask = 3; - return (c >> 1) & two_bit_mask; // Ns are counted as G so must be subtracted -} - -[[nodiscard]] inline constexpr auto -is_gc(const char c) { - return (c >> 1) & 1; -} - -[[nodiscard]] inline constexpr auto -encode_nibble(const char c) { - static constexpr auto four_bit_mask = 15; // ADS: 15 is to keep 4 bits - return (c >> 1) & four_bit_mask; // N gets separate encoding -} - [[nodiscard]] inline constexpr auto pct(const double a) { return 100.0 * a; @@ -252,34 +287,6 @@ ipow(const auto b, const auto e) -> std::remove_cvref_t { return e == 0 ? 1 : (e & 1 ? b : 1) * ipow(b * b, e >> 1); } -inline constexpr auto -count_nucs(auto seq_itr, - const auto seq_end, - auto &tab) { // cppcheck-suppress constParameterReference - auto out_itr = std::begin(tab); - while (seq_itr != seq_end) - ++(*out_itr++)[encode(*seq_itr++)]; -} - -inline constexpr auto -count_ns(auto seq_itr, - const auto seq_end, - auto &tab) { // cppcheck-suppress constParameterReference - auto out_itr = std::begin(tab); - while (seq_itr != seq_end) - *out_itr++ += (*seq_itr++ == 'N'); -} - -[[nodiscard]] inline auto -count_gc(auto seq_itr, const auto seq_end) { - auto gc = 0; - while (seq_itr != seq_end) { - gc += (*seq_itr != 'N' && is_gc(*seq_itr)); - ++seq_itr; - } - return gc; -} - [[nodiscard]] inline auto tabular_dot(const auto &a) { typename std::remove_cvref_t::value_type total{}; From 43712ff0e7de4e3b8380d1ee414de47264eb5ed4 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 16:24:28 -0800 Subject: [PATCH 10/13] ensuring all lookup arrays that should hold characters for alphabet conversion are chars and not 4 byte ints --- src/adapter_matcher.cpp | 2 +- src/bamrec.cpp | 4 ++-- src/fqrec.hpp | 2 +- src/original_duplicates.cpp | 6 +++--- src/samrec.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/adapter_matcher.cpp b/src/adapter_matcher.cpp index df3c46d..e59505a 100644 --- a/src/adapter_matcher.cpp +++ b/src/adapter_matcher.cpp @@ -29,7 +29,7 @@ adapter_matcher::adapter_matcher() { [[maybe_unused]] // ADS: false positive compiler warning static constexpr auto base_to_idx = [](const auto c) -> char { static constexpr auto mask = 31; - static constexpr auto to_acgtn = std::array{ + static constexpr auto to_acgtn = std::array{ 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; diff --git a/src/bamrec.cpp b/src/bamrec.cpp index ab7977f..b98e2b5 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -37,7 +37,7 @@ bamrec::to_string() const -> std::string { template static inline constexpr output_itr_t assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr auto seq_nt16_str_cmpl = std::array{ + static constexpr auto seq_nt16_str_cmpl = std::array{ 4, 2, 3, 4, 1, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, }; static constexpr auto bam_seqi = [](const auto s, const auto i) { @@ -53,7 +53,7 @@ assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { template static inline constexpr output_itr_t assign_sequence(bidir_itr_t first, auto last, output_itr_t d_first) { - static constexpr auto seq_nt16_str = std::array{ + static constexpr auto seq_nt16_str = std::array{ 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, }; static constexpr auto bam_seqi = [](const auto s, const auto i) { diff --git a/src/fqrec.hpp b/src/fqrec.hpp index e53291d..859d1ac 100644 --- a/src/fqrec.hpp +++ b/src/fqrec.hpp @@ -76,7 +76,7 @@ struct fq_gz_task_t { get_next(fqrec::pos_t &cursor, const fqrec::pos_t end_itr) -> fqrec { const auto to_acgtn = [](auto &c) { static constexpr auto mask = 31; - static constexpr auto x = std::array{ + static constexpr auto x = std::array{ 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; diff --git a/src/original_duplicates.cpp b/src/original_duplicates.cpp index 5ab432a..09242fa 100644 --- a/src/original_duplicates.cpp +++ b/src/original_duplicates.cpp @@ -35,7 +35,7 @@ init_orig_dups_bam(const std::string &filename, const std::uint64_t n_unique) // the target, so try to overshoot. static constexpr auto n_unique_multiplier = 10; static constexpr auto complem = [](char &x) { - static constexpr auto complement_mapping = std::array{ + static constexpr auto complement_mapping = std::array{ 2, 3, 0, 1, 4, // (A, C, T, G) -> (T, G, A, C) }; assert(x >= 0 && x <= 4); @@ -43,7 +43,7 @@ init_orig_dups_bam(const std::string &filename, const std::uint64_t n_unique) }; static constexpr auto to_acgtn = [](const char x) { static constexpr auto mask = 15; - static constexpr auto seq_nt16_str_acgtn = std::array{ + static constexpr auto seq_nt16_str_acgtn = std::array{ 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, }; return seq_nt16_str_acgtn[x & mask]; @@ -97,7 +97,7 @@ init_orig_dups_fq(const std::string &filename, const std::uint64_t n_unique) static constexpr auto record_line_index = 1; static constexpr auto to_acgtn = [](const auto c) { static constexpr auto mask = 31; - static constexpr auto to_acgtn_a = std::array{ + static constexpr auto to_acgtn_a = std::array{ 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; diff --git a/src/samrec.cpp b/src/samrec.cpp index a3fac52..35a7b0b 100644 --- a/src/samrec.cpp +++ b/src/samrec.cpp @@ -43,7 +43,7 @@ samrec::get_next(samrec::pos_t &cursor, static constexpr auto n_fields_to_skip = 7; static constexpr auto base_to_idx = [](const auto c) -> char { static constexpr auto mask = 31; - static constexpr auto to_acgtn = std::array{ + static constexpr auto to_acgtn = std::array{ 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; @@ -51,7 +51,7 @@ samrec::get_next(samrec::pos_t &cursor, }; static constexpr auto base_to_idx_cmpl = [](const auto c) -> char { static constexpr auto mask = 31; - static constexpr auto to_acgtn_cmpl = std::array{ + static constexpr auto to_acgtn_cmpl = std::array{ 4, 2, 4, 3, 4, 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; From c951aee786ce47e8a4d52ce9f575167510d37144 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 16:40:09 -0800 Subject: [PATCH 11/13] iwyu --- src/adapter_matcher.cpp | 1 + src/bamrec.cpp | 1 + src/original_duplicates.cpp | 1 + src/samrec.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/src/adapter_matcher.cpp b/src/adapter_matcher.cpp index e59505a..e798e8a 100644 --- a/src/adapter_matcher.cpp +++ b/src/adapter_matcher.cpp @@ -13,6 +13,7 @@ #include "fmt/ranges.h" // IWYU pragma: keep #include +#include #include #include #include diff --git a/src/bamrec.cpp b/src/bamrec.cpp index b98e2b5..f7407aa 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -3,6 +3,7 @@ #include "bamrec.hpp" #include +#include #include #include #include diff --git a/src/original_duplicates.cpp b/src/original_duplicates.cpp index 09242fa..7d2a8d9 100644 --- a/src/original_duplicates.cpp +++ b/src/original_duplicates.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/src/samrec.cpp b/src/samrec.cpp index 35a7b0b..90afe46 100644 --- a/src/samrec.cpp +++ b/src/samrec.cpp @@ -4,6 +4,7 @@ #include "quality_score.hpp" #include +#include #include #include #include From 94987e78e0a090f794a1dae4cf7dfb8ac46de712 Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 16:44:40 -0800 Subject: [PATCH 12/13] clang-tidy warning suppression for array access --- src/bamrec.cpp | 2 ++ src/original_duplicates.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/bamrec.cpp b/src/bamrec.cpp index f7407aa..292f4b9 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -47,6 +47,7 @@ assign_sequence_revcomp(bidir_itr_t first, auto last, output_itr_t d_first) { }; auto j = last; while (j != 0) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) *d_first++ = seq_nt16_str_cmpl[bam_seqi(first, --j)]; return d_first; } @@ -62,6 +63,7 @@ assign_sequence(bidir_itr_t first, auto last, output_itr_t d_first) { return (s[i >> 1] >> ((~i & 1) << 2)) & low_nibble_on; }; for (auto j = 0U; j != last; ++j) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) *d_first++ = seq_nt16_str[bam_seqi(first, j)]; return d_first; } diff --git a/src/original_duplicates.cpp b/src/original_duplicates.cpp index 7d2a8d9..967174c 100644 --- a/src/original_duplicates.cpp +++ b/src/original_duplicates.cpp @@ -40,6 +40,7 @@ init_orig_dups_bam(const std::string &filename, const std::uint64_t n_unique) 2, 3, 0, 1, 4, // (A, C, T, G) -> (T, G, A, C) }; assert(x >= 0 && x <= 4); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) x = complement_mapping[x]; }; static constexpr auto to_acgtn = [](const char x) { @@ -47,6 +48,7 @@ init_orig_dups_bam(const std::string &filename, const std::uint64_t n_unique) static constexpr auto seq_nt16_str_acgtn = std::array{ 4, 0, 1, 4, 3, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, }; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) return seq_nt16_str_acgtn[x & mask]; }; const std::unique_ptr in( @@ -102,6 +104,7 @@ init_orig_dups_fq(const std::string &filename, const std::uint64_t n_unique) 4, 0, 4, 1, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) return to_acgtn_a[c & mask]; }; const std::unique_ptr in( From 8c125396a9b28db66aed208eb6ec7777835d323b Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Sun, 22 Nov 2026 16:51:57 -0800 Subject: [PATCH 13/13] src/fastq_file.cpp: fixed includes --- src/fastq_file.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastq_file.cpp b/src/fastq_file.cpp index c634a1e..ca71791 100644 --- a/src/fastq_file.cpp +++ b/src/fastq_file.cpp @@ -19,15 +19,15 @@ #include #include #include +#include #include #include #include +#include +#include #ifndef USE_MMAP_FOR_PLAIN_FASTQ #include -#include #include -#include -#include #else // USE_MMAP_FOR_PLAIN_FASTQ #include #include