Skip to content

Commit

Permalink
style: Run treefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundmiller committed Jul 5, 2024
1 parent ecafcc2 commit 85967a9
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 31 deletions.
6 changes: 1 addition & 5 deletions crates.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{...}: {
perSystem = {
pkgs,
config,
...
}: let
perSystem = {pkgs, ...}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
crateName = cargoToml.package.name;
in {
Expand Down
3 changes: 1 addition & 2 deletions doc/cli-output.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

```
dragenos -r <reference> -b <base calls> [optional arguments]
Expand Down Expand Up @@ -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<dragenos::common::InvalidOptionException>
std::exception::what: fastq-file1 or bam-input must point to an existing fastq file
```
```
3 changes: 1 addition & 2 deletions doc/refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
1 change: 0 additions & 1 deletion doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 change: 0 additions & 1 deletion docs/rust-notes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
https://github.com/markschl/seq_io

1 change: 0 additions & 1 deletion docs/zig-notes.md
Original file line number Diff line number Diff line change
@@ -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

5 changes: 1 addition & 4 deletions src/include/align/VectorSmithWaterman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ class VectorSmithWaterman {
#endif
}

~VectorSmithWaterman()
{
free(sswScoringMat_);
}
~VectorSmithWaterman() { free(sswScoringMat_); }

uint16_t align(
const unsigned char* queryBegin,
Expand Down
2 changes: 1 addition & 1 deletion src/include/common/Threads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
10 changes: 2 additions & 8 deletions src/include/reference/ReferenceSequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/lib/common/SystemCompatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const unsigned char*>(&v);
for (unsigned i = 0; i < sizeof(v); ++i) {
if (p[i] != i) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/reference/ReferenceDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(bufPtr.get()), size);
if (!file) {
// THROW(DragenException, "Could not load reference - could not read ", path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const HashRecord*>(ss[i]);
const auto end = begin + 2;
Expand Down Expand Up @@ -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<const HashRecord*>(ss[i]);
const auto end = begin + 3;
Expand Down
3 changes: 2 additions & 1 deletion todo.org
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 85967a9

Please sign in to comment.