[med-svn] [Git][med-team/btllib][master] 6 commits: Exclude 32bit architectures since upstream confirmed these are not supported.

Andreas Tille (@tille) gitlab at salsa.debian.org
Thu Feb 2 07:13:36 GMT 2023



Andreas Tille pushed to branch master at Debian Med / btllib


Commits:
fbbed381 by Andreas Tille at 2023-02-02T08:10:05+01:00
Exclude 32bit architectures since upstream confirmed these are not supported.

- - - - -
04e2126c by Andreas Tille at 2023-02-02T08:10:24+01:00
New upstream version 1.4.10+dfsg
- - - - -
0dd6b782 by Andreas Tille at 2023-02-02T08:10:24+01:00
routine-update: New upstream version

- - - - -
a170e3c5 by Andreas Tille at 2023-02-02T08:10:25+01:00
Update upstream source from tag 'upstream/1.4.10+dfsg'

Update to upstream version '1.4.10+dfsg'
with Debian dir 1a75f5a0c21b285ba963fc81c1d6d769b3d69c7f
- - - - -
515b6f1a by Andreas Tille at 2023-02-02T08:10:25+01:00
routine-update: Standards-Version: 4.6.2

- - - - -
73c804fa by Andreas Tille at 2023-02-02T08:12:03+01:00
routine-update: Ready to upload to unstable

- - - - -


19 changed files:

- + CITATION.cff
- README.md
- debian/changelog
- debian/control
- include/btllib/counting_bloom_filter.hpp
- include/btllib/mi_bloom_filter.hpp
- include/btllib/nthash.hpp
- include/btllib/seq_reader.hpp
- include/btllib/seq_reader_sam_module.hpp
- recipes/indexlr.cpp
- src/btllib/data_stream.cpp
- src/btllib/nthash.cpp
- src/btllib/nthash_lowlevel.cpp
- src/btllib/process_pipeline.cpp
- src/btllib/seq_reader.cpp
- src/btllib/seq_reader_gfa2_module.cpp
- src/btllib/seq_reader_sam_module.cpp
- src/btllib/seq_writer.cpp
- tests/nthash.cpp


Changes:

=====================================
CITATION.cff
=====================================
@@ -0,0 +1,59 @@
+cff-version: 1.2.0
+message: "If you use this software, please cite it as below."
+authors:
+  - family-names: "Nikolić"
+    given-names: "Vladimir"
+    orcid: "https://orcid.org/0000-0002-2992-9935"
+  - family-names: Kazemi
+    given-names: Parham
+  - family-names: Coombe
+    given-names: Lauren
+    orcid: "https://orcid.org/0000-0002-7518-2326"
+  - family-names: Wong
+    given-names: Johnathan
+  - family-names: Afshinfard
+    given-names: Amirhossein
+    orcid: "https://orcid.org/0000-0002-6875-4939"
+  - family-names: Chu
+    given-names: Justin
+  - family-names: Warren
+    given-names: René L.
+    orcid: "https://orcid.org/0000-0002-9890-2293"
+  - family-names: Birol
+    given-names: Inanç
+    orcid: "https://orcid.org/0000-0003-0950-7839"
+title: "btllib"
+url: "https://github.com/bcgsc/btllib"
+preferred-citation:
+  type: article
+  authors:
+    - family-names: "Nikolić"
+      given-names: "Vladimir"
+      orcid: "https://orcid.org/0000-0002-2992-9935"
+    - family-names: Kazemi
+      given-names: Parham
+    - family-names: Coombe
+      given-names: Lauren
+      orcid: "https://orcid.org/0000-0002-7518-2326"
+    - family-names: Wong
+      given-names: Johnathan
+    - family-names: Afshinfard
+      given-names: Amirhossein
+      orcid: "https://orcid.org/0000-0002-6875-4939"
+    - family-names: Chu
+      given-names: Justin
+    - family-names: Warren
+      given-names: René L.
+      orcid: "https://orcid.org/0000-0002-9890-2293"
+    - family-names: Birol
+      given-names: Inanç
+      orcid: "https://orcid.org/0000-0003-0950-7839"
+  doi: "10.21105/joss.04720"
+  url: "https://doi.org/10.21105/joss.04720"
+  year: 2022
+  publisher: "The Open Journal"
+  volume: 7
+  number: 79
+  pages: 4720
+  title: "btllib: A C++ library with Python interface for efficient genomic sequence processing"
+  journal: "Journal of Open Source Software"


