From 2a88504a508897d8878014c191da1483b67c819a Mon Sep 17 00:00:00 2001 From: Andrew D Smith Date: Mon, 21 Sep 2026 15:51:49 -0700 Subject: [PATCH 1/3] format update --- .clang-format | 30 +++++++--------------------- src/adapter_matcher.hpp | 6 ++++-- src/bam_file.cpp | 26 ++++++++++++------------ src/bam_file.hpp | 40 +++++++++++++++++++++---------------- src/bam_header.cpp | 4 ++-- src/bam_header.hpp | 12 +++++++---- src/bamrec.cpp | 8 ++++---- src/base_groups.cpp | 3 ++- src/base_groups.hpp | 3 ++- src/duplication_results.cpp | 18 +++++++++-------- src/duplication_results.hpp | 3 ++- src/falco.cpp | 10 ++++++---- src/falco_analyzer.cpp | 6 ++++-- src/falco_analyzer.hpp | 6 ++++-- src/falco_config.hpp | 4 ++-- src/falco_file_format.hpp | 18 +++++++++-------- src/falco_utils.hpp | 20 +++++++++++-------- src/fastq_bgzf_file.cpp | 20 ++++++++++--------- src/fastq_bgzf_file.hpp | 40 +++++++++++++++++++++---------------- src/fastq_file.cpp | 10 +++++++--- src/fastq_file.hpp | 14 +++++++------ src/fastq_gz_file.hpp | 20 +++++++++++++------ src/fastq_stdin.cpp | 6 ++++-- src/fastq_stdin.hpp | 12 +++++++---- src/file_info.hpp | 11 ++++++++-- src/html.cpp | 18 ++++++++++------- src/html.hpp | 13 +++++++----- src/original_duplicates.hpp | 7 ++++--- src/quality_score.cpp | 5 +---- src/quality_score.hpp | 19 +++++++++++------- src/reads_file.hpp | 12 +++++++---- src/report.cpp | 10 ++++++---- src/report.hpp | 10 ++++++---- src/sam_file.hpp | 23 +++++++++++---------- src/sam_stdin.cpp | 12 +++++------ src/sam_stdin.hpp | 23 +++++++++++---------- src/samrec.cpp | 3 ++- 37 files changed, 289 insertions(+), 216 deletions(-) diff --git a/.clang-format b/.clang-format index fb14c1cd..4bf0a3c2 100644 --- a/.clang-format +++ b/.clang-format @@ -1,29 +1,9 @@ -# MIT License -# -# Copyright (c) 2026 Andrew Smith -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - +# SPDX-License-Identifier: MIT; Copyright 2026 Andrew D Smith BasedOnStyle: LLVM ColumnLimit: 80 IndentWidth: 2 -AlwaysBreakAfterReturnType: All +BreakAfterReturnType: All +AlignAfterOpenBracket: true ContinuationIndentWidth: 2 ConstructorInitializerIndentWidth: 2 BraceWrapping: @@ -32,3 +12,7 @@ BraceWrapping: BreakBeforeBraces: Custom BreakConstructorInitializers: AfterColon SpacesBeforeTrailingComments: 2 +PackParameters: + BinPack: OnePerLine + BreakAfter: 0 +AllowShortFunctionsOnASingleLine: All diff --git a/src/adapter_matcher.hpp b/src/adapter_matcher.hpp index 154d6aa1..987ecc4a 100644 --- a/src/adapter_matcher.hpp +++ b/src/adapter_matcher.hpp @@ -71,12 +71,14 @@ struct adapter_matcher { get_grade(const std::uint64_t n_reads) const -> std::string; [[nodiscard]] auto - report(const std::uint64_t n_reads, const std::uint64_t max_read_len, + report(const std::uint64_t n_reads, + const std::uint64_t max_read_len, const base_group_vec &groups, const file_grades &grades) const -> std::string; [[nodiscard]] auto - html(const std::uint64_t n_reads, const std::uint64_t max_read_len, + html(const std::uint64_t n_reads, + const std::uint64_t max_read_len, const base_group_vec &groups, const file_grades &grades) const -> std::string; }; diff --git a/src/bam_file.cpp b/src/bam_file.cpp index bee2257d..6563aa1a 100644 --- a/src/bam_file.cpp +++ b/src/bam_file.cpp @@ -111,8 +111,8 @@ init_dups(const std::string &filename, const std::uint64_t n_unique) } auto -bam_file::load_next(const std::int32_t file_id, // - task_queue &tq, // +bam_file::load_next(const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void { is_first_load = false; if (output_cursor > 0) { @@ -134,11 +134,11 @@ bam_file::load_next(const std::int32_t file_id, // } [[nodiscard]] inline auto -partition(auto itr, // - const auto end, // - const std::int64_t n_chunks, // - const std::int32_t file_id, // - task_queue &tq, // +partition(auto itr, + const auto end, + const std::int64_t n_chunks, + const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) { // ADS: this isn't working as desired: the end position of each part should be // the first record end past the 'end_itr' below unless end_itr == end @@ -160,9 +160,9 @@ partition(auto itr, // } auto -bam_file::get_chunks(const std::int64_t n_chunks, // - const std::int32_t file_id, // - task_queue &tq, // +bam_file::get_chunks(const std::int64_t n_chunks, + const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void { // Swap so the input buffer can be used to inflate more data and the former // input buffer has been inflated and will provide data for analysis @@ -179,9 +179,9 @@ bam_file::get_chunks(const std::int64_t n_chunks, // } auto -bam_file::make_tasks(const std::int64_t n_threads, // - const std::int32_t file_id, // - task_queue &tq, // +bam_file::make_tasks(const std::int64_t n_threads, + const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void { static constexpr auto n_chunks_per_thread = 8; const auto n_chunks = n_chunks_per_thread * n_threads; diff --git a/src/bam_file.hpp b/src/bam_file.hpp index 93b52e41..00a7f276 100644 --- a/src/bam_file.hpp +++ b/src/bam_file.hpp @@ -49,9 +49,9 @@ class bam_file { public: bam_file(const std::string &filename, const std::int64_t buf_size) : - input_buffer(get_input_buffer_size(buf_size) + min_buf_size), // - output_buffer(get_output_buffer_size(buf_size) + min_buf_size), // - br(filename, get_reader_buffer_size(buf_size)) // + input_buffer(get_input_buffer_size(buf_size) + min_buf_size), + output_buffer(get_output_buffer_size(buf_size) + min_buf_size), + br(filename, get_reader_buffer_size(buf_size)) // {} // clang-format off @@ -71,10 +71,10 @@ class bam_file { reset(bam_file &reads_file) -> void; friend auto - make_tasks(bam_file &reads_file, // - const std::int64_t n_threads, // - const std::int32_t file_id, // - task_queue &tq, // + make_tasks(bam_file &reads_file, + const std::int64_t n_threads, + const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void; private: @@ -88,20 +88,26 @@ class bam_file { } auto - get_chunks(const std::int64_t n_chunks, const std::int32_t file_id, - task_queue &tq, std::atomic_int32_t &n_tasks) -> void; + get_chunks(const std::int64_t n_chunks, + const std::int32_t file_id, + task_queue &tq, + std::atomic_int32_t &n_tasks) -> void; auto - load_next(const std::int32_t file_id, task_queue &tq, + load_next(const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void; auto - make_tasks_inflate(const std::int32_t file_id, task_queue &tq, + make_tasks_inflate(const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void; auto - make_tasks(const std::int64_t n_chunks, const std::int32_t file_id, - task_queue &tq, std::atomic_int32_t &n_tasks) -> void; + make_tasks(const std::int64_t n_chunks, + const std::int32_t file_id, + task_queue &tq, + std::atomic_int32_t &n_tasks) -> void; [[nodiscard]] auto inflate_only() const -> bool { @@ -128,10 +134,10 @@ init_dups(const std::string &filename, const std::uint64_t n_unique) -> dups_map_t; inline auto -make_tasks(bam_file &reads_file, // - const std::int64_t n_threads, // - const std::int32_t file_id, // - task_queue &tq, // +make_tasks(bam_file &reads_file, + const std::int64_t n_threads, + const std::int32_t file_id, + task_queue &tq, std::atomic_int32_t &n_tasks) -> void { n_tasks = 1; // for current task, which makes tasks if (!reads_file.inflate_only()) diff --git a/src/bam_header.cpp b/src/bam_header.cpp index 5f7bd3ee..13b92753 100644 --- a/src/bam_header.cpp +++ b/src/bam_header.cpp @@ -6,8 +6,8 @@ #include [[nodiscard]] auto -bam_header::update(const_iterator itr, - const const_iterator end) -> const_iterator { +bam_header::update(const_iterator itr, const const_iterator end) + -> const_iterator { static constexpr auto msg = "incorrect BAM magic identified: {} at {}"; const auto update_u32 = [](auto &val, const auto inc, const auto the_byte) { // NOLINTNEXTLINE(*-avoid-magic-numbers) diff --git a/src/bam_header.hpp b/src/bam_header.hpp index 8f4068f9..09058490 100644 --- a/src/bam_header.hpp +++ b/src/bam_header.hpp @@ -56,10 +56,14 @@ struct bam_header { } } - NLOHMANN_DEFINE_TYPE_INTRUSIVE(bam_header, magic_bytes_remaining, - l_text_bytes_remaining, l_text, - n_ref_bytes_remaining, n_ref, - l_name_bytes_remaining, name_bytes_remaining, + NLOHMANN_DEFINE_TYPE_INTRUSIVE(bam_header, + magic_bytes_remaining, + l_text_bytes_remaining, + l_text, + n_ref_bytes_remaining, + n_ref, + l_name_bytes_remaining, + name_bytes_remaining, l_ref_bytes_remaining); }; diff --git a/src/bamrec.cpp b/src/bamrec.cpp index b951e6c3..7afafdd9 100644 --- a/src/bamrec.cpp +++ b/src/bamrec.cpp @@ -64,8 +64,8 @@ assign_sequence(bidir_itr_t first, auto last, output_itr_t d_first) { } [[nodiscard]] auto -bamrec::get_next(bamrec::pos_t &itr, const bamrec::pos_t end, - bamrec &rec) -> bool { +bamrec::get_next(bamrec::pos_t &itr, const bamrec::pos_t end, bamrec &rec) + -> bool { if (std::distance(itr, end) < bam_core_t::sz) return false; bam_core_t core{}; @@ -102,8 +102,8 @@ bamrec::get_next(bamrec::pos_t &itr, const bamrec::pos_t end, } [[nodiscard]] auto -bamrec::find_end_pos(bamrec::pos_t itr, - const bamrec::pos_t end) -> bamrec::pos_t { +bamrec::find_end_pos(bamrec::pos_t itr, const bamrec::pos_t end) + -> bamrec::pos_t { static constexpr std::int64_t record_size_size = sizeof(std::uint32_t); std::uint32_t record_size{}; while (itr != end) { diff --git a/src/base_groups.cpp b/src/base_groups.cpp index ab09bbcf..331cca78 100644 --- a/src/base_groups.cpp +++ b/src/base_groups.cpp @@ -36,7 +36,8 @@ get_linear_interval(const std::uint64_t n_bases, } [[nodiscard]] auto -make_base_groups(const std::uint64_t n_bases, const std::uint64_t n_initial, +make_base_groups(const std::uint64_t n_bases, + const std::uint64_t n_initial, const std::uint64_t n_groups_target) -> base_group_vec { static constexpr auto make_one_group = [](const auto a, const auto b) { return base_group_t{a, b}; diff --git a/src/base_groups.hpp b/src/base_groups.hpp index 2dcbc068..a07e7f2f 100644 --- a/src/base_groups.hpp +++ b/src/base_groups.hpp @@ -19,7 +19,8 @@ using base_group_t = std::pair; using base_group_vec = std::vector; [[nodiscard]] auto -make_base_groups(const std::uint64_t n_bases, const std::uint64_t n_initial, +make_base_groups(const std::uint64_t n_bases, + const std::uint64_t n_initial, const std::uint64_t n_groups_target) -> base_group_vec; [[nodiscard]] auto diff --git a/src/duplication_results.cpp b/src/duplication_results.cpp index a1f6a038..bf7e88ce 100644 --- a/src/duplication_results.cpp +++ b/src/duplication_results.cpp @@ -127,8 +127,8 @@ duplication_results::get_overrepresented(const std::uint64_t n_reads) const } auto -duplication_results::initialize(const run_mode &mode, - const file_info &info) -> void { +duplication_results::initialize(const run_mode &mode, const file_info &info) + -> void { read_skip = info.n_reads_est < max_n_reads_total ? 0 @@ -138,7 +138,8 @@ duplication_results::initialize(const run_mode &mode, } auto -duplication_results::initialize(const run_mode &mode, const file_info &info, +duplication_results::initialize(const run_mode &mode, + const file_info &info, const dups_init_t &dups_init) -> void { initialize(mode, info); dups = dups_init.dups_zero; @@ -196,7 +197,8 @@ make_bins(const auto &breaks, const auto &hist) { // ADS: for original dups, from FastQC extrapolation of dup counts. [[nodiscard]] auto get_corrected_count(const std::uint64_t count_at_limit, - const std::uint64_t n_reads, const std::uint64_t dup_level, + const std::uint64_t n_reads, + const std::uint64_t dup_level, const std::uint64_t n_obs) -> double { static constexpr auto epsilon = 0.01; if (count_at_limit == n_reads) // we saw everything @@ -285,8 +287,8 @@ get_grade_duplication(const dup_summary_t &summary) -> std::string { } [[nodiscard]] auto -duplication_report(const dup_summary_t &summary, - const file_grades &grades) -> std::string { +duplication_report(const dup_summary_t &summary, const file_grades &grades) + -> std::string { static constexpr auto label = "duplication"; static constexpr auto start_tag = ">>Sequence Duplication Levels\t{}\n" "#Total Deduplicated Percentage\t{:.6f}\n"; @@ -349,8 +351,8 @@ overrepresented_html(const std::vector &overrep, } [[nodiscard]] auto -duplication_html(const dup_summary_t &summary, - const file_grades &grades) -> std::string { +duplication_html(const dup_summary_t &summary, const file_grades &grades) + -> std::string { static constexpr auto label = "duplication"; static constexpr auto plot_format = R"(