From 85967a900034732bf991bbde657c035fe86ea88a Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 25 Jun 2024 11:50:11 -0500 Subject: [PATCH] style: Run treefmt --- crates.nix | 6 +----- doc/cli-output.md | 3 +-- doc/refactor.md | 3 +-- doc/usage.md | 1 - docs/rust-notes.md | 1 - docs/zig-notes.md | 1 - src/include/align/VectorSmithWaterman.hpp | 5 +---- src/include/common/Threads.hpp | 2 +- src/include/reference/ReferenceSequence.hpp | 10 ++-------- src/lib/common/SystemCompatibility.cpp | 4 ++-- src/lib/reference/ReferenceDir.cpp | 2 +- .../tests/integration/ExtendTableIntervalGtest.cpp | 4 ++-- todo.org | 3 ++- 13 files changed, 14 insertions(+), 31 deletions(-) diff --git a/crates.nix b/crates.nix index 967a637..5584d67 100644 --- a/crates.nix +++ b/crates.nix @@ -1,9 +1,5 @@ {...}: { - perSystem = { - pkgs, - config, - ... - }: let + perSystem = {pkgs, ...}: let cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); crateName = cargoToml.package.name; in { diff --git a/doc/cli-output.md b/doc/cli-output.md index 90a3601..1a83095 100644 --- a/doc/cli-output.md +++ b/doc/cli-output.md @@ -1,4 +1,3 @@ - ``` dragenos -r -b [optional arguments] @@ -195,4 +194,4 @@ Command line options: Failed to parse the options: /build/i5zj4f8yjlk2spizc3krc2x4k1yqkvz1-source/src/lib/options/DragenOsOptions.cpp(335): Throw in function postProcess Dynamic exception type: boost::wrapexcept std::exception::what: fastq-file1 or bam-input must point to an existing fastq file -``` \ No newline at end of file +``` diff --git a/doc/refactor.md b/doc/refactor.md index ad244eb..ff574aa 100644 --- a/doc/refactor.md +++ b/doc/refactor.md @@ -2,7 +2,6 @@ Ran `config.mk` through chatgpt4 - ## Refactoring Explanation: 1. The checks for certain environment variables and command-line parameters (like `GTEST_INCLUDEDIR`, `GTEST_LIBRARYDIR`, `BOOST_INCLUDEDIR`, `BOOST_LIBRARYDIR`) are repeated, which can be refactored into a function-like macro for reusability. @@ -134,7 +133,7 @@ GTEST_LDFLAGS+=-lgtest_main -lgtest sources := $(wildcard $(DRAGEN_OS_SRC_DIR)/*.cpp) programs := $(sources:$(DRAGEN_OS_SRC_DIR)/%.cpp=%) -``` +``` Diff: Given the amount of code and the complexity of the original file, it would be impractical to display all the exact diffs here. However, applying the above refactoring suggestions would result in removal of commented code blocks, consolidation of repeated checks into function-macros, and cleanliness and clarity in variable assignments and conditionals. diff --git a/doc/usage.md b/doc/usage.md index 64f6b45..cd90aa5 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -25,4 +25,3 @@ Or directly to a file : ## Align single-end reads : dragen-os -r /home/data/reference/ -1 reads_1.fastq.gz > result.sam - diff --git a/docs/rust-notes.md b/docs/rust-notes.md index 5777dfe..948c0d7 100644 --- a/docs/rust-notes.md +++ b/docs/rust-notes.md @@ -1,2 +1 @@ https://github.com/markschl/seq_io - diff --git a/docs/zig-notes.md b/docs/zig-notes.md index 2d1df0c..576bf34 100644 --- a/docs/zig-notes.md +++ b/docs/zig-notes.md @@ -1,3 +1,2 @@ https://github.com/blark/mmdvmhost-zig/blob/main/build.zig https://zig.news/kristoff/compile-a-c-c-project-with-zig-368j - diff --git a/src/include/align/VectorSmithWaterman.hpp b/src/include/align/VectorSmithWaterman.hpp index 864df29..a1cf8d9 100644 --- a/src/include/align/VectorSmithWaterman.hpp +++ b/src/include/align/VectorSmithWaterman.hpp @@ -66,10 +66,7 @@ class VectorSmithWaterman { #endif } - ~VectorSmithWaterman() - { - free(sswScoringMat_); - } + ~VectorSmithWaterman() { free(sswScoringMat_); } uint16_t align( const unsigned char* queryBegin, diff --git a/src/include/common/Threads.hpp b/src/include/common/Threads.hpp index 7057090..e22e4bb 100644 --- a/src/include/common/Threads.hpp +++ b/src/include/common/Threads.hpp @@ -109,7 +109,7 @@ class BasicThreadPool { { return os << "Executor(" << e.maxThreads_ << "mt," << e.threadsIn_ << "ti," << e.complete_ << "c)"; } - } * head_, *tail_; + } * head_, *tail_; static std::mutex mutex_; std::condition_variable stateChangedCondition_; diff --git a/src/include/reference/ReferenceSequence.hpp b/src/include/reference/ReferenceSequence.hpp index 96ca696..db7287c 100644 --- a/src/include/reference/ReferenceSequence.hpp +++ b/src/include/reference/ReferenceSequence.hpp @@ -199,14 +199,8 @@ class ReferenceSequence { return getRcBaseNoCheck(position); } - const unsigned char* getData() const - { - return data_; - } - size_t getSize() const - { - return size_; - } + const unsigned char* getData() const { return data_; } + size_t getSize() const { return size_; } /// decode 4 bits into AIUPAC character using only 4 LSB static char decodeBase(unsigned char base); /// translate into 2 bits encoding using only 4 LSB diff --git a/src/lib/common/SystemCompatibility.cpp b/src/lib/common/SystemCompatibility.cpp index 44bb6b6..161605b 100644 --- a/src/lib/common/SystemCompatibility.cpp +++ b/src/lib/common/SystemCompatibility.cpp @@ -323,7 +323,7 @@ int64_t clock() bool isLittleEndian() { - const uint64_t v = 0x0706050403020100; + const uint64_t v = 0x0706050403020100; const unsigned char* const p = reinterpret_cast(&v); for (unsigned i = 0; i < sizeof(v); ++i) { if (p[i] != i) { @@ -354,7 +354,7 @@ uint64_t getFileSize(const PathCharType* filePath) boost::filesystem::path getModuleFileName() { char szBuffer[10240]; - int readBytes = readlink("/proc/self/exe", szBuffer, sizeof(szBuffer)); + int readBytes = readlink("/proc/self/exe", szBuffer, sizeof(szBuffer)); DRAGEN_OS_ASSERT_MSG(-1 != readBytes, "TODO: handle the readlink error: " << errno); // readlink does not zero-terminate the string. szBuffer[readBytes] = 0; diff --git a/src/lib/reference/ReferenceDir.cpp b/src/lib/reference/ReferenceDir.cpp index e676928..36c8a89 100644 --- a/src/lib/reference/ReferenceDir.cpp +++ b/src/lib/reference/ReferenceDir.cpp @@ -53,7 +53,7 @@ typename ReferenceDir7::UcharPtr ReferenceDir7::ReadFileIntoBuffer( size = file.tellg(); file.seekg(0, file.beg); - UcharPtr bufPtr(new uint8_t[size], [](uint8_t* p) -> void { delete[](p); }); + UcharPtr bufPtr(new uint8_t[size], [](uint8_t* p) -> void { delete[] (p); }); file.read(reinterpret_cast(bufPtr.get()), size); if (!file) { // THROW(DragenException, "Could not load reference - could not read ", path); diff --git a/src/lib/reference/tests/integration/ExtendTableIntervalGtest.cpp b/src/lib/reference/tests/integration/ExtendTableIntervalGtest.cpp index 8359a28..444e9b3 100644 --- a/src/lib/reference/tests/integration/ExtendTableIntervalGtest.cpp +++ b/src/lib/reference/tests/integration/ExtendTableIntervalGtest.cpp @@ -41,7 +41,7 @@ TEST(ExtendTableInterval, SetOfTwo) uint64_t s4[] = {0x7bf9df58fa123456, 0x7bf9fedcfb987654}; uint64_t* ss[] = {s1, s2, s3, s4}; uint32_t esl[][3] = { - {0, 0x56987654, 0x1234}, {0x12, 0x56987654, 0x34}, {0, 0x56, 0x34987654}, {0, 0x123456, 0x987654}}; + {0, 0x56987654, 0x1234}, {0x12, 0x56987654, 0x34}, {0, 0x56, 0x34987654}, {0, 0x123456, 0x987654}}; for (unsigned i = 0; 4 > i; ++i) { const auto begin = reinterpret_cast(ss[i]); const auto end = begin + 2; @@ -94,7 +94,7 @@ TEST(ExtendTableInterval, SetOfThree) uint64_t s5[] = {0xc851b149f900001a, 0xc851b148fabb10ae, 0xc851b14afb01f3b0}; uint64_t* ss[] = {s1, s2, s3, s4, s5}; uint32_t sl[][2] = { - {5777464, 92356}, {4231852, 80514}, {0x27c4fc2, 106658}, {0x1b46391e, 96576}, {0x1abb10ae, 127920}}; + {5777464, 92356}, {4231852, 80514}, {0x27c4fc2, 106658}, {0x1b46391e, 96576}, {0x1abb10ae, 127920}}; for (unsigned i = 0; 5 > i; ++i) { const auto begin = reinterpret_cast(ss[i]); const auto end = begin + 3; diff --git a/todo.org b/todo.org index e3de1ae..1db0e3d 100644 --- a/todo.org +++ b/todo.org @@ -3,7 +3,8 @@ https://crates.io/crates/clap_mangen * Build System -** TODO Add treefmt back in +** DONE Add treefmt back in +CLOSED: [2024-06-25 Tue 12:17] ** DONE Use https://flake.parts/ again CLOSED: [2024-06-25 Tue 12:15] ** TODO Use build.zig