=====================================
README.md
=====================================
@@ -3,6 +3,7 @@
 [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/bcgsc/btllib.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bcgsc/btllib/context:cpp)
 [![Total alerts](https://img.shields.io/lgtm/alerts/g/bcgsc/btllib.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bcgsc/btllib/alerts/)
 [![Build Status](https://dev.azure.com/bcgsc/btl_public/_apis/build/status/bcgsc.btllib)](https://dev.azure.com/bcgsc/btl_public/_build/latest?definitionId=1)
+[![DOI](https://joss.theoj.org/papers/10.21105/joss.04720/status.svg)](https://doi.org/10.21105/joss.04720)
 
 [Bioinformatics Technology Lab](http://www.birollab.ca/) common code library in C++ with Python wrappers.
 
@@ -82,5 +83,12 @@ Credits
 - Components:
   - [Hamid Mohamadi](https://github.com/mohamadi) and [Parham Kazemi](https://github.com/parham-k) for [ntHash](https://github.com/bcgsc/ntHash)
   - [Justin Chu](https://github.com/JustinChu) for [MIBloomFilter](https://github.com/bcgsc/btl_bloomfilter)
+- Included dependencies:
   - [Chase Geigle](https://github.com/skystrife) for [cpptoml](https://github.com/skystrife/cpptoml)
   - Simon Gog, Timo Beller, Alistair Moffat, and Matthias Petri for [sdsl-lite](https://github.com/simongog/sdsl-lite)
+
+Citing
+---
+If you use btllib in your research, please cite:
+
+Nikolić et al., (2022). btllib: A C++ library with Python interface for efficient genomic sequence processing. Journal of Open Source Software, 7(79), 4720, https://doi.org/10.21105/joss.04720


=====================================
debian/changelog
=====================================
@@ -1,3 +1,13 @@
+btllib (1.4.10+dfsg-1) unstable; urgency=medium
+
+  * Exclude 32bit architectures since upstream confirmed these are not
+    supported.
+    Closes: #1022772
+  * New upstream version
+  * Standards-Version: 4.6.2 (routine-update)
+
+ -- Andreas Tille <tille at debian.org>  Thu, 02 Feb 2023 08:10:47 +0100
+
 btllib (1.4.9+dfsg-2) unstable; urgency=medium
 
   * Packaging update


=====================================
debian/control
=====================================
@@ -11,14 +11,14 @@ Build-Depends: debhelper-compat (= 13),
 #               libsdsl-dev, # only mentioned in doc but package builds without this as well
                libomp-dev,
                samtools
-Standards-Version: 4.6.1
+Standards-Version: 4.6.2
 Vcs-Browser: https://salsa.debian.org/med-team/btllib
 Vcs-Git: https://salsa.debian.org/med-team/btllib.git
 Homepage: https://github.com/bcgsc/btllib
 Rules-Requires-Root: no
 
 Package: libbtllib-dev
-Architecture: any
+Architecture: any-amd64 arm64 mips64el ppc64el s390x ia64 ppc64 riscv64 sparc64 alpha
 Section: libdevel
 Depends: ${shlibs:Depends},
          ${misc:Depends},


=====================================
include/btllib/counting_bloom_filter.hpp
=====================================
@@ -695,8 +695,11 @@ CountingBloomFilter<T>::insert(const uint64_t* hashes, T min_val)
       update_done = array[hashes[i] % array_size].compare_exchange_strong(
         tmp_min_val, new_val);
     }
-    if (update_done ||
-        (min_val = contains(hashes)) == std::numeric_limits<T>::max()) {
+    if (update_done) {
+      break;
+    }
+    min_val = contains(hashes);
+    if (min_val == std::numeric_limits<T>::max()) {
       break;
     }
   }
@@ -1005,4 +1008,4 @@ KmerCountingBloomFilter<T>::save(const std::string& path)
 
 } // namespace btllib
 
-#endif
\ No newline at end of file
+#endif


=====================================
include/btllib/mi_bloom_filter.hpp
=====================================
@@ -84,9 +84,9 @@ public:
     unsigned colli_count = 0;
     for (unsigned i = 0; i < hash_num; ++i) {
       const int magic = 0x3f;
-      uint64_t pos = hash_values[i] % bv.size();
+      const uint64_t pos = hash_values[i] % bv.size();
       uint64_t* data_index = bv.data() + (pos >> 6); // NOLINT
-      uint64_t bit_mask_value = (uint64_t)1 << (pos & magic);
+      const uint64_t bit_mask_value = (uint64_t)1 << (pos & magic);
       colli_count +=
         __sync_fetch_and_or(data_index, bit_mask_value) >> (pos & magic) & 1;
     }
@@ -208,7 +208,7 @@ public:
 
         log_info("MIBloomFilter: Loading data vector");
 
-        long int l_cur_pos = ftell(file);
+        const long int l_cur_pos = ftell(file);
         auto ret = fseek(file, 0, 2);
         check_error(ret != 0,
                     "MIBloomFilter: Failed to seek to end of file: " +
@@ -233,7 +233,7 @@ public:
       }
 
       else {
-        std::string bv_filename = filter_file_path + ".sdsl";
+        const std::string bv_filename = filter_file_path + ".sdsl";
         log_info("MIBloomFilter: Loading sdsl interleaved bit vector from: " +
                  bv_filename);
         load_from_file(m_bv, bv_filename);
@@ -280,7 +280,7 @@ public:
                     "MIBloomFilter: " + filter_file_path +
                       " could not be read.");
       } else {
-        std::string bv_filename = filter_file_path + ".sdsl";
+        const std::string bv_filename = filter_file_path + ".sdsl";
         //				std::cerr << "Storing sdsl interleaved
         // bit
         // vector to: " << bv_filename


=====================================
include/btllib/nthash.hpp
=====================================
@@ -674,10 +674,14 @@ BTLLIB_NTHASH_PEEK(
   peek(),
 
   {
-    std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> forward_hash_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> reverse_hash_tmp(new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> forward_hash_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> reverse_hash_tmp(
+      new uint64_t[blocks.size()]);
     std::memcpy(fh_no_monomers_tmp.get(),
                 forward_hash.get(),
                 blocks.size() * sizeof(uint64_t));
@@ -708,10 +712,14 @@ BTLLIB_NTHASH_PEEK(
   peek(char char_in),
 
   {
-    std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> forward_hash_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> reverse_hash_tmp(new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> forward_hash_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> reverse_hash_tmp(
+      new uint64_t[blocks.size()]);
     std::memcpy(fh_no_monomers_tmp.get(),
                 forward_hash.get(),
                 blocks.size() * sizeof(uint64_t));
@@ -743,10 +751,14 @@ BTLLIB_NTHASH_PEEK(
   peek_back(),
 
   {
-    std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> forward_hash_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> reverse_hash_tmp(new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> forward_hash_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> reverse_hash_tmp(
+      new uint64_t[blocks.size()]);
     std::memcpy(fh_no_monomers_tmp.get(),
                 forward_hash.get(),
                 blocks.size() * sizeof(uint64_t));
@@ -777,10 +789,14 @@ BTLLIB_NTHASH_PEEK(
   peek_back(char char_in),
 
   {
-    std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> forward_hash_tmp(new uint64_t[blocks.size()]);
-    std::unique_ptr<uint64_t[]> reverse_hash_tmp(new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> fh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> rh_no_monomers_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> forward_hash_tmp(
+      new uint64_t[blocks.size()]);
+    const std::unique_ptr<uint64_t[]> reverse_hash_tmp(
+      new uint64_t[blocks.size()]);
     std::memcpy(fh_no_monomers_tmp.get(),
                 forward_hash.get(),
                 blocks.size() * sizeof(uint64_t));
@@ -815,4 +831,4 @@ BTLLIB_NTHASH_PEEK(
 
 } // namespace btllib
 
-#endif
\ No newline at end of file
+#endif


=====================================
include/btllib/seq_reader.hpp
=====================================
@@ -311,7 +311,7 @@ SeqReader::read_transition(Module& module,
     if (!reader_record->seq.empty()) {
       update_cstring_records(records, counter);
     }
-  } else if (!reader_record->seq.empty()) {
+  } else if (reader_record != nullptr && !reader_record->seq.empty()) {
     update_cstring_records(records, counter);
   }
 }
@@ -334,4 +334,4 @@ SeqReader::read_from_file(Module& module,
 
 } // namespace btllib
 
-#endif
\ No newline at end of file
+#endif


=====================================
include/btllib/seq_reader_sam_module.hpp
=====================================
@@ -25,6 +25,13 @@ private:
     ALIGNMENTS
   };
 
+  ~SeqReaderSamModule()
+  {
+    if (loader_thread) {
+      loader_thread->join();
+    }
+  }
+
   std::unique_ptr<ProcessPipeline> samtools_process;
   std::unique_ptr<std::thread> loader_thread;
   CString tmp;
@@ -46,7 +53,8 @@ SeqReaderSamModule::read_buffer(ReaderType& reader, RecordType& record)
   (void)reader;
   (void)record;
   {
-    ProcessPipeline version_test("samtools --version 2>/dev/stdout | head -n2");
+    const ProcessPipeline version_test(
+      "samtools --version 2>/dev/stdout | head -n2");
     char* line = nullptr;
     size_t n = 0;
     std::string version = "\n";
@@ -92,7 +100,6 @@ SeqReaderSamModule::read_buffer(ReaderType& reader, RecordType& record)
       }
       samtools_process->close_in();
     }));
-  loader_thread->detach();
   return false;
 }
 


=====================================
recipes/indexlr.cpp
=====================================
@@ -164,7 +164,7 @@ main(int argc, char* argv[])
                     " threads does not scale, reverting to 5.\n")
                 << std::flush;
     }
-    std::vector<std::string> infiles(&argv[optind], &argv[argc]);
+    const std::vector<std::string> infiles(&argv[optind], &argv[argc]);
     if (argc < 2) {
       print_usage();
       std::exit(EXIT_FAILURE); // NOLINT(concurrency-mt-unsafe)
@@ -226,7 +226,7 @@ main(int argc, char* argv[])
       out = fopen(outfile.c_str(), "w"); // NOLINT(android-cloexec-fopen)
 #endif
     }
-    for (auto& infile : infiles) {
+    for (const auto& infile : infiles) {
       std::unique_ptr<btllib::Indexlr> indexlr;
       if (with_repeat && with_solid) {
         flags |= btllib::Indexlr::Flag::FILTER_IN;
@@ -305,7 +305,7 @@ main(int argc, char* argv[])
           }
         }
         {
-          std::unique_lock<std::mutex> lock(output_queue_mutex);
+          const std::unique_lock<std::mutex> lock(output_queue_mutex);
           if (!ss.str().empty()) {
             output_queue.push(ss.str());
           }


=====================================
src/btllib/data_stream.cpp
=====================================
@@ -12,6 +12,7 @@
 #include <cstring>
 #include <map>
 #include <memory>
+#include <sstream>
 #include <string>
 #include <vector>
 
@@ -133,7 +134,7 @@ get_datatype_cmd(const std::string& path,
   for (const auto& existence_cmd : datatype.cmds_check_existence) {
     const pid_t pid = fork();
     if (pid == 0) {
-      int null_fd = open("/dev/null", O_WRONLY, 0);
+      const int null_fd = open("/dev/null", O_WRONLY, 0);
       dup2(null_fd, STDOUT_FILENO);
       dup2(null_fd, STDERR_FILENO);
       close(null_fd);
@@ -238,13 +239,13 @@ peel_datatype(const std::string& path, DataStream::Operation op)
 }
 
 static std::string
-form_string_cmd(std::vector<std::string>& cmd_layers,
-                DataStream::Operation op,
+form_string_cmd(const std::vector<std::string>& cmd_layers,
+                const DataStream::Operation op,
                 const std::string& path)
 {
-  std::string result_cmd;
+  std::stringstream result_cmd_ss;
   for (size_t i = 0; i < cmd_layers.size(); i++) {
-    auto& cmd = cmd_layers[i];
+    std::string cmd = cmd_layers[i];
     if (op == DataStream::Operation::WRITE ||
         op == DataStream::Operation::APPEND) {
       if (i == cmd_layers.size() - 1) {
@@ -278,10 +279,11 @@ form_string_cmd(std::vector<std::string>& cmd_layers,
       }
     }
     if (i > 0) {
-      result_cmd += " | ";
+      result_cmd_ss << " | ";
     }
-    result_cmd += cmd;
+    result_cmd_ss << cmd;
   }
+  std::string result_cmd = result_cmd_ss.str();
 
   check_error(result_cmd.empty(),
               (op == DataStream::Operation::READ ? "Error loading from "


=====================================
src/btllib/nthash.cpp
=====================================
@@ -211,7 +211,7 @@ check_seeds(const std::vector<std::string>& seeds, unsigned k)
     check_error(seed.length() != k,
                 "Spaced seed string length (" + std::to_string(seed.length()) +
                   ") not equal to k=" + std::to_string(k) + " in " + seed);
-    std::string reversed(seed.rbegin(), seed.rend());
+    const std::string reversed(seed.rbegin(), seed.rend());
     check_warning(
       seed != reversed,
       "Seed " + seed +
@@ -243,7 +243,7 @@ parse_seeds(const std::vector<std::string>& seed_strings,
             std::vector<SpacedSeedMonomers>& out_monomers)
 {
   for (const auto& seed_string : seed_strings) {
-    char pad = seed_string[seed_string.length() - 1] == '1' ? '0' : '1';
+    const char pad = seed_string[seed_string.length() - 1] == '1' ? '0' : '1';
     const std::string padded_string = seed_string + pad;
     SpacedSeedBlocks care_blocks, ignore_blocks;
     std::vector<unsigned> care_monos, ignore_monos;
@@ -254,7 +254,7 @@ parse_seeds(const std::vector<std::string>& seed_strings,
         if (pos - i_start == 1) {
           care_monos.push_back(i_start);
         } else {
-          std::array<unsigned, 2> block{ { i_start, pos } };
+          const std::array<unsigned, 2> block{ { i_start, pos } };
           care_blocks.push_back(block);
         }
         i_start = pos;
@@ -263,18 +263,19 @@ parse_seeds(const std::vector<std::string>& seed_strings,
         if (pos - i_start == 1) {
           ignore_monos.push_back(i_start);
         } else {
-          std::array<unsigned, 2> block{ { i_start, pos } };
+          const std::array<unsigned, 2> block{ { i_start, pos } };
           ignore_blocks.push_back(block);
         }
         i_start = pos;
         is_care_block = true;
       }
     }
-    unsigned num_cares = care_blocks.size() * 2 + care_monos.size();
-    unsigned num_ignores = ignore_blocks.size() * 2 + ignore_monos.size() + 2;
+    const unsigned num_cares = care_blocks.size() * 2 + care_monos.size();
+    const unsigned num_ignores =
+      ignore_blocks.size() * 2 + ignore_monos.size() + 2;
     if (num_ignores < num_cares) {
       unsigned string_end = seed_string.length();
-      std::array<unsigned, 2> block{ { 0, string_end } };
+      const std::array<unsigned, 2> block{ { 0, string_end } };
       ignore_blocks.push_back(block);
       out_blocks.push_back(ignore_blocks);
       out_monomers.push_back(ignore_monos);
@@ -330,4 +331,4 @@ BlindNtHash::sub(const std::vector<unsigned>& positions,
            hashes_array.get());
 }
 
-} // namespace btllib
\ No newline at end of file
+} // namespace btllib


=====================================
src/btllib/nthash_lowlevel.cpp
=====================================
@@ -8,25 +8,25 @@ ntf64(const char* kmer_seq, const unsigned k)
   uint64_t h_val = 0;
   for (unsigned i = 0; i < k / 4; i++) {
     h_val = srol(h_val, 4);
-    uint8_t curr_offset = 4 * i;
-    uint8_t tetramer_loc =
+    const uint8_t curr_offset = 4 * i;
+    const uint8_t tetramer_loc =
       64 * CONVERT_TAB[(unsigned char)kmer_seq[curr_offset]] +     // NOLINT
       16 * CONVERT_TAB[(unsigned char)kmer_seq[curr_offset + 1]] + // NOLINT
       4 * CONVERT_TAB[(unsigned char)kmer_seq[curr_offset + 2]] +
       CONVERT_TAB[(unsigned char)kmer_seq[curr_offset + 3]];
     h_val ^= TETRAMER_TAB[tetramer_loc];
   }
-  unsigned remainder = k % 4;
+  const unsigned remainder = k % 4;
   h_val = srol(h_val, remainder);
   if (remainder == 3) {
-    uint8_t trimer_loc =
+    const uint8_t trimer_loc =
       16 * CONVERT_TAB[(unsigned char)kmer_seq[k - 3]] + // NOLINT
       4 * CONVERT_TAB[(unsigned char)kmer_seq[k - 2]] +
       CONVERT_TAB[(unsigned char)kmer_seq[k - 1]];
     h_val ^= TRIMER_TAB[trimer_loc];
   } else if (remainder == 2) {
-    uint8_t dimer_loc = 4 * CONVERT_TAB[(unsigned char)kmer_seq[k - 2]] +
-                        CONVERT_TAB[(unsigned char)kmer_seq[k - 1]];
+    const uint8_t dimer_loc = 4 * CONVERT_TAB[(unsigned char)kmer_seq[k - 2]] +
+                              CONVERT_TAB[(unsigned char)kmer_seq[k - 1]];
     h_val ^= DIMER_TAB[dimer_loc];
   } else if (remainder == 1) {
     h_val ^= SEED_TAB[(unsigned char)kmer_seq[k - 1]];
@@ -38,24 +38,25 @@ uint64_t
 ntr64(const char* kmer_seq, const unsigned k)
 {
   uint64_t h_val = 0;
-  unsigned remainder = k % 4;
+  const unsigned remainder = k % 4;
   if (remainder == 3) {
-    uint8_t trimer_loc =
+    const uint8_t trimer_loc =
       16 * RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 1]] + // NOLINT
       4 * RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 2]] +
       RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 3]];
     h_val ^= TRIMER_TAB[trimer_loc];
   } else if (remainder == 2) {
-    uint8_t dimer_loc = 4 * RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 1]] +
-                        RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 2]];
+    const uint8_t dimer_loc =
+      4 * RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 1]] +
+      RC_CONVERT_TAB[(unsigned char)kmer_seq[k - 2]];
     h_val ^= DIMER_TAB[dimer_loc];
   } else if (remainder == 1) {
     h_val ^= SEED_TAB[(unsigned char)kmer_seq[k - 1] & CP_OFF];
   }
   for (unsigned i = 0; i < k / 4; i++) {
     h_val = srol(h_val, 4);
-    uint8_t curr_offset = 4 * (k / 4 - i) - 1;
-    uint8_t tetramer_loc =
+    const uint8_t curr_offset = 4 * (k / 4 - i) - 1;
+    const uint8_t tetramer_loc =
       64 * RC_CONVERT_TAB[(unsigned char)kmer_seq[curr_offset]] +     // NOLINT
       16 * RC_CONVERT_TAB[(unsigned char)kmer_seq[curr_offset - 1]] + // NOLINT
       4 * RC_CONVERT_TAB[(unsigned char)kmer_seq[curr_offset - 2]] +
@@ -178,7 +179,7 @@ ntmc64(const char* kmer_seq,
        const unsigned m,
        uint64_t* h_val)
 {
-  uint64_t b_val = ntc64(kmer_seq, k);
+  const uint64_t b_val = ntc64(kmer_seq, k);
   nte64(b_val, k, m, h_val);
 }
 
@@ -190,7 +191,7 @@ ntmc64(const char* kmer_seq,
        uint64_t& rh_val,
        uint64_t* h_val)
 {
-  uint64_t b_val = ntc64(kmer_seq, k, fh_val, rh_val);
+  const uint64_t b_val = ntc64(kmer_seq, k, fh_val, rh_val);
   nte64(b_val, k, m, h_val);
 }
 
@@ -203,7 +204,7 @@ ntmc64(const unsigned char char_out,
        uint64_t& rh_val,
        uint64_t* h_val)
 {
-  uint64_t b_val = ntc64(char_out, char_in, k, fh_val, rh_val);
+  const uint64_t b_val = ntc64(char_out, char_in, k, fh_val, rh_val);
   nte64(b_val, k, m, h_val);
 }
 
@@ -216,7 +217,7 @@ ntmc64l(const unsigned char char_out,
         uint64_t& rh_val,
         uint64_t* h_val)
 {
-  uint64_t b_val = ntc64l(char_out, char_in, k, fh_val, rh_val);
+  const uint64_t b_val = ntc64l(char_out, char_in, k, fh_val, rh_val);
   nte64(b_val, k, m, h_val);
 }
 
@@ -359,7 +360,7 @@ ntmc64(const unsigned char char_out,
        uint64_t* h_val,
        bool& h_stn)
 {
-  uint64_t b_val = ntc64(char_out, char_in, k, fh_val, rh_val);
+  const uint64_t b_val = ntc64(char_out, char_in, k, fh_val, rh_val);
   h_stn = rh_val < fh_val;
   nte64(b_val, k, m, h_val);
 }
@@ -440,7 +441,7 @@ ntmsm64(const char* kmer_seq,
     }
     fh_nomonos[i_seed] = fh_seed;
     rh_nomonos[i_seed] = rh_seed;
-    for (unsigned pos : seeds_monomers[i_seed]) {
+    for (const unsigned pos : seeds_monomers[i_seed]) {
       fh_seed ^= MS_TAB((unsigned char)kmer_seq[pos], k - 1 - pos);
       rh_seed ^= MS_TAB((unsigned char)kmer_seq[pos] & CP_OFF, pos);
     }
@@ -548,4 +549,4 @@ ntmsm64l(const char* kmer_seq,
     , fh_seed = sror(fh_seed);)
 }
 
-} // namespace btllib
\ No newline at end of file
+} // namespace btllib


=====================================
src/btllib/process_pipeline.cpp
=====================================
@@ -805,7 +805,7 @@ process_spawner_init()
 
 ProcessPipeline::ProcessPipeline(const std::string& cmd)
 {
-  std::unique_lock<std::mutex> lock(process_spawner_comm_mutex);
+  const std::unique_lock<std::mutex> lock(process_spawner_comm_mutex);
 
   const auto op = PipelineOperation::RUN;
   check_error(!write_to_spawner(&op, sizeof(op)),
@@ -903,7 +903,7 @@ ProcessPipeline::end()
     close_in();
     close_out();
 
-    std::unique_lock<std::mutex> lock(process_spawner_comm_mutex);
+    const std::unique_lock<std::mutex> lock(process_spawner_comm_mutex);
 
     const auto op = PipelineOperation::END;
     check_error(!write_to_spawner(&op, sizeof(op)) ||


=====================================
src/btllib/seq_reader.cpp
=====================================
@@ -97,7 +97,7 @@ bool
 SeqReader::load_buffer()
 {
   buffer.start = 0;
-  char last = buffer.end > 0 ? buffer.data[buffer.end - 1] : char(0);
+  const char last = buffer.end > 0 ? buffer.data[buffer.end - 1] : char(0);
   buffer.end = 0;
   do {
     buffer.end += fread(buffer.data.data() + buffer.end,
@@ -224,7 +224,7 @@ void
 SeqReader::determine_format()
 {
   load_buffer();
-  bool empty = buffer.end - buffer.start == 1;
+  const bool empty = buffer.end - buffer.start == 1;
   check_warning(empty, std::string(source_path) + " is empty.");
 
   if (empty) {
@@ -254,7 +254,7 @@ SeqReader::start_reader()
 {
   reader_thread = std::unique_ptr<std::thread>(new std::thread([this]() {
     {
-      std::unique_lock<std::mutex> lock(format_mutex);
+      const std::unique_lock<std::mutex> lock(format_mutex);
       determine_format();
       format_cv.notify_all();
     }
@@ -330,10 +330,11 @@ SeqReader::start_processors()
                 break;
               }
             }
-            size_t id_start = (format == Format::FASTA ||
-                               format == Format::FASTQ || format == Format::SAM)
-                                ? 1
-                                : 0;
+            const size_t id_start =
+              (format == Format::FASTA || format == Format::FASTQ ||
+               format == Format::SAM)
+                ? 1
+                : 0;
 
             switch (format) {
               case Format::FASTA:
@@ -400,7 +401,7 @@ SeqReader::start_processors()
             }
             if (fold_case()) {
               for (auto& c : seq) {
-                char old = c;
+                const char old = c;
                 c = CAPITALS[(unsigned char)(c)];
                 if (!bool(c)) {
                   log_error(std::string("A sequence contains invalid "
@@ -463,4 +464,4 @@ SeqReader::read_block()
   return block;
 }
 
-} // namespace btllib
\ No newline at end of file
+} // namespace btllib


=====================================
src/btllib/seq_reader_gfa2_module.cpp
=====================================
@@ -18,7 +18,7 @@ SeqReaderGfa2Module::buffer_valid(const char* buffer, const size_t size)
 
   auto is_a_spec = [&](unsigned char c) {
     bool found = false;
-    for (unsigned char spec : specs) {
+    for (const unsigned char spec : specs) {
       if (c == spec) {
         found = true;
         break;
@@ -70,4 +70,4 @@ SeqReaderGfa2Module::buffer_valid(const char* buffer, const size_t size)
   return has_id;
 }
 
-} // namespace btllib
\ No newline at end of file
+} // namespace btllib


=====================================
src/btllib/seq_reader_sam_module.cpp
=====================================
@@ -93,7 +93,7 @@ SeqReaderSamModule::buffer_valid(const char* buffer, const size_t size)
           }
           break;
         case TLEN:
-          if (!(bool(std::isdigit(c)) || c == '-')) {
+          if (!bool(std::isdigit(c)) && c != '-') {
             return false;
           }
           break;


=====================================
src/btllib/seq_writer.cpp
=====================================
@@ -67,11 +67,11 @@ SeqWriter::write(const std::string& id,
   }
 
   {
-    std::unique_lock<std::mutex> lock(mutex);
+    const std::unique_lock<std::mutex> lock(mutex);
     if (fwrite(output.c_str(), 1, output.size(), sink) != output.size()) {
       log_error("SeqWriter: fwrite failed: " + get_strerror());
     }
   }
 }
 
-} // namespace btllib
\ No newline at end of file
+} // namespace btllib


=====================================
tests/nthash.cpp
=====================================
@@ -465,11 +465,16 @@ main()
 
     btllib::SeedNtHash nthash1(seq_fwd, seeds, h, seeds[0].length());
     btllib::SeedNtHash nthash2(seq_rev, seeds, h, seeds[0].length());
+    
+    bool r1 = nthash1.roll();
+    bool r2 = nthash2.roll();
 
-    while (nthash1.roll() & nthash2.roll()) {
+    while (r1 && r2) {
       TEST_ASSERT_ARRAY_EQ(nthash1.hashes(), nthash2.hashes(), h);
+      r1 = nthash1.roll();
+      r2 = nthash2.roll();
     }
   }
 
   return 0;
-}
\ No newline at end of file
+}



View it on GitLab: https://salsa.debian.org/med-team/btllib/-/compare/8fd69c043b914972f4df42174085055eb8b23720...73c804fa28afeeaa8c0034fdd510559d9ac473d2

-- 
View it on GitLab: https://salsa.debian.org/med-team/btllib/-/compare/8fd69c043b914972f4df42174085055eb8b23720...73c804fa28afeeaa8c0034fdd510559d9ac473d2
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230202/632fbdea/attachment-0001.htm>


More information about the debian-med-commit mailing list