From 99030c2f70de322e01063e787f00ae49ca8c24b9 Mon Sep 17 00:00:00 2001 From: Pall Melsted Date: Thu, 23 Oct 2025 13:27:31 +0000 Subject: [PATCH] fixes 'using namespace std' in header files and compilation on mac --- CMakeLists.txt | 12 +- src/Bifrost.cpp | 4 +- src/BitContainer.cpp | 10 +- src/BitContainer.hpp | 8 +- src/BlockedBloomFilter.cpp | 18 +- src/ColorSet.cpp | 14 +- src/ColorSet.hpp | 12 +- src/ColoredCDBG.hpp | 44 +-- src/ColoredCDBG.tcc | 574 +++++++++++++-------------- src/Common.hpp | 28 +- src/CompactedDBG.hpp | 162 ++++---- src/CompactedDBG.tcc | 784 ++++++++++++++++++------------------- src/CompressedCoverage.cpp | 24 +- src/CompressedCoverage.hpp | 8 +- src/CompressedSequence.cpp | 2 + src/CompressedSequence.hpp | 8 +- src/DataAccessor.hpp | 4 +- src/DataAccessor.tcc | 38 +- src/DataStorage.hpp | 26 +- src/DataStorage.tcc | 318 +++++++-------- src/FASTX_Parser.cpp | 1 + src/FASTX_Parser.hpp | 16 +- src/File_Parser.hpp | 20 +- src/GFA_Parser.cpp | 52 +-- src/GFA_Parser.hpp | 48 ++- src/IO.tcc | 376 +++++++++--------- src/KmerCovIndex.hpp | 6 +- src/KmerCovIndex.tcc | 24 +- src/KmerHashTable.hpp | 36 +- src/KmerIterator.cpp | 2 + src/KmerIterator.hpp | 6 +- src/KmerStream.hpp | 85 ++-- src/MinimizerIndex.cpp | 16 +- src/MinimizerIndex.hpp | 2 +- src/RepHash.hpp | 10 +- src/Search.tcc | 268 ++++++------- src/StreamCounter.hpp | 2 +- src/TinyBitmap.cpp | 2 + src/TinyBitmap.hpp | 6 +- src/Unitig.hpp | 4 +- src/UnitigMap.cpp | 2 + src/UnitigMap.hpp | 4 +- src/UnitigMap.tcc | 12 +- src/minHashIterator.hpp | 12 +- src/rw_spin_lock.h | 26 +- 45 files changed, 1575 insertions(+), 1561 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2647829..5f9eac9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,16 @@ endif(COMPILATION_ARCH MATCHES "OFF") if(ENABLE_AVX2 MATCHES "OFF") message("Disabling AVX2 instructions") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-avx2") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-avx2") + # Only add -mno-avx2 for GCC or for Intel architectures where it's meaningful + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR + (NOT APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-avx2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-avx2") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") + # For clang on x86_64, use -mno-avx2 but suppress the warning if it's unused + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument -mno-avx2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument -mno-avx2") + endif() endif(ENABLE_AVX2 MATCHES "OFF") # Manages build types diff --git a/src/Bifrost.cpp b/src/Bifrost.cpp index f91f6b8..f6a5b8f 100755 --- a/src/Bifrost.cpp +++ b/src/Bifrost.cpp @@ -333,7 +333,7 @@ bool check_ProgramOptions(CCDBG_Build_opt& opt) { } } - v_files = move(files_tmp); + v_files = std::move(files_tmp); delete[] buffer; }; @@ -672,7 +672,7 @@ int main(int argc, char **argv){ ColoredCDBG<>& ccdbg_a = (ccdbg1_len > ccdbg2_len) ? ccdbg1 : ccdbg2; ColoredCDBG<>& ccdbg_b = (ccdbg1_len > ccdbg2_len) ? ccdbg2 : ccdbg1; - if (success) success = ccdbg_a.merge(move(ccdbg_b), lopt.nb_threads, lopt.verbose); + if (success) success = ccdbg_a.merge(std::move(ccdbg_b), lopt.nb_threads, lopt.verbose); if (success) success = ccdbg_a.simplify(lopt.deleteIsolated, lopt.clipTips, lopt.verbose); if (success) success = ccdbg_a.write(lopt.prefixFilenameOut, lopt.nb_threads, lopt.writeIndexFile, lopt.compressOutput, lopt.verbose); diff --git a/src/BitContainer.cpp b/src/BitContainer.cpp index 32d3ccc..2f05ebf 100755 --- a/src/BitContainer.cpp +++ b/src/BitContainer.cpp @@ -1,5 +1,7 @@ #include "BitContainer.hpp" +using namespace std; + BitContainer::BitContainer() : setBits(localBitVector) {} BitContainer::BitContainer(const BitContainer& o) { @@ -580,7 +582,7 @@ void BitContainer::remove(const size_t pair_id) { setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; - *this = move(new_uc); + *this = std::move(new_uc); } else setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; } @@ -630,7 +632,7 @@ void BitContainer::remove(const size_t pair_id) { for (; it != it_end; ++it) new_uc.add(*it); - *this = move(new_uc); + *this = std::move(new_uc); } else if ((setBits & flagMask) == ptrBitmap) bitmap->r.runOptimize(); } @@ -704,7 +706,7 @@ void BitContainer::removeSortedVector(const vector& v) { setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; - *this = move(new_uc); + *this = std::move(new_uc); } else setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; } @@ -752,7 +754,7 @@ void BitContainer::removeSortedVector(const vector& v) { for (const_iterator it = begin(), it_end = end(); it != it_end; ++it) new_uc.add(*it); - *this = move(new_uc); + *this = std::move(new_uc); } else if ((setBits & flagMask) == ptrBitmap) bitmap->r.runOptimize(); } diff --git a/src/BitContainer.hpp b/src/BitContainer.hpp index 4c87f19..656f583 100755 --- a/src/BitContainer.hpp +++ b/src/BitContainer.hpp @@ -103,8 +103,8 @@ class BitContainer { size_t size() const; inline size_t cardinality() const { return size(); } - bool write(ostream& stream_out) const; - bool read(istream& stream_in); + bool write(std::ostream& stream_out) const; + bool read(std::istream& stream_in); size_t getSizeInBytes() const; @@ -130,8 +130,8 @@ class BitContainer { private: - void addSortedVector(const vector& v); - void removeSortedVector(const vector& v); + void addSortedVector(const std::vector& v); + void removeSortedVector(const std::vector& v); inline void releaseMemory(){ diff --git a/src/BlockedBloomFilter.cpp b/src/BlockedBloomFilter.cpp index 34ba94f..c5a11a5 100755 --- a/src/BlockedBloomFilter.cpp +++ b/src/BlockedBloomFilter.cpp @@ -27,7 +27,7 @@ BlockedBloomFilter::BlockedBloomFilter(const BlockedBloomFilter& o) : table_(n } BlockedBloomFilter::BlockedBloomFilter(BlockedBloomFilter&& o) : table_(o.table_), blocks_(o.blocks_), nb_bits_per_elem(o.nb_bits_per_elem), - k_(o.k_), M_u64(o.M_u64), seed1(o.seed1), seed2(o.seed2), ush(move(o.ush)) { + k_(o.k_), M_u64(o.M_u64), seed1(o.seed1), seed2(o.seed2), ush(std::move(o.ush)) { o.table_ = nullptr; @@ -80,7 +80,7 @@ BlockedBloomFilter& BlockedBloomFilter::operator=(BlockedBloomFilter&& o) { seed1 = o.seed1; seed2 = o.seed2; - ush = move(o.ush); + ush = std::move(o.ush); o.table_ = nullptr; @@ -160,7 +160,7 @@ DualBlockedBloomFilter BlockedBloomFilter::transferToDBBF(const uint64_t idx_bbf dbbf.seed1 = seed1; dbbf.seed2 = seed2; - dbbf.ush[idx_bbf_norm] = move(ush); + dbbf.ush[idx_bbf_norm] = std::move(ush); dbbf.table_ = new DualBlockedBloomFilter::BBF_Block[blocks_ << 1]; for (size_t i = 0; i < blocks_; ++i) { @@ -622,7 +622,7 @@ DualBlockedBloomFilter::DualBlockedBloomFilter(const DualBlockedBloomFilter& o) } DualBlockedBloomFilter::DualBlockedBloomFilter(DualBlockedBloomFilter&& o) : table_(o.table_), blocks_(o.blocks_), nb_bits_per_elem(o.nb_bits_per_elem), - k_(o.k_), M_u64(o.M_u64), seed1(o.seed1), seed2(o.seed2), ush{move(o.ush[0]), move(o.ush[1])} { + k_(o.k_), M_u64(o.M_u64), seed1(o.seed1), seed2(o.seed2), ush{std::move(o.ush[0]), std::move(o.ush[1])} { o.table_ = nullptr; @@ -645,8 +645,8 @@ DualBlockedBloomFilter& DualBlockedBloomFilter::operator=(const DualBlockedBloom seed1 = o.seed1; seed2 = o.seed2; - ush[0] = o.ush[0]; - ush[1] = o.ush[1]; + ush[0] = std::move(o.ush[0]); + ush[1] = std::move(o.ush[1]); if (blocks_ != 0) { @@ -677,8 +677,8 @@ DualBlockedBloomFilter& DualBlockedBloomFilter::operator=(DualBlockedBloomFilter seed1 = o.seed1; seed2 = o.seed2; - ush[0] = move(o.ush[0]); - ush[1] = move(o.ush[1]); + ush[0] = std::move(o.ush[0]); + ush[1] = std::move(o.ush[1]); o.table_ = nullptr; @@ -927,7 +927,7 @@ BlockedBloomFilter DualBlockedBloomFilter::transferToBBF(const uint64_t idx_bbf) bbf.seed2 = seed2; bbf.M_u64 = M_u64; - bbf.ush = move(ush[idx_bbf_norm]); + bbf.ush = std::move(ush[idx_bbf_norm]); bbf.table_ = new BlockedBloomFilter::BBF_Block[blocks_]; for (size_t i = 0; i < blocks_; ++i) { diff --git a/src/ColorSet.cpp b/src/ColorSet.cpp index cbfb15e..c5af284 100755 --- a/src/ColorSet.cpp +++ b/src/ColorSet.cpp @@ -4,6 +4,8 @@ #include "ColorSet.hpp" +using namespace std; + UnitigColors::UnitigColors() : setBits(localBitVector) {} UnitigColors::UnitigColors(const UnitigColors& o) { @@ -721,7 +723,7 @@ void UnitigColors::remove(const UnitigMapBase& um, const size_t color_id) { setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; - *this = move(new_uc); + *this = std::move(new_uc); } else setBits = (reinterpret_cast(t_bmp.detach()) & pointerMask) | localTinyBitmap; } @@ -771,7 +773,7 @@ void UnitigColors::remove(const UnitigMapBase& um, const size_t color_id) { for (; it != it_end; ++it) new_uc.add(it.getColorID() * um_km_sz + it.getKmerPosition()); - *this = move(new_uc); + *this = std::move(new_uc); } else if ((setBits & flagMask) == ptrBitmap) bitmap->r.runOptimize(); } @@ -1097,8 +1099,8 @@ bool UnitigColors::optimizeFullColors(const UnitigMapBase& um){ UnitigColors* uc = new UnitigColors[2]; - uc[0] = move(full_uc); - uc[1] = move(non_full_uc); + uc[0] = std::move(full_uc); + uc[1] = std::move(non_full_uc); setBits = (reinterpret_cast(uc) & pointerMask) | ptrUnitigColors; @@ -1121,8 +1123,8 @@ UnitigColors UnitigColors::makeFullColors(const UnitigMapBase& um) const { UnitigColors* uc = new UnitigColors[2]; - uc[0] = move(full_uc); - uc[1] = move(non_full_uc); + uc[0] = std::move(full_uc); + uc[1] = std::move(non_full_uc); new_uc.setBits = (reinterpret_cast(uc) & pointerMask) | ptrUnitigColors; diff --git a/src/ColorSet.hpp b/src/ColorSet.hpp index 102fe90..5b82859 100755 --- a/src/ColorSet.hpp +++ b/src/ColorSet.hpp @@ -29,12 +29,12 @@ class UnitigColors { public: - typedef pair SharedUnitigColors; + typedef std::pair SharedUnitigColors; /** @class UnitigColors_const_iterator * @brief See UnitigColors::const_iterator */ - class UnitigColors_const_iterator : public std::iterator> { + class UnitigColors_const_iterator : public std::iterator> { friend class UnitigColors; @@ -70,9 +70,9 @@ class UnitigColors { * @return a pair p of integers representing the position of a k-mer in the unitig (p.first) * and the ID of the color associated with the k-mer at the given position (p.second). */ - inline pair operator*() const { + inline std::pair operator*() const { - return make_pair(ck_id % um_sz, ck_id / um_sz); + return std::make_pair(ck_id % um_sz, ck_id / um_sz); } /** @@ -281,7 +281,7 @@ class UnitigColors { * opened prior to the call of this function and it won't be closed by this function. * @return a boolean indicating if the write was successful. */ - bool write(ostream& stream_out, const bool copy_UnitigColors = true) const; + bool write(std::ostream& stream_out, const bool copy_UnitigColors = true) const; /** * Read a UnitigColors from a stream. @@ -289,7 +289,7 @@ class UnitigColors { * opened prior to the call of this function and it won't be closed by this function. * @return a boolean indicating if the write was successful. */ - bool read(istream& stream_in); + bool read(std::istream& stream_in); /** * Size of the UnitigColors in bytes. diff --git a/src/ColoredCDBG.hpp b/src/ColoredCDBG.hpp index 75e3852..1e4522c 100755 --- a/src/ColoredCDBG.hpp +++ b/src/ColoredCDBG.hpp @@ -29,7 +29,7 @@ */ struct CCDBG_Build_opt : CDBG_Build_opt { - string filename_colors_in; + std::string filename_colors_in; bool outputColors; @@ -125,9 +125,9 @@ class CCDBG_Data_t { * associated. * @return a string which is the serialization of the data. */ - string serialize(const const_UnitigColorMap& um_src) const { + std::string serialize(const const_UnitigColorMap& um_src) const { - return string(); + return std::string(); } }; @@ -152,7 +152,7 @@ class CCDBG_Data_t { template class ColoredCDBG : public CompactedDBG, DataStorage> { - static_assert(is_void::value || is_base_of, Unitig_data_t>::value, + static_assert(std::is_void::value || std::is_base_of, Unitig_data_t>::value, "Type Unitig_data_t of data associated with vertices of class ColoredCDBG must " " be void (no data) or a class extending class CCDBG_Data_t"); @@ -252,7 +252,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information message are printed during writing (true) or not (false). * @return a boolean indicating whether the graph was successfully written. */ - bool write(const string& prefix_output_fn, const size_t nb_threads = 1, const bool write_index_file = true, const bool compress_output = false, const bool verbose = false) const; + bool write(const std::string& prefix_output_fn, const size_t nb_threads = 1, const bool write_index_file = true, const bool compress_output = false, const bool verbose = false) const; /** Load a colored and compacted de Bruijn graph from disk. The graph (in GFA, FASTA or BFG format) must * have been produced by Bifrost. By default, the function detects if an index file (BFI format) exists for the @@ -264,7 +264,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages are printed during reading (true) or not (false). * @return a boolean indicating whether the graph was successfully read. */ - bool read(const string& input_graph_fn, const string& input_colors_fn, const size_t nb_threads = 1, const bool verbose = false); + bool read(const std::string& input_graph_fn, const std::string& input_colors_fn, const size_t nb_threads = 1, const bool verbose = false); /** Load a colored and compacted de Bruijn graph from disk using an index file. * The graph (in GFA, FASTA or BFG format) must have been produced by Bifrost. @@ -275,7 +275,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages are printed during reading (true) or not (false). * @return a boolean indicating whether the graph was successfully read. */ - bool read(const string& input_graph_fn, const string& input_index_fn, const string& input_colors_fn, const size_t nb_threads = 1, const bool verbose = false); + bool read(const std::string& input_graph_fn, const std::string& input_index_fn, const std::string& input_colors_fn, const size_t nb_threads = 1, const bool verbose = false); /** Load a colored and compacted de Bruijn graph without its colors from disk. * A call to ColoredCDBG::mapColors is required afterwards to map colors to unitigs. @@ -284,7 +284,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages are printed during reading (true) or not (false). * @return a boolean indicating whether the graph was successfully read. */ - bool readGraph(const string& input_graph_fn, const size_t nb_threads = 1, const bool verbose = false); + bool readGraph(const std::string& input_graph_fn, const size_t nb_threads = 1, const bool verbose = false); /** Load a colored and compacted de Bruijn graph without its colors from disk using an index file. * A call to ColoredCDBG::mapColors is required afterwards to map colors to unitigs. @@ -294,7 +294,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages are printed during reading (true) or not (false). * @return a boolean indicating whether the graph was successfully read. */ - bool readGraph(const string& input_graph_fn, const string& input_index_fn, const size_t nb_threads = 1, const bool verbose = false); + bool readGraph(const std::string& input_graph_fn, const std::string& input_index_fn, const size_t nb_threads = 1, const bool verbose = false); /** Merge a colored and compacted de Bruijn graph. * After merging, all unitigs and colors of the input graph have been added to and compacted with the current @@ -336,7 +336,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages must be printed during the execution of the function. * @return a boolean indicating whether the graphs have been successfully merged. */ - bool merge(const vector& v, const size_t nb_threads = 1, const bool verbose = false); + bool merge(const std::vector& v, const size_t nb_threads = 1, const bool verbose = false); /** Merge and clear multiple colored and compacted de Bruijn graphs. * After merging, all unitigs and colors of the input colored and compacted de Bruijn graphs have been added to and @@ -350,19 +350,19 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating if information messages must be printed during the execution of the function. * @return a boolean indicating whether the graphs have been successfully merged. */ - bool merge(vector&& v, const size_t nb_threads = 1, const bool verbose = false); + bool merge(std::vector&& v, const size_t nb_threads = 1, const bool verbose = false); /** Get the name of a color. As colors match the input files, the color names match the input filenames. * @return a string which is either a color name or an empty string if the color ID is invalid or if the * colors have not yet been mapped to the unitigs. */ - string getColorName (const size_t color_id) const; + std::string getColorName (const size_t color_id) const; /** Get the names of all colors. As colors match the input files, the color names match the input filenames. * @return a vector of strings for which each string is either a color name or an empty string if the color ID is * invalid or if the colors have not yet been mapped to the unitigs. */ - vector getColorNames() const; + std::vector getColorNames() const; /** Get the number of colors in the graph. * @return the number of colors in the graph. @@ -387,7 +387,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, + bool searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -408,7 +408,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, + bool searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const size_t min_nb_colors, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -428,7 +428,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool search(const vector& query_filenames, const string& out_filename_prefix, + bool search(const std::vector& query_filenames, const std::string& out_filename_prefix, const bool found_km_ratio_out = false, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -448,7 +448,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, ostream& out, const double ratio_kmers, + bool searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double ratio_kmers, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -469,7 +469,7 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, ostream& out, + bool searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const size_t min_nb_colors, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -490,19 +490,19 @@ class ColoredCDBG : public CompactedDBG, DataStorage * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool search(const vector& query_filenames, ostream& out, + bool search(const std::vector& query_filenames, std::ostream& out, const bool found_km_ratio_out = false, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; private: - bool searchMinRatioKmer_( const vector& query_filenames, ostream& out, + bool searchMinRatioKmer_( const std::vector& query_filenames, std::ostream& out, const double ratio_kmers, const size_t min_nb_colors, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const; - void checkColors(const vector& filename_seq_in) const; - bool loadColors(const string& input_graph_fn, const string& input_colors_fn, const size_t nb_threads, const bool verbose); + void checkColors(const std::vector& filename_seq_in) const; + bool loadColors(const std::string& input_graph_fn, const std::string& input_colors_fn, const size_t nb_threads, const bool verbose); void initUnitigColors(const CCDBG_Build_opt& opt, const size_t max_nb_hash = 31); void buildUnitigColors(const size_t nb_threads); diff --git a/src/ColoredCDBG.tcc b/src/ColoredCDBG.tcc index 1382683..5cd0099 100755 --- a/src/ColoredCDBG.tcc +++ b/src/ColoredCDBG.tcc @@ -11,7 +11,7 @@ template ColoredCDBG::ColoredCDBG(const ColoredCDBG& o) : CompactedDBG, DataStorage>(o), invalid(o.invalid) {} template -ColoredCDBG::ColoredCDBG(ColoredCDBG&& o) : CompactedDBG, DataStorage>(move(o)), invalid(o.invalid) {} +ColoredCDBG::ColoredCDBG(ColoredCDBG&& o) : CompactedDBG, DataStorage>(std::move(o)), invalid(o.invalid) {} template void ColoredCDBG::clear(){ @@ -37,7 +37,7 @@ ColoredCDBG& ColoredCDBG::operator=(ColoredCDBG&& o) { if (this != &o) { - CompactedDBG, DataStorage>::operator=(move(o)); + CompactedDBG, DataStorage>::operator=(std::move(o)); invalid = o.invalid; @@ -72,7 +72,7 @@ bool ColoredCDBG::operator==(const ColoredCDBG& o) const { unitig_o.dist = 0; unitig_o.len = unitig_o.size - k + 1; - const string unitig_o_str = unitig_o.strand ? unitig_o.referenceUnitigToString() : reverse_complement(unitig_o.referenceUnitigToString()); + const std::string unitig_o_str = unitig_o.strand ? unitig_o.referenceUnitigToString() : reverse_complement(unitig_o.referenceUnitigToString()); if (unitig_o_str != unitig.referenceUnitigToString()) return false; else { @@ -108,25 +108,25 @@ bool ColoredCDBG::merge(const ColoredCDBG& o, const size_t nb_threads, const if (invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Current graph is invalid." << std::endl; ret = false; } if (o.invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Graph to merge is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Graph to merge is invalid." << std::endl; ret = false; } if (this->getK() != o.getK()){ - if (verbose) cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (this == &o){ - if (verbose) cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } @@ -141,19 +141,19 @@ bool ColoredCDBG::merge(const ColoredCDBG& o, const size_t nb_threads, const if (ret){ const size_t sz_after = this->size(); - const pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); + const std::pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); resizeDataUC(sz_after + (p1.second - p1.first), nb_threads); - const pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); + const std::pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); const size_t joined = (p1.second != 0) ? CompactedDBG, DataStorage>::joinUnitigs() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << std::endl; } for (size_t i = 0; i < o.getNbColors(); ++i) this->getData()->color_names.push_back(o.getColorName(i)); @@ -172,25 +172,25 @@ bool ColoredCDBG::merge(ColoredCDBG&& o, const size_t nb_threads, const bool if (invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Current graph is invalid." << std::endl; ret = false; } if (o.invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Graph to merge is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Graph to merge is invalid." << std::endl; ret = false; } if (this->getK() != o.getK()){ - if (verbose) cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (this == &o){ - if (verbose) cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } @@ -205,24 +205,24 @@ bool ColoredCDBG::merge(ColoredCDBG&& o, const size_t nb_threads, const bool if (ret){ const size_t sz_after = this->size(); - const pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); + const std::pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); resizeDataUC(sz_after + (p1.second - p1.first), nb_threads); - const pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); + const std::pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); const size_t joined = (p1.second != 0) ? CompactedDBG, DataStorage>::joinUnitigs() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << std::endl; } for (size_t i = 0; i < o.getNbColors(); ++i) this->getData()->color_names.push_back(o.getColorName(i)); - const bool ret = CompactedDBG, DataStorage>::mergeData(move(o), nb_threads, verbose); + const bool ret = CompactedDBG, DataStorage>::mergeData(std::move(o), nb_threads, verbose); o.clear(); @@ -234,13 +234,13 @@ bool ColoredCDBG::merge(ColoredCDBG&& o, const size_t nb_threads, const bool } template -bool ColoredCDBG::merge(const vector& v, const size_t nb_threads, const bool verbose){ +bool ColoredCDBG::merge(const std::vector& v, const size_t nb_threads, const bool verbose){ bool ret = true; if (invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Current graph is invalid." << std::endl; ret = false; } @@ -248,19 +248,19 @@ bool ColoredCDBG::merge(const vector& v, const size_t nb_threads if (ccdbg.invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): One of the graph to merge is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): One of the graph to merge is invalid." << std::endl; ret = false; } if (this->getK() != ccdbg.getK()){ - if (verbose) cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (this == &ccdbg){ - if (verbose) cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } } @@ -281,19 +281,19 @@ bool ColoredCDBG::merge(const vector& v, const size_t nb_threads if (ret){ const size_t sz_after = this->size(); - const pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); + const std::pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); resizeDataUC(sz_after + (p1.second - p1.first), nb_threads); - const pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); + const std::pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); const size_t joined = (p1.second != 0) ? CompactedDBG, DataStorage>::joinUnitigs() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << std::endl; } for (const auto& ccdbg : v){ @@ -311,13 +311,13 @@ bool ColoredCDBG::merge(const vector& v, const size_t nb_threads } template -bool ColoredCDBG::merge(vector&& v, const size_t nb_threads, const bool verbose){ +bool ColoredCDBG::merge(std::vector&& v, const size_t nb_threads, const bool verbose){ bool ret = true; if (invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Current graph is invalid." << std::endl; ret = false; } @@ -325,19 +325,19 @@ bool ColoredCDBG::merge(vector&& v, const size_t nb_threads, con if (ccdbg.invalid){ - if (verbose) cerr << "ColoredCDBG::merge(): One of the graph to merge is invalid." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): One of the graph to merge is invalid." << std::endl; ret = false; } if (this->getK() != ccdbg.getK()){ - if (verbose) cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (this == &ccdbg){ - if (verbose) cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "ColoredCDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } } @@ -358,26 +358,26 @@ bool ColoredCDBG::merge(vector&& v, const size_t nb_threads, con if (ret){ const size_t sz_after = this->size(); - const pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); + const std::pair p1 = CompactedDBG, DataStorage>::getSplitInfoAllUnitigs(); resizeDataUC(sz_after + (p1.second - p1.first), nb_threads); - const pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); + const std::pair p2 = CompactedDBG, DataStorage>::splitAllUnitigs(); const size_t joined = (p1.second != 0) ? CompactedDBG, DataStorage>::joinUnitigs() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p1.first << " unitigs into " << p1.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << this->size() << " unitigs after merging." << std::endl; } for (auto& ccdbg : v){ for (size_t i = 0; i < ccdbg.getNbColors(); ++i) this->getData()->color_names.push_back(ccdbg.getColorName(i)); - if (!CompactedDBG, DataStorage>::mergeData(move(ccdbg), nb_threads, verbose)) return false; + if (!CompactedDBG, DataStorage>::mergeData(std::move(ccdbg), nb_threads, verbose)) return false; ccdbg.clear(); } @@ -398,7 +398,7 @@ bool ColoredCDBG::buildGraph(const CCDBG_Build_opt& opt){ invalid = !this->build(opt_); } - else cerr << "ColoredCDBG::buildGraph(): Graph is invalid and cannot be built." << endl; + else std::cerr << "ColoredCDBG::buildGraph(): Graph is invalid and cannot be built." << std::endl; return !invalid; } @@ -411,13 +411,13 @@ bool ColoredCDBG::buildColors(const CCDBG_Build_opt& opt){ initUnitigColors(opt); buildUnitigColors(opt.nb_threads); } - else cerr << "ColoredCDBG::buildColors(): Graph is invalid (maybe not built yet?) and colors cannot be mapped." << endl; + else std::cerr << "ColoredCDBG::buildColors(): Graph is invalid (maybe not built yet?) and colors cannot be mapped." << std::endl; return !invalid; } template -bool ColoredCDBG::write(const string& prefix_output_fn, const size_t nb_threads, const bool write_index_file, const bool compress_output, const bool verbose) const { +bool ColoredCDBG::write(const std::string& prefix_output_fn, const size_t nb_threads, const bool write_index_file, const bool compress_output, const bool verbose) const { if (!CompactedDBG, DataStorage>::write(prefix_output_fn, nb_threads, true, false, false, write_index_file, compress_output, verbose)) return false; // Write graph @@ -425,17 +425,17 @@ bool ColoredCDBG::write(const string& prefix_output_fn, const size_t nb_threa } template -bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& input_colors_fn, const size_t nb_threads, const bool verbose) { +bool ColoredCDBG::loadColors(const std::string& input_graph_fn, const std::string& input_colors_fn, const size_t nb_threads, const bool verbose) { if (!this->getData()->read(input_colors_fn, nb_threads, verbose)) return false; // Read colors - if (verbose) cout << "ColoredCDBG::loadColors(): Joining unitigs to their color sets." << endl; + if (verbose) std::cout << "ColoredCDBG::loadColors(): Joining unitigs to their color sets." << std::endl; GFA_Parser graph(input_graph_fn); graph.open_read(); - auto reading_function = [&graph](vector>& unitig_tags, const size_t chunk_size) { + auto reading_function = [&graph](std::vector>& unitig_tags, const size_t chunk_size) { size_t i = 0; size_t graph_file_id = 0; @@ -450,7 +450,7 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu if (r.first->tags.empty()){ - cerr << "ColoredCDBG::loadColors(): One sequence line in GFA file has no DataAccessor tag. Operation aborted." << endl; + std::cerr << "ColoredCDBG::loadColors(): One sequence line in GFA file has no DataAccessor tag. Operation aborted." << std::endl; return false; } @@ -463,7 +463,7 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu if (i == r.first->tags.size()){ - cerr << "ColoredCDBG::loadColors(): One sequence line in GFA file has no DataAccessor tag. Operation aborted." << endl; + std::cerr << "ColoredCDBG::loadColors(): One sequence line in GFA file has no DataAccessor tag. Operation aborted." << std::endl; return false; } @@ -478,7 +478,7 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu return ((r.first != nullptr) || (r.second != nullptr)); }; - auto join_function = [this](const vector>& unitig_tags) { + auto join_function = [this](const std::vector>& unitig_tags) { for (const auto& p : unitig_tags){ @@ -486,9 +486,9 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu if (ucm.isEmpty){ - cerr << "ColoredCDBG::loadColors(): Internal error, operation aborted." << endl; - cerr << "ColoredCDBG::loadColors(): A unitig from GFA file is not found in the in-memory graph." << endl; - cerr << "ColoredCDBG::loadColors(): Graph from GFA file possibly incorrectly compacted." << endl; + std::cerr << "ColoredCDBG::loadColors(): Internal error, operation aborted." << std::endl; + std::cerr << "ColoredCDBG::loadColors(): A unitig from GFA file is not found in the in-memory graph." << std::endl; + std::cerr << "ColoredCDBG::loadColors(): Graph from GFA file possibly incorrectly compacted." << std::endl; return false; } @@ -502,7 +502,7 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu UnitigColors* uc = da->getUnitigColors(ucm); UnitigColors r_uc = uc->reverse(ucm); - *uc = move(r_uc); + *uc = std::move(r_uc); } } @@ -512,9 +512,9 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu { const size_t chunk = 10000; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; bool file_valid_for_read = true; @@ -524,12 +524,12 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu [&]{ - vector> v; + std::vector> v; while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (!file_valid_for_read) return; @@ -551,7 +551,7 @@ bool ColoredCDBG::loadColors(const string& input_graph_fn, const string& inpu } template -bool ColoredCDBG::read(const string& input_graph_fn, const string& input_colors_fn, const size_t nb_threads, const bool verbose) { +bool ColoredCDBG::read(const std::string& input_graph_fn, const std::string& input_colors_fn, const size_t nb_threads, const bool verbose) { bool valid_input_files = true; @@ -563,20 +563,20 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_colo if (fp == NULL) { - cerr << "ColoredCDBG::read(): Could not open input graph file " << input_graph_fn << endl; + std::cerr << "ColoredCDBG::read(): Could not open input graph file " << input_graph_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::read(): Input graph file " << input_graph_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::read(): Input graph file " << input_graph_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::read(): No input graph file provided." << endl; + std::cerr << "ColoredCDBG::read(): No input graph file provided." << std::endl; valid_input_files = false; } @@ -588,31 +588,31 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_colo if (fp == NULL) { - cerr << "ColoredCDBG::read(): Could not open input colors file " << input_colors_fn << endl; + std::cerr << "ColoredCDBG::read(): Could not open input colors file " << input_colors_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::read(): Input colors file " << input_colors_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::read(): Input colors file " << input_colors_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::read(): No input colors file provided." << endl; + std::cerr << "ColoredCDBG::read(): No input colors file provided." << std::endl; valid_input_files = false; } if (valid_input_files){ - if (verbose) cout << "ColoredCDBG::read(): Reading graph." << endl; + if (verbose) std::cout << "ColoredCDBG::read(): Reading graph." << std::endl; invalid = !CompactedDBG, DataStorage>::read(input_graph_fn, nb_threads, verbose); if (invalid) return false; // Read graph - if (verbose) cout << "ColoredCDBG::read(): Reading colors." << endl; + if (verbose) std::cout << "ColoredCDBG::read(): Reading colors." << std::endl; invalid = !loadColors(input_graph_fn, input_colors_fn, nb_threads, verbose); @@ -623,7 +623,7 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_colo } template -bool ColoredCDBG::read(const string& input_graph_fn, const string& input_index_fn, const string& input_colors_fn, const size_t nb_threads, const bool verbose) { +bool ColoredCDBG::read(const std::string& input_graph_fn, const std::string& input_index_fn, const std::string& input_colors_fn, const size_t nb_threads, const bool verbose) { bool valid_input_files = true; @@ -635,20 +635,20 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_inde if (fp == NULL) { - cerr << "ColoredCDBG::read(): Could not open input graph file " << input_graph_fn << endl; + std::cerr << "ColoredCDBG::read(): Could not open input graph file " << input_graph_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::read(): Input graph file " << input_graph_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::read(): Input graph file " << input_graph_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::read(): No input graph file provided." << endl; + std::cerr << "ColoredCDBG::read(): No input graph file provided." << std::endl; valid_input_files = false; } @@ -660,20 +660,20 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_inde if (fp == NULL) { - cerr << "ColoredCDBG::read(): Could not open input colors file " << input_colors_fn << endl; + std::cerr << "ColoredCDBG::read(): Could not open input colors file " << input_colors_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::read(): Input colors file " << input_colors_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::read(): Input colors file " << input_colors_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::read(): No input colors file provided." << endl; + std::cerr << "ColoredCDBG::read(): No input colors file provided." << std::endl; valid_input_files = false; } @@ -685,31 +685,31 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_inde if (fp == NULL) { - cerr << "ColoredCDBG::read(): Could not open input index file " << input_index_fn << endl; + std::cerr << "ColoredCDBG::read(): Could not open input index file " << input_index_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::read(): Input index file " << input_index_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::read(): Input index file " << input_index_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::read(): No input index file provided." << endl; + std::cerr << "ColoredCDBG::read(): No input index file provided." << std::endl; valid_input_files = false; } if (valid_input_files){ - if (verbose) cout << "ColoredCDBG::read(): Reading graph." << endl; + if (verbose) std::cout << "ColoredCDBG::read(): Reading graph." << std::endl; invalid = !CompactedDBG, DataStorage>::read(input_graph_fn, input_index_fn, nb_threads, verbose); if (invalid) return false; // Read graph - if (verbose) cout << "ColoredCDBG::read(): Reading colors." << endl; + if (verbose) std::cout << "ColoredCDBG::read(): Reading colors." << std::endl; invalid = !loadColors(input_graph_fn, input_colors_fn, nb_threads, verbose); @@ -720,7 +720,7 @@ bool ColoredCDBG::read(const string& input_graph_fn, const string& input_inde } template -bool ColoredCDBG::readGraph(const string& input_graph_fn, const size_t nb_threads, const bool verbose) { +bool ColoredCDBG::readGraph(const std::string& input_graph_fn, const size_t nb_threads, const bool verbose) { bool valid_input_files = true; @@ -732,26 +732,26 @@ bool ColoredCDBG::readGraph(const string& input_graph_fn, const size_t nb_thr if (fp == NULL) { - cerr << "ColoredCDBG::readGraph(): Could not open input graph file " << input_graph_fn << endl; + std::cerr << "ColoredCDBG::readGraph(): Could not open input graph file " << input_graph_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::readGraph(): Input graph file " << input_graph_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::readGraph(): Input graph file " << input_graph_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::readGraph(): No input graph file provided." << endl; + std::cerr << "ColoredCDBG::readGraph(): No input graph file provided." << std::endl; valid_input_files = false; } if (valid_input_files){ - if (verbose) cout << "ColoredCDBG::readGraph(): Reading graph." << endl; + if (verbose) std::cout << "ColoredCDBG::readGraph(): Reading graph." << std::endl; invalid = !CompactedDBG, DataStorage>::read(input_graph_fn, nb_threads, verbose); @@ -762,7 +762,7 @@ bool ColoredCDBG::readGraph(const string& input_graph_fn, const size_t nb_thr } template -bool ColoredCDBG::readGraph(const string& input_graph_fn, const string& input_index_fn, const size_t nb_threads, const bool verbose) { +bool ColoredCDBG::readGraph(const std::string& input_graph_fn, const std::string& input_index_fn, const size_t nb_threads, const bool verbose) { bool valid_input_files = true; @@ -774,20 +774,20 @@ bool ColoredCDBG::readGraph(const string& input_graph_fn, const string& input if (fp == NULL) { - cerr << "ColoredCDBG::readGraph(): Could not open input graph file " << input_graph_fn << endl; + std::cerr << "ColoredCDBG::readGraph(): Could not open input graph file " << input_graph_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::readGraph(): Input graph file " << input_graph_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::readGraph(): Input graph file " << input_graph_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::readGraph(): No input graph file provided." << endl; + std::cerr << "ColoredCDBG::readGraph(): No input graph file provided." << std::endl; valid_input_files = false; } @@ -799,26 +799,26 @@ bool ColoredCDBG::readGraph(const string& input_graph_fn, const string& input if (fp == NULL) { - cerr << "ColoredCDBG::readGraph(): Could not open input index file " << input_index_fn << endl; + std::cerr << "ColoredCDBG::readGraph(): Could not open input index file " << input_index_fn << std::endl; valid_input_files = false; } else fclose(fp); } else { - cerr << "ColoredCDBG::readGraph(): Input index file " << input_index_fn << " does not exist." << endl; + std::cerr << "ColoredCDBG::readGraph(): Input index file " << input_index_fn << " does not exist." << std::endl; valid_input_files = false; } } else { - cerr << "ColoredCDBG::readGraph(): No input index file provided." << endl; + std::cerr << "ColoredCDBG::readGraph(): No input index file provided." << std::endl; valid_input_files = false; } if (valid_input_files){ - if (verbose) cout << "ColoredCDBG::readGraph(): Reading graph." << endl; + if (verbose) std::cout << "ColoredCDBG::readGraph(): Reading graph." << std::endl; invalid = !CompactedDBG, DataStorage>::read(input_graph_fn, input_index_fn, nb_threads, verbose); @@ -831,25 +831,25 @@ bool ColoredCDBG::readGraph(const string& input_graph_fn, const string& input template void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t max_nb_hash){ - vector v_files(opt.filename_seq_in); + std::vector v_files(opt.filename_seq_in); v_files.insert(v_files.end(), opt.filename_ref_in.begin(), opt.filename_ref_in.end()); DataStorage* ds = this->getData(); DataStorage new_ds(max_nb_hash, this->size(), v_files); - *ds = move(new_ds); + *ds = std::move(new_ds); v_files.clear(); const size_t chunk = 1000; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < opt.nb_threads; ++t){ @@ -862,7 +862,7 @@ void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t m while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -885,7 +885,7 @@ void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t m for (auto& t : workers) t.join(); - //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << endl; + //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << std::endl; } template @@ -897,12 +897,12 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons const size_t chunk = 100; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -915,7 +915,7 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -934,12 +934,12 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons if ((uc != nullptr) || (data != nullptr)){ - const pair, pair> p = new_ds.insert(*it_unitig); + const std::pair, std::pair> p = new_ds.insert(*it_unitig); *(it_unitig->getData()) = p.first; - if (uc != nullptr) *(p.second.first) = move(*uc); - if (data != nullptr) *(p.second.second) = move(*data); + if (uc != nullptr) *(p.second.first) = std::move(*uc); + if (data != nullptr) *(p.second.second) = std::move(*data); } } } @@ -949,9 +949,9 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons for (auto& t : workers) t.join(); - *ds = move(new_ds); + *ds = std::move(new_ds); - //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << endl; + //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << std::endl; } template<> @@ -963,12 +963,12 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr const size_t chunk = 100; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -981,7 +981,7 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -999,7 +999,7 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr if (uc != nullptr){ - const pair, pair> p = new_ds.insert(*it_unitig); + const std::pair, std::pair> p = new_ds.insert(*it_unitig); *(it_unitig->getData()) = p.first; *(p.second.first) = std::move(*uc); @@ -1014,7 +1014,7 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr *ds = std::move(new_ds); - //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << endl; + //cout << "Number of unitigs not hashed is " << ds->overflow.size() << " on " << ds->nb_cs << " unitigs." << std::endl; } template @@ -1037,7 +1037,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ bool next_file = true; - string s; + std::string s; FileParser fp(ds->color_names); @@ -1061,7 +1061,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ for (size_t i = 0; i < len - k_ + 1; i += max_len_seq - k_ + 1){ - const int curr_len = min(len - i, max_len_seq); + const int curr_len = std::min(len - i, max_len_seq); const char saved_char = str[i + curr_len]; const char* str_tmp = &str[i]; @@ -1170,9 +1170,9 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ { bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; size_t prev_uc_sz = getCurrentRSS(); @@ -1194,7 +1194,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) { @@ -1229,7 +1229,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -1242,7 +1242,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -1283,7 +1283,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ mutex mutex_u_map; - vector workers; + std::vector workers; auto add_hash_function = [&](typename ColoredCDBG::iterator it_a, typename ColoredCDBG::iterator it_b) { @@ -1296,7 +1296,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ if (uc_full_array[0].size() != 0){ - const pair pv(0 - static_cast(uc_full_array[0].getSizeInBytes()) - static_cast(sizeof(size_t)), 0); + const std::pair pv(0 - static_cast(uc_full_array[0].getSizeInBytes()) - static_cast(sizeof(size_t)), 0); const int64_t to_add = static_cast(uc->getSizeInBytes()); const int64_t to_rm = (static_cast(uc_full_array[1].getSizeInBytes() + 2 * sizeof(UnitigColors))); @@ -1339,7 +1339,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ if (ds->shared_color_sets[id_shared].second == 0){ - ds->shared_color_sets[id_shared].first = move(uc_full_array[0]); + ds->shared_color_sets[id_shared].first = std::move(uc_full_array[0]); ds->shared_color_sets[id_shared].second = 0; uc_full_array[0] = ds->shared_color_sets[id_shared]; @@ -1353,7 +1353,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ cs_locks[id_lock].clear(std::memory_order_release); - if (move_full) *uc = move(uc_full); + if (move_full) *uc = std::move(uc_full); } } @@ -1367,7 +1367,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -1380,7 +1380,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -1420,7 +1420,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ typename ColoredCDBG::iterator g_a = this->begin(); typename ColoredCDBG::iterator g_b = this->end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -1433,7 +1433,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -1460,65 +1460,65 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ } template -string ColoredCDBG::getColorName(const size_t color_id) const { +std::string ColoredCDBG::getColorName(const size_t color_id) const { if (invalid){ - cerr << "ColoredCDBG::getColorName(): Graph is invalid or colors are not yet mapped to unitigs." << endl; - return string(); + std::cerr << "ColoredCDBG::getColorName(): Graph is invalid or colors are not yet mapped to unitigs." << std::endl; + return std::string(); } const DataStorage* ds = this->getData(); if (color_id >= ds->color_names.size()){ - cerr << "ColoredCDBG::getColorName(): Color ID " << color_id << " is invalid, graph only has " << - ds->color_names.size() << " colors." << endl; + std::cerr << "ColoredCDBG::getColorName(): Color ID " << color_id << " is invalid, graph only has " << + ds->color_names.size() << " colors." << std::endl; - return string(); + return std::string(); } return ds->color_names[color_id]; } template -vector ColoredCDBG::getColorNames() const { +std::vector ColoredCDBG::getColorNames() const { if (invalid){ - cerr << "ColoredCDBG::getColorNames(): Graph is invalid or colors are not yet mapped to unitigs." << endl; - return vector(); + std::cerr << "ColoredCDBG::getColorNames(): Graph is invalid or colors are not yet mapped to unitigs." << std::endl; + return std::vector(); } return this->getData()->color_names; } template -bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, +bool ColoredCDBG::searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { - const string out_tmp = out_filename_prefix + ".tsv"; + const std::string out_tmp = out_filename_prefix + ".tsv"; { FILE* fp_tmp = fopen(out_tmp.c_str(), "w"); if (fp_tmp == NULL) { - cerr << "ColoredCDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << std::endl; return false; } else { fclose(fp_tmp); - if (std::remove(out_tmp.c_str()) != 0) cerr << "ColoredCDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << endl; + if (std::remove(out_tmp.c_str()) != 0) std::cerr << "ColoredCDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << std::endl; } } - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(out_tmp.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1531,31 +1531,31 @@ bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, c } template -bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, +bool ColoredCDBG::searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const size_t nb_min_colors, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { - const string out_tmp = out_filename_prefix + ".tsv"; + const std::string out_tmp = out_filename_prefix + ".tsv"; { FILE* fp_tmp = fopen(out_tmp.c_str(), "w"); if (fp_tmp == NULL) { - cerr << "ColoredCDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << std::endl; return false; } else { fclose(fp_tmp); - if (std::remove(out_tmp.c_str()) != 0) cerr << "ColoredCDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << endl; + if (std::remove(out_tmp.c_str()) != 0) std::cerr << "ColoredCDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << std::endl; } } - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(out_tmp.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1568,31 +1568,31 @@ bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, c } template -bool ColoredCDBG::search(const vector& query_filenames, const string& out_filename_prefix, +bool ColoredCDBG::search(const std::vector& query_filenames, const std::string& out_filename_prefix, const bool found_km_ratio_out, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { - const string out_tmp = out_filename_prefix + ".tsv"; + const std::string out_tmp = out_filename_prefix + ".tsv"; { FILE* fp_tmp = fopen(out_tmp.c_str(), "w"); if (fp_tmp == NULL) { - cerr << "ColoredCDBG::search(): Could not open file " << out_tmp << " for writing." << endl; + std::cerr << "ColoredCDBG::search(): Could not open file " << out_tmp << " for writing." << std::endl; return false; } else { fclose(fp_tmp); - if (std::remove(out_tmp.c_str()) != 0) cerr << "ColoredCDBG::search(): Could not remove temporary file " << out_tmp << endl; + if (std::remove(out_tmp.c_str()) != 0) std::cerr << "ColoredCDBG::search(): Could not remove temporary file " << out_tmp << std::endl; } } - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(out_tmp.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1605,7 +1605,7 @@ bool ColoredCDBG::search(const vector& query_filenames, const string& } template -bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, ostream& out, +bool ColoredCDBG::searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { @@ -1615,14 +1615,14 @@ bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, o } template -bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, ostream& out, +bool ColoredCDBG::searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const size_t min_nb_colors, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { if (min_nb_colors == 0) { - cerr << "ColoredCDBG::searchMinRatioKmer(): Minimum number of required colors is 0." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Minimum number of required colors is 0." << std::endl; return false; } @@ -1631,54 +1631,54 @@ bool ColoredCDBG::searchMinRatioKmer(const vector& query_filenames, o } template -bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filenames, ostream& out, +bool ColoredCDBG::searchMinRatioKmer_( const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const size_t min_nb_colors, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { if (invalid){ - cerr << "ColoredCDBG::searchMinRatioKmer(): Graph is invalid and cannot be searched" << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Graph is invalid and cannot be searched" << std::endl; return false; } if (nb_threads > std::thread::hardware_concurrency()){ - cerr << "ColoredCDBG::searchMinRatioKmer(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << std::endl; return false; } if (nb_threads <= 0){ - cerr << "ColoredCDBG::searchMinRatioKmer(): Number of threads cannot be less than or equal to 0." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Number of threads cannot be less than or equal to 0." << std::endl; return false; } if (min_ratio_kmers <= 0.0){ - cerr << "ColoredCDBG::searchMinRatioKmer(): Ratio of k-mers is less than or equal to 0.0." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Ratio of k-mers is less than or equal to 0.0." << std::endl; return false; } if (min_ratio_kmers > 1.0){ - cerr << "ColoredCDBG::searchMinRatioKmer(): Ratio of k-mers is greater than 1.0." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Ratio of k-mers is greater than 1.0." << std::endl; return false; } if (min_nb_colors > getNbColors()) { - cerr << "ColoredCDBG::searchMinRatioKmer(): Minimum number of required colors is larger than total number of colors in graph." << endl; + std::cerr << "ColoredCDBG::searchMinRatioKmer(): Minimum number of required colors is larger than total number of colors in graph." << std::endl; return false; } if (out.fail()) { - cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to." << std::endl; return false; } - if (verbose) cout << "ColoredCDBG::searchMinRatioKmer(): Querying graph." << endl; + if (verbose) std::cout << "ColoredCDBG::searchMinRatioKmer(): Querying graph." << std::endl; const size_t k = this->getK(); const size_t thread_seq_buf_sz = BUFFER_SIZE; @@ -1694,7 +1694,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename const size_t nb_colors = getNbColors(); const size_t sz_binary_color_query_out = nb_colors * l_query_res + 1; - string s; + std::string s; bool write_success = true; bool query_success = true; @@ -1702,19 +1702,19 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename size_t file_id = 0; size_t prev_file_id = 0xffffffffffffffffULL; - auto processCounts = [&](const vector>>& v_um, Roaring* color_occ_r, uint32_t* color_occ_u){ + auto processCounts = [&](const std::vector>>& v_um, Roaring* color_occ_r, uint32_t* color_occ_u){ struct hash_pair { - size_t operator() (const pair>& p) const { + size_t operator() (const std::pair>& p) const { - return wyhash(&p, sizeof(pair>), 0, _wyp); + return wyhash(&p, sizeof(std::pair>), 0, _wyp); } }; - unordered_set>, hash_pair> s_um; + std::unordered_set>, hash_pair> s_um; - typename unordered_set>, hash_pair>::const_iterator it; + typename std::unordered_set>, hash_pair>::const_iterator it; for (const auto& p : v_um){ @@ -1821,9 +1821,9 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename } }; - auto searchQuery = [&](const string& query, Roaring* color_occ_r, uint32_t* color_occ_u, const size_t nb_km_min){ + auto searchQuery = [&](const std::string& query, Roaring* color_occ_r, uint32_t* color_occ_u, const size_t nb_km_min){ - const vector>> v_um_e = this->searchSequence(query, true, false, false, false, false); + const std::vector>> v_um_e = this->searchSequence(query, true, false, false, false, false); processCounts(v_um_e, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color @@ -1839,7 +1839,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename else if (!nb_color_found_filtering && (nb_color_pres == nb_colors)) return; } - const vector>> v_um_d = this->searchSequence(query, false, false, true, false, false); + const std::vector>> v_um_d = this->searchSequence(query, false, false, true, false, false); processCounts(v_um_d, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color @@ -1853,7 +1853,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename else if (!nb_color_found_filtering && (nb_color_pres == nb_colors)) return; } - const vector>> v_um_m = this->searchSequence(query, false, false, false, true, false); + const std::vector>> v_um_m = this->searchSequence(query, false, false, false, true, false); processCounts(v_um_m, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color @@ -1867,14 +1867,14 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename else if (!nb_color_found_filtering && (nb_color_pres == nb_colors)) return; } - const vector>> v_um_i = this->searchSequence(query, false, true, false, false, false); + const std::vector>> v_um_i = this->searchSequence(query, false, true, false, false, false); processCounts(v_um_i, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color } }; auto writeBinaryOutput = [&]( const char* query_name, const size_t len_query_name, const uint32_t* color_occ, - char* buffer_res, size_t& pos_buffer_out, const size_t nb_km_min, mutex& mtx){ + char* buffer_res, size_t& pos_buffer_out, const size_t nb_km_min, std::mutex& mtx){ bool is_found = false; @@ -1888,7 +1888,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if ((pos_buffer_out + len_query_name + l_query_res + 1) > thread_seq_buf_sz){ - unique_lock lock(mtx); + std::unique_lock lock(mtx); if (pos_buffer_out > 0) { @@ -1911,7 +1911,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if ((pos_buffer_out + len_query_name + sz_binary_color_query_out) > thread_seq_buf_sz){ - unique_lock lock(mtx); + std::unique_lock lock(mtx); if (pos_buffer_out > 0) { @@ -1972,7 +1972,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (nb_color_found_filtering) out << "\tpresence_query\n"; else { - const vector color_names = getColorNames(); + const std::vector color_names = getColorNames(); for (const auto& name : color_names) out << '\t' << name; @@ -1997,7 +1997,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename Roaring* color_occ_r = inexact_search ? new Roaring[nb_colors] : nullptr; - mutex mtx_file_out; // Dummy + std::mutex mtx_file_out; // Dummy size_t pos_buffer_out = 0; size_t nb_queries_found = 0; @@ -2009,7 +2009,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename // Write previous results if there are any { - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); if (files_as_queries) { @@ -2058,7 +2058,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename for (auto& c : s) c &= 0xDF; if (files_as_queries) searchQuery(s, color_occ_r, color_occ_u, s.length() - k + 1); - else searchQuery(s, color_occ_r, color_occ_u, max(static_cast(1), static_cast(round(static_cast(s.length() - k + 1) * min_ratio_kmers)))); + else searchQuery(s, color_occ_r, color_occ_u, std::max(static_cast(1), static_cast(round(static_cast(s.length() - k + 1) * min_ratio_kmers)))); prev_file_id = file_id; } @@ -2066,7 +2066,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename // Flush rest of buffer result to final output if (write_success && (prev_file_id != 0xffffffffffffffffULL)) { - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); if (files_as_queries) { @@ -2089,8 +2089,8 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (write_success && verbose) { - cout << "ColoredCDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries." << endl; - cout << "ColoredCDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries in at least " << ((min_nb_colors == 0) ? 1 : min_nb_colors) << " color(s)." << endl; + std::cout << "ColoredCDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries." << std::endl; + std::cout << "ColoredCDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries in at least " << ((min_nb_colors == 0) ? 1 : min_nb_colors) << " color(s)." << std::endl; } } else { @@ -2107,14 +2107,14 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them std::atomic nb_queries_found; std::atomic nb_queries_processed; - mutex mtx_files_in, mtx_file_out, mtx_file_id; + std::mutex mtx_files_in, mtx_file_out, mtx_file_id; - unordered_map um_file_id; + std::unordered_map um_file_id; nb_queries_found = 0; nb_queries_processed = 0; @@ -2131,16 +2131,16 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename uint32_t* color_occ_u = new uint32_t[nb_colors](); Roaring* color_occ_r = inexact_search ? new Roaring[nb_colors] : nullptr; - vector buffer_seq; - vector buffer_name; - vector buffer_file_id; + std::vector buffer_seq; + std::vector buffer_name; + std::vector buffer_file_id; while (true) { { size_t buffer_sz = 0; - unique_lock lock(mtx_files_in); + std::unique_lock lock(mtx_files_in); if (stop) break; // Exit loop @@ -2152,19 +2152,19 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename buffer_sz += s.length(); - buffer_seq.push_back(move(s)); + buffer_seq.push_back(std::move(s)); if (files_as_queries) buffer_file_id.push_back(file_id); - else buffer_name.push_back(string(fp.getNameString())); + else buffer_name.push_back(std::string(fp.getNameString())); } else break; } if (files_as_queries) { - unique_lock lock(mtx_file_id); + std::unique_lock lock(mtx_file_id); - pair::iterator, bool> p_it_um_file_id; + std::pair::iterator, bool> p_it_um_file_id; size_t prev_file_id_local = 0xffffffffffffffffULL; @@ -2172,7 +2172,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (file_id_local != prev_file_id_local) { - p_it_um_file_id = um_file_id.insert(pair(file_id_local, ResultFileQuery())); + p_it_um_file_id = um_file_id.insert(std::pair(file_id_local, ResultFileQuery())); prev_file_id_local = file_id_local; if (p_it_um_file_id.first->second.color_occ == nullptr) p_it_um_file_id.first->second.color_occ = new uint32_t[nb_colors](); @@ -2182,7 +2182,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if ((file_id_local != prev_file_id) && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -2197,7 +2197,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (query_success && stop && (prev_file_id != 0xffffffffffffffffULL)) { // This thread is the last one to read from input - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -2212,7 +2212,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename size_t l_nb_queries_found = 0; size_t l_nb_queries_processed = 0; - vector> v_rfq_out; + std::vector> v_rfq_out; for (size_t i = 0; i < buffer_seq.size(); ++i){ @@ -2225,9 +2225,9 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename searchQuery(buffer_seq[i], color_occ_r, color_occ_u, nb_km_query); { - unique_lock lock(mtx_file_id); + std::unique_lock lock(mtx_file_id); - typename unordered_map::iterator it_um_file_id = um_file_id.find(buffer_file_id[i]); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(buffer_file_id[i]); if (it_um_file_id == um_file_id.end()) { @@ -2245,7 +2245,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (rfq.is_read && (rfq.nb_queries == 0)) { // All records for this file have been 1/ read from input 2/ queried - v_rfq_out.push_back(pair(buffer_file_id[i], rfq)); // Makes a copy + v_rfq_out.push_back(std::pair(buffer_file_id[i], rfq)); // Makes a copy rfq.color_occ = nullptr; um_file_id.erase(it_um_file_id); } @@ -2254,7 +2254,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename } else { - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(std::round(static_cast(nb_km_query) * min_ratio_kmers))); searchQuery(buffer_seq[i], color_occ_r, color_occ_u, nb_km_min); @@ -2279,8 +2279,8 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename for (const auto& p : v_rfq_out) { const ResultFileQuery& rfq = p.second; - const string& q_name = query_filenames[p.first]; - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(rfq.nb_km_queries) * min_ratio_kmers))); + const std::string& q_name = query_filenames[p.first]; + const size_t nb_km_min = std::max(static_cast(1), static_cast(std::round(static_cast(rfq.nb_km_queries) * min_ratio_kmers))); const bool is_found = writeBinaryOutput(q_name.c_str(), q_name.length(), rfq.color_occ, buffer_res, pos_buffer_out, nb_km_min, mtx_file_out); delete[] rfq.color_occ; @@ -2304,7 +2304,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename // Flush rest of the thread buffer to output if (write_success && (pos_buffer_out > 0)) { - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); } @@ -2342,8 +2342,8 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename } else { - const string& q_name = query_filenames[p.first]; - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(rfq.nb_km_queries) * min_ratio_kmers))); + const std::string& q_name = query_filenames[p.first]; + const size_t nb_km_min = std::max(static_cast(1), static_cast(std::round(static_cast(rfq.nb_km_queries) * min_ratio_kmers))); const bool is_found = writeBinaryOutput(q_name.c_str(), q_name.length(), rfq.color_occ, buffer_res, pos_buffer_out, nb_km_min, mtx_file_out); delete[] rfq.color_occ; @@ -2356,7 +2356,7 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename // Flush rest of the thread buffer to output if (write_success && (pos_buffer_out > 0)) { - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); } @@ -2366,50 +2366,50 @@ bool ColoredCDBG::searchMinRatioKmer_( const vector& query_filename if (write_success && query_success && verbose) { - cout << "ColoredCDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries." << endl; - cout << "ColoredCDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries in at least " << ((min_nb_colors == 0) ? 1 : min_nb_colors) << " color(s)." << endl; + std::cout << "ColoredCDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries." << std::endl; + std::cout << "ColoredCDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries in at least " << ((min_nb_colors == 0) ? 1 : min_nb_colors) << " color(s)." << std::endl; } } fp.close(); } - if (!query_success) cerr << "ColoredCDBG::searchMinRatioKmer(): Unexpected error encountered. Please file an issue. Operation aborted." << endl; - if (!write_success) cerr << "ColoredCDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to. Operation aborted." << endl; + if (!query_success) std::cerr << "ColoredCDBG::searchMinRatioKmer(): Unexpected error encountered. Please file an issue. Operation aborted." << std::endl; + if (!write_success) std::cerr << "ColoredCDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to. Operation aborted." << std::endl; return write_success && query_success; } template -bool ColoredCDBG::search(const vector& query_filenames, ostream& out, +bool ColoredCDBG::search(const std::vector& query_filenames, std::ostream& out, const bool found_km_ratio_out, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { if (invalid){ - cerr << "ColoredCDBG::search(): Graph is invalid and cannot be searched" << endl; + std::cerr << "ColoredCDBG::search(): Graph is invalid and cannot be searched" << std::endl; return false; } if (nb_threads > std::thread::hardware_concurrency()){ - cerr << "ColoredCDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << endl; + std::cerr << "ColoredCDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << std::endl; return false; } if (nb_threads <= 0){ - cerr << "ColoredCDBG::search(): Number of threads cannot be less than or equal to 0." << endl; + std::cerr << "ColoredCDBG::search(): Number of threads cannot be less than or equal to 0." << std::endl; return false; } if (out.fail()) { - cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to." << endl; + std::cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to." << std::endl; return false; } - if (verbose) cout << "ColoredCDBG::search(): Querying graph." << endl; + if (verbose) std::cout << "ColoredCDBG::search(): Querying graph." << std::endl; const size_t k = this->getK(); const size_t thread_seq_buf_sz = BUFFER_SIZE; @@ -2417,7 +2417,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, const char eol = '\n'; - string s; + std::string s; bool write_success = true; bool query_success = true; @@ -2425,19 +2425,19 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, size_t file_id = 0; size_t prev_file_id = 0xffffffffffffffffULL; - auto processCounts = [&](const vector>>& v_um, Roaring* color_occ_r, uint32_t* color_occ_u){ + auto processCounts = [&](const std::vector>>& v_um, Roaring* color_occ_r, uint32_t* color_occ_u){ struct hash_pair { - size_t operator() (const pair>& p) const { + size_t operator() (const std::pair>& p) const { - return wyhash(&p, sizeof(pair>), 0, _wyp); + return wyhash(&p, sizeof(std::pair>), 0, _wyp); } }; - unordered_set>, hash_pair> s_um; + std::unordered_set>, hash_pair> s_um; - typename unordered_set>, hash_pair>::const_iterator it; + typename std::unordered_set>, hash_pair>::const_iterator it; for (const auto& p : v_um){ @@ -2544,46 +2544,46 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, } }; - auto searchQuery = [&](const string& query, Roaring* color_occ_r, uint32_t* color_occ_u, const size_t nb_km_min){ + auto searchQuery = [&](const std::string& query, Roaring* color_occ_r, uint32_t* color_occ_u, const size_t nb_km_min){ - const vector>> v_um_e = this->searchSequence(query, true, false, false, false, false); + const std::vector>> v_um_e = this->searchSequence(query, true, false, false, false, false); processCounts(v_um_e, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color if (inexact_search){ - const vector>> v_um_d = this->searchSequence(query, false, false, true, false, false); + const std::vector>> v_um_d = this->searchSequence(query, false, false, true, false, false); processCounts(v_um_d, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color - const vector>> v_um_m = this->searchSequence(query, false, false, false, true, false); + const std::vector>> v_um_m = this->searchSequence(query, false, false, false, true, false); processCounts(v_um_m, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color - const vector>> v_um_i = this->searchSequence(query, false, true, false, false, false); + const std::vector>> v_um_i = this->searchSequence(query, false, true, false, false, false); processCounts(v_um_i, color_occ_r, color_occ_u); // Extract k-mer occurrences for each color } }; auto writeQuantifiedOutput = [&]( const char* query_name, const size_t len_query_name, const size_t nb_km_query, - const uint32_t* color_occ, char* buffer_res, size_t& pos_buffer_out, mutex& mtx){ + const uint32_t* color_occ, char* buffer_res, size_t& pos_buffer_out, std::mutex& mtx){ - string color_query_out = ""; + std::string color_query_out = ""; for (size_t i = 0; i < nb_colors; ++i) { color_query_out += '\t'; - if (!found_km_ratio_out) color_query_out += to_string(color_occ[i]); - else color_query_out += to_string(static_cast(color_occ[i]) / static_cast(nb_km_query)); + if (!found_km_ratio_out) color_query_out += std::to_string(color_occ[i]); + else color_query_out += std::to_string(static_cast(color_occ[i]) / static_cast(nb_km_query)); } const size_t l_color_query_out = color_query_out.length(); if ((pos_buffer_out + len_query_name + l_color_query_out + 1) > thread_seq_buf_sz){ - unique_lock lock(mtx); + std::unique_lock lock(mtx); if (pos_buffer_out > 0) { @@ -2612,7 +2612,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, // Write header to TSV file if (write_success) { - const vector color_names = getColorNames(); + const std::vector color_names = getColorNames(); out << "query_name"; @@ -2638,7 +2638,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, Roaring* color_occ_r = inexact_search ? new Roaring[nb_colors] : nullptr; - mutex mtx_file_out; // Dummy + std::mutex mtx_file_out; // Dummy size_t pos_buffer_out = 0; size_t nb_queries_processed = 0; @@ -2721,7 +2721,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if (color_occ_r != nullptr) delete[] color_occ_r; if (color_occ_u_fid != nullptr) delete[] color_occ_u_fid; - if (write_success && verbose) cout << "ColoredCDBG::search(): Processed " << nb_queries_processed << " queries. " << endl; + if (write_success && verbose) std::cout << "ColoredCDBG::search(): Processed " << nb_queries_processed << " queries. " << std::endl; } else { @@ -2737,13 +2737,13 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them std::atomic nb_queries_processed; - mutex mtx_files_in, mtx_file_out, mtx_file_id; + std::mutex mtx_files_in, mtx_file_out, mtx_file_id; - unordered_map um_file_id; + std::unordered_map um_file_id; nb_queries_processed = 0; @@ -2759,16 +2759,16 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, uint32_t* color_occ_u = new uint32_t[nb_colors](); Roaring* color_occ_r = inexact_search ? new Roaring[nb_colors] : nullptr; - vector buffer_seq; - vector buffer_name; - vector buffer_file_id; + std::vector buffer_seq; + std::vector buffer_name; + std::vector buffer_file_id; while (true) { { size_t buffer_sz = 0; - unique_lock lock(mtx_files_in); + std::unique_lock lock(mtx_files_in); if (stop) break; // Exit loop @@ -2780,19 +2780,19 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, buffer_sz += s.length(); - buffer_seq.push_back(move(s)); + buffer_seq.push_back(std::move(s)); if (files_as_queries) buffer_file_id.push_back(file_id); - else buffer_name.push_back(string(fp.getNameString())); + else buffer_name.push_back(std::string(fp.getNameString())); } else break; } if (files_as_queries) { - unique_lock lock(mtx_file_id); + std::unique_lock lock(mtx_file_id); - pair::iterator, bool> p_it_um_file_id; + std::pair::iterator, bool> p_it_um_file_id; size_t prev_file_id_local = 0xffffffffffffffffULL; @@ -2800,7 +2800,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if (file_id_local != prev_file_id_local) { - p_it_um_file_id = um_file_id.insert(pair(file_id_local, ResultFileQuery())); + p_it_um_file_id = um_file_id.insert(std::pair(file_id_local, ResultFileQuery())); prev_file_id_local = file_id_local; if (p_it_um_file_id.first->second.color_occ == nullptr) p_it_um_file_id.first->second.color_occ = new uint32_t[nb_colors](); @@ -2810,7 +2810,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if ((file_id_local != prev_file_id) && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -2825,7 +2825,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if (query_success && stop && (prev_file_id != 0xffffffffffffffffULL)) { // This thread is the last one to read from input - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -2840,7 +2840,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, size_t l_nb_queries_found = 0; size_t l_nb_queries_processed = 0; - vector> v_rfq_out; + std::vector> v_rfq_out; for (size_t i = 0; i < buffer_seq.size(); ++i) { @@ -2852,9 +2852,9 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if (files_as_queries) { - unique_lock lock(mtx_file_id); + std::unique_lock lock(mtx_file_id); - typename unordered_map::iterator it_um_file_id = um_file_id.find(buffer_file_id[i]); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(buffer_file_id[i]); if (it_um_file_id == um_file_id.end()) { @@ -2872,7 +2872,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, if (rfq.is_read && (rfq.nb_queries == 0)) { // All records for this file have been 1/ read from input 2/ queried - v_rfq_out.push_back(pair(buffer_file_id[i], rfq)); // Makes a copy + v_rfq_out.push_back(std::pair(buffer_file_id[i], rfq)); // Makes a copy rfq.color_occ = nullptr; um_file_id.erase(it_um_file_id); } @@ -2900,7 +2900,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, for (const auto& p : v_rfq_out) { const ResultFileQuery& rfq = p.second; - const string& q_name = query_filenames[p.first]; + const std::string& q_name = query_filenames[p.first]; writeQuantifiedOutput(q_name.c_str(), q_name.length(), rfq.nb_km_queries, rfq.color_occ, buffer_res, pos_buffer_out, mtx_file_out); @@ -2923,7 +2923,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, // Flush rest of the thread buffer to output if (write_success && (pos_buffer_out > 0)) { - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); } @@ -2961,7 +2961,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, } else { - const string& q_name = query_filenames[p.first]; + const std::string& q_name = query_filenames[p.first]; writeQuantifiedOutput(q_name.c_str(), q_name.length(), rfq.nb_km_queries, rfq.color_occ, buffer_res, pos_buffer_out, mtx_file_out); @@ -2974,7 +2974,7 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, // Flush rest of the thread buffer to output if (write_success && (pos_buffer_out > 0)) { - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); } @@ -2982,26 +2982,26 @@ bool ColoredCDBG::search(const vector& query_filenames, ostream& out, delete[] buffer_res; } - if (write_success && query_success && verbose) cout << "ColoredCDBG::search(): Processed " << nb_queries_processed << " queries. " << endl; + if (write_success && query_success && verbose) std::cout << "ColoredCDBG::search(): Processed " << nb_queries_processed << " queries. " << std::endl; } fp.close(); } - if (!query_success) cerr << "ColoredCDBG::search(): Unexpected error encountered. Please file an issue. Operation aborted." << endl; - if (!write_success) cerr << "ColoredCDBG::search(): Output stream is in a failed state and cannot be written to. Operation aborted." << endl; + if (!query_success) std::cerr << "ColoredCDBG::search(): Unexpected error encountered. Please file an issue. Operation aborted." << std::endl; + if (!write_success) std::cerr << "ColoredCDBG::search(): Output stream is in a failed state and cannot be written to. Operation aborted." << std::endl; return write_success && query_success; } template -void ColoredCDBG::checkColors(const vector& filename_seq_in) const { +void ColoredCDBG::checkColors(const std::vector& filename_seq_in) const { - cout << "ColoredCDBG::checkColors(): Start" << endl; + std::cout << "ColoredCDBG::checkColors(): Start" << std::endl; size_t file_id = 0; - string s; + std::string s; KmerHashTable> km_h; @@ -3011,7 +3011,7 @@ void ColoredCDBG::checkColors(const vector& filename_seq_in) const { for (KmerIterator it_km(s.c_str()), it_km_end; it_km != it_km_end; ++it_km) { - pair>::iterator, bool> it = km_h.insert(it_km->first.rep(), tiny_vector()); + std::pair>::iterator, bool> it = km_h.insert(it_km->first.rep(), tiny_vector()); tiny_vector& tv = *(it.first); @@ -3025,7 +3025,7 @@ void ColoredCDBG::checkColors(const vector& filename_seq_in) const { FQ.close(); - cout << "ColoredCDBG::checkColors(): All k-mers in the hash table with their colors" << endl; + std::cout << "ColoredCDBG::checkColors(): All k-mers in the hash table with their colors" << std::endl; for (typename KmerHashTable>::const_iterator it_km = km_h.begin(), it_km_end = km_h.end(); it_km != it_km_end; ++it_km){ @@ -3034,7 +3034,7 @@ void ColoredCDBG::checkColors(const vector& filename_seq_in) const { if (ucm.isEmpty){ - cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " is not found in the graph" << endl; + std::cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " is not found in the graph" << std::endl; exit(1); } @@ -3042,7 +3042,7 @@ void ColoredCDBG::checkColors(const vector& filename_seq_in) const { if (cs == nullptr){ - cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " has no color set associated" << endl; + std::cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " has no color set associated" << std::endl; exit(1); } @@ -3056,21 +3056,21 @@ void ColoredCDBG::checkColors(const vector& filename_seq_in) const { if (color_pres_graph != color_pres_hasht){ - cerr << "ColoredCDBG::checkColors(): Current color is " << i << ": " << filename_seq_in[i] << endl; - cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " for color " << i << ": " << filename_seq_in[i] << endl; - cerr << "ColoredCDBG::checkColors(): Size unitig: " << ucm.size << endl; - cerr << "ColoredCDBG::checkColors(): Mapping position: " << ucm.dist << endl; - cerr << "ColoredCDBG::checkColors(): Mapping strand: " << ucm.strand << endl; - cerr << "ColoredCDBG::checkColors(): Present in graph: " << color_pres_graph << endl; - cerr << "ColoredCDBG::checkColors(): Present in hash table: " << color_pres_hasht << endl; + std::cerr << "ColoredCDBG::checkColors(): Current color is " << i << ": " << filename_seq_in[i] << std::endl; + std::cerr << "ColoredCDBG::checkColors(): K-mer " << km.toString() << " for color " << i << ": " << filename_seq_in[i] << std::endl; + std::cerr << "ColoredCDBG::checkColors(): Size unitig: " << ucm.size << std::endl; + std::cerr << "ColoredCDBG::checkColors(): Mapping position: " << ucm.dist << std::endl; + std::cerr << "ColoredCDBG::checkColors(): Mapping strand: " << ucm.strand << std::endl; + std::cerr << "ColoredCDBG::checkColors(): Present in graph: " << color_pres_graph << std::endl; + std::cerr << "ColoredCDBG::checkColors(): Present in hash table: " << color_pres_hasht << std::endl; exit(1); } } } - cout << "ColoredCDBG::checkColors(): Checked all colors of all k-mers: everything is fine" << endl; - cout << "ColoredCDBG::checkColors(): Number of k-mers in the graph: " << km_h.size() << endl; + std::cout << "ColoredCDBG::checkColors(): Checked all colors of all k-mers: everything is fine" << std::endl; + std::cout << "ColoredCDBG::checkColors(): Number of k-mers in the graph: " << km_h.size() << std::endl; } #endif diff --git a/src/Common.hpp b/src/Common.hpp index 5d796ee..e467da3 100755 --- a/src/Common.hpp +++ b/src/Common.hpp @@ -39,8 +39,6 @@ #define BFG_METABIN_FORMAT_HEADER 0x267c3d5d #define BFG_GRAPHBIN_FORMAT_HEADER 0x7e215f3f -using namespace std; - static const char alpha[4] = {'A','C','G','T'}; BFG_INLINE bool isDNA(const char c) { @@ -101,11 +99,11 @@ BFG_INLINE char reverse_complement(const char nuc){ } } -BFG_INLINE string reverse_complement(const string& s){ +BFG_INLINE std::string reverse_complement(const std::string& s){ - string seq(s); + std::string seq(s); - reverse(seq.begin(), seq.end()); + std::reverse(seq.begin(), seq.end()); for (size_t i = 0; i < seq.length(); ++i){ @@ -141,11 +139,11 @@ BFG_INLINE string reverse_complement(const string& s){ return seq; } -BFG_INLINE string reverse_complement(const char* s){ +BFG_INLINE std::string reverse_complement(const char* s){ - string seq(s); + std::string seq(s); - reverse(seq.begin(), seq.end()); + std::reverse(seq.begin(), seq.end()); for (size_t i = 0; i < seq.length(); ++i){ @@ -220,24 +218,24 @@ BFG_INLINE uint16_t rndup(uint16_t v) { return v; } -BFG_INLINE bool check_file_exists(const string& filename) { +BFG_INLINE bool check_file_exists(const std::string& filename) { struct stat stFileInfo; return (stat(filename.c_str(), &stFileInfo) == 0); } -BFG_INLINE bool check_dir_writable(const string& path) { +BFG_INLINE bool check_dir_writable(const std::string& path) { return (access(path.c_str(), W_OK) == 0); } -BFG_INLINE bool check_dir_readable(const string& path) { +BFG_INLINE bool check_dir_readable(const std::string& path) { return (access(path.c_str(), R_OK) == 0); } -BFG_INLINE uint32_t crc32_checksum(istream& in) { +BFG_INLINE uint32_t crc32_checksum(std::istream& in) { unsigned char buffer[65536]; @@ -256,12 +254,12 @@ BFG_INLINE uint32_t crc32_checksum(istream& in) { return crc; } -BFG_INLINE uint32_t crc32_checksum(const string& fn) { +BFG_INLINE uint32_t crc32_checksum(const std::string& fn) { if ((fn.length() == 0) || !check_file_exists(fn)) return 0; - ifstream infile; - istream in(0); + std::ifstream infile; + std::istream in(0); infile.open(fn.c_str()); in.rdbuf(infile.rdbuf()); diff --git a/src/CompactedDBG.hpp b/src/CompactedDBG.hpp index b6431df..a96458a 100755 --- a/src/CompactedDBG.hpp +++ b/src/CompactedDBG.hpp @@ -57,7 +57,6 @@ * Code snippets using this interface are provided in snippets/test.cpp. */ -using namespace std; /** @struct CDBG_Build_opt * @brief Most members of this structure are parameters for CompactedDBG::build(), except for: @@ -133,11 +132,11 @@ struct CDBG_Build_opt { size_t nb_bits_kmers_bf; - string inFilenameBBF; - string outFilenameBBF; + std::string inFilenameBBF; + std::string outFilenameBBF; - vector filename_seq_in; - vector filename_ref_in; + std::vector filename_seq_in; + std::vector filename_ref_in; // The following members are NOT used by CompactedDBG::build // but you can set them to use them as parameters for other functions @@ -168,13 +167,13 @@ struct CDBG_Build_opt { double min_ratio_kmers_search; // Ratio of k-mers shared between query and graph to report the query as "present" - string prefixTmp; // Prefix of the tmp directory used by Bifrost - string prefixFilenameOut; // Prefix of the output filename(s) + std::string prefixTmp; // Prefix of the tmp directory used by Bifrost + std::string prefixFilenameOut; // Prefix of the output filename(s) - string filename_graph_in; // Filename of the input graph - string filename_index_in; // Filename of the input graph index + std::string filename_graph_in; // Filename of the input graph + std::string filename_index_in; // Filename of the input graph index - vector filename_query_in; // Query filenames + std::vector filename_query_in; // Query filenames CDBG_Build_opt() : nb_threads(1), k(DEFAULT_K), g(-1), nb_bits_kmers_bf(24), min_count_km(1), build(false), update(false), query(false), clipTips(false), deleteIsolated(false), @@ -282,9 +281,9 @@ class CDBG_Data_t { * associated. * @return a string which is the serialization of the data. */ - string serialize(const const_UnitigMap& um_src) const { + std::string serialize(const const_UnitigMap& um_src) const { - return string(); + return std::string(); } }; @@ -315,7 +314,7 @@ class CDBG_Data_t { template class CompactedDBG { - static_assert(is_void::value || is_base_of, Unitig_data_t>::value, + static_assert(std::is_void::value || std::is_base_of, Unitig_data_t>::value, "Type of data associated with vertices of class CompactedDBG must be void (no data) or a class extending class CDBG_Data_t"); typedef Unitig_data_t U; @@ -427,7 +426,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the function execution. * @return boolean indicating whether the graph has been written successfully. */ - bool write( const string& output_fn, const size_t nb_threads = 1, const bool GFA_output = true, const bool FASTA_output = false, + bool write( const std::string& output_fn, const size_t nb_threads = 1, const bool GFA_output = true, const bool FASTA_output = false, const bool BFG_output = false, const bool write_index_file = true, const bool compressed_output = false, const bool verbose = false) const; @@ -442,7 +441,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the function execution. * @return boolean indicating whether the graph has been read successfully. */ - bool read(const string& input_graph_fn, const size_t nb_threads = 1, const bool verbose = false); + bool read(const std::string& input_graph_fn, const size_t nb_threads = 1, const bool verbose = false); /** Read a Compacted de Bruijn graph from disk (GFA1, FASTA or BFG format) using an index file (BFI format). * Index files make the loading much faster than the other function read() without meta graph file. @@ -455,7 +454,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the function execution. * @return boolean indicating whether the graph has been read successfully. */ - bool read(const string& input_graph_fn, const string& input_index_fn, const size_t nb_threads = 1, const bool verbose = false); + bool read(const std::string& input_graph_fn, const std::string& input_index_fn, const size_t nb_threads = 1, const bool verbose = false); /** Find the unitig containing the queried k-mer in the Compacted de Bruijn graph. * @param km is the queried k-mer (see Kmer class). It does not need to be a canonical k-mer. @@ -507,7 +506,7 @@ class CompactedDBG { * and the corresponding k-mer match in the graph. Note that no information is given on whether the match is exact or inexact, nor on what edit * operation makes the match to be inexact or at what position the edit operation takes place. */ - vector>> searchSequence( const string& s, const bool exact, const bool insertion, const bool deletion, + std::vector>> searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match = false); /** Performs exact and/or inexact search of the k-mers of a sequence query in the Compacted de Bruijn graph. @@ -522,7 +521,7 @@ class CompactedDBG { * and the corresponding k-mer match in the graph. Note that no information is given on whether the match is exact or inexact, nor on what edit * operation makes the match to be inexact or at what position the edit operation takes place. */ - vector>> searchSequence( const string& s, const bool exact, const bool insertion, const bool deletion, + std::vector>> searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match = false) const; /** @@ -540,7 +539,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, const double min_ratio_kmers, + bool searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const size_t verbose = false) const; @@ -560,7 +559,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool searchMinRatioKmer(const vector& query_filenames, ostream& out, const double min_ratio_kmers, + bool searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const size_t verbose = false) const; @@ -579,7 +578,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool search(const vector& query_filenames, const string& out_filename_prefix, + bool search(const std::vector& query_filenames, const std::string& out_filename_prefix, const bool found_km_ratio_out = false, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -599,7 +598,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return Boolean indicating whether the querying completed successfully. */ - bool search(const vector& query_filenames, ostream& out, + bool search(const std::vector& query_filenames, std::ostream& out, const bool found_km_ratio_out = false, const bool inexact_search = false, const bool files_as_queries = false, const size_t nb_threads = 1, const bool verbose = false) const; @@ -610,7 +609,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the function execution. * @return a boolean indicating whether the sequence was successfully inserted in the graph. */ - bool add(const string& seq, const bool verbose = false); + bool add(const std::string& seq, const bool verbose = false); /** Remove a unitig from the Compacted de Bruijn graph. * @param um is a UnitigMap object containing the information of the unitig to remove from the graph. @@ -643,7 +642,7 @@ class CompactedDBG { * @param verbose is a boolean indicating whether information messages must be printed during the execution of the function. * @return a boolean indicating whether the graphs have been successfully merged. */ - bool merge(const vector& v, const size_t nb_threads = 1, const bool verbose = false); + bool merge(const std::vector& v, const size_t nb_threads = 1, const bool verbose = false); /** Create an iterator to the first unitig of the Compacted de Bruijn graph (unitigs are NOT sorted lexicographically). * @return an iterator to the first unitig of the graph. @@ -705,22 +704,22 @@ class CompactedDBG { */ inline const G* getData() const { return data.getData(); } - bool writeBinary(const string& fn, const size_t nb_threads = 1) const; - bool writeBinary(ostream& out, const size_t nb_threads = 1) const; + bool writeBinary(const std::string& fn, const size_t nb_threads = 1) const; + bool writeBinary(std::ostream& out, const size_t nb_threads = 1) const; - bool readBinary(const string& fn); - bool readBinary(istream& in); + bool readBinary(const std::string& fn); + bool readBinary(std::istream& in); protected: bool annotateSplitUnitigs(const CompactedDBG& o, const size_t nb_threads = 1, const bool verbose = false); - pair splitAllUnitigs(); - pair getSplitInfoAllUnitigs() const; + std::pair splitAllUnitigs(); + std::pair getSplitInfoAllUnitigs() const; - inline size_t joinUnitigs(vector* v_joins = nullptr, const size_t nb_threads = 1) { + inline size_t joinUnitigs(std::vector* v_joins = nullptr, const size_t nb_threads = 1) { - return joinUnitigs_::value>(v_joins, nb_threads); + return joinUnitigs_::value>(v_joins, nb_threads); } bool mergeData(const CompactedDBG& o, const size_t nb_threads = 1, const bool verbose = false); @@ -728,22 +727,22 @@ class CompactedDBG { private: - bool writeBinaryGraph(ostream& out, const size_t nb_threads = 1) const; - bool writeBinaryGraph(const string& fn, const size_t nb_threads = 1) const; + bool writeBinaryGraph(std::ostream& out, const size_t nb_threads = 1) const; + bool writeBinaryGraph(const std::string& fn, const size_t nb_threads = 1) const; - bool writeBinaryIndex(ostream& out, const uint64_t checksum, const size_t nb_threads = 1) const; - bool writeBinaryIndex(const string& fn, const uint64_t checksum, const size_t nb_threads = 1) const; + bool writeBinaryIndex(std::ostream& out, const uint64_t checksum, const size_t nb_threads = 1) const; + bool writeBinaryIndex(const std::string& fn, const uint64_t checksum, const size_t nb_threads = 1) const; - pair readBinaryGraph(istream& in); - pair readBinaryGraph(const string& fn); + std::pair readBinaryGraph(std::istream& in); + std::pair readBinaryGraph(const std::string& fn); - bool readBinaryIndex(istream& in, const uint64_t checksum); - bool readBinaryIndex(const string& fn, const uint64_t checksum); + bool readBinaryIndex(std::istream& in, const uint64_t checksum); + bool readBinaryIndex(const std::string& fn, const uint64_t checksum); - bool readBinaryIndexHead(const string& fn, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, + bool readBinaryIndexHead(const std::string& fn, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, size_t& h_kmers_ccov_sz, size_t& hmap_min_unitigs_sz, uint64_t& read_checksum) const; - bool readBinaryIndexHead(istream& in, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, + bool readBinaryIndexHead(std::istream& in, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, size_t& h_kmers_ccov_sz, size_t& hmap_min_unitigs_sz, uint64_t& read_checksum) const; uint64_t checksum() const; @@ -755,21 +754,20 @@ class CompactedDBG { bool construct(const CDBG_Build_opt& opt, DualBlockedBloomFilter& bf, Roaring& r, const size_t nb_unique_minimizers, const size_t nb_non_unique_minimizers, const size_t nb_unique_kmers, const size_t nb_non_unique_kmers); bool construct_dev(const CDBG_Build_opt& opt, DualBlockedBloomFilter& bf, Roaring& r, const size_t nb_unique_minimizers, const size_t nb_non_unique_minimizers, const size_t nb_unique_kmers, const size_t nb_non_unique_kmers); - void addUnitigSequence(const Kmer km, const string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g, const bool map_read = true); - void addUnitigSequence(const string& seq); + void addUnitigSequence(const Kmer km, const std::string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g, const bool map_read = true); + void addUnitigSequence(const std::string& seq); - size_t findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip); - size_t findUnitigSequenceBBF(const DualBlockedBloomFilter& bf, const Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip); - //size_t findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip, LockGraph& lck_g); + size_t findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, std::string& s, bool& isIsolated, std::vector& l_ignored_km_tip); + size_t findUnitigSequenceBBF(const DualBlockedBloomFilter& bf, const Kmer km, std::string& s, bool& isIsolated, std::vector& l_ignored_km_tip); + //size_t findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, std::string& s, bool& isIsolated, std::vector& l_ignored_km_tip, LockGraph& lck_g); - pair bwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand = true) const; - pair bwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand = true) const; + std::pair bwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand = true) const; + std::pair bwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand = true) const; - pair fwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand = true) const; - pair fwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand = true) const; + std::pair fwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand = true) const; + std::pair fwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand = true) const; inline size_t find(const preAllocMinHashIterator& it_min_h) const { - const int pos = it_min_h.getPosition(); return (hmap_min_unitigs.find(Minimizer(it_min_h.s + pos).rep()) != hmap_min_unitigs.end() ? 0 : pos - it_min_h.p); } @@ -779,11 +777,11 @@ class CompactedDBG { UnitigMap find(const Kmer& km, const preAllocMinHashIterator& it_min_h); - vector> findPredecessors(const Kmer& km, const bool extremities_only = false) const; - vector> findSuccessors(const Kmer& km, const size_t limit = 4, const bool extremities_only = false) const; + std::vector> findPredecessors(const Kmer& km, const bool extremities_only = false) const; + std::vector> findSuccessors(const Kmer& km, const size_t limit = 4, const bool extremities_only = false) const; - vector> findPredecessors(const Kmer& km, const bool extremities_only = false); - vector> findSuccessors(const Kmer& km, const size_t limit = 4, const bool extremities_only = false); + std::vector> findPredecessors(const Kmer& km, const bool extremities_only = false); + std::vector> findSuccessors(const Kmer& km, const size_t limit = 4, const bool extremities_only = false); UnitigMap findUnitig(const Kmer& km, const char* s, const size_t pos); UnitigMap findUnitig(const Kmer& km, const char* s, const size_t pos, const preAllocMinHashIterator& it_min_h); @@ -791,14 +789,14 @@ class CompactedDBG { UnitigMap findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min); const_UnitigMap findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min) const; - bool addUnitig(const string& str_unitig, const size_t id_unitig); - bool addUnitig(const string& str_unitig, const size_t id_unitig, const size_t id_unitig_r, const size_t is_short_r); - //bool addUnitig(const string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer/*, const bool enable_abundant = true*/); + bool addUnitig(const std::string& str_unitig, const size_t id_unitig); + bool addUnitig(const std::string& str_unitig, const size_t id_unitig, const size_t id_unitig_r, const size_t is_short_r); + //bool addUnitig(const std::string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer/*, const bool enable_abundant = true*/); void swapUnitigs(const bool isShort, const size_t id_a, const size_t id_b); - bool mergeUnitig(const string& seq, const bool verbose = false); - bool annotateSplitUnitig(const string& seq, const bool verbose = false); - bool annotateSplitUnitig(const string& seq, LockGraph& lck_g, const bool verbose = false); + bool mergeUnitig(const std::string& seq, const bool verbose = false); + bool annotateSplitUnitig(const std::string& seq, const bool verbose = false); + bool annotateSplitUnitig(const std::string& seq, LockGraph& lck_g, const bool verbose = false); template inline typename std::enable_if::type mergeData_(const UnitigMap& a, const const_UnitigMap& b){ @@ -817,45 +815,45 @@ class CompactedDBG { typename std::enable_if::type deleteUnitig_( const bool isShort, const bool isAbundant, const size_t id_unitig, const bool delete_data = true); - void deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const string& str); + void deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const std::string& str); template typename std::enable_if::type extractUnitig_(size_t& pos_v_unitigs, size_t& nxt_pos_insert_v_unitigs, - size_t& v_unitigs_sz, size_t& v_kmers_sz, const vector>& sp); + size_t& v_unitigs_sz, size_t& v_kmers_sz, const std::vector>& sp); template typename std::enable_if::type extractUnitig_(size_t& pos_v_unitigs, size_t& nxt_pos_insert_v_unitigs, - size_t& v_unitigs_sz, size_t& v_kmers_sz, const vector>& sp); + size_t& v_unitigs_sz, size_t& v_kmers_sz, const std::vector>& sp); - pair extractAllUnitigs(); + std::pair extractAllUnitigs(); template - typename std::enable_if::type joinUnitigs_(vector* v_joins = nullptr, const size_t nb_threads = 1); + typename std::enable_if::type joinUnitigs_(std::vector* v_joins = nullptr, const size_t nb_threads = 1); template - typename std::enable_if::type joinUnitigs_(vector* v_joins = nullptr, const size_t nb_threads = 1); + typename std::enable_if::type joinUnitigs_(std::vector* v_joins = nullptr, const size_t nb_threads = 1); void moveToAbundant(); void setFullCoverage(const size_t cov) const; - void createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const; - void createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const; + void createJoinHT(std::vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const; + void createJoinHT(std::vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const; bool checkJoin(const Kmer& a, const const_UnitigMap& cm_a, Kmer& b) const; //void check_fp_tips(KmerHashTable& ignored_km_tips, const size_t nb_threads = 1); void check_fp_tips(BlockedBloomFilter& bf, const size_t nb_threads = 1); - size_t removeUnitigs(bool rmIsolated, bool clipTips, vector& v); + size_t removeUnitigs(bool rmIsolated, bool clipTips, std::vector& v); - size_t joinTips(string filename_MBBF_uniq_kmers, const size_t nb_threads = 1, const bool verbose = false); - vector extractMercyKmers(const BlockedBloomFilter& bf_uniq_km, const size_t nb_threads = 1, const bool verbose = false); + size_t joinTips(std::string filename_MBBF_uniq_kmers, const size_t nb_threads = 1, const bool verbose = false); + std::vector extractMercyKmers(const BlockedBloomFilter& bf_uniq_km, const size_t nb_threads = 1, const bool verbose = false); - bool writeGFA(const string& fn, const size_t nb_threads = 1, const bool compressed_output = false) const; - bool writeFASTA(const string& fn, const bool compressed_output = false) const; + bool writeGFA(const std::string& fn, const size_t nb_threads = 1, const bool compressed_output = false) const; + bool writeFASTA(const std::string& fn, const bool compressed_output = false) const; - void makeGraphFromGFA(const string& fn, const size_t nb_threads = 1); - void makeGraphFromFASTA(const string& fn, const size_t nb_threads = 1); + void makeGraphFromGFA(const std::string& fn, const size_t nb_threads = 1); + void makeGraphFromFASTA(const std::string& fn, const size_t nb_threads = 1); - pair readGraphFromIndexGFA(const string& graph_fn, const string& index_fn, const size_t k, const size_t g); - pair readGraphFromIndexFASTA(const string& graph_fn, const string& index_fn, const size_t k, const size_t g); + std::pair readGraphFromIndexGFA(const std::string& graph_fn, const std::string& index_fn, const size_t k, const size_t g); + std::pair readGraphFromIndexFASTA(const std::string& graph_fn, const std::string& index_fn, const size_t k, const size_t g); template typename std::enable_if::type writeGFA_sequence_(GFA_Parser& graph, KmerHashTable& idmap) const; @@ -871,10 +869,10 @@ class CompactedDBG { void setKmerGmerLength(const int kmer_length, const int minimizer_length = -1); void print() const; - vector>> searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, + std::vector>> searchSequence( const std::string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match); - vector>> searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, + std::vector>> searchSequence( const std::string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match) const; int k_; @@ -888,7 +886,7 @@ class CompactedDBG { typedef KmerHashTable> h_kmers_ccov_t; - vector*> v_unitigs; + std::vector*> v_unitigs; KmerCovIndex km_unitigs; h_kmers_ccov_t h_kmers_ccov; diff --git a/src/CompactedDBG.tcc b/src/CompactedDBG.tcc index da7733a..0061719 100755 --- a/src/CompactedDBG.tcc +++ b/src/CompactedDBG.tcc @@ -22,9 +22,9 @@ CompactedDBG::CompactedDBG(const CompactedDBG& o) : k_(o.k_), g_(o.g template CompactedDBG::CompactedDBG(CompactedDBG&& o) : k_(o.k_), g_(o.g_), invalid(o.invalid), - km_unitigs(move(o.km_unitigs)), data(move(o.data)), - v_unitigs(move(o.v_unitigs)), h_kmers_ccov(move(o.h_kmers_ccov)), - hmap_min_unitigs(move(o.hmap_min_unitigs)){ + km_unitigs(std::move(o.km_unitigs)), data(std::move(o.data)), + v_unitigs(std::move(o.v_unitigs)), h_kmers_ccov(std::move(o.h_kmers_ccov)), + hmap_min_unitigs(std::move(o.hmap_min_unitigs)){ o.clear(); } @@ -52,7 +52,7 @@ CompactedDBG& CompactedDBG::operator=(const CompactedDBG& o){ data = o.data; - v_unitigs = vector*>(o.v_unitigs.size(), nullptr); + v_unitigs = std::vector*>(o.v_unitigs.size(), nullptr); for (size_t i = 0; i < o.v_unitigs.size(); ++i){ @@ -78,7 +78,7 @@ CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o data = wrapperData(); - v_unitigs = vector*>(o.v_unitigs.size(), nullptr); + v_unitigs = std::vector*>(o.v_unitigs.size(), nullptr); auto moveUnitigs = [&](const size_t start, const size_t end){ @@ -93,7 +93,7 @@ CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o if ((nb_threads == 1) || (v_unitigs.size() < 1024)) moveUnitigs(0, v_unitigs.size()); else { - vector workers; + std::vector workers; const size_t slice = (v_unitigs.size() / nb_threads) + 1; @@ -104,7 +104,7 @@ CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o [&, t]{ const size_t start = t * slice; - const size_t end = min(start + slice, v_unitigs.size()); + const size_t end = std::min(start + slice, v_unitigs.size()); if (start < v_unitigs.size()) moveUnitigs(start, end); } @@ -125,7 +125,7 @@ CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o Kmer km = it_s.getKey(); - h_kmers_ccov.insert(move(km), move(it_s->ccov)); + h_kmers_ccov.insert(std::move(km), std::move(it_s->ccov)); ++it_s; } @@ -185,8 +185,8 @@ bool CompactedDBG::operator==(const CompactedDBG& o) const { um_o.dist = 0; um_o.len = um_o.size - k_ + 1; - const string unitig_str = unitig.referenceUnitigToString(); - const string unitig_o_str = um_o.referenceUnitigToString(); + const std::string unitig_str = unitig.referenceUnitigToString(); + const std::string unitig_o_str = um_o.referenceUnitigToString(); if ((unitig_o_str != unitig_str) && (reverse_complement(unitig_o_str) != unitig_str)) return false; } @@ -233,19 +233,19 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (invalid){ - cerr << "CompactedDBG::build(): Graph is invalid and cannot be built" << endl; + std::cerr << "CompactedDBG::build(): Graph is invalid and cannot be built" << std::endl; construct_finished = false; } if (opt.nb_threads <= 0){ - cerr << "CompactedDBG::build(): Number of threads cannot be less than or equal to 0" << endl; + std::cerr << "CompactedDBG::build(): Number of threads cannot be less than or equal to 0" << std::endl; construct_finished = false; } if (opt.nb_threads > max_threads){ - cerr << "CompactedDBG::build(): Number of threads cannot exceed " << max_threads << "threads" << endl; + std::cerr << "CompactedDBG::build(): Number of threads cannot exceed " << max_threads << "threads" << std::endl; construct_finished = false; } @@ -255,7 +255,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << endl; + std::cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << std::endl; construct_finished = false; } else { @@ -264,7 +264,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (std::remove(opt.outFilenameBBF.c_str()) != 0){ - cerr << "CompactedDBG::build(): Could not remove temporary file " << opt.outFilenameBBF << "." << endl; + std::cerr << "CompactedDBG::build(): Could not remove temporary file " << opt.outFilenameBBF << "." << std::endl; } } } @@ -277,21 +277,21 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not read input Blocked Bloom filter file " << opt.inFilenameBBF << "." << endl; + std::cerr << "CompactedDBG::build(): Could not read input Blocked Bloom filter file " << opt.inFilenameBBF << "." << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input Blocked Bloom filter file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input Blocked Bloom filter file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } if (opt.filename_seq_in.size() + opt.filename_ref_in.size() == 0){ - cerr << "CompactedDBG::build(): Number of FASTA/FASTQ files in input cannot be 0." << endl; + std::cerr << "CompactedDBG::build(): Number of FASTA/FASTQ files in input cannot be 0." << std::endl; construct_finished = false; } else { @@ -304,14 +304,14 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << endl; + std::cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } @@ -324,14 +324,14 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << endl; + std::cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } @@ -382,7 +382,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ const bool reference_mode = (opt.filename_ref_in.size() != 0); - const vector& v_files = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; + const std::vector& v_files = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; setFullCoverage(reference_mode ? 1 : 2); @@ -398,20 +398,20 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ KmerStream kms(kms_opt); - const size_t nb_unique_kmers = max(1UL, kms.KmerF0()); - const size_t nb_unique_minimizers = max(1UL, kms.MinimizerF0()); - const size_t nb_non_unique_kmers = reference_mode ? 0 : max(1UL, nb_unique_kmers - min(nb_unique_kmers, kms.Kmerf1())); - const size_t nb_non_unique_minimizers = reference_mode ? 0 : max(1UL, nb_unique_minimizers - min(nb_unique_minimizers, kms.Minimizerf1())); + const size_t nb_unique_kmers = std::max(1UL, kms.KmerF0()); + const size_t nb_unique_minimizers = std::max(1UL, kms.MinimizerF0()); + const size_t nb_non_unique_kmers = reference_mode ? 0 : std::max(1UL, nb_unique_kmers - std::min(nb_unique_kmers, kms.Kmerf1())); + const size_t nb_non_unique_minimizers = reference_mode ? 0 : std::max(1UL, nb_unique_minimizers - std::min(nb_unique_minimizers, kms.Minimizerf1())); if (opt.verbose){ - cout << "CompactedDBG::build(): Estimated number of k-mers occurring at least once: " << nb_unique_kmers << endl; - cout << "CompactedDBG::build(): Estimated number of minimizer occurring at least once: " << nb_unique_minimizers << endl; + std::cout << "CompactedDBG::build(): Estimated number of k-mers occurring at least once: " << nb_unique_kmers << std::endl; + std::cout << "CompactedDBG::build(): Estimated number of minimizer occurring at least once: " << nb_unique_minimizers << std::endl; if (!reference_mode){ - cout << "CompactedDBG::build(): Estimated number of k-mers occurring twice or more: " << nb_non_unique_kmers << endl; - cout << "CompactedDBG::build(): Estimated number of minimizers occurring twice or more: " << nb_non_unique_minimizers << endl; + std::cout << "CompactedDBG::build(): Estimated number of k-mers occurring twice or more: " << nb_non_unique_kmers << std::endl; + std::cout << "CompactedDBG::build(): Estimated number of minimizers occurring twice or more: " << nb_non_unique_minimizers << std::endl; } } @@ -421,7 +421,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open input Blocked Bloom filter file " << opt.inFilenameBBF << "." << endl; + std::cerr << "CompactedDBG::build(): Could not open input Blocked Bloom filter file " << opt.inFilenameBBF << "." << std::endl; construct_finished = false; } else { @@ -441,7 +441,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << endl; + std::cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << std::endl; construct_finished = false; } else { @@ -475,19 +475,19 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (invalid){ - cerr << "CompactedDBG::build(): Graph is invalid and cannot be built" << endl; + std::cerr << "CompactedDBG::build(): Graph is invalid and cannot be built" << std::endl; construct_finished = false; } if (opt.nb_threads <= 0){ - cerr << "CompactedDBG::build(): Number of threads cannot be less than or equal to 0" << endl; + std::cerr << "CompactedDBG::build(): Number of threads cannot be less than or equal to 0" << std::endl; construct_finished = false; } if (opt.nb_threads > max_threads){ - cerr << "CompactedDBG::build(): Number of threads cannot exceed " << max_threads << "threads" << endl; + std::cerr << "CompactedDBG::build(): Number of threads cannot exceed " << max_threads << "threads" << std::endl; construct_finished = false; } @@ -497,7 +497,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << endl; + std::cerr << "CompactedDBG::build(): Could not open Blocked Bloom filter file " << opt.outFilenameBBF << " for writing." << std::endl; construct_finished = false; } else { @@ -506,7 +506,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (std::remove(opt.outFilenameBBF.c_str()) != 0){ - cerr << "CompactedDBG::build(): Could not remove temporary file " << opt.outFilenameBBF << "." << endl; + std::cerr << "CompactedDBG::build(): Could not remove temporary file " << opt.outFilenameBBF << "." << std::endl; } } } @@ -519,21 +519,21 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not read input Blocked Bloom filter file " << opt.inFilenameBBF << "." << endl; + std::cerr << "CompactedDBG::build(): Could not read input Blocked Bloom filter file " << opt.inFilenameBBF << "." << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input Blocked Bloom filter file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input Blocked Bloom filter file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } if (opt.filename_seq_in.size() + opt.filename_ref_in.size() == 0){ - cerr << "CompactedDBG::build(): Number of FASTA/FASTQ files in input cannot be 0." << endl; + std::cerr << "CompactedDBG::build(): Number of FASTA/FASTQ files in input cannot be 0." << std::endl; construct_finished = false; } else { @@ -546,14 +546,14 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << endl; + std::cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } @@ -566,14 +566,14 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if (fp == NULL) { - cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << endl; + std::cerr << "CompactedDBG::build(): Could not open input FASTA/FASTQ file " << file << std::endl; construct_finished = false; } else fclose(fp); } else { - cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << endl; + std::cerr << "CompactedDBG::build(): Input file " << opt.inFilenameBBF << " does not exist." << std::endl; construct_finished = false; } } @@ -620,7 +620,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ setFullCoverage(2); } - else if (!is_void::value) { + else if (!std::is_void::value) { CompactedDBG graph(k_, g_); @@ -636,7 +636,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ size_t nb_non_unique_kmers, nb_non_unique_minimizers; { - const vector& v_files = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; + const std::vector& v_files = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; KmerStream_Build_opt kms_opt; @@ -650,20 +650,20 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ KmerStream kms(kms_opt); - nb_unique_kmers = max(1UL, kms.KmerF0()); - nb_unique_minimizers = max(1UL, kms.MinimizerF0()); - nb_non_unique_kmers = reference_mode ? 0 : max(1UL, nb_unique_kmers - min(nb_unique_kmers, kms.Kmerf1())); - nb_non_unique_minimizers = reference_mode ? 0 : max(1UL, nb_unique_minimizers - min(nb_unique_minimizers, kms.Minimizerf1())); + nb_unique_kmers = std::max(1UL, kms.KmerF0()); + nb_unique_minimizers = std::max(1UL, kms.MinimizerF0()); + nb_non_unique_kmers = reference_mode ? 0 : std::max(1UL, nb_unique_kmers - std::min(nb_unique_kmers, kms.Kmerf1())); + nb_non_unique_minimizers = reference_mode ? 0 : std::max(1UL, nb_unique_minimizers - std::min(nb_unique_minimizers, kms.Minimizerf1())); if (opt.verbose){ - cout << "CompactedDBG::build(): Estimated number of k-mers occurring at least once: " << nb_unique_kmers << endl; - cout << "CompactedDBG::build(): Estimated number of minimizer occurring at least once: " << nb_unique_minimizers << endl; + std::cout << "CompactedDBG::build(): Estimated number of k-mers occurring at least once: " << nb_unique_kmers << std::endl; + std::cout << "CompactedDBG::build(): Estimated number of minimizer occurring at least once: " << nb_unique_minimizers << std::endl; if (!reference_mode){ - cout << "CompactedDBG::build(): Estimated number of k-mers occurring twice or more: " << nb_non_unique_kmers << endl; - cout << "CompactedDBG::build(): Estimated number of minimizers occurring twice or more: " << nb_non_unique_minimizers << endl; + std::cout << "CompactedDBG::build(): Estimated number of k-mers occurring twice or more: " << nb_non_unique_kmers << std::endl; + std::cout << "CompactedDBG::build(): Estimated number of minimizers occurring twice or more: " << nb_non_unique_minimizers << std::endl; } } } @@ -692,28 +692,28 @@ bool CompactedDBG::simplify(const bool delete_short_isolated_unitigs, cons if (invalid){ - cerr << "CompactedDBG::simplify(): Graph is invalid and cannot be simplified" << endl; + std::cerr << "CompactedDBG::simplify(): Graph is invalid and cannot be simplified" << std::endl; return false; } if (delete_short_isolated_unitigs || clip_short_tips){ - if (verbose) cout << endl << "CompactedDBG::simplify(): Removing isolated unitigs and/or clipping tips" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::simplify(): Removing isolated unitigs and/or clipping tips" << std::endl; - vector v_joins; + std::vector v_joins; size_t joined = 0; size_t removed = removeUnitigs(delete_short_isolated_unitigs, clip_short_tips, v_joins); - if (clip_short_tips) joined = joinUnitigs_::value>(&v_joins); + if (clip_short_tips) joined = joinUnitigs_::value>(&v_joins); v_joins.clear(); if (verbose){ - cout << "CompactedDBG::simplify(): After: " << size() << " unitigs" << endl; - cout << "CompactedDBG::simplify(): Removed " << removed << " unitigs" << endl; - cout << "CompactedDBG::simplify(): Joined " << joined << " unitigs" << endl; + std::cout << "CompactedDBG::simplify(): After: " << size() << " unitigs" << std::endl; + std::cout << "CompactedDBG::simplify(): Removed " << removed << " unitigs" << std::endl; + std::cout << "CompactedDBG::simplify(): Joined " << joined << " unitigs" << std::endl; } } @@ -725,7 +725,7 @@ const_UnitigMap CompactedDBG::find(const char* s, const size_t pos_k if (invalid){ - cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << std::endl; return const_UnitigMap(); } @@ -849,7 +849,7 @@ UnitigMap CompactedDBG::find(const char* s, const size_t pos_km, con if (invalid){ - cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << std::endl; return UnitigMap(); } @@ -973,7 +973,7 @@ const_UnitigMap CompactedDBG::find(const Kmer& km, const bool extrem if (invalid){ - cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << std::endl; return const_UnitigMap(); } @@ -1092,17 +1092,17 @@ const_UnitigMap CompactedDBG::find(const Kmer& km, const bool extrem } /*template -vector> CompactedDBG::find(const Minimizer& minz) const { +std::vector> CompactedDBG::find(const Minimizer& minz) const { if (invalid){ - cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << endl; - return vector>(); + std::cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << std::endl; + return std::vector>(); } - vector> v_um; + std::vector> v_um; - const Minimizer minz_rep = minz.rep(); + const Minimizer minz_rep = std::minz.rep(); const MinimizerIndex::const_iterator it = hmap_min_unitigs.find(minz_rep); if (it != hmap_min_unitigs.end()){ // If the minimizer is found @@ -1132,7 +1132,7 @@ vector> CompactedDBG::find(const Minimizer& minz) co const size_t pos_s = (unitig_id_pos + g_ < k_) ? 0 : (unitig_id_pos + g_ - k_); const size_t pos_e = (unitig_id_pos + k_ > len_unitig) ? len_unitig : (unitig_id_pos + k_); - const string subseq = v_unitigs[unitig_id]->getSeq().toString(pos_s, pos_e - pos_s); + const std::string subseq = v_unitigs[unitig_id]->getSeq().toString(pos_s, pos_e - pos_s); const char* subseq_str = subseq.c_str(); @@ -1148,10 +1148,10 @@ vector> CompactedDBG::find(const Minimizer& minz) co while (mhrit_s != mhrit_e) { - if (Minimizer(subseq_str + mhrit_s->pos).rep() == minz_rep) { + if (Minimizer(subseq_str + mhrit_s->pos).rep() == std::minz_rep) { - l_pos_s = min(l_pos_s, static_cast(mhi_s.getKmerPosition())); - l_pos_e = max(l_pos_e, static_cast(mhi_s.getKmerPosition())); + l_pos_s = std::min(l_pos_s, static_cast(mhi_s.getKmerPosition())); + l_pos_e = std::max(l_pos_e, static_cast(mhi_s.getKmerPosition())); break; } @@ -1176,7 +1176,7 @@ UnitigMap CompactedDBG::find(const Kmer& km, const bool extremities_ if (invalid){ - cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::find(): Graph is invalid and cannot be searched" << std::endl; return UnitigMap(); } @@ -1295,7 +1295,7 @@ UnitigMap CompactedDBG::find(const Kmer& km, const bool extremities_ } template -vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) const { +std::vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) const { const Kmer km_pred[4] = {km.backwardBase('A'), km.backwardBase('C'), km.backwardBase('G'), km.backwardBase('T')}; const Kmer km_rep[4] = {km_pred[0].rep(), km_pred[1].rep(), km_pred[2].rep(), km_pred[3].rep()}; @@ -1318,7 +1318,7 @@ vector> CompactedDBG::findPredecessors(const Kmer& k minHashResult mhr, mhr_tmp; - vector> v_um(4, const_UnitigMap(1, this)); + std::vector> v_um(4, const_UnitigMap(1, this)); while (it_it_min != it_it_min_end){ @@ -1451,7 +1451,7 @@ vector> CompactedDBG::findPredecessors(const Kmer& k } template -vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) { +std::vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) { const Kmer km_pred[4] = {km.backwardBase('A'), km.backwardBase('C'), km.backwardBase('G'), km.backwardBase('T')}; const Kmer km_rep[4] = {km_pred[0].rep(), km_pred[1].rep(), km_pred[2].rep(), km_pred[3].rep()}; @@ -1474,7 +1474,7 @@ vector> CompactedDBG::findPredecessors(const Kmer& km, con minHashResult mhr, mhr_tmp; - vector> v_um(4, UnitigMap(1, this)); + std::vector> v_um(4, UnitigMap(1, this)); while (it_it_min != it_it_min_end){ @@ -1607,9 +1607,9 @@ vector> CompactedDBG::findPredecessors(const Kmer& km, con } template -vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) const { +std::vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) const { - vector> v_um(4, const_UnitigMap(1, this)); + std::vector> v_um(4, const_UnitigMap(1, this)); if (limit == 0) return v_um; @@ -1797,9 +1797,9 @@ vector> CompactedDBG::findSuccessors(const Kmer& km, } template -vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) { +std::vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) { - vector> v_um(4, UnitigMap(1, this)); + std::vector> v_um(4, UnitigMap(1, this)); if (limit == 0) return v_um; @@ -1987,25 +1987,25 @@ vector> CompactedDBG::findSuccessors(const Kmer& km, const } template -bool CompactedDBG::add(const string& seq, const bool verbose){ +bool CompactedDBG::add(const std::string& seq, const bool verbose){ if (invalid){ - cerr << "CompactedDBG::add(): Graph is invalid and no sequence can be added to it" << endl; + std::cerr << "CompactedDBG::add(): Graph is invalid and no sequence can be added to it" << std::endl; return false; } if (seq.length() < k_){ - cerr << "CompactedDBG::add(): Input sequence length cannot be less than k = " << k_ << endl; + std::cerr << "CompactedDBG::add(): Input sequence length cannot be less than k = " << k_ << std::endl; return false; } const char* str_seq = seq.c_str(); - string no_dup_km_seq; + std::string no_dup_km_seq; - unordered_set km_seen; + std::unordered_set km_seen; size_t last_start_pos = 0; @@ -2039,13 +2039,13 @@ bool CompactedDBG::remove(const const_UnitigMap& um, const bool verb if (invalid){ - cerr << "CompactedDBG::remove(): Graph is invalid and no unitig can be removed from it" << endl; + std::cerr << "CompactedDBG::remove(): Graph is invalid and no unitig can be removed from it" << std::endl; return false; } if (um.isEmpty) return false; - vector v_km; + std::vector v_km; const Kmer head(um.getUnitigHead()); const Kmer tail(um.getUnitigTail()); @@ -2066,7 +2066,7 @@ bool CompactedDBG::remove(const const_UnitigMap& um, const bool verb if (um.isAbundant){ - deleteUnitig_::value>(um.isShort, um.isAbundant, um.pos_unitig); + deleteUnitig_::value>(um.isShort, um.isAbundant, um.pos_unitig); } else { @@ -2074,13 +2074,13 @@ bool CompactedDBG::remove(const const_UnitigMap& um, const bool verb if (um.pos_unitig != swap_position) swapUnitigs(um.isShort, um.pos_unitig, swap_position); - deleteUnitig_::value>(um.isShort, um.isAbundant, swap_position); + deleteUnitig_::value>(um.isShort, um.isAbundant, swap_position); if (um.isShort) km_unitigs.resize(swap_position); else v_unitigs.resize(swap_position); } - joinUnitigs_::value>(&v_km); + joinUnitigs_::value>(&v_km); return true; } @@ -2092,31 +2092,31 @@ bool CompactedDBG::merge(const CompactedDBG& o, const size_t nb_threads, c if (invalid){ - if (verbose) cerr << "CompactedDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): Current graph is invalid." << std::endl; ret = false; } if (o.invalid){ - if (verbose) cerr << "CompactedDBG::merge(): Graph to merge is invalid." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): Graph to merge is invalid." << std::endl; ret = false; } if (k_ != o.k_){ - if (verbose) cerr << "CompactedDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (g_ != o.g_){ - if (verbose) cerr << "CompactedDBG::merge(): The graphs to merge do not have the same minimizer length." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): The graphs to merge do not have the same minimizer length." << std::endl; ret = false; } if (this == &o){ - if (verbose) cerr << "CompactedDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } @@ -2129,18 +2129,18 @@ bool CompactedDBG::merge(const CompactedDBG& o, const size_t nb_threads, c if (annotateSplitUnitigs(o, nb_threads, verbose)){ const size_t sz_after = size(); - const pair p = splitAllUnitigs(); - const size_t joined = (p.second != 0) ? joinUnitigs_::value>() : 0; + const std::pair p = splitAllUnitigs(); + const size_t joined = (p.second != 0) ? joinUnitigs_::value>() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p.first << " unitigs into " << p.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p.first << " unitigs into " << p.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << size() << " unitigs after merging." << std::endl; } - if (!is_void::value) mergeData(o, nb_threads, verbose); + if (!std::is_void::value) mergeData(o, nb_threads, verbose); return true; } @@ -2150,13 +2150,13 @@ bool CompactedDBG::merge(const CompactedDBG& o, const size_t nb_threads, c } template -bool CompactedDBG::merge(const vector& v, const size_t nb_threads, const bool verbose){ +bool CompactedDBG::merge(const std::vector& v, const size_t nb_threads, const bool verbose){ bool ret = true; if (invalid){ - if (verbose) cerr << "CompactedDBG::merge(): Current graph is invalid." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): Current graph is invalid." << std::endl; ret = false; } @@ -2164,25 +2164,25 @@ bool CompactedDBG::merge(const vector& v, const size_t nb_th if (cdbg.invalid){ - if (verbose) cerr << "CompactedDBG::merge(): One of the graph to merge is invalid." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): One of the graph to merge is invalid." << std::endl; ret = false; } if (k_ != cdbg.k_){ - if (verbose) cerr << "CompactedDBG::merge(): The graphs to merge do not have the same k-mer length." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): The graphs to merge do not have the same k-mer length." << std::endl; ret = false; } if (g_ != cdbg.g_){ - if (verbose) cerr << "CompactedDBG::merge(): The graphs to merge do not have the same minimizer length." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): The graphs to merge do not have the same minimizer length." << std::endl; ret = false; } if (this == &cdbg){ - if (verbose) cerr << "CompactedDBG::merge(): Cannot merge graph with itself." << endl; + if (verbose) std::cerr << "CompactedDBG::merge(): Cannot merge graph with itself." << std::endl; ret = false; } } @@ -2203,18 +2203,18 @@ bool CompactedDBG::merge(const vector& v, const size_t nb_th if (ret){ const size_t sz_after = size(); - const pair p = splitAllUnitigs(); - const size_t joined = (p.second != 0) ? joinUnitigs_::value>() : 0; + const std::pair p = splitAllUnitigs(); + const size_t joined = (p.second != 0) ? joinUnitigs_::value>() : 0; if (verbose){ - cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Split " << p.first << " unitigs into " << p.second << " new unitigs." << endl; - cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << endl; - cout << "CompactedDBG::merge(): " << size() << " unitigs after merging." << endl; + std::cout << "CompactedDBG::merge(): Added " << (sz_after - sz_before) << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Split " << p.first << " unitigs into " << p.second << " new unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): Joined " << joined << " unitigs." << std::endl; + std::cout << "CompactedDBG::merge(): " << size() << " unitigs after merging." << std::endl; } - if (!is_void::value){ + if (!std::is_void::value){ for (const auto& cdbg : v) mergeData(cdbg, nb_threads, verbose); } @@ -2233,9 +2233,9 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const if (verbose){ - cout << "CompactedDBG::annotateSplitUnitigs(): Current graph has " << size() << " unitigs." << endl; - cout << "CompactedDBG::annotateSplitUnitigs(): Graph to merge has " << o.size() << " unitigs." << endl; - cout << "CompactedDBG::annotateSplitUnitigs(): Start unitigs merging." << endl; + std::cout << "CompactedDBG::annotateSplitUnitigs(): Current graph has " << size() << " unitigs." << std::endl; + std::cout << "CompactedDBG::annotateSplitUnitigs(): Graph to merge has " << o.size() << " unitigs." << std::endl; + std::cout << "CompactedDBG::annotateSplitUnitigs(): Start unitigs merging." << std::endl; } if (nb_threads == 1){ @@ -2247,14 +2247,14 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const const size_t chunk = 100; const size_t nb_locks = nb_threads * 1024; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename CompactedDBG::const_iterator g_a(o.begin()); typename CompactedDBG::const_iterator g_b(o.end()); LockGraph lck_g(nb_locks); - mutex mutex_o_unitig; + std::mutex mutex_o_unitig; for (size_t t = 0; t < nb_threads; ++t){ @@ -2267,7 +2267,7 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const while (true) { { - unique_lock lock(mutex_o_unitig); + std::unique_lock lock(mutex_o_unitig); if (g_a == g_b) return; @@ -2291,7 +2291,7 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const for (auto& t : workers) t.join(); } - if (verbose) cout << "CompactedDBG::annotateSplitUnitigs(): Merging unitigs finished." << endl; + if (verbose) std::cout << "CompactedDBG::annotateSplitUnitigs(): Merging unitigs finished." << std::endl; return true; } @@ -2304,7 +2304,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ if ((this != &o) && !invalid && !o.invalid){ // TODO: Check if k_ and g_ are the same - if (verbose) cout << "CompactedDBG::mergeData(): Merging data started." << endl; + if (verbose) std::cout << "CompactedDBG::mergeData(): Merging data started." << std::endl; const size_t nb_locks = nb_threads * 1024; @@ -2316,7 +2316,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ while (it_a != it_b) { - const string str(it_a->referenceUnitigToString()); + const std::string str(it_a->referenceUnitigToString()); const char* str_seq = str.c_str(); for (KmerIterator it_km(str_seq), it_km_end; it_km != it_km_end;) { //non-ACGT char. are discarded @@ -2337,7 +2337,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ while (locks_unitig[id_lock].test_and_set(std::memory_order_acquire)); - mergeData_::value>(um_dest, um_src); + mergeData_::value>(um_dest, um_src); locks_unitig[id_lock].clear(std::memory_order_release); @@ -2351,12 +2351,12 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ const size_t chunk = 100; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename CompactedDBG::const_iterator g_a = o.begin(); typename CompactedDBG::const_iterator g_b = o.end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -2369,7 +2369,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -2389,7 +2389,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ for (auto& t : workers) t.join(); - if (verbose) cout << "CompactedDBG::mergeData(): Merging data finished." << endl; + if (verbose) std::cout << "CompactedDBG::mergeData(): Merging data finished." << std::endl; delete[] locks_unitig; @@ -2404,7 +2404,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa if ((this != &o) && !invalid && !o.invalid){ // TODO: Check if k_ and g_ are the same - if (verbose) cout << "CompactedDBG::mergeData(): Merging data started." << endl; + if (verbose) std::cout << "CompactedDBG::mergeData(): Merging data started." << std::endl; const size_t nb_locks = nb_threads * 1024; @@ -2416,7 +2416,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa while (it_a != it_b) { - const string str(it_a->referenceUnitigToString()); + const std::string str(it_a->referenceUnitigToString()); const char* str_seq = str.c_str(); for (KmerIterator it_km(str_seq), it_km_end; it_km != it_km_end;) { //non-ACGT char. are discarded @@ -2437,7 +2437,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa while (locks_unitig[id_lock].test_and_set(std::memory_order_acquire)); - mergeData_::value>(um_dest, um_src); + mergeData_::value>(um_dest, um_src); locks_unitig[id_lock].clear(std::memory_order_release); @@ -2453,12 +2453,12 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa const size_t chunk = 100; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them typename CompactedDBG::iterator g_a = o.begin(); typename CompactedDBG::iterator g_b = o.end(); - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -2471,7 +2471,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); if (g_a == g_b) return; @@ -2491,7 +2491,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa for (auto& t : workers) t.join(); - if (verbose) cout << "CompactedDBG::mergeData(): Merging data finished." << endl; + if (verbose) std::cout << "CompactedDBG::mergeData(): Merging data finished." << std::endl; delete[] locks_unitig; @@ -2564,7 +2564,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte if (invalid){ - cerr << "CompactedDBG::filter(): Graph is invalid and it cannot be built" << endl; + std::cerr << "CompactedDBG::filter(): Graph is invalid and it cannot be built" << std::endl; return false; } @@ -2573,15 +2573,15 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte const size_t thread_seq_buf_sz = BUFFER_SIZE; - const vector& filename_in = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; + const std::vector& filename_in = reference_mode ? opt.filename_ref_in : opt.filename_seq_in; size_t len_read = 0; size_t pos_read = 0; size_t read_id = 0; - atomic num_kmers(0), num_ins(0), num_seq_tot(0); + std::atomic num_kmers(0), num_ins(0), num_seq_tot(0); - string s; + std::string s; FileParser fp(filename_in); @@ -2619,7 +2619,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte for (; it_kmer_h != it_kmer_h_end; ++it_kmer_h, ++l_num_kmers) { - const pair p_ = *it_kmer_h; // + const std::pair p_ = *it_kmer_h; // it_min += (p_.second - it_min.getKmerPosition()); //If one or more k-mer were jumped because contained non-ACGT char. @@ -2635,7 +2635,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte for (; it_kmer_h != it_kmer_h_end; ++it_kmer_h, ++l_num_kmers) { - const pair p_ = *it_kmer_h; // + const std::pair p_ = *it_kmer_h; // it_min += (p_.second - it_min.getKmerPosition()); //If one or more k-mer were jumped because contained non-ACGT char. @@ -2715,10 +2715,10 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte { bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; - mutex mutex_bitmap; + std::mutex mutex_file; + std::mutex mutex_bitmap; for (size_t t = 0; t < opt.nb_threads; ++t){ @@ -2734,7 +2734,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) { @@ -2749,7 +2749,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte const Roaring lr = worker_function(buffer_seq, buffer_seq_sz, prev_read_id); { - unique_lock lock(mutex_bitmap); + std::unique_lock lock(mutex_bitmap); r |= lr; } @@ -2771,7 +2771,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte char* tmp_dir = nullptr; - string tmp_dir_path; + std::string tmp_dir_path; bf1.clear(); // Empty BF1, not needed anymore @@ -2781,7 +2781,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte if (!check_dir_writable(opt.prefixTmp) || !check_dir_readable(opt.prefixTmp)) { - cerr << "CompactedDBG::filter(): Tmp directory does not exist or is not readable/writable. Abort." << endl; + std::cerr << "CompactedDBG::filter(): Tmp directory does not exist or is not readable/writable. Abort." << std::endl; return false; } @@ -2800,14 +2800,14 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte if (mkdtemp(tmp_dir) == nullptr) { - cerr << "CompactedDBG::filter(): Could not create tmp directory. Abort." << endl; + std::cerr << "CompactedDBG::filter(): Could not create tmp directory. Abort." << std::endl; return false; } } { - const string tmp_bbf_fn = string(tmp_dir) + string("/km.bbf"); + const std::string tmp_bbf_fn = std::string(tmp_dir) + std::string("/km.bbf"); // Write BF2 to disk { @@ -2815,7 +2815,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte if (!bf2.write(fp_bbf)) { - cerr << "CompactedDBG::filter(): Could not write temporary Blocked Bloom Filter file. Abort." << endl; + std::cerr << "CompactedDBG::filter(): Could not write temporary Blocked Bloom Filter file. Abort." << std::endl; exit(1); } @@ -2830,25 +2830,25 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, DualBlockedBloomFilte if (!bf_d.readFromBBF(fp_bbf, 0)) { - cerr << "CompactedDBG::filter(): Could not read temporary Blocked Bloom Filter file. Abort." << endl; + std::cerr << "CompactedDBG::filter(): Could not read temporary Blocked Bloom Filter file. Abort." << std::endl; exit(1); } fclose(fp_bbf); } - if (std::remove(tmp_bbf_fn.c_str()) != 0) cerr << "CompactedDBG::filter(): Could not remove temporary Blocked Bloom Filter file." << endl; + if (std::remove(tmp_bbf_fn.c_str()) != 0) std::cerr << "CompactedDBG::filter(): Could not remove temporary Blocked Bloom Filter file." << std::endl; } - if (rmdir(tmp_dir) != 0) cerr << "CompactedDBG::filter(): Could not remove temporary directory." << endl; + if (rmdir(tmp_dir) != 0) std::cerr << "CompactedDBG::filter(): Could not remove temporary directory." << std::endl; if (tmp_dir != nullptr) delete[] tmp_dir; } if (opt.verbose) { - cout << "CompactedDBG::filter(): Processed " << num_kmers << " k-mers in " << read_id << " reads" << endl; - cout << "CompactedDBG::filter(): Found " << num_ins << " unique k-mers" << endl; - cout << "CompactedDBG::filter(): Number of blocks in Bloom filter is " << bf_d.getNbBlocks() << endl; + std::cout << "CompactedDBG::filter(): Processed " << num_kmers << " k-mers in " << read_id << " reads" << std::endl; + std::cout << "CompactedDBG::filter(): Found " << num_ins << " unique k-mers" << std::endl; + std::cout << "CompactedDBG::filter(): Number of blocks in Bloom filter is " << bf_d.getNbBlocks() << std::endl; } return true; @@ -2859,7 +2859,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (invalid){ - cerr << "CompactedDBG::construct(): Graph is invalid and cannot be built" << endl; + std::cerr << "CompactedDBG::construct(): Graph is invalid and cannot be built" << std::endl; return false; } @@ -2869,10 +2869,10 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi const size_t thread_seq_buf_sz = BUFFER_SIZE; const size_t nb_locks = opt.nb_threads * 1024; - const size_t nb_estimated_min = max((reference_mode ? nb_unique_minimizers : nb_non_unique_minimizers), static_cast(1)); - const size_t nb_estimated_fp_tips = max((reference_mode ? nb_unique_kmers : nb_non_unique_kmers) * 8 * dbbf.getFPrate(), static_cast(1)); + const size_t nb_estimated_min = std::max((reference_mode ? nb_unique_minimizers : nb_non_unique_minimizers), static_cast(1)); + const size_t nb_estimated_fp_tips = std::max((reference_mode ? nb_unique_kmers : nb_non_unique_kmers) * 8 * dbbf.getFPrate(), static_cast(1)); - const vector& filename_in = (reference_mode ? opt.filename_ref_in : opt.filename_seq_in); + const std::vector& filename_in = (reference_mode ? opt.filename_ref_in : opt.filename_seq_in); size_t len_read = 0; size_t pos_read = 0; @@ -2889,7 +2889,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi SpinLock lck_kmt_fp_cand; - string s; + std::string s; BlockedBloomFilter bf_fp_tips(nb_estimated_fp_tips, opt.nb_bits_kmers_bf), bf; @@ -2903,10 +2903,10 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi char* str = seq_buf; - vector l_ignored_km_tips; + std::vector l_ignored_km_tips; - vector v_approx_cs; - vector v_approx_km; + std::vector v_approx_cs; + std::vector v_approx_km; RepHash rep; @@ -2918,7 +2918,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi for (size_t i = 0; i < len - k_ + 1; i += max_len_seq - k_ + 1){ - const int curr_len = min(len - i, max_len_seq); + const int curr_len = std::min(len - i, max_len_seq); const char saved_char = str[i + curr_len]; const char* str_tmp = str + i; @@ -2939,7 +2939,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi const Kmer km = Kmer(str_tmp + p_.second); - string approx_unitig; + std::string approx_unitig; bool isIsolated = false; @@ -2955,20 +2955,20 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi KmerHashIterator it_kmer_h2(approx_unitig.c_str(), approx_unitig.length(), k_), it_kmer_h_end2; minHashIterator it_min2(approx_unitig.c_str(), approx_unitig.length(), k_, g_, rep, true); - vector> vh; + std::vector> vh; vh.reserve(approx_unitig.length() - k_ + 1); for (; it_kmer_h2 != it_kmer_h_end2; ++it_kmer_h2) { - const pair p_2 = *it_kmer_h2; // + const std::pair p_2 = *it_kmer_h2; // it_min2 += (p_2.second - it_min2.getKmerPosition()); //If one or more k-mer were jumped because contained non-ACGT char. vh.push_back({p_2.first, it_min2.getHash()}); } - sort(vh.begin(), vh.end(), [](const pair& l, const pair& r) { + sort(vh.begin(), vh.end(), [](const std::pair& l, const std::pair& r) { return (l.second < r.second) || ((l.second == r.second) && (l.first < r.first)); } ); @@ -2995,7 +2995,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi for (const auto& km_tip : l_ignored_km_tips) { - const string km_str = km_tip.toString(); + const std::string km_str = km_tip.toString(); const uint64_t kmh = km_tip.hash(); minHashIterator it_min(km_str.c_str(), km_str.length(), k_, g_, rep, true); @@ -3005,12 +3005,12 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi bf_fp_tips.insert(kmh, minh, multi_threaded); } - return pair, vector>(move(v_approx_cs), move(v_approx_km)); + return std::pair, std::vector>(std::move(v_approx_cs), std::move(v_approx_km)); }; auto worker_map_function = [&](FileParser& fp, char* seq_buf, const size_t seq_buf_sz) { - vector l_ignored_km_tips; + std::vector l_ignored_km_tips; RepHash rep; @@ -3030,7 +3030,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi for (size_t i = 0; i < len - k_ + 1; i += max_len_seq - k_ + 1){ - const int curr_len = min(len - i, max_len_seq); + const int curr_len = std::min(len - i, max_len_seq); const char saved_char = str[i + curr_len]; const char* str_tmp = str + i; @@ -3063,7 +3063,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi lck_h.release_reader(); - string approx_unitig; + std::string approx_unitig; bool isIsolated = false; @@ -3077,7 +3077,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi lck_kmt_fp_cand.acquire(); - const pair::const_iterator, bool> p_insert_kmt_fp_cand = kmt_fp_cand.insert(km_rep, 0); + const std::pair::const_iterator, bool> p_insert_kmt_fp_cand = kmt_fp_cand.insert(km_rep, 0); has_full_cov = !p_insert_kmt_fp_cand.second; @@ -3134,7 +3134,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi for (const auto& km_tip : l_ignored_km_tips) { - const string km_str = km_tip.toString(); + const std::string km_str = km_tip.toString(); const uint64_t kmh = km_tip.hash(); const minHashIterator it_min(km_str.c_str(), km_str.length(), k_, g_, rep, true); @@ -3255,7 +3255,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi { char* tmp_dir = nullptr; - string tmp_dir_path; + std::string tmp_dir_path; // Create tmp dir { @@ -3263,7 +3263,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (!check_dir_writable(opt.prefixTmp) || !check_dir_readable(opt.prefixTmp)) { - cerr << "CompactedDBG::construct(): Tmp directory does not exist or is not readable/writable. Abort." << endl; + std::cerr << "CompactedDBG::construct(): Tmp directory does not exist or is not readable/writable. Abort." << std::endl; return false; } @@ -3282,13 +3282,13 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (mkdtemp(tmp_dir) == nullptr) { - cerr << "CompactedDBG::construct(): Could not create tmp directory. Abort." << endl; + std::cerr << "CompactedDBG::construct(): Could not create tmp directory. Abort." << std::endl; return false; } } - const string tmp_graph_fn = string(tmp_dir) + string("/approx_unitigs.fasta"); + const std::string tmp_graph_fn = std::string(tmp_dir) + std::string("/approx_unitigs.fasta"); const bool approx_unitigs_detected = (its != ite); size_t id_unitig_out = 0; @@ -3299,17 +3299,17 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi FileParser fp_in(filename_in); - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(tmp_graph_fn.c_str()); out.rdbuf(outfile.rdbuf()); - mutex mtx_fn_in, mtx_fn_out; + std::mutex mtx_fn_in, mtx_fn_out; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - if (opt.verbose) cout << "CompactedDBG::construct(): Extract approximate unitigs (1/3)" << endl; + if (opt.verbose) std::cout << "CompactedDBG::construct(): Extract approximate unitigs (1/3)" << std::endl; for (size_t t = 0; t < opt.nb_threads; ++t) { @@ -3317,7 +3317,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi [&]{ - pair, vector> v_unitigs; + std::pair, std::vector> v_unitigs; char* buffer_seq = new char[thread_seq_buf_sz]; @@ -3327,17 +3327,17 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi while (true) { { - unique_lock lock(mtx_fn_in); + std::unique_lock lock(mtx_fn_in); stop = stop || (its == ite); if (stop) { { - unique_lock lock(mtx_fn_out); + std::unique_lock lock(mtx_fn_out); - for (const auto& cs : v_unitigs.first) out << ">" << id_unitig_out++ << "\n" << cs.toString() << endl; - for (const auto& km : v_unitigs.second) out << ">" << id_unitig_out++ << "\n" << km.toString() << endl; + for (const auto& cs : v_unitigs.first) out << ">" << id_unitig_out++ << "\n" << cs.toString() << std::endl; + for (const auto& km : v_unitigs.second) out << ">" << id_unitig_out++ << "\n" << km.toString() << std::endl; } delete[] buffer_seq; @@ -3348,7 +3348,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi stop = reading_build_function(fp_in, buffer_seq, buffer_seq_sz); } - pair, vector> p_approx_unitigs = worker_build_function(fp_in, buffer_seq, buffer_seq_sz); + std::pair, std::vector> p_approx_unitigs = worker_build_function(fp_in, buffer_seq, buffer_seq_sz); v_unitigs.first.insert(v_unitigs.first.end(), p_approx_unitigs.first.begin(), p_approx_unitigs.first.end()); v_unitigs.second.insert(v_unitigs.second.end(), p_approx_unitigs.second.begin(), p_approx_unitigs.second.end()); @@ -3364,10 +3364,10 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (l_count >= 1000000) { { - unique_lock lock(mtx_fn_out); + std::unique_lock lock(mtx_fn_out); - for (const auto& cs : v_unitigs.first) out << ">" << id_unitig_out++ << "\n" << cs.toString() << endl; - for (const auto& km : v_unitigs.second) out << ">" << id_unitig_out++ << "\n" << km.toString() << endl; + for (const auto& cs : v_unitigs.first) out << ">" << id_unitig_out++ << "\n" << cs.toString() << std::endl; + for (const auto& km : v_unitigs.second) out << ">" << id_unitig_out++ << "\n" << km.toString() << std::endl; } v_unitigs.first.clear(); @@ -3392,13 +3392,13 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi // Write DBBF[0] to disk, empty DBBF, reloads BF=DBBF[0] { - const string tmp_bbf_fn = string(tmp_dir) + string("/km.bbf"); + const std::string tmp_bbf_fn = std::string(tmp_dir) + std::string("/km.bbf"); FILE* fp_bbf = fopen(tmp_bbf_fn.c_str(), "wb"); if (!dbbf.writeAsBBF(fp_bbf, 0)) { - cerr << "CompactedDBG::construct(): Could not write temporary Blocked Bloom Filter file. Abort." << endl; + std::cerr << "CompactedDBG::construct(): Could not write temporary Blocked Bloom Filter file. Abort." << std::endl; exit(1); } @@ -3410,24 +3410,24 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (!bf.read(fp_bbf)) { - cerr << "CompactedDBG::construct(): Could not read temporary Blocked Bloom Filter file. Abort." << endl; + std::cerr << "CompactedDBG::construct(): Could not read temporary Blocked Bloom Filter file. Abort." << std::endl; exit(1); } fclose(fp_bbf); - if (std::remove(tmp_bbf_fn.c_str()) != 0) cerr << "CompactedDBG::construct(): Could not remove temporary Blocked Bloom Filter file." << endl; + if (std::remove(tmp_bbf_fn.c_str()) != 0) std::cerr << "CompactedDBG::construct(): Could not remove temporary Blocked Bloom Filter file." << std::endl; } if (id_unitig_out != 0) { - const vector v_tmp_file(1, tmp_graph_fn); + const std::vector v_tmp_file(1, tmp_graph_fn); FileParser fp_approx_unitigs(v_tmp_file); size_t file_id_approx = 0; - string approx_unitig; + std::string approx_unitig; hmap_min_unitigs = MinimizerIndex(nb_estimated_min * 1.07); // Index has 95% max occupancy by default @@ -3439,8 +3439,8 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi h_kmers_ccov.recomputeMaxPSL(opt.nb_threads); } - if (approx_unitigs_detected && (std::remove(tmp_graph_fn.c_str()) != 0)) cerr << "CompactedDBG::construct(): Could not remove temporary file." << endl; - if (rmdir(tmp_dir) != 0) cerr << "CompactedDBG::construct(): Could not remove temporary directory." << endl; + if (approx_unitigs_detected && (std::remove(tmp_graph_fn.c_str()) != 0)) std::cerr << "CompactedDBG::construct(): Could not remove temporary file." << std::endl; + if (rmdir(tmp_dir) != 0) std::cerr << "CompactedDBG::construct(): Could not remove temporary directory." << std::endl; if (tmp_dir != nullptr) delete[] tmp_dir; } @@ -3451,11 +3451,11 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi FileParser fp(filename_in); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; - if (opt.verbose) cout << "CompactedDBG::construct(): Extract approximate unitigs (2/3)" << endl; + if (opt.verbose) std::cout << "CompactedDBG::construct(): Extract approximate unitigs (2/3)" << std::endl; unitig_full = new uint64_t[(v_unitigs.size() + km_unitigs.size() + 63) / 64](); // Kmers with abundant minimizers cannot be included here @@ -3475,7 +3475,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) { @@ -3509,7 +3509,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi lck_h.clear(); { - if (opt.verbose) cout << "CompactedDBG::construct(): Extract approximate unitigs (3/3)" << endl; + if (opt.verbose) std::cout << "CompactedDBG::construct(): Extract approximate unitigs (3/3)" << std::endl; { for (typename h_kmers_ccov_t::iterator it = dbg_extra.h_kmers_ccov.begin(); it != dbg_extra.h_kmers_ccov.end(); ++it) { @@ -3556,15 +3556,15 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (!u->getCov().isFull()) { //Coverage not full, unitig must be splitted - const vector> sp = u->getCov().splittingVector(); + const std::vector> sp = u->getCov().splittingVector(); if (!sp.empty()) { - const string unitig = u->getSeq().toString(); + const std::string unitig = u->getSeq().toString(); for (const auto& p : sp) { - const string split_unitig = unitig.substr(p.first, (p.second - p.first) + k_ - 1); // Split unitig sequence + const std::string split_unitig = unitig.substr(p.first, (p.second - p.first) + k_ - 1); // Split unitig sequence const Kmer head_split_unitig = Kmer(split_unitig.c_str()); addUnitigSequence(split_unitig); @@ -3577,7 +3577,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi } else { - const string unitig = u->getSeq().toString(); + const std::string unitig = u->getSeq().toString(); const Kmer head_unitig = Kmer(unitig.c_str()); addUnitigSequence(unitig); @@ -3601,17 +3601,17 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi dbg_extra.clear(); } - if (opt.verbose) cout << "CompactedDBG::construct(): Closed all input files" << endl; + if (opt.verbose) std::cout << "CompactedDBG::construct(): Closed all input files" << std::endl; const size_t unitigsBefore = size(); - if (opt.verbose) cout << endl << "CompactedDBG::construct(): Splitting unitigs (1/2)" << endl; + if (opt.verbose) std::cout << std::endl << "CompactedDBG::construct(): Splitting unitigs (1/2)" << std::endl; - pair unitigSplit = extractAllUnitigs(); + std::pair unitigSplit = extractAllUnitigs(); const int unitigsAfter1 = size(); - if (opt.verbose) cout << endl << "CompactedDBG::construct(): Splitting unitigs (2/2)" << endl; + if (opt.verbose) std::cout << std::endl << "CompactedDBG::construct(): Splitting unitigs (2/2)" << std::endl; check_fp_tips(bf_fp_tips, opt.nb_threads); @@ -3624,16 +3624,16 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (opt.verbose) { - cout << "CompactedDBG::construct(): Before split: " << unitigsBefore << " unitigs" << endl; - cout << "CompactedDBG::construct(): After split (1/" << (reference_mode ? "1" : "2" ) << "): " << unitigsAfter1 << " unitigs" << endl; - if (!reference_mode) cout << "CompactedDBG::construct(): After split (2/2): " << unitigsAfter2 << " unitigs" << endl; - cout << "CompactedDBG::construct(): Unitigs split: " << unitigSplit.first << endl; - cout << "CompactedDBG::construct(): Unitigs deleted: " << unitigSplit.second << endl; + std::cout << "CompactedDBG::construct(): Before split: " << unitigsBefore << " unitigs" << std::endl; + std::cout << "CompactedDBG::construct(): After split (1/" << (reference_mode ? "1" : "2" ) << "): " << unitigsAfter1 << " unitigs" << std::endl; + if (!reference_mode) std::cout << "CompactedDBG::construct(): After split (2/2): " << unitigsAfter2 << " unitigs" << std::endl; + std::cout << "CompactedDBG::construct(): Unitigs split: " << unitigSplit.first << std::endl; + std::cout << "CompactedDBG::construct(): Unitigs deleted: " << unitigSplit.second << std::endl; - cout << endl << "CompactedDBG::construct(): Joining unitigs" << endl; + std::cout << std::endl << "CompactedDBG::construct(): Joining unitigs" << std::endl; } - const size_t joined = joinUnitigs_::value>(nullptr, opt.nb_threads); + const size_t joined = joinUnitigs_::value>(nullptr, opt.nb_threads); const int unitigsAfter3 = size(); @@ -3642,15 +3642,15 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, DualBlockedBloomFi if (opt.verbose) { - cout << "CompactedDBG::construct(): After join: " << unitigsAfter3 << " unitigs" << endl; - cout << "CompactedDBG::construct(): Joined " << joined << " unitigs" << endl; + std::cout << "CompactedDBG::construct(): After join: " << unitigsAfter3 << " unitigs" << std::endl; + std::cout << "CompactedDBG::construct(): Joined " << joined << " unitigs" << std::endl; } return true; } template -void CompactedDBG::addUnitigSequence(const Kmer km, const string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g, const bool map_read) { +void CompactedDBG::addUnitigSequence(const Kmer km, const std::string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g, const bool map_read) { bool isAbundant = false; @@ -3693,7 +3693,7 @@ void CompactedDBG::addUnitigSequence(const Kmer km, const string& seq, con } template -void CompactedDBG::addUnitigSequence(const string& seq) { +void CompactedDBG::addUnitigSequence(const std::string& seq) { const Kmer km = Kmer(seq.c_str()); @@ -3706,12 +3706,12 @@ void CompactedDBG::addUnitigSequence(const string& seq) { template -size_t CompactedDBG::findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip) { +size_t CompactedDBG::findUnitigSequenceBBF(const BlockedBloomFilter& bf, const Kmer km, std::string& s, bool& isIsolated, std::vector& l_ignored_km_tip) { - string fw_s, bw_s; + std::string fw_s, bw_s; Kmer end(km); - Kmer last(km); + Kmer last(km); char km_str[MAX_KMER_SIZE]; char neigh_str[MAX_KMER_SIZE]; @@ -3736,7 +3736,7 @@ size_t CompactedDBG::findUnitigSequenceBBF(const BlockedBloomFilter& bf, c isIsolated = false; - pair p_neigh = fwStepBBF(bf, end, end, rep_neigh, neigh_str, has_no_neighbor, l_ignored_km_tip); + std::pair p_neigh = fwStepBBF(bf, end, end, rep_neigh, neigh_str, has_no_neighbor, l_ignored_km_tip); while (p_neigh.first != -1) { @@ -3803,9 +3803,9 @@ size_t CompactedDBG::findUnitigSequenceBBF(const BlockedBloomFilter& bf, c } template -size_t CompactedDBG::findUnitigSequenceBBF(const DualBlockedBloomFilter& bf, const Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip) { +size_t CompactedDBG::findUnitigSequenceBBF(const DualBlockedBloomFilter& bf, const Kmer km, std::string& s, bool& isIsolated, std::vector& l_ignored_km_tip) { - string fw_s, bw_s; + std::string fw_s, bw_s; Kmer end(km); Kmer last(km); @@ -3833,7 +3833,7 @@ size_t CompactedDBG::findUnitigSequenceBBF(const DualBlockedBloomFilter& b isIsolated = false; - pair p_neigh = fwStepBBF(bf, end, end, rep_neigh, neigh_str, has_no_neighbor, l_ignored_km_tip); + std::pair p_neigh = fwStepBBF(bf, end, end, rep_neigh, neigh_str, has_no_neighbor, l_ignored_km_tip); while (p_neigh.first != -1) { @@ -3898,7 +3898,7 @@ size_t CompactedDBG::findUnitigSequenceBBF(const DualBlockedBloomFilter& b } template -pair CompactedDBG::bwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +std::pair CompactedDBG::bwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -4069,7 +4069,7 @@ pair CompactedDBG::bwStepBBF(const BlockedBloomFilter& bf, c } template -pair CompactedDBG::bwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +std::pair CompactedDBG::bwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& front, const RepHash& rep_front, const char* front_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -4240,7 +4240,7 @@ pair CompactedDBG::bwStepBBF(const DualBlockedBloomFilter& b } template -pair CompactedDBG::fwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +std::pair CompactedDBG::fwStepBBF(const BlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -4412,7 +4412,7 @@ pair CompactedDBG::fwStepBBF(const BlockedBloomFilter& bf, c } template -pair CompactedDBG::fwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +std::pair CompactedDBG::fwStepBBF(const DualBlockedBloomFilter& bf, const Kmer km, Kmer& end, const RepHash& rep_end, const char* end_str, bool& has_no_neighbor, std::vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -4718,7 +4718,7 @@ UnitigMap CompactedDBG::findUnitig(const Kmer& km, const char* s, co } template -bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig){ +bool CompactedDBG::addUnitig(const std::string& str_unitig, const size_t id_unitig){ const size_t len = str_unitig.size(); size_t pos_id_unitig = id_unitig << 32; @@ -4839,7 +4839,7 @@ bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_uni if (id_unitig == km_unitigs.size()) km_unitigs.push_back(km_rep); else km_unitigs.set(id_unitig, km_rep); - deleteUnitig_::value>(true, false, id_unitig, false); + deleteUnitig_::value>(true, false, id_unitig, false); if (id_unitig == km_unitigs.size() - 1) km_unitigs.resize(km_unitigs.size() - 1); @@ -4888,7 +4888,7 @@ void CompactedDBG::moveToAbundant() { MinimizerIndex::iterator it = hmap_min_unitigs.begin(); MinimizerIndex::iterator it_end = hmap_min_unitigs.end(); - vector v_km_rm; + std::vector v_km_rm; char km_tmp[MAX_KMER_SIZE]; @@ -4917,7 +4917,7 @@ void CompactedDBG::moveToAbundant() { for (auto unitig_id : v_km_rm) { - const string unitig_str = km_unitigs.getKmer(unitig_id).toString(); + const std::string unitig_str = km_unitigs.getKmer(unitig_id).toString(); { size_t id_swap = km_unitigs.size() - 1; @@ -4976,7 +4976,7 @@ void CompactedDBG::moveToAbundant() { } /*template -bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer){ +bool CompactedDBG::addUnitig(const std::string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer){ const size_t len = str_unitig.size(); size_t pos_id_unitig = id_unitig << 32; @@ -5113,7 +5113,7 @@ bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_uni }*/ template -bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig, const size_t id_unitig_r, const size_t is_short_r){ +bool CompactedDBG::addUnitig(const std::string& str_unitig, const size_t id_unitig, const size_t id_unitig_r, const size_t is_short_r){ const size_t pos_id_unitig_r = (id_unitig_r << 32) | ((static_cast(!is_short_r) - 1) & MASK_CONTIG_TYPE); @@ -5263,7 +5263,7 @@ bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_uni if (id_unitig == km_unitigs.size()) km_unitigs.push_back(km_rep); else km_unitigs.set(id_unitig, km_rep); - deleteUnitig_::value>(true, false, id_unitig, false); + deleteUnitig_::value>(true, false, id_unitig, false); if (id_unitig == km_unitigs.size() - 1) km_unitigs.resize(km_unitigs.size() - 1); @@ -5316,7 +5316,7 @@ void CompactedDBG::swapUnitigs(const bool isShort, const size_t id_a, cons size_t shift_id_unitig_a = id_a << 32; size_t shift_id_unitig_b = id_b << 32; - unordered_set us_minz; + std::unordered_set us_minz; if (isShort){ @@ -5324,7 +5324,7 @@ void CompactedDBG::swapUnitigs(const bool isShort, const size_t id_a, cons shift_id_unitig_b |= MASK_CONTIG_TYPE; } - auto swapUnitig = [&](const string str){ + auto swapUnitig = [&](const std::string str){ bool isForbidden = false; @@ -5408,17 +5408,17 @@ void CompactedDBG::swapUnitigs(const bool isShort, const size_t id_a, cons // Input sequence must not contain duplicated k-mers // If it does, use CompactedDBG::add(). template -bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ +bool CompactedDBG::mergeUnitig(const std::string& seq, const bool verbose){ if (invalid){ - cerr << "CompactedDBG::mergeUnitig(): Graph is invalid and no sequence can be added to it" << endl; + std::cerr << "CompactedDBG::mergeUnitig(): Graph is invalid and no sequence can be added to it" << std::endl; return false; } if (seq.length() < k_){ - cerr << "CompactedDBG::mergeUnitig(): Input sequence length cannot be less than k = " << k_ << endl; + std::cerr << "CompactedDBG::mergeUnitig(): Input sequence length cannot be less than k = " << k_ << std::endl; return false; } @@ -5436,17 +5436,17 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ bool prev_found = true; - string curr_unitig; + std::string curr_unitig; - vector v_joins; + std::vector v_joins; - KmerHashTable> kht; + KmerHashTable> kht; const char* str_seq = seq.c_str(); const size_t str_seq_len = seq.length(); - auto add_graph_function = [&](const string& unitig){ + auto add_graph_function = [&](const std::string& unitig){ const char* str_unitig = unitig.c_str(); const size_t len_unitig = unitig.length(); @@ -5479,10 +5479,10 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ auto add_split_function = [&](){ - KmerHashTable>::iterator it(kht.begin()); - const KmerHashTable>::iterator it_end(kht.end()); + KmerHashTable>::iterator it(kht.begin()); + const KmerHashTable>::iterator it_end(kht.end()); - vector> sp; + std::vector> sp; while (it != it_end){ @@ -5491,7 +5491,7 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ const_UnitigMap um(find(it.getKey(), true)); - vector& split_v = *it; + std::vector& split_v = *it; sort(split_v.begin(), split_v.end()); @@ -5517,7 +5517,7 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ v_joins.push_back(um.getUnitigKmer(prev_split_pos)); if (prev_split_pos != um.size - k_) v_joins.push_back(um.getUnitigKmer(um.size - k_)); - extractUnitig_::value>(um.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); + extractUnitig_::value>(um.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); sp.clear(); split_v.clear(); @@ -5536,8 +5536,8 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if (cm.isEmpty){ - vector> um_bw(findPredecessors(p.first)); - vector> um_fw(findSuccessors(p.first)); + std::vector> um_bw(findPredecessors(p.first)); + std::vector> um_fw(findSuccessors(p.first)); nb_curr_pred = 0; nb_curr_succ = 0; @@ -5551,7 +5551,7 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if (!um.isAbundant && !um.isShort){ um.dist += um.strand; - if ((um.dist != 0) && (um.dist != um.size - k_ + 1)) kht.insert(um.getUnitigHead(), vector()).first->push_back(um.dist); + if ((um.dist != 0) && (um.dist != um.size - k_ + 1)) kht.insert(um.getUnitigHead(), std::vector()).first->push_back(um.dist); } } } @@ -5565,7 +5565,7 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if (!um.isAbundant && !um.isShort){ um.dist += !um.strand; - if ((um.dist != 0) && (um.dist != um.size - k_ + 1)) kht.insert(um.getUnitigHead(), vector()).first->push_back(um.dist); + if ((um.dist != 0) && (um.dist != um.size - k_ + 1)) kht.insert(um.getUnitigHead(), std::vector()).first->push_back(um.dist); } } } @@ -5592,13 +5592,13 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if ((p.second == 0) && !cm.isAbundant && !cm.isShort){ - if ((cm.dist != 0) && (cm.dist != cm.size - k_ + 1)) kht.insert(cm.getUnitigHead(), vector()).first->push_back(cm.dist); + if ((cm.dist != 0) && (cm.dist != cm.size - k_ + 1)) kht.insert(cm.getUnitigHead(), std::vector()).first->push_back(cm.dist); } else if ((p.second + cm.len == str_seq_len - k_ + 1) && !cm.isAbundant && !cm.isShort){ cm.dist += cm.len; - if ((cm.dist != 0) && (cm.dist != cm.size - k_ + 1)) kht.insert(cm.getUnitigHead(), vector()).first->push_back(cm.dist); + if ((cm.dist != 0) && (cm.dist != cm.size - k_ + 1)) kht.insert(cm.getUnitigHead(), std::vector()).first->push_back(cm.dist); } it_km += cm.len; @@ -5619,30 +5619,30 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if (nxt_pos_insert_v_unitigs < v_unitigs.size()) v_unitigs.resize(nxt_pos_insert_v_unitigs); if (v_kmers_sz < km_unitigs.size()) km_unitigs.resize(v_kmers_sz); - const size_t joined = joinUnitigs_::value>(&v_joins); + const size_t joined = joinUnitigs_::value>(&v_joins); if (verbose){ - cout << "CompactedDBG::mergeUnitig(): Added " << added << " new unitigs to the graph." << endl; - cout << "CompactedDBG::mergeUnitig(): Split " << split_before << " unitigs into " << split_after << " new unitigs." << endl; - cout << "CompactedDBG::mergeUnitig(): Joined " << joined << " unitigs from the graph." << endl; + std::cout << "CompactedDBG::mergeUnitig(): Added " << added << " new unitigs to the graph." << std::endl; + std::cout << "CompactedDBG::mergeUnitig(): Split " << split_before << " unitigs into " << split_after << " new unitigs." << std::endl; + std::cout << "CompactedDBG::mergeUnitig(): Joined " << joined << " unitigs from the graph." << std::endl; } return true; } template -bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbose){ +bool CompactedDBG::annotateSplitUnitig(const std::string& seq, const bool verbose){ if (invalid){ - cerr << "CompactedDBG::annotateSplitUnitig(): Graph is invalid and no sequence can be added to it" << endl; + std::cerr << "CompactedDBG::annotateSplitUnitig(): Graph is invalid and no sequence can be added to it" << std::endl; return false; } if (seq.length() < k_){ - cerr << "CompactedDBG::annotateSplitUnitig(): Input sequence length cannot be less than k = " << k_ << endl; + std::cerr << "CompactedDBG::annotateSplitUnitig(): Input sequence length cannot be less than k = " << k_ << std::endl; return false; } @@ -5656,13 +5656,13 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbo bool prev_found = true; - string curr_unitig; + std::string curr_unitig; const char* str_seq = seq.c_str(); const size_t str_seq_len = seq.length(); - auto add_graph_function = [&](const string& unitig){ + auto add_graph_function = [&](const std::string& unitig){ const char* str_unitig = unitig.c_str(); const size_t len_unitig = unitig.length(); @@ -5688,8 +5688,8 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbo if (cm.isEmpty){ - vector> um_bw(findPredecessors(p.first)); - vector> um_fw(findSuccessors(p.first)); + std::vector> um_bw(findPredecessors(p.first)); + std::vector> um_fw(findSuccessors(p.first)); nb_curr_pred = 0; nb_curr_succ = 0; @@ -5786,17 +5786,17 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbo } template -bool CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g, const bool verbose){ +bool CompactedDBG::annotateSplitUnitig(const std::string& seq, LockGraph& lck_g, const bool verbose){ if (invalid){ - cerr << "CompactedDBG::annotateSplitUnitig(): Graph is invalid and no sequence can be added to it" << endl; + std::cerr << "CompactedDBG::annotateSplitUnitig(): Graph is invalid and no sequence can be added to it" << std::endl; return false; } if (seq.length() < k_){ - cerr << "CompactedDBG::annotateSplitUnitig(): Input sequence length cannot be less than k = " << k_ << endl; + std::cerr << "CompactedDBG::annotateSplitUnitig(): Input sequence length cannot be less than k = " << k_ << std::endl; return false; } @@ -5807,13 +5807,13 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g bool prev_found = true; - string curr_unitig; + std::string curr_unitig; const char* str_seq = seq.c_str(); const size_t str_seq_len = seq.length(); - auto add_graph_function = [&](const string& unitig){ + auto add_graph_function = [&](const std::string& unitig){ const char* str_unitig = unitig.c_str(); const size_t len_unitig = unitig.length(); @@ -5845,8 +5845,8 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g if (cm.isEmpty){ - vector> um_bw(findPredecessors(p.first)); - vector> um_fw(findSuccessors(p.first)); + std::vector> um_bw(findPredecessors(p.first)); + std::vector> um_fw(findSuccessors(p.first)); nb_curr_pred = 0; nb_curr_succ = 0; @@ -6009,7 +6009,7 @@ typename std::enable_if::type CompactedDBG::deleteUnitig_( size_t pos_id_unitig = id_unitig << 32; const size_t mask = MASK_CONTIG_ID | MASK_CONTIG_TYPE; - string str; + std::string str; if (isShort){ @@ -6169,7 +6169,7 @@ typename std::enable_if::type CompactedDBG::deleteUnitig_( size_t pos_id_unitig = id_unitig << 32; const size_t mask = MASK_CONTIG_ID | MASK_CONTIG_TYPE; - string str; + std::string str; if (isShort){ @@ -6264,7 +6264,7 @@ typename std::enable_if::type CompactedDBG::deleteUnitig_( } template -void CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const string& str){ +void CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const std::string& str){ const char* s = str.c_str(); const size_t len = str.size(); @@ -6385,7 +6385,7 @@ void CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant template template typename std::enable_if::type CompactedDBG::extractUnitig_(size_t& pos_v_unitigs, size_t& nxt_pos_insert_v_unitigs, - size_t& v_unitigs_sz, size_t& v_kmers_sz, const vector>& sp){ + size_t& v_unitigs_sz, size_t& v_kmers_sz, const std::vector>& sp){ bool deleted = true; @@ -6398,24 +6398,24 @@ typename std::enable_if::type CompactedDBG::extractUnitig_ //const size_t totalcoverage = unitig->coveragesum - lowpair.second; //const size_t ccov_size = unitig->ccov.size(); - const string str = unitig->getSeq().toString(); + const std::string str = unitig->getSeq().toString(); size_t i = 0; UnitigMap um(pos_v_unitigs, 0, 0, unitig->length(), false, false, true, this); - vector> v_data(sp.size()); + std::vector> v_data(sp.size()); deleted = false; - for (vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit, ++i) { //Iterate over created split unitigs + for (std::vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit, ++i) { //Iterate over created split unitigs um.dist = sit->first; um.len = sit->second - um.dist; if (um.len == 1){ - const string split_str = str.substr(um.dist, um.len + k_ - 1); + const std::string split_str = str.substr(um.dist, um.len + k_ - 1); um.strand = (split_str <= reverse_complement(split_str)); } @@ -6426,17 +6426,17 @@ typename std::enable_if::type CompactedDBG::extractUnitig_ i = 0; - for (vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit, ++i) { //Iterate over created split unitigs + for (std::vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit, ++i) { //Iterate over created split unitigs const size_t len = sit->second - sit->first; //const uint64_t cov_tmp = (totalcoverage * len) / (ccov_size - lowpair.first); // Split unitig coverage const uint64_t cov_tmp = len * CompressedCoverage::getFullCoverage(); - string split_str = str.substr(sit->first, len + k_ - 1); // Split unitig sequence + std::string split_str = str.substr(sit->first, len + k_ - 1); // Split unitig sequence if (len == 1){ - const string split_str_rev = reverse_complement(split_str); + const std::string split_str_rev = reverse_complement(split_str); if (split_str > split_str_rev) split_str = split_str_rev; @@ -6493,7 +6493,7 @@ typename std::enable_if::type CompactedDBG::extractUnitig_ template template typename std::enable_if::type CompactedDBG::extractUnitig_(size_t& pos_v_unitigs, size_t& nxt_pos_insert_v_unitigs, - size_t& v_unitigs_sz, size_t& v_kmers_sz, const vector>& sp){ + size_t& v_unitigs_sz, size_t& v_kmers_sz, const std::vector>& sp){ bool deleted = true; @@ -6506,16 +6506,16 @@ typename std::enable_if::type CompactedDBG::extractUnitig_( //const size_t totalcoverage = unitig->coveragesum - lowpair.second; //const size_t ccov_size = unitig->ccov.size(); - const string str = unitig->getSeq().toString(); + const std::string str = unitig->getSeq().toString(); deleted = false; - for (vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit) { //Iterate over created split unitigs + for (std::vector>::const_iterator sit = sp.begin(); sit != sp.end(); ++sit) { //Iterate over created split unitigs const size_t len = sit->second - sit->first; //const uint64_t cov_tmp = (totalcoverage * len) / (ccov_size - lowpair.first); // Split unitig coverage const uint64_t cov_tmp = len * CompressedCoverage::getFullCoverage(); - const string split_str = str.substr(sit->first, len + k_ - 1); // Split unitig sequence + const std::string split_str = str.substr(sit->first, len + k_ - 1); // Split unitig sequence if (len == 1){ @@ -6669,7 +6669,7 @@ UnitigMap CompactedDBG::find(const Kmer& km, const preAllocMinHashIt // post: All unitigs have a per k-mer coverage of CompressedCoverage::getFullCoverage(). The graph is not // necessarily compacted after calling this function. template -pair CompactedDBG::extractAllUnitigs() { +std::pair CompactedDBG::extractAllUnitigs() { size_t i; size_t split = 0, deleted = 0; @@ -6681,7 +6681,7 @@ pair CompactedDBG::extractAllUnitigs() { if (!it->ccov.isFull()){ - deleteUnitig_::value>(false, true, it.getHash()); + deleteUnitig_::value>(false, true, it.getHash()); ++deleted; } } @@ -6694,7 +6694,7 @@ pair CompactedDBG::extractAllUnitigs() { if (i != v_kmers_sz) swapUnitigs(true, i, v_kmers_sz); - deleteUnitig_::value>(true, false, v_kmers_sz); + deleteUnitig_::value>(true, false, v_kmers_sz); ++deleted; } @@ -6705,9 +6705,9 @@ pair CompactedDBG::extractAllUnitigs() { if (!v_unitigs[i]->getCov().isFull()) { //Coverage not full, unitig must be splitted - vector> sp = v_unitigs[i]->getCov().splittingVector(); + std::vector> sp = v_unitigs[i]->getCov().splittingVector(); - if (extractUnitig_::value>(i, nxt_pos_insert, v_unitigs_sz, v_kmers_sz, sp)) ++deleted; + if (extractUnitig_::value>(i, nxt_pos_insert, v_unitigs_sz, v_kmers_sz, sp)) ++deleted; else { ++split; @@ -6728,9 +6728,9 @@ pair CompactedDBG::extractAllUnitigs() { // post: All unitigs have a per k-mer coverage of CompressedCoverage::getFullCoverage(). The graph is not // necessarily compacted after calling this function. template -pair CompactedDBG::splitAllUnitigs() { +std::pair CompactedDBG::splitAllUnitigs() { - pair p = {0, 0}; + std::pair p = {0, 0}; size_t v_kmers_sz = km_unitigs.size(); size_t v_unitigs_sz = v_unitigs.size(); @@ -6746,7 +6746,7 @@ pair CompactedDBG::splitAllUnitigs() { size_t prev_split_pos = 0; - vector> sp; + std::vector> sp; for (size_t pos = 0; pos < ccov.size(); ++pos){ @@ -6764,7 +6764,7 @@ pair CompactedDBG::splitAllUnitigs() { ++(p.second); ++(p.first); - extractUnitig_::value>(i, nxt_pos_insert, v_unitigs_sz, v_kmers_sz, sp); + extractUnitig_::value>(i, nxt_pos_insert, v_unitigs_sz, v_kmers_sz, sp); } else ++i; } @@ -6776,9 +6776,9 @@ pair CompactedDBG::splitAllUnitigs() { } template -pair CompactedDBG::getSplitInfoAllUnitigs() const { +std::pair CompactedDBG::getSplitInfoAllUnitigs() const { - pair p = {0, 0}; + std::pair p = {0, 0}; const size_t cov_full = CompressedCoverage::getFullCoverage(); @@ -6809,7 +6809,7 @@ pair CompactedDBG::getSplitInfoAllUnitigs() const { } template -void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { +void CompactedDBG::createJoinHT(std::vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { const size_t v_unitigs_size = v_unitigs.size(); const size_t v_kmers_size = km_unitigs.size(); @@ -6936,8 +6936,8 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable } }; - auto worker_v_unitigs = [&joins, &lck, this]( typename vector*>::const_iterator a, - typename vector*>::const_iterator b){ + auto worker_v_unitigs = [&joins, &lck, this]( typename std::vector*>::const_iterator a, + typename std::vector*>::const_iterator b){ for (size_t i = a - v_unitigs.begin(), end = b - v_unitigs.begin(); i != end; ++i) { @@ -6976,9 +6976,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable { typename h_kmers_ccov_t::const_iterator it = h_kmers_ccov.begin(), it_end = h_kmers_ccov.end(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -6993,7 +6993,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); l_it = it; @@ -7016,9 +7016,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable size_t it_km = 0, it_km_end = km_unitigs.size(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it_km; + std::mutex mutex_it_km; for (size_t t = 0; t < nb_threads; ++t){ @@ -7031,12 +7031,12 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it_km); + std::unique_lock lock(mutex_it_km); if (it_km == it_km_end) return; l_it_km = it_km; - it_km = min(it_km + chunk, it_km_end); + it_km = std::min(it_km + chunk, it_km_end); l_it_km_end = it_km; } @@ -7053,9 +7053,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable auto it_unitig = v_unitigs.begin(); auto it_unitig_end = v_unitigs.end(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it_unitig; + std::mutex mutex_it_unitig; for (size_t t = 0; t < nb_threads; ++t){ @@ -7069,7 +7069,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it_unitig); + std::unique_lock lock(mutex_it_unitig); if (it_unitig == it_unitig_end) return; @@ -7128,7 +7128,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable } template -void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { +void CompactedDBG::createJoinHT(std::vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { const size_t v_unitigs_size = v_unitigs.size(); const size_t v_kmers_size = km_unitigs.size(); @@ -7255,8 +7255,8 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable } }; - auto worker_v_unitigs = [&joins, &lck, this]( typename vector*>::const_iterator a, - typename vector*>::const_iterator b){ + auto worker_v_unitigs = [&joins, &lck, this]( typename std::vector*>::const_iterator a, + typename std::vector*>::const_iterator b){ for (size_t i = a - v_unitigs.begin(), end = b - v_unitigs.begin(); i != end; ++i) { @@ -7295,9 +7295,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable { typename h_kmers_ccov_t::const_iterator it = h_kmers_ccov.begin(), it_end = h_kmers_ccov.end(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -7312,7 +7312,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); l_it = it; @@ -7335,9 +7335,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable size_t it_km = 0, it_km_end = km_unitigs.size(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it_km; + std::mutex mutex_it_km; for (size_t t = 0; t < nb_threads; ++t){ @@ -7350,12 +7350,12 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it_km); + std::unique_lock lock(mutex_it_km); if (it_km == it_km_end) return; l_it_km = it_km; - it_km = min(it_km + chunk, it_km_end); + it_km = std::min(it_km + chunk, it_km_end); l_it_km_end = it_km; } @@ -7372,9 +7372,9 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable auto it_unitig = v_unitigs.begin(); auto it_unitig_end = v_unitigs.end(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it_unitig; + std::mutex mutex_it_unitig; for (size_t t = 0; t < nb_threads; ++t){ @@ -7388,7 +7388,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable while (true) { { - unique_lock lock(mutex_it_unitig); + std::unique_lock lock(mutex_it_unitig); if (it_unitig == it_unitig_end) return; @@ -7452,7 +7452,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable // joined is the number of joined unitigs template template -typename std::enable_if::type CompactedDBG::joinUnitigs_(vector* v_joins, const size_t nb_threads) { +typename std::enable_if::type CompactedDBG::joinUnitigs_(std::vector* v_joins, const size_t nb_threads) { size_t joined = 0; size_t cov_full = CompressedCoverage::getFullCoverage(); @@ -7508,15 +7508,15 @@ typename std::enable_if::type CompactedDBG::joinUnitigs_ else continue; //Compute join sequence - string joinSeq; + std::string joinSeq; joinSeq.reserve((len_k_head ? k_ : cmHead.size) + (len_k_tail ? k_ : cmTail.size) - k_ + 1); if (headDir) joinSeq = len_k_head ? cmHead_head.toString() : v_unitigs[cmHead.pos_unitig]->getSeq().toString(); else joinSeq = len_k_head ? cmHead_head.twin().toString() : v_unitigs[cmHead.pos_unitig]->getSeq().rev().toString(); - if (tailDir) joinSeq.append(len_k_tail ? cmTail_head.toString() : v_unitigs[cmTail.pos_unitig]->getSeq().toString(), k_ - 1, string::npos); - else joinSeq.append(len_k_tail ? cmTail_head.twin().toString() : v_unitigs[cmTail.pos_unitig]->getSeq().rev().toString(), k_ - 1, string::npos); + if (tailDir) joinSeq.append(len_k_tail ? cmTail_head.toString() : v_unitigs[cmTail.pos_unitig]->getSeq().toString(), k_ - 1, std::string::npos); + else joinSeq.append(len_k_tail ? cmTail_head.twin().toString() : v_unitigs[cmTail.pos_unitig]->getSeq().rev().toString(), k_ - 1, std::string::npos); Unitig data_tmp; //Store temporarily the new merged data Unitig* unitig; //New unitig @@ -7629,7 +7629,7 @@ typename std::enable_if::type CompactedDBG::joinUnitigs_ template template -typename std::enable_if::type CompactedDBG::joinUnitigs_(vector* v_joins, const size_t nb_threads) { +typename std::enable_if::type CompactedDBG::joinUnitigs_(std::vector* v_joins, const size_t nb_threads) { size_t joined = 0; size_t cov_full = CompressedCoverage::getFullCoverage(); @@ -7685,15 +7685,15 @@ typename std::enable_if::type CompactedDBG::joinUnitigs_( else continue; //Compute join sequence - string joinSeq; + std::string joinSeq; joinSeq.reserve((len_k_head ? k_ : cmHead.size) + (len_k_tail ? k_ : cmTail.size) - k_ + 1); if (headDir) joinSeq = len_k_head ? cmHead_head.toString() : v_unitigs[cmHead.pos_unitig]->getSeq().toString(); else joinSeq = len_k_head ? cmHead_head.twin().toString() : v_unitigs[cmHead.pos_unitig]->getSeq().rev().toString(); - if (tailDir) joinSeq.append(len_k_tail ? cmTail_head.toString() : v_unitigs[cmTail.pos_unitig]->getSeq().toString(), k_ - 1, string::npos); - else joinSeq.append(len_k_tail ? cmTail_head.twin().toString() : v_unitigs[cmTail.pos_unitig]->getSeq().rev().toString(), k_ - 1, string::npos); + if (tailDir) joinSeq.append(len_k_tail ? cmTail_head.toString() : v_unitigs[cmTail.pos_unitig]->getSeq().toString(), k_ - 1, std::string::npos); + else joinSeq.append(len_k_tail ? cmTail_head.twin().toString() : v_unitigs[cmTail.pos_unitig]->getSeq().rev().toString(), k_ - 1, std::string::npos); Unitig* unitig; //New unitig @@ -7796,7 +7796,7 @@ bool CompactedDBG::checkJoin(const Kmer& a, const const_UnitigMap& c size_t i, j, count_succ; - vector> v_um(findSuccessors(a, 2, true)); + std::vector> v_um(findSuccessors(a, 2, true)); for (i = 0, count_succ = 0; i != 4; ++i){ @@ -7847,10 +7847,10 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t size_t v_unitigs_sz = v_unitigs.size(); size_t v_kmers_sz = km_unitigs.size(); - vector> sp; + std::vector> sp; - vector> vv_km(nb_threads); - vector> vv_pres_neigh(nb_threads); + std::vector> vv_km(nb_threads); + std::vector> vv_pres_neigh(nb_threads); { const size_t nb_short_per_thread = (v_kmers_sz + nb_threads - 1) / nb_threads; @@ -7859,9 +7859,9 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t typename h_kmers_ccov_t::iterator its = h_kmers_ccov.begin(); typename h_kmers_ccov_t::iterator ite = h_kmers_ccov.end(); - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_it; + std::mutex mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -7872,13 +7872,13 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t typename h_kmers_ccov_t::iterator lits, lite; const size_t pos_s = t * nb_short_per_thread; - const size_t pos_e = min(v_kmers_sz, (t+1) * nb_short_per_thread); + const size_t pos_e = std::min(v_kmers_sz, (t+1) * nb_short_per_thread); - vector& v_km = vv_km[t]; - vector& v_pres_neigh = vv_pres_neigh[t]; + std::vector& v_km = vv_km[t]; + std::vector& v_pres_neigh = vv_pres_neigh[t]; { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); lits = its; @@ -7890,7 +7890,7 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t while (lits != lite) { const Kmer& km = lits.getKey(); - const string km_str = km.toString(); + const std::string km_str = km.toString(); const uint64_t km_h = km.hash(); minHashIterator it_min(km_str.c_str(), km_str.length(), k_, g_, RepHash(), true); @@ -7932,7 +7932,7 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t for (size_t pos = pos_s; pos < pos_e; ++pos) { const Kmer& km = km_unitigs.getKmer(pos); - const string km_str = km.toString(); + const std::string km_str = km.toString(); const uint64_t km_h = km.hash(); minHashIterator it_min(km_str.c_str(), km_str.length(), k_, g_, RepHash(), true); @@ -7979,8 +7979,8 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t for (size_t t = 0; t < nb_threads; ++t){ - vector& v_km = vv_km[t]; - vector& v_pres_neigh = vv_pres_neigh[t]; + std::vector& v_km = vv_km[t]; + std::vector& v_pres_neigh = vv_pres_neigh[t]; for (size_t i = 0; i < v_km.size(); ++i) { @@ -8005,10 +8005,10 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t if ((cm_bw.dist != 0) && (cm_bw.dist != cm_bw.size - k_ + 1)){ - sp.push_back(make_pair(0, cm_bw.dist)); - sp.push_back(make_pair(cm_bw.dist, cm_bw.size - k_ + 1)); + sp.push_back(std::make_pair(0, cm_bw.dist)); + sp.push_back(std::make_pair(cm_bw.dist, cm_bw.size - k_ + 1)); - extractUnitig_::value>(cm_bw.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); + extractUnitig_::value>(cm_bw.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); sp.clear(); } @@ -8030,10 +8030,10 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t if ((cm_fw.dist != 0) && (cm_fw.dist != cm_fw.size - k_ + 1)){ - sp.push_back(make_pair(0, cm_fw.dist)); - sp.push_back(make_pair(cm_fw.dist, cm_fw.size - k_ + 1)); + sp.push_back(std::make_pair(0, cm_fw.dist)); + sp.push_back(std::make_pair(cm_fw.dist, cm_fw.size - k_ + 1)); - extractUnitig_::value>(cm_fw.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); + extractUnitig_::value>(cm_fw.pos_unitig, nxt_pos_insert_v_unitigs, v_unitigs_sz, v_kmers_sz, sp); sp.clear(); } @@ -8054,7 +8054,7 @@ void CompactedDBG::check_fp_tips(BlockedBloomFilter& bf, const size_t nb_t } template -size_t CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, vector& v){ +size_t CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, std::vector& v){ if (!rmIsolated && !clipTips) return 0; @@ -8209,15 +8209,15 @@ size_t CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, vector< } } - for (j = v_unitigs_sz; j < v_unitigs.size(); ++j) deleteUnitig_::value>(false, false, j); + for (j = v_unitigs_sz; j < v_unitigs.size(); ++j) deleteUnitig_::value>(false, false, j); v_unitigs.resize(v_unitigs_sz); - for (j = v_kmers_sz; j < km_unitigs.size(); ++j) deleteUnitig_::value>(true, false, j); + for (j = v_kmers_sz; j < km_unitigs.size(); ++j) deleteUnitig_::value>(true, false, j); km_unitigs.resize(v_kmers_sz); for (typename h_kmers_ccov_t::iterator it = h_kmers_ccov.begin(); it != h_kmers_ccov.end(); ++it){ - if (it->ccov.size() == 0) deleteUnitig_::value>(false, true, it.getHash()); + if (it->ccov.size() == 0) deleteUnitig_::value>(false, true, it.getHash()); } return removed; @@ -8316,7 +8316,7 @@ void CompactedDBG::unmapRead(const const_UnitigMap& um, LockGraph& l } template -vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_uniq_km, const size_t nb_threads, const bool verbose) { +std::vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_uniq_km, const size_t nb_threads, const bool verbose) { const size_t v_unitigs_sz = v_unitigs.size(); const size_t v_kmers_sz = km_unitigs.size(); @@ -8327,13 +8327,13 @@ vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_ KmerHashTable tips; - vector v_out; + std::vector v_out; for (typename h_kmers_ccov_t::iterator it_ccov = h_kmers_ccov.begin(); it_ccov != h_kmers_ccov.end(); ++it_ccov) { const Kmer km = it_ccov.getKey().rep(); - vector> v_um = findPredecessors(km, true); + std::vector> v_um = findPredecessors(km, true); for (i = 0; (i != 4) && v_um[i].isEmpty; ++i){} @@ -8350,7 +8350,7 @@ vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_ const Kmer km = km_unitigs.getKmer(it_v_km).rep(); - vector> v_um = findPredecessors(km, true); + std::vector> v_um = findPredecessors(km, true); for (i = 0; (i != 4) && v_um[i].isEmpty; ++i){} @@ -8370,7 +8370,7 @@ vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_ const Kmer head = seq.getKmer(0); const Kmer tail = seq.getKmer(seq.size() - k_); - vector> v_um = findPredecessors(head, true); + std::vector> v_um = findPredecessors(head, true); for (i = 0; (i != 4) && v_um[i].isEmpty; ++i){} @@ -8526,17 +8526,17 @@ vector CompactedDBG::extractMercyKmers(const BlockedBloomFilter& bf_ } } - if (verbose) cout << "CompactedDBG::extractMercyKmers(): " << v_out.size() << " k-mers extracted" << endl; + if (verbose) std::cout << "CompactedDBG::extractMercyKmers(): " << v_out.size() << " k-mers extracted" << std::endl; return v_out; } template -size_t CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_t nb_threads, const bool verbose) { +size_t CompactedDBG::joinTips(std::string filename_MBBF_uniq_kmers, const size_t nb_threads, const bool verbose) { if (invalid){ - cerr << "CompactedDBG::joinTips(): Graph is invalid and tips cannot be joined" << endl; + std::cerr << "CompactedDBG::joinTips(): Graph is invalid and tips cannot be joined" << std::endl; return 0; } @@ -8546,7 +8546,7 @@ size_t CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_ if ((f_mbbf = fopen(filename_MBBF_uniq_kmers.c_str(), "rb")) == NULL){ - cerr << "CompactedDBG::joinTips(): Minimizer Blocked Bloom filter file of unique k-mers cannot be opened" << endl; + std::cerr << "CompactedDBG::joinTips(): Minimizer Blocked Bloom filter file of unique k-mers cannot be opened" << std::endl; return 0; } @@ -8554,13 +8554,13 @@ size_t CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_ fclose(f_mbbf); - vector v_mercy_km = extractMercyKmers(mbbf, nb_threads, verbose); + std::vector v_mercy_km = extractMercyKmers(mbbf, nb_threads, verbose); for (const auto& km_mercy : v_mercy_km) addUnitig(km_mercy.rep().toString(), km_unitigs.size()); - size_t nb_join = joinUnitigs_::value>(&v_mercy_km, nb_threads); + size_t nb_join = joinUnitigs_::value>(&v_mercy_km, nb_threads); - if (verbose) cout << "CompactedDBG::joinTips(): " << nb_join << " unitigs have been joined using mercy k-mers" << endl; + if (verbose) std::cout << "CompactedDBG::joinTips(): " << nb_join << " unitigs have been joined using mercy k-mers" << std::endl; return nb_join; } @@ -8572,31 +8572,31 @@ void CompactedDBG::setKmerGmerLength(const int kmer_length, const int mini if (kmer_length <= 2){ - cerr << "CompactedDBG::CompactedDBG(): Length k of k-mers cannot be less than 3" << endl; + std::cerr << "CompactedDBG::CompactedDBG(): Length k of k-mers cannot be less than 3" << std::endl; invalid = true; } if (kmer_length >= MAX_KMER_SIZE){ - cerr << "CompactedDBG::CompactedDBG(): Length k of k-mers cannot exceed or be equal to " << MAX_KMER_SIZE << endl; + std::cerr << "CompactedDBG::CompactedDBG(): Length k of k-mers cannot exceed or be equal to " << MAX_KMER_SIZE << std::endl; invalid = true; } if (minimizer_length == 0){ - cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot be equal to 0" << endl; + std::cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot be equal to 0" << std::endl; invalid = true; } if (minimizer_length >= MAX_GMER_SIZE){ - cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot exceed or be equal to " << MAX_KMER_SIZE << endl; + std::cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot exceed or be equal to " << MAX_KMER_SIZE << std::endl; invalid = true; } if ((minimizer_length > 0) && (minimizer_length > kmer_length - 2)){ - cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot exceed k - 2" << endl; + std::cerr << "CompactedDBG::CompactedDBG(): Length g of minimizers cannot exceed k - 2" << std::endl; invalid = true; } @@ -8627,10 +8627,10 @@ void CompactedDBG::setFullCoverage(const size_t cov) const { template void CompactedDBG::print() const { - cout << "CompactedDBG::print(): v_unitigs.size() = " << v_unitigs.size() << endl; - cout << "CompactedDBG::print(): v_kmers.size() = " << km_unitigs.size() << endl; - cout << "CompactedDBG::print(): h_kmers_ccov.size() = " << h_kmers_ccov.size() << endl; - cout << "CompactedDBG::print(): hmap_min_unitigs.size() = " << hmap_min_unitigs.size() << endl; + std::cout << "CompactedDBG::print(): v_unitigs.size() = " << v_unitigs.size() << std::endl; + std::cout << "CompactedDBG::print(): v_kmers.size() = " << km_unitigs.size() << std::endl; + std::cout << "CompactedDBG::print(): h_kmers_ccov.size() = " << h_kmers_ccov.size() << std::endl; + std::cout << "CompactedDBG::print(): hmap_min_unitigs.size() = " << hmap_min_unitigs.size() << std::endl; } #endif diff --git a/src/CompressedCoverage.cpp b/src/CompressedCoverage.cpp index 4ac7847..42a9116 100755 --- a/src/CompressedCoverage.cpp +++ b/src/CompressedCoverage.cpp @@ -147,21 +147,21 @@ size_t CompressedCoverage::size() const { // use: s = cc.toString(); // post: s contains all important information about cc -string CompressedCoverage::toString() const { +std::string CompressedCoverage::toString() const { bool isPtr = ((asBits & tagMask) == 0); size_t sz = size(); bool full = isFull(); uintptr_t one(1); - string bits(64, '0'); + std::string bits(64, '0'); for (int i = 0; i < 64; i++) { if (asBits & (one << (63-i))) bits[i] = '1'; } - ostringstream info; + std::ostringstream info; if (isPtr) { @@ -171,14 +171,14 @@ string CompressedCoverage::toString() const { info << "Full, size = "; info << sz; - info << endl; + info << std::endl; } else { const uint32_t filled = *(getConst32Pointer() + 1); info << "Non-full, size = " << sz << ", not-filled = "; - info << filled << endl; + info << filled << std::endl; info << "["; for (int i = 0; i < sz; i++) { @@ -188,7 +188,7 @@ string CompressedCoverage::toString() const { info << (int)covAt(i); } - info << "] " << endl; + info << "] " << std::endl; } } else { @@ -199,7 +199,7 @@ string CompressedCoverage::toString() const { info <<" size = " << sz; - info << endl << "["; + info << std::endl << "["; for (int i = 0; i < sz; i++) { @@ -208,7 +208,7 @@ string CompressedCoverage::toString() const { info << (int)covAt(i); } - info << "] " << endl; + info << "] " << std::endl; } return bits + "\n" + info.str(); @@ -360,7 +360,7 @@ uint8_t CompressedCoverage::covAt(const size_t index) const { // pre: // post: low is the number of kmers under coverage limtis // sum is the sum of these low coverages -pair CompressedCoverage::lowCoverageInfo() const { +std::pair CompressedCoverage::lowCoverageInfo() const { if (isFull()) return {0, 0}; @@ -377,7 +377,7 @@ pair CompressedCoverage::lowCoverageInfo() const { sum += (cov < cov_full) * cov; } - return {low, sum}; + return std::make_pair(low, sum); } @@ -388,12 +388,12 @@ pair CompressedCoverage::lowCoverageInfo() const { // and bi < bj if i < j // these pairs are all the fully covered subintervals of the corresponding contig // i.e. [ai,...,bi-1] is fully covered -vector> CompressedCoverage::splittingVector() const { +std::vector> CompressedCoverage::splittingVector() const { size_t a = 0, b = 0; const size_t sz = size(); - vector> v; + std::vector> v; while (b != sz) { // [a,...,b-1] is a fully covered subinterval and (a,b) has been added to v diff --git a/src/CompressedCoverage.hpp b/src/CompressedCoverage.hpp index 2d9cbfe..884f2e9 100755 --- a/src/CompressedCoverage.hpp +++ b/src/CompressedCoverage.hpp @@ -53,8 +53,8 @@ class CompressedCoverage { bool isFull() const; void setFull(); - vector> splittingVector() const; - pair lowCoverageInfo() const; + std::vector> splittingVector() const; + std::pair lowCoverageInfo() const; size_t size() const; std::string toString() const; // for debugging @@ -166,7 +166,7 @@ template struct CompressedCoverage_t { CompressedCoverage_t(size_t sz = 0, bool full = false) : ccov(sz, full) {} CompressedCoverage_t(const CompressedCoverage& c) : ccov(c) {} - CompressedCoverage_t(CompressedCoverage&& c) : ccov(move(c)) {} + CompressedCoverage_t(CompressedCoverage&& c) : ccov(std::move(c)) {} BFG_INLINE const T* getData() const { return &data; } BFG_INLINE T* getData() { return &data; } @@ -179,7 +179,7 @@ template<> struct CompressedCoverage_t { CompressedCoverage_t(size_t sz = 0, bool full = false) : ccov(sz, full) {} CompressedCoverage_t(const CompressedCoverage& c) : ccov(c) {} - CompressedCoverage_t(CompressedCoverage&& c) : ccov(move(c)) {} + CompressedCoverage_t(CompressedCoverage&& c) : ccov(std::move(c)) {} BFG_INLINE const void* getData() const { return nullptr; } BFG_INLINE void* getData() { return nullptr; } diff --git a/src/CompressedSequence.cpp b/src/CompressedSequence.cpp index fa2faef..149e159 100755 --- a/src/CompressedSequence.cpp +++ b/src/CompressedSequence.cpp @@ -4,6 +4,8 @@ #include "CompressedSequence.hpp" #include "Kmer.hpp" +using namespace std; + CompressedSequence::CompressedSequence() { initShort(); diff --git a/src/CompressedSequence.hpp b/src/CompressedSequence.hpp index 5e8d262..bae0026 100755 --- a/src/CompressedSequence.hpp +++ b/src/CompressedSequence.hpp @@ -24,7 +24,7 @@ class CompressedSequence { ~CompressedSequence(); CompressedSequence(const char *s); - CompressedSequence(const string& s); + CompressedSequence(const std::string& s); CompressedSequence(const Kmer& km); CompressedSequence(const CompressedSequence& o); // Copy constructor @@ -45,9 +45,9 @@ class CompressedSequence { void setSequence(const char *s, const size_t offset, const size_t length, const bool reversed = false); void toString(char *s, const size_t offset, const size_t length) const; - string toString(const size_t offset, const size_t length) const; + std::string toString(const size_t offset, const size_t length) const; - BFG_INLINE string toString() const { + BFG_INLINE std::string toString() const { return toString(0, size()); } @@ -58,7 +58,7 @@ class CompressedSequence { } - BFG_INLINE void setSequence(const string& s, const size_t offset, const size_t length, const bool reversed = false) { + BFG_INLINE void setSequence(const std::string& s, const size_t offset, const size_t length, const bool reversed = false) { setSequence(s.c_str(), offset, length, reversed); } diff --git a/src/DataAccessor.hpp b/src/DataAccessor.hpp index 7b7863f..119b5a1 100755 --- a/src/DataAccessor.hpp +++ b/src/DataAccessor.hpp @@ -79,7 +79,7 @@ class DataAccessor : public CDBG_Data_t, DataStorage * @param um is a constant reference to a const_UnitigColorMap object which is a unitig mapping. * @return a vector of string, each string is the name of a color. */ - vector getSubUnitigColorNames(const const_UnitigColorMap& um) const; + std::vector getSubUnitigColorNames(const const_UnitigColorMap& um) const; /** * Join data and colors of two colored unitigs which are going to be concatenated. Specifically, if A is the reference unitig @@ -128,7 +128,7 @@ class DataAccessor : public CDBG_Data_t, DataStorage * associated. * @return a GFA-formatted string which is the serialization of the data. */ - string serialize(const const_UnitigColorMap& um_src) const; + std::string serialize(const const_UnitigColorMap& um_src) const; private: diff --git a/src/DataAccessor.tcc b/src/DataAccessor.tcc index c4014be..2930bba 100755 --- a/src/DataAccessor.tcc +++ b/src/DataAccessor.tcc @@ -98,7 +98,7 @@ UnitigColors DataAccessor::getSubUnitigColors(const const_UnitigColorMap& } template -vector DataAccessor::getSubUnitigColorNames(const const_UnitigColorMap& um) const { +std::vector DataAccessor::getSubUnitigColorNames(const const_UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -107,7 +107,7 @@ vector DataAccessor::getSubUnitigColorNames(const const_UnitigColorMa if (ds != nullptr) return ds->getSubUnitigColorNames(um); } - return vector(); + return std::vector(); } template @@ -138,7 +138,7 @@ void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColor if ((uc_ptr == nullptr) || (head != new_head) || (da_dest->get() == 0)){ // If (da_dest->get() == 0, UnitigColors of um_dest cannot be recycled 'cause new unitig length will be different from the one of um_dest - const pair, pair> p = ds->insert(new_head, um_dest.size + um_src.size - um_dest.getGraph()->getK() + 1); + const std::pair, std::pair> p = ds->insert(new_head, um_dest.size + um_src.size - um_dest.getGraph()->getK() + 1); uc_ptr = p.second.first; data_ptr = p.second.second; @@ -150,8 +150,8 @@ void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColor *da_dest = DataAccessor(0); } - *uc_ptr = move(uc_); - *data_ptr = move(data_); + *uc_ptr = std::move(uc_); + *data_ptr = std::move(data_); } } @@ -181,7 +181,7 @@ inline void DataAccessor::concat(const UnitigColorMap& um_dest, cons if ((uc_ptr == nullptr) || (head != new_head) || (da_dest->get() == 0)){ // // If (da_dest->get() == 0, UnitigColors of um_dest cannot be recycled 'cause new unitig length will be different from the one of um_dest - const pair, pair> p = ds->insert(new_head, um_dest.size + um_src.size - um_dest.getGraph()->getK() + 1); + const std::pair, std::pair> p = ds->insert(new_head, um_dest.size + um_src.size - um_dest.getGraph()->getK() + 1); uc_ptr = p.second.first; *this = p.first; @@ -194,7 +194,7 @@ inline void DataAccessor::concat(const UnitigColorMap& um_dest, cons *da_dest = DataAccessor(0); } - *uc_ptr = move(uc_); + *uc_ptr = std::move(uc_); } } @@ -221,7 +221,7 @@ void DataAccessor::merge(const UnitigColorMap& um_dest, const const_Unitig um.strand = true; // Insert new UnitigColors and data for reference unitig of um_dest - const pair, pair> p = ds->insert(um); + const std::pair, std::pair> p = ds->insert(um); uc_dest = p.second.first; // Set the new UnitigColors data_dest = p.second.second; // Set the new data @@ -252,7 +252,7 @@ inline void DataAccessor::merge(const UnitigColorMap& um_dest, const um.strand = true; // Insert new UnitigColors for reference unitig of um_dest - const pair, pair> p = ds->insert(um); + const std::pair, std::pair> p = ds->insert(um); uc_dest = p.second.first; // Set the new UnitigColors *this = p.first; // Set the new DataAccessor to locate new UnitigColors @@ -267,13 +267,13 @@ void DataAccessor::extract(const UnitigColorMap& um_src, const bool last_e DataStorage* ds = um_src.getGraph()->getData(); // Get DataStorage where the UnitigColors and data are stored - const pair, pair> p = ds->insert(um_src); // Insert new UnitigColors + data associated with that mapping + const std::pair, std::pair> p = ds->insert(um_src); // Insert new UnitigColors + data associated with that mapping if (ds->getUnitigColors(um_src) != nullptr){ // If reference unitig of um_src has a UnitigColors associated UnitigColors new_cs = ds->getSubUnitigColors(um_src); // Extract colors for k-mer positions matching mapping of um_src - if (!new_cs.isEmpty()) *(p.second.first) = move(new_cs); // Move extracted colors to new (inserted) UnitigColors + if (!new_cs.isEmpty()) *(p.second.first) = std::move(new_cs); // Move extracted colors to new (inserted) UnitigColors } U* new_data = p.second.second; // Get new data slot @@ -294,35 +294,35 @@ inline void DataAccessor::extract(const UnitigColorMap& um_src, cons if (!new_cs.isEmpty()){ // If some colors were extracted - const pair, pair> p = ds->insert(um_src); // Insert new UnitigColors associated with that mapping + const std::pair, std::pair> p = ds->insert(um_src); // Insert new UnitigColors associated with that mapping - *(p.second.first) = move(new_cs); // Move extracted colors to new (inserted) UnitigColors + *(p.second.first) = std::move(new_cs); // Move extracted colors to new (inserted) UnitigColors *this = p.first; // Set the new DataAccessor to locate new UnitigColors } } } template -string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { +std::string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { - string da_str("DA:Z:" + std::to_string(da_id)); + std::string da_str("DA:Z:" + std::to_string(da_id)); const U* data_src = um_src.getData()->getData(um_src); if (data_src != nullptr) { - const string data_str(data_src->serialize(um_src)); + const std::string data_str(data_src->serialize(um_src)); - if (!data_str.empty()) da_str += string('\t' + data_str); + if (!data_str.empty()) da_str += std::string('\t' + data_str); } return da_str; } template<> -inline string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { +inline std::string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { - return string("DA:Z:" + std::to_string(da_id)); + return std::string("DA:Z:" + std::to_string(da_id)); } #endif diff --git a/src/DataStorage.hpp b/src/DataStorage.hpp index 568808d..6615f18 100755 --- a/src/DataStorage.hpp +++ b/src/DataStorage.hpp @@ -16,9 +16,9 @@ template using const_UnitigColorMap = const_UnitigMap - struct hash> { + struct hash> { - size_t operator()(pair const& p) const { + size_t operator()(std::pair const& p) const { return (2 * p.second + 1) * p.first.hash(); } @@ -36,7 +36,7 @@ class DataStorage { typedef Unitig_data_t U; DataStorage(); - DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const vector& color_names_); + DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const std::vector& color_names_); DataStorage(const DataStorage& o); DataStorage(DataStorage&& o); @@ -55,10 +55,10 @@ class DataStorage { UnitigColors getSubUnitigColors(const const_UnitigColorMap& um) const; - vector getSubUnitigColorNames(const const_UnitigColorMap& um) const; + std::vector getSubUnitigColorNames(const const_UnitigColorMap& um) const; - bool write(const string& prefix_output_fn, const bool verbose = false) const; - bool read(const string& color_fn, const size_t nb_threads = 1, const bool verbose = false); + bool write(const std::string& prefix_output_fn, const bool verbose = false) const; + bool read(const std::string& color_fn, const size_t nb_threads = 1, const bool verbose = false); bool addUnitigColors(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src); UnitigColors joinUnitigColors(const const_UnitigColorMap& um_dest, const const_UnitigColorMap& um_src) const; @@ -69,8 +69,8 @@ class DataStorage { uint64_t getHash(const UnitigColorMap& um) const; - pair, pair> insert(const UnitigColorMap& um, const bool force_overflow = false); - pair, pair> insert(const Kmer head_unitig, const size_t unitig_sz, const bool force_overflow = false); + std::pair, std::pair> insert(const UnitigColorMap& um, const bool force_overflow = false); + std::pair, std::pair> insert(const Kmer head_unitig, const size_t unitig_sz, const bool force_overflow = false); void remove(const UnitigColorMap& um_dest); @@ -80,7 +80,7 @@ class DataStorage { void releaseMemory(); - pair, UnitigColors*> insert_(const Kmer head_unitig, const size_t unitig_sz, const bool force_overflow = false); + std::pair, UnitigColors*> insert_(const Kmer head_unitig, const size_t unitig_sz, const bool force_overflow = false); size_t nb_seeds; @@ -95,15 +95,15 @@ class DataStorage { UnitigColors* color_sets; UnitigColors::SharedUnitigColors* shared_color_sets; - atomic* unitig_cs_link; + std::atomic* unitig_cs_link; U* data; - unordered_map, size_t> overflow; + std::unordered_map, size_t> overflow; - mutable mutex mutex_overflow; + mutable std::mutex mutex_overflow; - vector color_names; + std::vector color_names; }; #endif diff --git a/src/DataStorage.tcc b/src/DataStorage.tcc index 22967c9..6a0e80e 100755 --- a/src/DataStorage.tcc +++ b/src/DataStorage.tcc @@ -13,7 +13,7 @@ DataStorage::DataStorage() : color_sets(nullptr), shared_color_sets(nullptr), } template -DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const vector& color_names_) : +DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const std::vector& color_names_) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), nb_seeds(nb_seeds_), nb_cs(sz_cs_), sz_cs(sz_cs_), sz_shared_cs(0), pos_empty_cs(0), color_names(color_names_) { @@ -27,14 +27,14 @@ DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const v for (size_t i = 0; i != 256; ++i) seeds[i] = distribution(generator); //Initialize the hash function seeds color_sets = new UnitigColors[sz_cs]; - unitig_cs_link = new atomic[sz_unitig_cs_link]; + unitig_cs_link = new std::atomic[sz_unitig_cs_link]; data = new U[sz_cs]; for (size_t i = 0; i != sz_unitig_cs_link; ++i) unitig_cs_link[i] = 0; } template<> -inline DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const vector& color_names_) : +inline DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const std::vector& color_names_) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), nb_seeds(nb_seeds_), nb_cs(sz_cs_), sz_cs(sz_cs_), sz_shared_cs(0), pos_empty_cs(0), color_names(color_names_) { @@ -48,7 +48,7 @@ inline DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs for (int i = 0; i < 256; ++i) seeds[i] = distribution(generator); //Initialize the hash function seeds color_sets = new UnitigColors[sz_cs]; - unitig_cs_link = new atomic[sz_unitig_cs_link]; + unitig_cs_link = new std::atomic[sz_unitig_cs_link]; for (size_t i = 0; i != sz_unitig_cs_link; ++i) unitig_cs_link[i] = 0; } @@ -76,7 +76,7 @@ DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_ const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != sz_link; ++i) unitig_cs_link[i] = o.sz_link[i].load(); } @@ -112,7 +112,7 @@ inline DataStorage::DataStorage(const DataStorage& o) : color_sets(nullp const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != sz_link; ++i) unitig_cs_link[i] = o.unitig_cs_link[i].load(); } @@ -120,9 +120,9 @@ inline DataStorage::DataStorage(const DataStorage& o) : color_sets(nullp template DataStorage::DataStorage(DataStorage&& o) : color_sets(o.color_sets), shared_color_sets(o.shared_color_sets), data(o.data), - unitig_cs_link(o.unitig_cs_link), overflow(move(o.overflow)), nb_seeds(o.nb_seeds), + unitig_cs_link(o.unitig_cs_link), overflow(std::move(o.overflow)), nb_seeds(o.nb_seeds), nb_cs(o.nb_cs), sz_cs(o.sz_cs), sz_shared_cs(o.sz_shared_cs), pos_empty_cs(o.pos_empty_cs), - color_names(move(o.color_names)) { + color_names(std::move(o.color_names)) { memcpy(seeds, o.seeds, 256 * sizeof(uint64_t)); @@ -241,7 +241,7 @@ DataStorage& DataStorage::operator=(const DataStorage& o) { const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != sz_link; ++i) unitig_cs_link[i] = o.unitig_cs_link[i].load(); } @@ -286,7 +286,7 @@ inline DataStorage& DataStorage::operator=(const DataStorage& o) { const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != sz_link; ++i) unitig_cs_link[i] = o.unitig_cs_link[i].load(); } @@ -307,9 +307,9 @@ DataStorage& DataStorage::operator=(DataStorage&& o) { sz_shared_cs = o.sz_shared_cs; pos_empty_cs = o.pos_empty_cs; - color_names = move(o.color_names); + color_names = std::move(o.color_names); - overflow = move(o.overflow); + overflow = std::move(o.overflow); color_sets = o.color_sets; shared_color_sets = o.shared_color_sets; @@ -342,9 +342,9 @@ inline DataStorage& DataStorage::operator=(DataStorage&& o) { sz_shared_cs = o.sz_shared_cs; pos_empty_cs = o.pos_empty_cs; - color_names = move(o.color_names); + color_names = std::move(o.color_names); - overflow = move(o.overflow); + overflow = std::move(o.overflow); color_sets = o.color_sets; shared_color_sets = o.shared_color_sets; @@ -372,9 +372,9 @@ const UnitigColors* DataStorage::getUnitigColors(const const_UnitigColorMap lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); if (it != overflow.end()) return &color_sets[it->second]; } else return &(color_sets[head.hash(seeds[da_id - 1]) % nb_cs]); @@ -393,9 +393,9 @@ UnitigColors* DataStorage::getUnitigColors(const UnitigColorMap& um) { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::iterator it = overflow.find({head, um.size}); if (it != overflow.end()) return &color_sets[it->second]; } else return &(color_sets[head.hash(seeds[da_id - 1]) % nb_cs]); @@ -414,9 +414,9 @@ const U* DataStorage::getData(const const_UnitigColorMap& um) const { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); if (it != overflow.end()) return &data[it->second]; } else return &(data[head.hash(seeds[da_id - 1]) % nb_cs]); @@ -440,9 +440,9 @@ U* DataStorage::getData(const UnitigColorMap& um) { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::iterator it = overflow.find({head, um.size}); if (it != overflow.end()) return &data[it->second]; } else return &(data[head.hash(seeds[da_id - 1]) % nb_cs]); @@ -510,9 +510,9 @@ UnitigColors DataStorage::getSubUnitigColors(const const_UnitigColorMap& u } template -vector DataStorage::getSubUnitigColorNames(const const_UnitigColorMap& um) const { +std::vector DataStorage::getSubUnitigColorNames(const const_UnitigColorMap& um) const { - vector v_out; + std::vector v_out; if (!um.isEmpty && (color_sets != nullptr)){ @@ -531,30 +531,30 @@ vector DataStorage::getSubUnitigColorNames(const const_UnitigColorMap } template -bool DataStorage::write(const string& prefix_output_fn, const bool verbose) const { +bool DataStorage::write(const std::string& prefix_output_fn, const bool verbose) const { - if (verbose) cout << endl << "DataStorage::write(): Writing colors to disk" << endl; + if (verbose) std::cout << std::endl << "DataStorage::write(): Writing colors to disk" << std::endl; - const string out = prefix_output_fn + ".color.bfg"; + const std::string out = prefix_output_fn + ".color.bfg"; FILE* fp = fopen(out.c_str(), "wb"); if (fp == NULL) { - cerr << "DataStorage::write(): Could not open file " << out << " for writing color sets" << endl; + std::cerr << "DataStorage::write(): Could not open file " << out << " for writing color sets" << std::endl; return false; } else { fclose(fp); - if (std::remove(out.c_str()) != 0) cerr << "DataStorage::write(): Could not remove temporary file " << out << endl; + if (std::remove(out.c_str()) != 0) std::cerr << "DataStorage::write(): Could not remove temporary file " << out << std::endl; } - ofstream colorsfile_out; - ostream colors_out(nullptr); + std::ofstream colorsfile_out; + std::ostream colors_out(nullptr); - colorsfile_out.open(out.c_str(), ios_base::out | ios_base::binary); + colorsfile_out.open(out.c_str(), std::ios_base::out | std::ios_base::binary); colors_out.rdbuf(colorsfile_out.rdbuf()); //colors_out.sync_with_stdio(false); @@ -566,9 +566,9 @@ bool DataStorage::write(const string& prefix_output_fn, const bool verbose) c const char nl = '\n'; - streampos pos_f_cs; + std::streampos pos_f_cs; - vector v_pos_f_cs; + std::vector v_pos_f_cs; //Write the file format version number if (colors_out.good()) colors_out.write(reinterpret_cast(&format_version), sizeof(size_t)); @@ -596,12 +596,12 @@ bool DataStorage::write(const string& prefix_output_fn, const bool verbose) c for (size_t i = 0; (i < nb_pos_shared_cs) && colors_out.good(); ++i){ // Reserve space to write positions in file of shared colorsets blocks - colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(streampos)); + colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(std::streampos)); } for (size_t i = 0; (i < nb_pos_cs) && colors_out.good(); ++i){ // Reserve space to write positions in file of non-shared colorsets blocks - colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(streampos)); + colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(std::streampos)); } for (size_t i = 0; (i < nb_colors) && colors_out.good(); ++i){ @@ -633,8 +633,8 @@ bool DataStorage::write(const string& prefix_output_fn, const bool verbose) c color_sets[i].write(colors_out, false); //Write the color sets } - unordered_map, size_t>::const_iterator it(overflow.begin()); - const unordered_map, size_t>::const_iterator it_end(overflow.end()); + std::unordered_map, size_t>::const_iterator it(overflow.begin()); + const std::unordered_map, size_t>::const_iterator it_end(overflow.end()); for (; (it != it_end) && colors_out.good(); ++it){ @@ -648,7 +648,7 @@ bool DataStorage::write(const string& prefix_output_fn, const bool verbose) c colors_out.seekp(pos_f_cs); // Re-position cursor to array of position of shared color sets at the beginning - if (colors_out.good()) colors_out.write(reinterpret_cast(&v_pos_f_cs[0]), v_pos_f_cs.size() * sizeof(streampos)); + if (colors_out.good()) colors_out.write(reinterpret_cast(&v_pos_f_cs[0]), v_pos_f_cs.size() * sizeof(std::streampos)); } const bool ret = colors_out.good(); @@ -659,30 +659,30 @@ bool DataStorage::write(const string& prefix_output_fn, const bool verbose) c } template<> -inline bool DataStorage::write(const string& prefix_output_fn, const bool verbose) const { +inline bool DataStorage::write(const std::string& prefix_output_fn, const bool verbose) const { - if (verbose) cout << endl << "DataStorage::write(): Writing colors to disk" << endl; + if (verbose) std::cout << std::endl << "DataStorage::write(): Writing colors to disk" << std::endl; - const string out = prefix_output_fn + ".color.bfg"; + const std::string out = prefix_output_fn + ".color.bfg"; FILE* fp = fopen(out.c_str(), "wb"); if (fp == NULL) { - cerr << "DataStorage::write(): Could not open file " << out << " for writing color sets" << endl; + std::cerr << "DataStorage::write(): Could not open file " << out << " for writing color sets" << std::endl; return false; } else { fclose(fp); - if (std::remove(out.c_str()) != 0) cerr << "DataStorage::write(): Could not remove temporary file " << out << endl; + if (std::remove(out.c_str()) != 0) std::cerr << "DataStorage::write(): Could not remove temporary file " << out << std::endl; } - ofstream colorsfile_out; - ostream colors_out(nullptr); + std::ofstream colorsfile_out; + std::ostream colors_out(nullptr); - colorsfile_out.open(out.c_str(), ios_base::out | ios_base::binary); + colorsfile_out.open(out.c_str(), std::ios_base::out | std::ios_base::binary); colors_out.rdbuf(colorsfile_out.rdbuf()); //colors_out.sync_with_stdio(false); @@ -694,9 +694,9 @@ inline bool DataStorage::write(const string& prefix_output_fn, const bool const char nl = '\n'; - streampos pos_f_cs; + std::streampos pos_f_cs; - vector v_pos_f_cs; + std::vector v_pos_f_cs; //Write the file format version number if (colors_out.good()) colors_out.write(reinterpret_cast(&format_version), sizeof(size_t)); @@ -724,12 +724,12 @@ inline bool DataStorage::write(const string& prefix_output_fn, const bool for (size_t i = 0; (i < nb_pos_shared_cs) && colors_out.good(); ++i){ // Reserve space to write positions in file of shared colorsets blocks - colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(streampos)); + colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(std::streampos)); } for (size_t i = 0; (i < nb_pos_cs) && colors_out.good(); ++i){ // Reserve space to write positions in file of non-shared colorsets blocks - colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(streampos)); + colors_out.write(reinterpret_cast(&pos_f_cs), sizeof(std::streampos)); } for (size_t i = 0; (i < nb_colors) && colors_out.good(); ++i){ @@ -761,8 +761,8 @@ inline bool DataStorage::write(const string& prefix_output_fn, const bool color_sets[i].write(colors_out, false); //Write the color sets } - unordered_map, size_t>::const_iterator it(overflow.begin()); - const unordered_map, size_t>::const_iterator it_end(overflow.end()); + std::unordered_map, size_t>::const_iterator it(overflow.begin()); + const std::unordered_map, size_t>::const_iterator it_end(overflow.end()); for (; (it != it_end) && colors_out.good(); ++it){ @@ -776,7 +776,7 @@ inline bool DataStorage::write(const string& prefix_output_fn, const bool colors_out.seekp(pos_f_cs); // Re-position cursor to array of position of shared color sets at the beginning - if (colors_out.good()) colors_out.write(reinterpret_cast(&v_pos_f_cs[0]), v_pos_f_cs.size() * sizeof(streampos)); + if (colors_out.good()) colors_out.write(reinterpret_cast(&v_pos_f_cs[0]), v_pos_f_cs.size() * sizeof(std::streampos)); } const bool ret = colors_out.good(); @@ -787,20 +787,20 @@ inline bool DataStorage::write(const string& prefix_output_fn, const bool } template -bool DataStorage::read(const string& color_fn, const size_t nb_threads, const bool verbose) { +bool DataStorage::read(const std::string& color_fn, const size_t nb_threads, const bool verbose) { - if (verbose) cout << endl << "DataStorage::read(): Reading color sets from disk" << endl; + if (verbose) std::cout << std::endl << "DataStorage::read(): Reading color sets from disk" << std::endl; FILE* fp = fopen(color_fn.c_str(), "rb"); if (fp == NULL) { - cerr << "DataStorage::read(): Could not open file " << color_fn << " for reading color sets" << endl; + std::cerr << "DataStorage::read(): Could not open file " << color_fn << " for reading color sets" << std::endl; return false; } else fclose(fp); - auto readSharedColorSets = [](UnitigColors::SharedUnitigColors* shared_color_sets, istream& colors_in, const size_t sz){ + auto readSharedColorSets = [](UnitigColors::SharedUnitigColors* shared_color_sets, std::istream& colors_in, const size_t sz){ for (size_t i = 0; (i < sz) && colors_in.good(); ++i){ @@ -811,7 +811,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const } }; - auto readColorSets = [](UnitigColors* color_sets, istream& colors_in, const size_t sz){ + auto readColorSets = [](UnitigColors* color_sets, std::istream& colors_in, const size_t sz){ for (size_t i = 0; (i < sz) && colors_in.good(); ++i) color_sets[i].read(colors_in); }; @@ -820,10 +820,10 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const size_t format_version, overflow_sz, nb_colors; - ifstream colorsfile_in; - istream colors_in(nullptr); + std::ifstream colorsfile_in; + std::istream colors_in(nullptr); - colorsfile_in.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in.rdbuf(colorsfile_in.rdbuf()); clear(); @@ -845,18 +845,18 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const if (nb_seeds >= 256){ - cerr << "DataStorage::read(): Does not support more than 255 hash seeds" << endl; + std::cerr << "DataStorage::read(): Does not support more than 255 hash seeds" << std::endl; return false; } if (format_version < 3) { // Color files v1 and v2 are incompatible with Bifrost v1.0.6.2 and versions onward - stringstream ss_bfg_version(string(BFG_VERSION)); - string segment; + std::stringstream ss_bfg_version(std::string(BFG_VERSION)); + std::string segment; - vector seglist; + std::vector seglist; - while(getline(ss_bfg_version, segment, '.')) seglist.push_back(atoi(segment.c_str())); + while(std::getline(ss_bfg_version, segment, '.')) seglist.push_back(atoi(segment.c_str())); const size_t len_bfg_v = seglist.size(); @@ -882,18 +882,18 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const if (!compatible) { - cerr << "DataStorage::read(): Color files v1 and v2 (computed prior to Bifrost v1.0.6.2) are incompatible with Bifrost v1.0.6.2 and versions onward." << endl; + std::cerr << "DataStorage::read(): Color files v1 and v2 (computed prior to Bifrost v1.0.6.2) are incompatible with Bifrost v1.0.6.2 and versions onward." << std::endl; return false; } } const size_t sz_unitig_cs_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - overflow = unordered_map, size_t>(overflow_sz); + overflow = std::unordered_map, size_t>(overflow_sz); color_sets = new UnitigColors[sz_cs]; shared_color_sets = new UnitigColors::SharedUnitigColors[sz_shared_cs]; - unitig_cs_link = new atomic[sz_unitig_cs_link]; + unitig_cs_link = new std::atomic[sz_unitig_cs_link]; data = new U[sz_cs]; //Read the hash function seeds of the graph @@ -903,7 +903,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const for (size_t i = 0; (i < nb_colors) && colors_in.good(); ++i){ //Read the hash function seeds of the graph - color_names.push_back(string()); + color_names.push_back(std::string()); getline(colors_in, color_names[i]); } @@ -920,7 +920,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const size_t block_sz = 0; - streampos* pos_f_cs = nullptr; + std::streampos* pos_f_cs = nullptr; //Read the hash function seeds of the graph if (colors_in.good()) colors_in.read(reinterpret_cast(&block_sz), sizeof(size_t)); @@ -931,14 +931,14 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const if (pos_f_cs_sz != 0){ - pos_f_cs = new streampos[pos_f_cs_sz]; + pos_f_cs = new std::streampos[pos_f_cs_sz]; - if (colors_in.good()) colors_in.read(reinterpret_cast(pos_f_cs), pos_f_cs_sz * sizeof(streampos)); + if (colors_in.good()) colors_in.read(reinterpret_cast(pos_f_cs), pos_f_cs_sz * sizeof(std::streampos)); } for (size_t i = 0; (i < nb_colors) && colors_in.good(); ++i){ //Read the hash function seeds of the graph - color_names.push_back(string()); + color_names.push_back(std::string()); getline(colors_in, color_names[i]); } @@ -955,13 +955,13 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const } else { - streampos colors_in_pos = colors_in.tellg(); + std::streampos colors_in_pos = colors_in.tellg(); colorsfile_in.close(); - mutex m_colors_in_pos; + std::mutex m_colors_in_pos; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them std::atomic i; @@ -973,10 +973,10 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const [&]{ - ifstream colorsfile_in_t; - istream colors_in_t(nullptr); + std::ifstream colorsfile_in_t; + std::istream colors_in_t(nullptr); - colorsfile_in_t.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in_t.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in_t.rdbuf(colorsfile_in_t.rdbuf()); while (true) { @@ -985,12 +985,12 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const if (l_i >= nb_pos_shared_cs){ - const streampos colors_in_t_pos = colors_in_t.tellg(); + const std::streampos colors_in_t_pos = colors_in_t.tellg(); { - unique_lock lock(m_colors_in_pos); + std::unique_lock lock(m_colors_in_pos); - colors_in_pos = max(colors_in_pos, colors_in_t_pos); + colors_in_pos = std::max(colors_in_pos, colors_in_t_pos); } colorsfile_in_t.close(); @@ -999,7 +999,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const } colors_in_t.seekg(pos_f_cs[l_i]); - readSharedColorSets(shared_color_sets + (l_i * block_sz), colors_in_t, min(block_sz, sz_shared_cs - (l_i * block_sz))); + readSharedColorSets(shared_color_sets + (l_i * block_sz), colors_in_t, std::min(block_sz, sz_shared_cs - (l_i * block_sz))); } } ); @@ -1017,10 +1017,10 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const [&]{ - ifstream colorsfile_in_t; - istream colors_in_t(nullptr); + std::ifstream colorsfile_in_t; + std::istream colors_in_t(nullptr); - colorsfile_in_t.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in_t.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in_t.rdbuf(colorsfile_in_t.rdbuf()); while (true) { @@ -1029,12 +1029,12 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const if (l_i >= pos_f_cs_sz){ - const streampos colors_in_t_pos = colors_in_t.tellg(); + const std::streampos colors_in_t_pos = colors_in_t.tellg(); { - unique_lock lock(m_colors_in_pos); + std::unique_lock lock(m_colors_in_pos); - colors_in_pos = max(colors_in_pos, colors_in_t_pos); + colors_in_pos = std::max(colors_in_pos, colors_in_t_pos); } colorsfile_in_t.close(); @@ -1046,7 +1046,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const l_i -= nb_pos_shared_cs; - readColorSets(color_sets + (l_i * block_sz), colors_in_t, min(block_sz, sz_cs - (l_i * block_sz))); + readColorSets(color_sets + (l_i * block_sz), colors_in_t, std::min(block_sz, sz_cs - (l_i * block_sz))); } } ); @@ -1054,7 +1054,7 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const for (auto& t : workers) t.join(); - colorsfile_in.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in.rdbuf(colorsfile_in.rdbuf()); colors_in.seekg(colors_in_pos); } @@ -1080,20 +1080,20 @@ bool DataStorage::read(const string& color_fn, const size_t nb_threads, const } template<> -inline bool DataStorage::read(const string& color_fn, const size_t nb_threads, const bool verbose) { +inline bool DataStorage::read(const std::string& color_fn, const size_t nb_threads, const bool verbose) { - if (verbose) cout << endl << "DataStorage::read(): Reading color sets from disk" << endl; + if (verbose) std::cout << std::endl << "DataStorage::read(): Reading color sets from disk" << std::endl; FILE* fp = fopen(color_fn.c_str(), "rb"); if (fp == NULL) { - cerr << "DataStorage::read(): Could not open file " << color_fn << " for reading color sets" << endl; + std::cerr << "DataStorage::read(): Could not open file " << color_fn << " for reading color sets" << std::endl; return false; } else fclose(fp); - auto readSharedColorSets = [](UnitigColors::SharedUnitigColors* shared_color_sets, istream& colors_in, const size_t sz){ + auto readSharedColorSets = [](UnitigColors::SharedUnitigColors* shared_color_sets, std::istream& colors_in, const size_t sz){ for (size_t i = 0; (i < sz) && colors_in.good(); ++i){ @@ -1104,7 +1104,7 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre } }; - auto readColorSets = [](UnitigColors* color_sets, istream& colors_in, const size_t sz){ + auto readColorSets = [](UnitigColors* color_sets, std::istream& colors_in, const size_t sz){ for (size_t i = 0; (i < sz) && colors_in.good(); ++i) color_sets[i].read(colors_in); }; @@ -1113,10 +1113,10 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre size_t format_version, overflow_sz, nb_colors; - ifstream colorsfile_in; - istream colors_in(nullptr); + std::ifstream colorsfile_in; + std::istream colors_in(nullptr); - colorsfile_in.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in.rdbuf(colorsfile_in.rdbuf()); clear(); @@ -1138,18 +1138,18 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre if (nb_seeds >= 256){ - cerr << "DataStorage::read(): Does not support more than 255 hash seeds" << endl; + std::cerr << "DataStorage::read(): Does not support more than 255 hash seeds" << std::endl; return false; } if (format_version < 3) { // Color files v1 and v2 are incompatible with Bifrost v1.0.6.2 and versions onward - stringstream ss_bfg_version(string(BFG_VERSION)); - string segment; + std::stringstream ss_bfg_version(std::string(BFG_VERSION)); + std::string segment; - vector seglist; + std::vector seglist; - while(getline(ss_bfg_version, segment, '.')) seglist.push_back(atoi(segment.c_str())); + while(std::getline(ss_bfg_version, segment, '.')) seglist.push_back(atoi(segment.c_str())); const size_t len_bfg_v = seglist.size(); @@ -1175,18 +1175,18 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre if (!compatible) { - cerr << "DataStorage::read(): Color files v1 and v2 (computed prior to Bifrost v1.0.6.2) are incompatible with Bifrost v1.0.6.2 and versions onward." << endl; + std::cerr << "DataStorage::read(): Color files v1 and v2 (computed prior to Bifrost v1.0.6.2) are incompatible with Bifrost v1.0.6.2 and versions onward." << std::endl; return false; } } const size_t sz_unitig_cs_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - overflow = unordered_map, size_t>(overflow_sz); + overflow = std::unordered_map, size_t>(overflow_sz); color_sets = new UnitigColors[sz_cs]; shared_color_sets = new UnitigColors::SharedUnitigColors[sz_shared_cs]; - unitig_cs_link = new atomic[sz_unitig_cs_link]; + unitig_cs_link = new std::atomic[sz_unitig_cs_link]; //Read the hash function seeds of the graph colors_in.read(reinterpret_cast(seeds), nb_seeds * sizeof(uint64_t)); @@ -1195,8 +1195,8 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre for (size_t i = 0; (i < nb_colors) && colors_in.good(); ++i){ //Read the hash function seeds of the graph - color_names.push_back(string()); - getline(colors_in, color_names[i]); + color_names.push_back(std::string()); + std::getline(colors_in, color_names[i]); } for (uint64_t i = 0, e; (i != sz_unitig_cs_link) && colors_in.good(); ++i){ @@ -1212,7 +1212,7 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre size_t block_sz = 0; - streampos* pos_f_cs = nullptr; + std::streampos* pos_f_cs = nullptr; //Read the hash function seeds of the graph if (colors_in.good()) colors_in.read(reinterpret_cast(&block_sz), sizeof(size_t)); @@ -1223,15 +1223,15 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre if (pos_f_cs_sz != 0){ - pos_f_cs = new streampos[pos_f_cs_sz]; + pos_f_cs = new std::streampos[pos_f_cs_sz]; - if (colors_in.good()) colors_in.read(reinterpret_cast(pos_f_cs), pos_f_cs_sz * sizeof(streampos)); + if (colors_in.good()) colors_in.read(reinterpret_cast(pos_f_cs), pos_f_cs_sz * sizeof(std::streampos)); } for (size_t i = 0; (i < nb_colors) && colors_in.good(); ++i){ //Read the hash function seeds of the graph - color_names.push_back(string()); - getline(colors_in, color_names[i]); + color_names.push_back(std::string()); + std::getline(colors_in, color_names[i]); } for (uint64_t i = 0, e; (i != sz_unitig_cs_link) && colors_in.good(); ++i){ @@ -1247,13 +1247,13 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre } else { - streampos colors_in_pos = colors_in.tellg(); + std::streampos colors_in_pos = colors_in.tellg(); colorsfile_in.close(); - mutex m_colors_in_pos; + std::mutex m_colors_in_pos; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them std::atomic i; @@ -1265,10 +1265,10 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre [&]{ - ifstream colorsfile_in_t; - istream colors_in_t(nullptr); + std::ifstream colorsfile_in_t; + std::istream colors_in_t(nullptr); - colorsfile_in_t.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in_t.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in_t.rdbuf(colorsfile_in_t.rdbuf()); while (true) { @@ -1277,12 +1277,12 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre if (l_i >= nb_pos_shared_cs){ - const streampos colors_in_t_pos = colors_in_t.tellg(); + const std::streampos colors_in_t_pos = colors_in_t.tellg(); { - unique_lock lock(m_colors_in_pos); + std::unique_lock lock(m_colors_in_pos); - colors_in_pos = max(colors_in_pos, colors_in_t_pos); + colors_in_pos = std::max(colors_in_pos, colors_in_t_pos); } colorsfile_in_t.close(); @@ -1291,7 +1291,7 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre } colors_in_t.seekg(pos_f_cs[l_i]); - readSharedColorSets(shared_color_sets + (l_i * block_sz), colors_in_t, min(block_sz, sz_shared_cs - (l_i * block_sz))); + readSharedColorSets(shared_color_sets + (l_i * block_sz), colors_in_t, std::min(block_sz, sz_shared_cs - (l_i * block_sz))); } } ); @@ -1309,10 +1309,10 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre [&]{ - ifstream colorsfile_in_t; - istream colors_in_t(nullptr); + std::ifstream colorsfile_in_t; + std::istream colors_in_t(nullptr); - colorsfile_in_t.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in_t.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in_t.rdbuf(colorsfile_in_t.rdbuf()); while (true) { @@ -1321,12 +1321,12 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre if (l_i >= pos_f_cs_sz){ - const streampos colors_in_t_pos = colors_in_t.tellg(); + const std::streampos colors_in_t_pos = colors_in_t.tellg(); { - unique_lock lock(m_colors_in_pos); + std::unique_lock lock(m_colors_in_pos); - colors_in_pos = max(colors_in_pos, colors_in_t_pos); + colors_in_pos = std::max(colors_in_pos, colors_in_t_pos); } colorsfile_in_t.close(); @@ -1338,7 +1338,7 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre l_i -= nb_pos_shared_cs; - readColorSets(color_sets + (l_i * block_sz), colors_in_t, min(block_sz, sz_cs - (l_i * block_sz))); + readColorSets(color_sets + (l_i * block_sz), colors_in_t, std::min(block_sz, sz_cs - (l_i * block_sz))); } } ); @@ -1346,7 +1346,7 @@ inline bool DataStorage::read(const string& color_fn, const size_t nb_thre for (auto& t : workers) t.join(); - colorsfile_in.open(color_fn.c_str(), ios_base::in | ios_base::binary); + colorsfile_in.open(color_fn.c_str(), std::ios_base::in | std::ios_base::binary); colors_in.rdbuf(colorsfile_in.rdbuf()); colors_in.seekg(colors_in_pos); } @@ -1559,9 +1559,9 @@ void DataStorage::remove(const UnitigColorMap& um) { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::iterator it = overflow.find({head, um.size}); if (it != overflow.end()){ @@ -1602,9 +1602,9 @@ inline void DataStorage::remove(const UnitigColorMap& um) { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::iterator it = overflow.find({head, um.size}); if (it != overflow.end()){ @@ -1635,7 +1635,7 @@ size_t DataStorage::getUnitigColorsSize(const size_t nb_threads) const { if (color_sets != nullptr){ - atomic sz_in_bytes(0); + std::atomic sz_in_bytes(0); auto worker_function = [&sz_in_bytes, this](const size_t idx_start, const size_t idx_end){ @@ -1646,7 +1646,7 @@ size_t DataStorage::getUnitigColorsSize(const size_t nb_threads) const { sz_in_bytes += cpt; }; - vector workers; + std::vector workers; const size_t load_per_thread = nb_cs / nb_threads; @@ -1674,9 +1674,9 @@ uint64_t DataStorage::getHash(const UnitigColorMap& um) const { if (da_id == 0){ - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); - unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); + std::unordered_map, size_t>::const_iterator it = overflow.find({head, um.size}); if (it != overflow.end()) return it->second; } else return head.hash(seeds[da_id - 1]) % nb_cs; @@ -1686,7 +1686,7 @@ uint64_t DataStorage::getHash(const UnitigColorMap& um) const { } template -pair, UnitigColors*> DataStorage::insert_(const Kmer head, const size_t unitig_sz, const bool force_overflow) { +std::pair, UnitigColors*> DataStorage::insert_(const Kmer head, const size_t unitig_sz, const bool force_overflow) { if (color_sets == nullptr) return {DataAccessor(0), nullptr}; @@ -1702,7 +1702,7 @@ pair, UnitigColors*> DataStorage::insert_(const Kmer head, co if (i == nb_seeds){ // IF we couldn't find a hash matching an unoccupied color set for current k-mer - unique_lock lock(mutex_overflow); + std::unique_lock lock(mutex_overflow); size_t j = 0; @@ -1746,43 +1746,43 @@ pair, UnitigColors*> DataStorage::insert_(const Kmer head, co } template -pair, pair> DataStorage::insert(const Kmer head, const size_t unitig_sz, const bool force_overflow) { +std::pair, std::pair> DataStorage::insert(const Kmer head, const size_t unitig_sz, const bool force_overflow) { if ((color_sets == nullptr) && (data == nullptr)) return {DataAccessor(0), {nullptr, nullptr}}; - const pair, UnitigColors*> p(insert_(head, unitig_sz, force_overflow)); + const std::pair, UnitigColors*> p(insert_(head, unitig_sz, force_overflow)); return {p.first, {p.second, &data[p.second - color_sets]}}; } template<> -inline pair, pair> DataStorage::insert(const Kmer head, const size_t unitig_sz, const bool force_overflow) { +inline std::pair, std::pair> DataStorage::insert(const Kmer head, const size_t unitig_sz, const bool force_overflow) { if ((color_sets == nullptr) && (data == nullptr)) return {DataAccessor(0), {nullptr, nullptr}}; - const pair, UnitigColors*> p(insert_(head, unitig_sz, force_overflow)); + const std::pair, UnitigColors*> p(insert_(head, unitig_sz, force_overflow)); return {p.first, {p.second, nullptr}}; } template -pair, pair> DataStorage::insert(const UnitigColorMap& um, const bool force_overflow) { +std::pair, std::pair> DataStorage::insert(const UnitigColorMap& um, const bool force_overflow) { if ((color_sets == nullptr) && (data == nullptr)) return {DataAccessor(0), {nullptr, nullptr}}; const Kmer head(um.getMappedHead()); - const pair, UnitigColors*> p(insert_(head, um.len + um.getGraph()->getK() - 1, force_overflow)); + const std::pair, UnitigColors*> p(insert_(head, um.len + um.getGraph()->getK() - 1, force_overflow)); return {p.first, {p.second, &data[p.second - color_sets]}}; } template<> -inline pair, pair> DataStorage::insert(const UnitigColorMap& um, const bool force_overflow) { +inline std::pair, std::pair> DataStorage::insert(const UnitigColorMap& um, const bool force_overflow) { if ((color_sets == nullptr) && (data == nullptr)) return {DataAccessor(0), {nullptr, nullptr}}; const Kmer head(um.getMappedHead()); - const pair, UnitigColors*> p(insert_(head, um.len + um.getGraph()->getK() - 1, force_overflow)); + const std::pair, UnitigColors*> p(insert_(head, um.len + um.getGraph()->getK() - 1, force_overflow)); return {p.first, {p.second, nullptr}}; } @@ -1791,7 +1791,7 @@ template void DataStorage::resize(const double growth) { UnitigColors* old_color_sets = color_sets; - atomic* old_unitig_cs_link = unitig_cs_link; + std::atomic* old_unitig_cs_link = unitig_cs_link; U* old_data = data; const size_t old_sz_cs = sz_cs; @@ -1804,11 +1804,11 @@ void DataStorage::resize(const double growth) { // Reallocate UnitigColors color_sets = new UnitigColors[sz_cs]; - move(old_color_sets, old_color_sets + old_sz_cs, color_sets); + std::move(old_color_sets, old_color_sets + old_sz_cs, color_sets); delete[] old_color_sets; // Reallocate UnitigColors occupancy - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != old_sz_link; ++i) unitig_cs_link[i] = old_unitig_cs_link[i].load(); for (size_t i = old_sz_link; i != sz_link; ++i) unitig_cs_link[i] = 0; @@ -1818,7 +1818,7 @@ void DataStorage::resize(const double growth) { // Reallocate data data = new U[sz_cs]; - move(old_data, old_data + old_sz_cs, data); + std::move(old_data, old_data + old_sz_cs, data); delete[] old_data; } @@ -1826,7 +1826,7 @@ template<> inline void DataStorage::resize(const double growth) { UnitigColors* old_color_sets = color_sets; - atomic* old_unitig_cs_link = unitig_cs_link; + std::atomic* old_unitig_cs_link = unitig_cs_link; const size_t old_sz_cs = sz_cs; const size_t old_sz_link = (old_sz_cs >> 6) + ((old_sz_cs & 0x3F) != 0); @@ -1837,10 +1837,10 @@ inline void DataStorage::resize(const double growth) { color_sets = new UnitigColors[sz_cs]; - move(old_color_sets, old_color_sets + old_sz_cs, color_sets); + std::move(old_color_sets, old_color_sets + old_sz_cs, color_sets); delete[] old_color_sets; - unitig_cs_link = new atomic[sz_link]; + unitig_cs_link = new std::atomic[sz_link]; for (size_t i = 0; i != old_sz_link; ++i) unitig_cs_link[i] = old_unitig_cs_link[i].load(); for (size_t i = old_sz_link; i != sz_link; ++i) unitig_cs_link[i] = 0; diff --git a/src/FASTX_Parser.cpp b/src/FASTX_Parser.cpp index 81888f4..71f968c 100755 --- a/src/FASTX_Parser.cpp +++ b/src/FASTX_Parser.cpp @@ -1,5 +1,6 @@ #include "FASTX_Parser.hpp" +using namespace std; FastqFile::FastqFile() : kseq(NULL), file_no(0) { fnit = fnames.end(); } FastqFile::FastqFile(const vector files) : kseq(NULL), fnames(files), file_no(0) { diff --git a/src/FASTX_Parser.hpp b/src/FASTX_Parser.hpp index 132ed4d..d4296de 100755 --- a/src/FASTX_Parser.hpp +++ b/src/FASTX_Parser.hpp @@ -23,7 +23,7 @@ class FastqFile { public: FastqFile(); - FastqFile(const vector fnames); + FastqFile(const std::vector fnames); ~FastqFile(); @@ -33,22 +33,22 @@ class FastqFile { void close(); void reopen(); - int read_next(char* read, size_t* read_len, string &seq, size_t* seq_len, unsigned int* file_id, char* qual = NULL); - int read_next(string &seq, size_t& id, bool& next_file_opened); - int read_next(stringstream& ss, size_t& id, bool& next_file_opened); - int read_next(string &seq, size_t& id); + int read_next(char* read, size_t* read_len, std::string &seq, size_t* seq_len, unsigned int* file_id, char* qual = NULL); + int read_next(std::string &seq, size_t& id, bool& next_file_opened); + int read_next(std::stringstream& ss, size_t& id, bool& next_file_opened); + int read_next(std::string &seq, size_t& id); int read_next(); inline const kseq_t* get_kseq() const { return kseq; } - vector::const_iterator fnit; // Current filename + std::vector::const_iterator fnit; // Current filename unsigned int file_no; private: - vector::const_iterator open_next(); // Method + std::vector::const_iterator open_next(); // Method - vector fnames; // All fasta/fastq files + std::vector fnames; // All fasta/fastq files gzFile fp; kseq_t* kseq; diff --git a/src/File_Parser.hpp b/src/File_Parser.hpp index 5313d25..98b1ab8 100755 --- a/src/File_Parser.hpp +++ b/src/File_Parser.hpp @@ -20,12 +20,12 @@ class FileParser { public: - FileParser(const vector& filenames) : files_it(0), files_fastx_it(0), files_gfa_it(0), + FileParser(const std::vector& filenames) : files_it(0), files_fastx_it(0), files_gfa_it(0), reading_fastx(false), invalid(false) { if (filenames.size() == 0) { - cerr << "FileParser::FileParser(): Missing input files" << endl; + std::cerr << "FileParser::FileParser(): Missing input files" << std::endl; invalid = true; } else { @@ -40,7 +40,7 @@ class FileParser { if (intStat != 0) { - cerr << "FileParser::FileParser(): File not found: " << s << endl; + std::cerr << "FileParser::FileParser(): File not found: " << s << std::endl; invalid = true; } else { @@ -49,8 +49,8 @@ class FileParser { if (format == -1){ - cerr << "FileParser::FileParser(): Input file " << s << " does not exist"; - cerr << ", is ill-formed or is not in FASTA/FASTQ/GFA format. Continuing without it." << endl; + std::cerr << "FileParser::FileParser(): Input file " << s << " does not exist"; + std::cerr << ", is ill-formed or is not in FASTA/FASTQ/GFA format. Continuing without it." << std::endl; } else if (format == 0) files_fastx.push_back(s); // FASTA else if (format == 1) files_fastx.push_back(s); // FASTQ @@ -76,7 +76,7 @@ class FileParser { } } - bool read(string& seq, size_t& file_id){ + bool read(std::string& seq, size_t& file_id){ if (!invalid){ @@ -129,7 +129,7 @@ class FileParser { return !invalid; } - bool read(stringstream& ss, size_t& file_id){ + bool read(std::stringstream& ss, size_t& file_id){ if (!invalid){ @@ -243,9 +243,9 @@ class FileParser { size_t files_fastx_it; size_t files_gfa_it; - vector files; - vector files_fastx; - vector files_gfa; + std::vector files; + std::vector files_fastx; + std::vector files_gfa; FastqFile ff; GFA_Parser gfap; diff --git a/src/GFA_Parser.cpp b/src/GFA_Parser.cpp index e4daeab..4420ba2 100755 --- a/src/GFA_Parser.cpp +++ b/src/GFA_Parser.cpp @@ -1,5 +1,7 @@ #include "GFA_Parser.hpp" +using namespace std; + GFA_Parser::GFA_Parser() : file_open_write(false), file_open_read(false), file_no(0), v_gfa(0), graph_out(nullptr), graph_in(nullptr) {} GFA_Parser::GFA_Parser(const string& filename) : file_open_write(false), file_open_read(false), file_no(0), @@ -14,8 +16,8 @@ GFA_Parser::GFA_Parser(const vector& filenames) : file_open_write(fals graph_filenames = filenames; } -GFA_Parser::GFA_Parser(GFA_Parser&& o) : graph_filenames(move(o.graph_filenames)), - graph_out(move(o.graph_out)), graph_in(move(o.graph_in)), +GFA_Parser::GFA_Parser(GFA_Parser&& o) : graph_filenames(std::move(o.graph_filenames)), + graph_out(std::move(o.graph_out)), graph_in(std::move(o.graph_in)), v_gfa(o.v_gfa), file_no(o.file_no), file_open_write(o.file_open_write), file_open_read(o.file_open_read) { @@ -31,8 +33,8 @@ GFA_Parser& GFA_Parser::operator=(GFA_Parser&& o){ graph_filenames = o.graph_filenames; - graph_in = move(o.graph_in); - graph_out = move(o.graph_out); + graph_in = std::move(o.graph_in); + graph_out = std::move(o.graph_out); v_gfa = o.v_gfa; file_no = o.file_no; @@ -314,10 +316,10 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id) { close(); } - s.id = move(line_fields[0]); - s.seq = move(line_fields[1]); + s.id = std::move(line_fields[0]); + s.seq = std::move(line_fields[1]); - for (size_t i = 2; i < line_fields_sz; ++i) s.tags.push_back(move(line_fields[i])); + for (size_t i = 2; i < line_fields_sz; ++i) s.tags.push_back(std::move(line_fields[i])); } else { @@ -327,11 +329,11 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id) { close(); } - s.id = move(line_fields[0]); + s.id = std::move(line_fields[0]); s.len = sscanf(line_fields[1].c_str(), "%zu", &(s.len)); - s.seq = move(line_fields[2]); + s.seq = std::move(line_fields[2]); - for (size_t i = 3; i < line_fields_sz; ++i) s.tags.push_back(move(line_fields[i])); + for (size_t i = 3; i < line_fields_sz; ++i) s.tags.push_back(std::move(line_fields[i])); } file_id = file_no; @@ -363,8 +365,8 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id) { close(); } - e.vertexA_id = move(line_fields[0]); - e.vertexB_id = move(line_fields[2]); + e.vertexA_id = std::move(line_fields[0]); + e.vertexB_id = std::move(line_fields[2]); if (line_fields[1] == "+") e.strand_overlapA = true; else if (line_fields[1] == "-") e.strand_overlapA = false; @@ -418,7 +420,7 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id) { e.strand_overlapA = (ca != '-'); if ((ca == '-') || (ca == '-')) e.vertexA_id = line_fields[1].substr(0, line_fields[1].length() - 1); - else e.vertexA_id = move(line_fields[1]); + else e.vertexA_id = std::move(line_fields[1]); sscanf(line_fields[2].c_str(), "%zu", &(e.pos_start_overlapA)); sscanf(line_fields[3].c_str(), "%zu", &(e.pos_end_overlapA)); @@ -428,7 +430,7 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id) { e.strand_overlapB = (cb != '-'); if ((cb == '-') || (cb == '-')) e.vertexB_id = line_fields[4].substr(0, line_fields[4].length() - 1); - else e.vertexB_id = move(line_fields[4]); + else e.vertexB_id = std::move(line_fields[4]); sscanf(line_fields[5].c_str(), "%zu", &(e.pos_start_overlapB)); sscanf(line_fields[6].c_str(), "%zu", &(e.pos_end_overlapB)); @@ -511,10 +513,10 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id, bool& new_file_opened, co close(); } - s.id = move(line_fields[0]); - s.seq = move(line_fields[1]); + s.id = std::move(line_fields[0]); + s.seq = std::move(line_fields[1]); - for (size_t i = 2; i < line_fields_sz; ++i) s.tags.push_back(move(line_fields[i])); + for (size_t i = 2; i < line_fields_sz; ++i) s.tags.push_back(std::move(line_fields[i])); } else { @@ -524,11 +526,11 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id, bool& new_file_opened, co close(); } - s.id = move(line_fields[0]); + s.id = std::move(line_fields[0]); s.len = sscanf(line_fields[1].c_str(), "%zu", &(s.len)); - s.seq = move(line_fields[2]); + s.seq = std::move(line_fields[2]); - for (size_t i = 3; i < line_fields_sz; ++i) s.tags.push_back(move(line_fields[i])); + for (size_t i = 3; i < line_fields_sz; ++i) s.tags.push_back(std::move(line_fields[i])); } file_id = file_no; @@ -562,8 +564,8 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id, bool& new_file_opened, co close(); } - e.vertexA_id = move(line_fields[0]); - e.vertexB_id = move(line_fields[2]); + e.vertexA_id = std::move(line_fields[0]); + e.vertexB_id = std::move(line_fields[2]); if (line_fields[1] == "+") e.strand_overlapA = true; else if (line_fields[1] == "-") e.strand_overlapA = false; @@ -610,14 +612,14 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id, bool& new_file_opened, co close(); } - e.edge_id = move(line_fields[0]); + e.edge_id = std::move(line_fields[0]); const char ca = line_fields[1][line_fields[1].length() - 1]; // Last char. of line_fields[1]; e.strand_overlapA = (ca != '-'); if ((ca == '-') || (ca == '-')) e.vertexA_id = line_fields[1].substr(0, line_fields[1].length() - 1); - else e.vertexA_id = move(line_fields[1]); + else e.vertexA_id = std::move(line_fields[1]); sscanf(line_fields[2].c_str(), "%zu", &(e.pos_start_overlapA)); sscanf(line_fields[3].c_str(), "%zu", &(e.pos_end_overlapA)); @@ -627,7 +629,7 @@ GFA_Parser::GFA_line GFA_Parser::read(size_t& file_id, bool& new_file_opened, co e.strand_overlapB = (cb != '-'); if ((cb == '-') || (cb == '-')) e.vertexB_id = line_fields[4].substr(0, line_fields[4].length() - 1); - else e.vertexB_id = move(line_fields[4]); + else e.vertexB_id = std::move(line_fields[4]); sscanf(line_fields[5].c_str(), "%zu", &(e.pos_start_overlapB)); sscanf(line_fields[6].c_str(), "%zu", &(e.pos_end_overlapB)); diff --git a/src/GFA_Parser.hpp b/src/GFA_Parser.hpp index 2ad0502..e3db719 100755 --- a/src/GFA_Parser.hpp +++ b/src/GFA_Parser.hpp @@ -14,20 +14,18 @@ #include "zstr.hpp" -using namespace std; - class GFA_Parser { struct Sequence { - string id; - string seq; + std::string id; + std::string seq; size_t len; - vector tags; + std::vector tags; Sequence() : seq("*"), len(0) {}; - Sequence(const string& id_, const string& seq_, const size_t len_) : id(id_), seq(seq_), len(len_) {}; + Sequence(const std::string& id_, const std::string& seq_, const size_t len_) : id(id_), seq(seq_), len(len_) {}; inline void clear() { @@ -41,14 +39,14 @@ class GFA_Parser { struct Edge { - string edge_id; + std::string edge_id; - string vertexA_id; + std::string vertexA_id; size_t pos_start_overlapA; size_t pos_end_overlapA; bool strand_overlapA; - string vertexB_id; + std::string vertexB_id; size_t pos_start_overlapB; size_t pos_end_overlapB; bool strand_overlapB; @@ -57,9 +55,9 @@ class GFA_Parser { vertexA_id(), pos_start_overlapA(0), pos_end_overlapA(0), strand_overlapA(true), vertexB_id(), pos_start_overlapB(0), pos_end_overlapB(0), strand_overlapB(true) {}; - Edge(const string vertexA_id_, const size_t pos_start_overlapA_, const size_t pos_end_overlapA_, const bool strand_overlapA_, - const string vertexB_id_, const size_t pos_start_overlapB_, const size_t pos_end_overlapB_, const bool strand_overlapB_, - const string edge_id_ = "*") : edge_id(edge_id_), + Edge(const std::string vertexA_id_, const size_t pos_start_overlapA_, const size_t pos_end_overlapA_, const bool strand_overlapA_, + const std::string vertexB_id_, const size_t pos_start_overlapB_, const size_t pos_end_overlapB_, const bool strand_overlapB_, + const std::string edge_id_ = "*") : edge_id(edge_id_), vertexA_id(vertexA_id_), pos_start_overlapA(pos_start_overlapA_), pos_end_overlapA(pos_end_overlapA_), strand_overlapA(strand_overlapA_), vertexB_id(vertexB_id_), pos_start_overlapB(pos_start_overlapB_), pos_end_overlapB(pos_end_overlapB_), strand_overlapB(strand_overlapB_) {}; @@ -82,38 +80,38 @@ class GFA_Parser { public: - typedef pair GFA_line; + typedef std::pair GFA_line; GFA_Parser(); - GFA_Parser(const string& filename); - GFA_Parser(const vector& filenames); + GFA_Parser(const std::string& filename); + GFA_Parser(const std::vector& filenames); ~GFA_Parser(); GFA_Parser(GFA_Parser&& o); GFA_Parser& operator=(GFA_Parser&& o); - bool open_write(const size_t version_GFA = 1, const string tags_line_header = "", const bool compressed_output = false); - pair open_read(); + bool open_write(const size_t version_GFA = 1, const std::string tags_line_header = "", const bool compressed_output = false); + std::pair open_read(); void close(); - bool write_sequence(const string& id, const size_t len, const string seq = "*", const string tags_line = ""); - bool write_edge(const string vertexA_id, const size_t pos_start_overlapA, const size_t pos_end_overlapA, const bool strand_overlapA, - const string vertexB_id, const size_t pos_start_overlapB, const size_t pos_end_overlapB, const bool strand_overlapB, - const string edge_id = "*"); + bool write_sequence(const std::string& id, const size_t len, const std::string seq = "*", const std::string tags_line = ""); + bool write_edge(const std::string vertexA_id, const size_t pos_start_overlapA, const size_t pos_end_overlapA, const bool strand_overlapA, + const std::string vertexB_id, const size_t pos_start_overlapB, const size_t pos_end_overlapB, const bool strand_overlapB, + const std::string edge_id = "*"); GFA_line read(size_t& file_id); GFA_line read(size_t& file_id, bool& new_file_opened, const bool skip_edges = false); private: - pair open(const size_t idx_filename); + std::pair open(const size_t idx_filename); - vector graph_filenames; + std::vector graph_filenames; - unique_ptr graph_in; - unique_ptr graph_out; + std::unique_ptr graph_in; + std::unique_ptr graph_out; size_t v_gfa; size_t file_no; diff --git a/src/IO.tcc b/src/IO.tcc index 3582109..5db0cdc 100755 --- a/src/IO.tcc +++ b/src/IO.tcc @@ -2,64 +2,64 @@ #define BIFROST_IO_CDBG_TCC template -bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, const bool GFA_output, const bool FASTA_output, const bool BFG_output, const bool write_index_file, const bool compressed_output, const bool verbose) const { +bool CompactedDBG::write(const std::string& output_fn, const size_t nb_threads, const bool GFA_output, const bool FASTA_output, const bool BFG_output, const bool write_index_file, const bool compressed_output, const bool verbose) const { if (invalid){ - cerr << "CompactedDBG::write(): Graph is invalid and cannot be written to disk" << endl; + std::cerr << "CompactedDBG::write(): Graph is invalid and cannot be written to disk" << std::endl; return false; } if (nb_threads <= 0){ - cerr << "CompactedDBG::write(): Number of threads cannot be less than 0" << endl; + std::cerr << "CompactedDBG::write(): Number of threads cannot be less than 0" << std::endl; return false; } if (nb_threads > std::thread::hardware_concurrency()){ - cerr << "CompactedDBG::write(): Number of threads cannot exceed " << std::thread::hardware_concurrency() << "threads" << endl; + std::cerr << "CompactedDBG::write(): Number of threads cannot exceed " << std::thread::hardware_concurrency() << "threads" << std::endl; return false; } if (!GFA_output && !FASTA_output && !BFG_output){ - cerr << "CompactedDBG::write(): No type of format output selected" << endl; + std::cerr << "CompactedDBG::write(): No type of format output selected" << std::endl; return false; } if (static_cast(GFA_output) + static_cast(FASTA_output) + static_cast(BFG_output) > 1){ - cerr << "CompactedDBG::write(): Multiple output formats selected. Please choose one." << endl; + std::cerr << "CompactedDBG::write(): Multiple output formats selected. Please choose one." << std::endl; return false; } bool write_success = true; { - if (verbose) cout << endl << "CompactedDBG::write(): Writing graph to disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::write(): Writing graph to disk" << std::endl; - string fn = output_fn; + std::string fn = output_fn; // Add file extensions if missing if (GFA_output || FASTA_output) { - const string g_ext = (GFA_output ? ".gfa" : ".fasta"); - const string c_ext = ".gz"; - const string gc_ext = g_ext + c_ext; + const std::string g_ext = (GFA_output ? ".gfa" : ".fasta"); + const std::string c_ext = ".gz"; + const std::string gc_ext = g_ext + c_ext; const size_t pos_ext = fn.find_last_of("."); - if (pos_ext == string::npos) fn.append(compressed_output ? gc_ext : g_ext); + if (pos_ext == std::string::npos) fn.append(compressed_output ? gc_ext : g_ext); else if (!compressed_output && (fn.substr(pos_ext) != g_ext)) fn.append(g_ext); else if (compressed_output && (fn.substr(pos_ext) != c_ext)) fn.append(gc_ext); } else if (BFG_output) { - const string g_ext = ".bfg"; + const std::string g_ext = ".bfg"; const size_t pos_ext = fn.find_last_of("."); - if ((pos_ext == string::npos) || (fn.substr(pos_ext) != g_ext)) fn.append(g_ext); + if ((pos_ext == std::string::npos) || (fn.substr(pos_ext) != g_ext)) fn.append(g_ext); } @@ -68,7 +68,7 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, if (fp == NULL) { - cerr << "CompactedDBG::write(): Could not open file " << fn << " for writing graph" << endl; + std::cerr << "CompactedDBG::write(): Could not open file " << fn << " for writing graph" << std::endl; return false; } @@ -76,7 +76,7 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, fclose(fp); - if (std::remove(fn.c_str()) != 0) cerr << "CompactedDBG::write(): Could not remove temporary file " << fn << endl; + if (std::remove(fn.c_str()) != 0) std::cerr << "CompactedDBG::write(): Could not remove temporary file " << fn << std::endl; } if (GFA_output) write_success = writeGFA(fn, nb_threads, compressed_output); @@ -86,13 +86,13 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, if (write_success && (write_index_file || BFG_output)) { - if (verbose) cout << endl << "CompactedDBG::write(): Writing index file to disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::write(): Writing index file to disk" << std::endl; - string fn = output_fn; + std::string fn = output_fn; // Add file extensions if missing { - const string ext = ".bfi"; + const std::string ext = ".bfi"; if ((fn.length() < ext.length()) || (fn.substr(fn.length() - ext.length()) != ext)) fn.append(ext); } @@ -101,7 +101,7 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, if (fp == NULL) { - cerr << "CompactedDBG::write(): Could not open file " << fn << " for writing index file" << endl; + std::cerr << "CompactedDBG::write(): Could not open file " << fn << " for writing index file" << std::endl; return false; } @@ -109,7 +109,7 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, fclose(fp); - if (std::remove(fn.c_str()) != 0) cerr << "CompactedDBG::write(): Could not remove temporary file " << fn << endl; + if (std::remove(fn.c_str()) != 0) std::cerr << "CompactedDBG::write(): Could not remove temporary file " << fn << std::endl; } const uint64_t graph_checksum = checksum(); @@ -121,48 +121,48 @@ bool CompactedDBG::write(const string& output_fn, const size_t nb_threads, } template -bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_threads, const bool verbose){ +bool CompactedDBG::read(const std::string& input_graph_fn, const size_t nb_threads, const bool verbose){ - if (verbose) cout << endl << "CompactedDBG::read(): Reading graph from disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::read(): Reading graph from disk" << std::endl; const int format = FileParser::getFileFormat(input_graph_fn.c_str()); if (format == -1){ - cerr << "CompactedDBG::read(): Input graph file " << input_graph_fn << " does not exist, is ill-formed or is not a valid graph file format." << endl; + std::cerr << "CompactedDBG::read(): Input graph file " << input_graph_fn << " does not exist, is ill-formed or is not a valid graph file format." << std::endl; return false; } else if ((format != 0) && (format != 2) && (format != 3)){ - cerr << "CompactedDBG::read(): Input graph file must be in FASTA, GFA or BFG format." << endl; + std::cerr << "CompactedDBG::read(): Input graph file must be in FASTA, GFA or BFG format." << std::endl; return false; } - string input_index_fn = input_graph_fn; + std::string input_index_fn = input_graph_fn; // Try to open index file if available { size_t pos_ext = input_index_fn.find_last_of("."); - string ext; + std::string ext; - if ((pos_ext != string::npos) && (input_index_fn.substr(pos_ext) == ".gz")) { + if ((pos_ext != std::string::npos) && (input_index_fn.substr(pos_ext) == ".gz")) { input_index_fn = input_index_fn.substr(0, pos_ext); pos_ext = input_index_fn.find_last_of("."); } - if (pos_ext != string::npos) ext = input_index_fn.substr(pos_ext); - if ((pos_ext != string::npos) && ((ext == ".gfa")) || (ext == ".fasta") || (ext == ".bfg")) input_index_fn = input_index_fn.substr(0, pos_ext); + if (pos_ext != std::string::npos) ext = input_index_fn.substr(pos_ext); + if ((pos_ext != std::string::npos) && ((ext == ".gfa")) || (ext == ".fasta") || (ext == ".bfg")) input_index_fn = input_index_fn.substr(0, pos_ext); input_index_fn += ".bfi"; // Add Bifrost graph index extension } if ((input_graph_fn != input_index_fn) && check_file_exists(input_index_fn)) { - if (verbose) cout << "CompactedDBG::read(): Reading using Bifrost index file " << input_index_fn << "." << endl; + if (verbose) std::cout << "CompactedDBG::read(): Reading using Bifrost index file " << input_index_fn << "." << std::endl; return read(input_graph_fn, input_index_fn, nb_threads, verbose); } @@ -188,7 +188,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre KmerStream kms(kms_opt); - MinimizerIndex hmap_min_unitigs_tmp(max(1UL, kms.MinimizerF0()) * 1.05); + MinimizerIndex hmap_min_unitigs_tmp(std::max(1UL, kms.MinimizerF0()) * 1.05); hmap_min_unitigs = std::move(hmap_min_unitigs_tmp); } @@ -198,7 +198,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre } else if (format == 2){ // GFA format - string header; + std::string header; int k = k_, g = g_; @@ -207,7 +207,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre if (fp == NULL) { - cerr << "CompactedDBG::read(): Could not open file " << input_graph_fn << " for reading graph" << endl; + std::cerr << "CompactedDBG::read(): Could not open file " << input_graph_fn << " for reading graph" << std::endl; return false; } @@ -225,18 +225,18 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre { if (header[0] != 'H'){ - cerr << "CompactedDBG::read(): An error occurred while reading input GFA file." << endl; + std::cerr << "CompactedDBG::read(): An error occurred while reading input GFA file." << std::endl; return false; } - stringstream hs(header.c_str() + 2); // Skip the first 2 char. of the line "H\t" - string sub; + std::stringstream hs(header.c_str() + 2); // Skip the first 2 char. of the line "H\t" + std::string sub; while (hs.good()){ // Split line based on tabulation - getline(hs, sub, '\t'); + std::getline(hs, sub, '\t'); - const string tag = sub.substr(0, 5); + const std::string tag = sub.substr(0, 5); if (tag == "KL:Z:") k = atoi(sub.c_str() + 5); else if (tag == "ML:Z:") g = atoi(sub.c_str() + 5); @@ -258,7 +258,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre KmerStream kms(kms_opt); - MinimizerIndex hmap_min_unitigs_tmp(max(1UL, kms.MinimizerF0()) * 1.05); + MinimizerIndex hmap_min_unitigs_tmp(std::max(1UL, kms.MinimizerF0()) * 1.05); hmap_min_unitigs = std::move(hmap_min_unitigs_tmp); } @@ -267,7 +267,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre } else { // BFG format - cerr << "CompactedDBG::read(): No index found for Bifrost graph file " << input_graph_fn << endl; + std::cerr << "CompactedDBG::read(): No index found for Bifrost graph file " << input_graph_fn << std::endl; invalid = true; } @@ -277,41 +277,41 @@ bool CompactedDBG::read(const string& input_graph_fn, const size_t nb_thre // Set coverages if (!invalid) for (auto& unitig : *this) unitig.setFullCoverage(); - if (verbose) cout << endl << "CompactedDBG::read(): Finished reading graph from disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::read(): Finished reading graph from disk" << std::endl; return !invalid; } } template -bool CompactedDBG::read(const string& input_graph_fn, const string& input_index_fn, const size_t nb_threads, const bool verbose){ +bool CompactedDBG::read(const std::string& input_graph_fn, const std::string& input_index_fn, const size_t nb_threads, const bool verbose){ - if (verbose) cout << endl << "CompactedDBG::read(): Reading graph from disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::read(): Reading graph from disk" << std::endl; const int format_graph = FileParser::getFileFormat(input_graph_fn.c_str()); const int format_index = FileParser::getFileFormat(input_index_fn.c_str()); if (format_graph == -1){ - cerr << "CompactedDBG::read(): Input graph file " << input_graph_fn << " does not exist, is ill-formed or is not a valid graph file format." << endl; + std::cerr << "CompactedDBG::read(): Input graph file " << input_graph_fn << " does not exist, is ill-formed or is not a valid graph file format." << std::endl; return false; } else if ((format_graph != 0) && (format_graph != 2) && (format_graph != 3)){ - cerr << "CompactedDBG::read(): Input graph file must be in FASTA, GFA or BFG format." << endl; + std::cerr << "CompactedDBG::read(): Input graph file must be in FASTA, GFA or BFG format." << std::endl; return false; } if (format_index != 4) { - cerr << "CompactedDBG::read(): Input index file " << input_index_fn << " does not exist, is ill-formed or is not a valid index file format." << endl; + std::cerr << "CompactedDBG::read(): Input index file " << input_index_fn << " does not exist, is ill-formed or is not a valid index file format." << std::endl; return false; } - pair p_readSuccess_checksum; + std::pair p_readSuccess_checksum; if (format_graph == 0) { // FASTA input @@ -326,7 +326,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const string& input_ } else if (format_graph == 2){ // GFA format - string header; + std::string header; int k = k_, g = g_; @@ -335,7 +335,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const string& input_ if (fp == NULL) { - cerr << "CompactedDBG::read(): Could not open file " << input_graph_fn << " for reading graph" << endl; + std::cerr << "CompactedDBG::read(): Could not open file " << input_graph_fn << " for reading graph" << std::endl; return false; } @@ -353,18 +353,18 @@ bool CompactedDBG::read(const string& input_graph_fn, const string& input_ { if (header[0] != 'H'){ - cerr << "CompactedDBG::read(): An error occurred while reading input GFA file." << endl; + std::cerr << "CompactedDBG::read(): An error occurred while reading input GFA file." << std::endl; return false; } - stringstream hs(header.c_str() + 2); // Skip the first 2 char. of the line "H\t" - string sub; + std::stringstream hs(header.c_str() + 2); // Skip the first 2 char. of the line "H\t" + std::string sub; while (hs.good()){ // Split line based on tabulation - getline(hs, sub, '\t'); + std::getline(hs, sub, '\t'); - const string tag = sub.substr(0, 5); + const std::string tag = sub.substr(0, 5); if (tag == "KL:Z:") k = atoi(sub.c_str() + 5); else if (tag == "ML:Z:") g = atoi(sub.c_str() + 5); @@ -392,7 +392,7 @@ bool CompactedDBG::read(const string& input_graph_fn, const string& input_ invalid = !readBinaryIndex(input_index_fn, p_readSuccess_checksum.first); } - if (verbose) cout << endl << "CompactedDBG::read(): Finished reading graph from disk" << endl; + if (verbose) std::cout << std::endl << "CompactedDBG::read(): Finished reading graph from disk" << std::endl; return !invalid; } @@ -405,7 +405,7 @@ typename std::enable_if::type CompactedDBG::writeGFA_seque for (const auto& unitig : *this){ - const string seq(unitig.referenceUnitigToString()); + const std::string seq(unitig.referenceUnitigToString()); graph.write_sequence(std::to_string(labelA), seq.size(), seq, unitig.getData()->serialize(unitig)); @@ -423,7 +423,7 @@ typename std::enable_if::type CompactedDBG::writeGFA_sequen for (const auto& unitig : *this){ - const string seq(unitig.referenceUnitigToString()); + const std::string seq(unitig.referenceUnitigToString()); graph.write_sequence(std::to_string(labelA), seq.size(), seq, ""); @@ -440,14 +440,14 @@ typename std::enable_if::type CompactedDBG::writeGFA_sequen // The binary graph file is written in that order // and the checksum is stored in the index file is computed for that order template -bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, const bool compressed_output) const { +bool CompactedDBG::writeGFA(const std::string& fn, const size_t nb_threads, const bool compressed_output) const { const size_t v_unitigs_sz = v_unitigs.size(); const size_t v_kmers_sz = km_unitigs.size(); size_t labelA, labelB, id = v_unitigs_sz + v_kmers_sz + 1; - const string header_tag("BV:Z:" + string(BFG_VERSION) + "\t" + "KL:Z:" + to_string(k_) + "\t" + "ML:Z:" + to_string(g_)); + const std::string header_tag("BV:Z:" + std::string(BFG_VERSION) + "\t" + "KL:Z:" + std::to_string(k_) + "\t" + "ML:Z:" + std::to_string(g_)); KmerHashTable idmap(h_kmers_ccov.size()); @@ -455,7 +455,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con graph.open_write(1, header_tag, compressed_output); - writeGFA_sequence_::value>(graph, idmap); + writeGFA_sequence_::value>(graph, idmap); if (nb_threads == 1){ @@ -465,8 +465,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const Kmer head = unitig->getSeq().getKmer(0); const Kmer tail = unitig->getSeq().getKmer(unitig->length() - k_); - const vector> pred = findPredecessors(head, true); - const vector> succ = findSuccessors(tail, 4, true); + const std::vector> pred = findPredecessors(head, true); + const std::vector> succ = findSuccessors(tail, 4, true); for (const auto& unitig : pred){ @@ -475,8 +475,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -491,8 +491,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -505,8 +505,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const Kmer km_unitig = km_unitigs.getKmer(labelA - v_unitigs_sz - 1); - const vector> pred = findPredecessors(km_unitig, true); - const vector> succ = findSuccessors(km_unitig, 4, true); + const std::vector> pred = findPredecessors(km_unitig, true); + const std::vector> succ = findSuccessors(km_unitig, 4, true); for (const auto& unitig : pred){ @@ -515,8 +515,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -531,8 +531,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -545,8 +545,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con labelA = *it; - const vector> pred = findPredecessors(it.getKey(), true); - const vector> succ = findSuccessors(it.getKey(), 4, true); + const std::vector> pred = findPredecessors(it.getKey(), true); + const std::vector> succ = findSuccessors(it.getKey(), 4, true); for (const auto& unitig : pred){ @@ -555,8 +555,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -571,8 +571,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con if (unitig.isAbundant) labelB = *(idmap.find(unitig.getUnitigHead().rep())); else labelB = unitig.pos_unitig + 1 + ((static_cast(!unitig.isShort) - 1) & v_unitigs_sz); - const string slabelA = std::to_string(labelA); - const string slabelB = std::to_string(labelB); + const std::string slabelA = std::to_string(labelA); + const std::string slabelB = std::to_string(labelB); const size_t pos = (static_cast(unitig.strand) - 1) & (unitig.size - k_ + 1); @@ -586,7 +586,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t chunk_size = 1024; auto worker_v_unitigs = [v_unitigs_sz, &idmap, this](const size_t labelA_start, const size_t labelA_end, - vector, pair>>* v_out){ + std::vector, std::pair>>* v_out){ // We need to deal with the tail of long unitigs for (size_t labelA = labelA_start; labelA < labelA_end; ++labelA) { @@ -596,8 +596,8 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const Kmer head = unitig->getSeq().getKmer(0); const Kmer tail = unitig->getSeq().getKmer(unitig->length() - k_); - const vector> pred = this->findPredecessors(head, true); - const vector> succ = this->findSuccessors(tail, 4, true); + const std::vector> pred = this->findPredecessors(head, true); + const std::vector> succ = this->findSuccessors(tail, 4, true); for (const auto& um : pred) { @@ -606,7 +606,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(labelA, false), make_pair(labelB, !um.strand))); + v_out->push_back(std::make_pair(std::make_pair(labelA, false), std::make_pair(labelB, !um.strand))); } } @@ -617,22 +617,22 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(labelA, true), make_pair(labelB, um.strand))); + v_out->push_back(std::make_pair(std::make_pair(labelA, true), std::make_pair(labelB, um.strand))); } } } }; auto worker_v_kmers = [v_unitigs_sz, &idmap, this](const size_t labelA_start, const size_t labelA_end, - vector, pair>>* v_out){ + std::vector, std::pair>>* v_out){ // We need to deal with the tail of long unitigs for (size_t labelA = labelA_start; labelA < labelA_end; ++labelA) { const Kmer km_unitig = km_unitigs.getKmer(labelA - v_unitigs_sz - 1); - const vector> pred = this->findPredecessors(km_unitig, true); - const vector> succ = this->findSuccessors(km_unitig, 4, true); + const std::vector> pred = this->findPredecessors(km_unitig, true); + const std::vector> succ = this->findSuccessors(km_unitig, 4, true); for (const auto& um : pred) { @@ -641,7 +641,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(labelA, false), make_pair(labelB, !um.strand))); + v_out->push_back(std::make_pair(std::make_pair(labelA, false), std::make_pair(labelB, !um.strand))); } } @@ -652,22 +652,22 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(labelA, true), make_pair(labelB, um.strand))); + v_out->push_back(std::make_pair(std::make_pair(labelA, true), std::make_pair(labelB, um.strand))); } } } }; auto worker_v_abundant = [v_unitigs_sz, chunk_size, &idmap, this]( KmerHashTable::iterator* l_it, - vector, pair>>* v_out){ + std::vector, std::pair>>* v_out){ KmerHashTable::iterator& it = *l_it; // We need to deal with the tail of long unitigs for (size_t i = 0; (it != idmap.end()) && (i < chunk_size); ++i, ++it) { - const vector> pred = this->findPredecessors(it.getKey(), true); - const vector> succ = this->findSuccessors(it.getKey(), 4, true); + const std::vector> pred = this->findPredecessors(it.getKey(), true); + const std::vector> succ = this->findSuccessors(it.getKey(), 4, true); for (const auto& um : pred) { @@ -676,7 +676,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(*it, false), make_pair(labelB, !um.strand))); + v_out->push_back(std::make_pair(std::make_pair(*it, false), std::make_pair(labelB, !um.strand))); } } @@ -687,19 +687,19 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con const size_t labelB = (um.isAbundant ? *(idmap.find(um.getUnitigHead().rep())) : um.pos_unitig + 1 + ((static_cast(!um.isShort) - 1) & v_unitigs_sz)); - v_out->push_back(make_pair(make_pair(*it, true), make_pair(labelB, um.strand))); + v_out->push_back(std::make_pair(std::make_pair(*it, true), std::make_pair(labelB, um.strand))); } } } }; { - atomic label(1); + std::atomic label(1); - vector, pair>>> v_out(nb_threads); - vector workers; // need to keep track of threads so we can join them + std::vector, std::pair>>> v_out(nb_threads); + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; for (size_t t = 0; t < nb_threads; ++t){ @@ -717,12 +717,12 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con else worker_v_unitigs(old_labelA, v_unitigs_sz + 1, &v_out[t]); { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); for (const auto& p : v_out[t]){ - const string slabelA = std::to_string(p.first.first); - const string slabelB = std::to_string(p.second.first); + const std::string slabelA = std::to_string(p.first.first); + const std::string slabelB = std::to_string(p.second.first); graph.write_edge(slabelA, 0, k_-1, p.first.second, slabelB, 0, k_-1, p.second.second); } @@ -742,12 +742,12 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con { const size_t v_kmers_unitigs_sz = v_kmers_sz + v_unitigs_sz; - atomic label(v_unitigs_sz + 1); + std::atomic label(v_unitigs_sz + 1); - vector, pair>>> v_out(nb_threads); - vector workers; // need to keep track of threads so we can join them + std::vector, std::pair>>> v_out(nb_threads); + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; for (size_t t = 0; t < nb_threads; ++t){ @@ -765,12 +765,12 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con else worker_v_kmers(old_labelA, v_kmers_unitigs_sz + 1, &v_out[t]); { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); for (const auto& p : v_out[t]){ - const string slabelA = std::to_string(p.first.first); - const string slabelB = std::to_string(p.second.first); + const std::string slabelA = std::to_string(p.first.first); + const std::string slabelB = std::to_string(p.second.first); graph.write_edge(slabelA, 0, k_-1, p.first.second, slabelB, 0, k_-1, p.second.second); } @@ -790,10 +790,10 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con { KmerHashTable::iterator it = idmap.begin(), it_end = idmap.end(); - vector, pair>>> v_out(nb_threads); - vector workers; // need to keep track of threads so we can join them + std::vector, std::pair>>> v_out(nb_threads); + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file, mutex_it; + std::mutex mutex_file, mutex_it; for (size_t t = 0; t < nb_threads; ++t){ @@ -808,7 +808,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con while (true) { { - unique_lock lock(mutex_it); + std::unique_lock lock(mutex_it); l_it = it; @@ -822,12 +822,12 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con worker_v_abundant(&l_it, &v_out[t]); { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); for (const auto& p : v_out[t]){ - const string slabelA = std::to_string(p.first.first); - const string slabelB = std::to_string(p.second.first); + const std::string slabelA = std::to_string(p.first.first); + const std::string slabelB = std::to_string(p.second.first); graph.write_edge(slabelA, 0, k_-1, p.first.second, slabelB, 0, k_-1, p.second.second); } @@ -857,7 +857,7 @@ bool CompactedDBG::writeGFA(const string& fn, const size_t nb_threads, con // The binary graph file is written in that order // and the checksum is stored in the index file is computed for that order template -bool CompactedDBG::writeFASTA(const string& fn, const bool compressed_output) const { +bool CompactedDBG::writeFASTA(const std::string& fn, const bool compressed_output) const { const size_t v_unitigs_sz = v_unitigs.size(); const size_t v_kmers_sz = km_unitigs.size(); @@ -868,7 +868,7 @@ bool CompactedDBG::writeFASTA(const string& fn, const bool compressed_outp if (compressed_output) { - zstr::ofstream gout(fn, ios_base::out); + zstr::ofstream gout(fn, std::ios_base::out); for (size_t j = 0; !gout.fail() && (j < v_unitigs_sz); ++j, ++i) gout << ">" << i << "\n" << v_unitigs[j]->getSeq().toString() << "\n"; for (size_t j = 0; !gout.fail() && (j < v_kmers_sz); ++j, ++i) gout << ">" << i << "\n" << km_unitigs.getKmer(j).toString() << "\n"; @@ -882,8 +882,8 @@ bool CompactedDBG::writeFASTA(const string& fn, const bool compressed_outp } else { - ofstream graphfile; - ostream graph(0); + std::ofstream graphfile; + std::ostream graph(0); graphfile.open(fn.c_str()); graph.rdbuf(graphfile.rdbuf()); @@ -905,12 +905,12 @@ bool CompactedDBG::writeFASTA(const string& fn, const bool compressed_outp } template -bool CompactedDBG::readBinary(const string& fn) { +bool CompactedDBG::readBinary(const std::string& fn) { if ((fn.length() == 0) || !check_file_exists(fn)) return false; - ifstream infile; - istream in(0); + std::ifstream infile; + std::istream in(0); infile.open(fn.c_str()); in.rdbuf(infile.rdbuf()); @@ -919,11 +919,11 @@ bool CompactedDBG::readBinary(const string& fn) { } template -bool CompactedDBG::readBinary(istream& in) { +bool CompactedDBG::readBinary(std::istream& in) { if (!in.fail()) { - const pair p_readSuccess_checksum = readBinaryGraph(in); + const std::pair p_readSuccess_checksum = readBinaryGraph(in); if (p_readSuccess_checksum.second) return readBinaryIndex(in, p_readSuccess_checksum.first); } @@ -932,12 +932,12 @@ bool CompactedDBG::readBinary(istream& in) { } template -bool CompactedDBG::readBinaryIndex(const string& fn, const uint64_t checksum) { +bool CompactedDBG::readBinaryIndex(const std::string& fn, const uint64_t checksum) { if ((fn.length() == 0) || !check_file_exists(fn)) return false; - ifstream infile; - istream in(0); + std::ifstream infile; + std::istream in(0); infile.open(fn.c_str()); in.rdbuf(infile.rdbuf()); @@ -946,13 +946,13 @@ bool CompactedDBG::readBinaryIndex(const string& fn, const uint64_t checks } template -bool CompactedDBG::readBinaryIndexHead(const string& fn, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, +bool CompactedDBG::readBinaryIndexHead(const std::string& fn, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, size_t& h_kmers_ccov_sz, size_t& hmap_min_unitigs_sz, uint64_t& read_checksum) const { if ((fn.length() == 0) || !check_file_exists(fn)) return false; - ifstream infile; - istream in(0); + std::ifstream infile; + std::istream in(0); infile.open(fn.c_str()); in.rdbuf(infile.rdbuf()); @@ -961,7 +961,7 @@ bool CompactedDBG::readBinaryIndexHead(const string& fn, size_t& file_form } template -bool CompactedDBG::readBinaryIndexHead(istream& in, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, +bool CompactedDBG::readBinaryIndexHead(std::istream& in, size_t& file_format_version, size_t& v_unitigs_sz, size_t& km_unitigs_sz, size_t& h_kmers_ccov_sz, size_t& hmap_min_unitigs_sz, uint64_t& read_checksum) const { if (in.fail()) return false; @@ -978,7 +978,7 @@ bool CompactedDBG::readBinaryIndexHead(istream& in, size_t& file_format_ve } template -bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { +bool CompactedDBG::readBinaryIndex(std::istream& in, const uint64_t checksum) { bool read_success = !in.fail(); @@ -995,22 +995,22 @@ bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { if (!read_success || (file_format_header != BFG_METABIN_FORMAT_HEADER)) { - cerr << "CompactedDBG::readBinaryIndex(): Unrecognized Bifrost index file header." << endl; + std::cerr << "CompactedDBG::readBinaryIndex(): Unrecognized Bifrost index file header." << std::endl; return false; // Is not an index file } if (!read_success || (file_format_version!= BFG_METABIN_FORMAT_VERSION)) { - cerr << "CompactedDBG::readBinaryIndex(): Current Bifrost version (" << BFG_VERSION << ") can only read index files in version v" << - BFG_METABIN_FORMAT_VERSION << " but provided input index file is in version v" << file_format_version << "." << endl; + std::cerr << "CompactedDBG::readBinaryIndex(): Current Bifrost version (" << BFG_VERSION << ") can only read index files in version v" << + BFG_METABIN_FORMAT_VERSION << " but provided input index file is in version v" << file_format_version << "." << std::endl; return false; // Is not a compatible index file version } if (!read_success || (read_checksum != checksum)) { - cerr << "CompactedDBG::readBinaryIndex(): Graph checksum does not match, input file(s) might be corrupted" << endl; + std::cerr << "CompactedDBG::readBinaryIndex(): Graph checksum does not match, input file(s) might be corrupted" << std::endl; return false; } @@ -1024,7 +1024,7 @@ bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { in.read(reinterpret_cast(&nb_bmp_unitigs), sizeof(size_t)); - vector v_bmp_unitigs(nb_bmp_unitigs); + std::vector v_bmp_unitigs(nb_bmp_unitigs); for (size_t i = 0; read_success && (i < nb_bmp_unitigs); ++i) read_success = v_bmp_unitigs[i].read(in); @@ -1072,7 +1072,7 @@ bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { in.read(reinterpret_cast(&nb_bmp_km), sizeof(size_t)); - vector v_bmp_km(nb_bmp_km); + std::vector v_bmp_km(nb_bmp_km); for (size_t i = 0; (i < nb_bmp_km) && read_success; ++i) read_success = v_bmp_km[i].read(in); @@ -1118,8 +1118,8 @@ bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { if (read_success) { - vector v_bmp_abundant((nb_special_minz >> 32) + 1); - vector v_bmp_overcrowded((nb_special_minz >> 32) + 1); + std::vector v_bmp_abundant((nb_special_minz >> 32) + 1); + std::vector v_bmp_overcrowded((nb_special_minz >> 32) + 1); for (size_t i = 0; (i < v_bmp_abundant.size()) && read_success; ++i) read_success = v_bmp_abundant[i].read(in); for (size_t i = 0; (i < v_bmp_overcrowded.size()) && read_success; ++i) read_success = v_bmp_overcrowded[i].read(in); @@ -1185,12 +1185,12 @@ bool CompactedDBG::readBinaryIndex(istream& in, const uint64_t checksum) { } template -pair CompactedDBG::readBinaryGraph(const string& fn) { +std::pair CompactedDBG::readBinaryGraph(const std::string& fn) { if ((fn.length() == 0) || !check_file_exists(fn)) return {0, false}; - ifstream infile; - istream in(0); + std::ifstream infile; + std::istream in(0); infile.open(fn.c_str()); in.rdbuf(infile.rdbuf()); @@ -1199,7 +1199,7 @@ pair CompactedDBG::readBinaryGraph(const string& fn) { } template -pair CompactedDBG::readBinaryGraph(istream& in) { +std::pair CompactedDBG::readBinaryGraph(std::istream& in) { bool read_success = !in.fail(); @@ -1232,15 +1232,15 @@ pair CompactedDBG::readBinaryGraph(istream& in) { if (file_format_header != BFG_GRAPHBIN_FORMAT_HEADER) { - cerr << "CompactedDBG::readBinaryGraph(): Unrecognized Bifrost binary graph file header." << endl; + std::cerr << "CompactedDBG::readBinaryGraph(): Unrecognized Bifrost binary graph file header." << std::endl; return {graph_checksum, false}; } if (file_format_version != BFG_GRAPHBIN_FORMAT_VERSION) { - cerr << "CompactedDBG::readBinaryGraph(): Current Bifrost version (" << BFG_VERSION << ") can only read binary graph files in version v" << - BFG_GRAPHBIN_FORMAT_VERSION << " but provided input binary graph file is in version v" << file_format_version << "." << endl; + std::cerr << "CompactedDBG::readBinaryGraph(): Current Bifrost version (" << BFG_VERSION << ") can only read binary graph files in version v" << + BFG_GRAPHBIN_FORMAT_VERSION << " but provided input binary graph file is in version v" << file_format_version << "." << std::endl; return {graph_checksum, false}; } @@ -1271,7 +1271,7 @@ pair CompactedDBG::readBinaryGraph(istream& in) { read_success = cs.read(in); graph_checksum = cs.hash(graph_checksum); cc = CompressedCoverage(cs.size() - k_ + 1, false); - unitig = new Unitig(move(cs), move(cc)); + unitig = new Unitig(std::move(cs), std::move(cc)); v_unitigs.push_back(unitig); } @@ -1322,12 +1322,12 @@ pair CompactedDBG::readBinaryGraph(istream& in) { } template -bool CompactedDBG::writeBinary(const string& fn, const size_t nb_threads) const { +bool CompactedDBG::writeBinary(const std::string& fn, const size_t nb_threads) const { if (fn.length() == 0) return false; - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(fn.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1336,7 +1336,7 @@ bool CompactedDBG::writeBinary(const string& fn, const size_t nb_threads) } template -bool CompactedDBG::writeBinary(ostream& out, const size_t nb_threads) const { +bool CompactedDBG::writeBinary(std::ostream& out, const size_t nb_threads) const { if (!out.fail()) { @@ -1349,12 +1349,12 @@ bool CompactedDBG::writeBinary(ostream& out, const size_t nb_threads) cons } template -bool CompactedDBG::writeBinaryGraph(const string& fn, const size_t nb_threads) const { +bool CompactedDBG::writeBinaryGraph(const std::string& fn, const size_t nb_threads) const { if (fn.length() == 0) return false; - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(fn.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1363,7 +1363,7 @@ bool CompactedDBG::writeBinaryGraph(const string& fn, const size_t nb_thre } template -bool CompactedDBG::writeBinaryGraph(ostream& out, const size_t nb_threads) const { +bool CompactedDBG::writeBinaryGraph(std::ostream& out, const size_t nb_threads) const { bool write_success = !out.fail(); @@ -1410,12 +1410,12 @@ bool CompactedDBG::writeBinaryGraph(ostream& out, const size_t nb_threads) } template -bool CompactedDBG::writeBinaryIndex(const string& fn, const uint64_t checksum, const size_t nb_threads) const { +bool CompactedDBG::writeBinaryIndex(const std::string& fn, const uint64_t checksum, const size_t nb_threads) const { if (fn.length() == 0) return false; - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(fn.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1424,7 +1424,7 @@ bool CompactedDBG::writeBinaryIndex(const string& fn, const uint64_t check } template -bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, const size_t nb_threads) const { +bool CompactedDBG::writeBinaryIndex(std::ostream& out, const uint64_t checksum, const size_t nb_threads) const { bool write_success = !out.fail(); @@ -1432,7 +1432,7 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, std::atomic nb_special_minz; - vector v_bmp_minz(nb_bmp_minz); + std::vector v_bmp_minz(nb_bmp_minz); nb_special_minz = 0; @@ -1461,9 +1461,9 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, if (write_success) { const size_t v_unitigs_sz = v_unitigs.size(); - const size_t nb_block_unitigs = max(static_cast((v_unitigs_sz + 15) / 16) + 1, static_cast(1)); + const size_t nb_block_unitigs = std::max(static_cast((v_unitigs_sz + 15) / 16) + 1, static_cast(1)); - vector v_block_len_unitigs(nb_block_unitigs, 0); + std::vector v_block_len_unitigs(nb_block_unitigs, 0); for (size_t i = 0; i < v_unitigs_sz; ++i) v_block_len_unitigs[(i >> 4) + 1] += v_unitigs[i]->getSeq().size() - g_ + 1; for (size_t i = 1; i < nb_block_unitigs; ++i) v_block_len_unitigs[i] += v_block_len_unitigs[i-1]; @@ -1471,12 +1471,12 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, const size_t nb_bmp_unitigs = (v_block_len_unitigs.back() >> 32) + 1; const size_t nb_bmp_km_short = ((km_unitigs.size() * (k_ - g_ + 1)) >> 32) + 1; - vector v_bmp_unitigs(nb_bmp_unitigs), v_bmp_km_short(nb_bmp_km_short); - vector s_bmp_unitigs(nb_bmp_unitigs), s_bmp_km_short(nb_bmp_km_short), s_bmp_minz(nb_bmp_minz); + std::vector v_bmp_unitigs(nb_bmp_unitigs), v_bmp_km_short(nb_bmp_km_short); + std::vector s_bmp_unitigs(nb_bmp_unitigs), s_bmp_km_short(nb_bmp_km_short), s_bmp_minz(nb_bmp_minz); auto compactMinimizers = [&](MinimizerIndex::const_iterator it, MinimizerIndex::const_iterator ite, size_t id_minz) { - vector lv_bmp_unitigs(nb_bmp_unitigs), lv_bmp_km_short(nb_bmp_km_short), lv_bmp_minz(nb_bmp_minz); + std::vector lv_bmp_unitigs(nb_bmp_unitigs), lv_bmp_km_short(nb_bmp_km_short), lv_bmp_minz(nb_bmp_minz); size_t l_nb_special_minz = 0; @@ -1608,9 +1608,9 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, } else { - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_minz_idx; + std::mutex mutex_minz_idx; for (size_t t = 0; t < nb_threads; ++t){ @@ -1626,7 +1626,7 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, while (true) { { - unique_lock lock(mutex_minz_idx); + std::unique_lock lock(mutex_minz_idx); if (it == ite) return; @@ -1682,7 +1682,7 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, size_t id_special = 0; - vector v_bmp_abundant(nb_bmp_special_minz), v_bmp_overcrowded(nb_bmp_special_minz); + std::vector v_bmp_abundant(nb_bmp_special_minz), v_bmp_overcrowded(nb_bmp_special_minz); { size_t id_minz = 0; @@ -1815,7 +1815,7 @@ bool CompactedDBG::writeBinaryIndex(ostream& out, const uint64_t checksum, } template -void CompactedDBG::makeGraphFromGFA(const string& fn, const size_t nb_threads) { +void CompactedDBG::makeGraphFromGFA(const std::string& fn, const size_t nb_threads) { size_t graph_file_id = 0; @@ -1848,9 +1848,9 @@ void CompactedDBG::makeGraphFromGFA(const string& fn, const size_t nb_thre SpinLock lck_unitig, lck_kmer; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; v_kmers_sz = 0; v_unitigs_sz = 0; @@ -1863,12 +1863,12 @@ void CompactedDBG::makeGraphFromGFA(const string& fn, const size_t nb_thre [&]{ - vector seq; + std::vector seq; while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) return; @@ -1899,13 +1899,13 @@ void CompactedDBG::makeGraphFromGFA(const string& fn, const size_t nb_thre } template -void CompactedDBG::makeGraphFromFASTA(const string& fn, const size_t nb_threads) { +void CompactedDBG::makeGraphFromFASTA(const std::string& fn, const size_t nb_threads) { size_t graph_file_id = 0; - FastqFile ff(vector(1, fn)); + FastqFile ff(std::vector(1, fn)); - string seq; + std::string seq; /*if (nb_threads == 1)*/{ @@ -1922,9 +1922,9 @@ void CompactedDBG::makeGraphFromFASTA(const string& fn, const size_t nb_th SpinLock lck_unitig, lck_kmer; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; v_kmers_sz = 0; v_unitigs_sz = 0; @@ -1937,12 +1937,12 @@ void CompactedDBG::makeGraphFromFASTA(const string& fn, const size_t nb_th [&]{ - vector v_seq; + std::vector v_seq; while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) return; @@ -1971,11 +1971,11 @@ void CompactedDBG::makeGraphFromFASTA(const string& fn, const size_t nb_th } template -pair CompactedDBG::readGraphFromIndexFASTA(const string& graph_fn, const string& index_fn, const size_t k, const size_t g) { +std::pair CompactedDBG::readGraphFromIndexFASTA(const std::string& graph_fn, const std::string& index_fn, const size_t k, const size_t g) { - FastqFile ff(vector(1, graph_fn)); + FastqFile ff(std::vector(1, graph_fn)); - string seq; + std::string seq; size_t file_format_version = 0, v_unitigs_sz = 0, km_unitigs_sz = 0, h_kmers_ccov_sz = 0, hmap_min_unitigs_sz = 0, graph_file_id = 0; uint64_t read_checksum = 0, graph_checksum = 0; @@ -2005,7 +2005,7 @@ pair CompactedDBG::readGraphFromIndexFASTA(const string& g Unitig* unitig; graph_checksum = cs.hash(graph_checksum); - unitig = new Unitig(move(cs), move(cc)); + unitig = new Unitig(std::move(cs), std::move(cc)); v_unitigs.push_back(unitig); } @@ -2074,7 +2074,7 @@ pair CompactedDBG::readGraphFromIndexFASTA(const string& g } template -pair CompactedDBG::readGraphFromIndexGFA(const string& graph_fn, const string& index_fn, const size_t k, const size_t g) { +std::pair CompactedDBG::readGraphFromIndexGFA(const std::string& graph_fn, const std::string& index_fn, const size_t k, const size_t g) { bool new_file_opened = false; @@ -2116,7 +2116,7 @@ pair CompactedDBG::readGraphFromIndexGFA(const string& gra Unitig* unitig; graph_checksum = cs.hash(graph_checksum); - unitig = new Unitig(move(cs), move(cc)); + unitig = new Unitig(std::move(cs), std::move(cc)); v_unitigs.push_back(unitig); } diff --git a/src/KmerCovIndex.hpp b/src/KmerCovIndex.hpp index a47aad5..97a37bc 100755 --- a/src/KmerCovIndex.hpp +++ b/src/KmerCovIndex.hpp @@ -40,8 +40,8 @@ class KmerCovIndex { BFG_INLINE static void setFullCoverage(const size_t cov_max) { - cov_full = min(cov_max, static_cast(2)); - cov_full = max(cov_full, static_cast(1)); + cov_full = std::min(cov_max, static_cast(2)); + cov_full = std::max(cov_full, static_cast(1)); } BFG_INLINE static size_t getFullCoverage() { @@ -133,7 +133,7 @@ class KmerCovIndex { size_t mask_mod; size_t sz; - vector*> v_blocks; + std::vector*> v_blocks; }; // Declare template specializations for type void diff --git a/src/KmerCovIndex.tcc b/src/KmerCovIndex.tcc index 90bc8c9..42254ba 100755 --- a/src/KmerCovIndex.tcc +++ b/src/KmerCovIndex.tcc @@ -4,7 +4,7 @@ KmerCovIndex::KmerCovIndex() : sz(0), shift_div(__builtin_ffsll(block_sz) - 1 template KmerCovIndex::KmerCovIndex(const KmerCovIndex& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod) { - v_blocks = vector*>(o.v_blocks.size()); + v_blocks = std::vector*>(o.v_blocks.size()); for (size_t i = 0; i < v_blocks.size(); ++i) { @@ -19,7 +19,7 @@ KmerCovIndex::KmerCovIndex(const KmerCovIndex& o) : sz(o.sz), shift_div(o.shi template<> inline KmerCovIndex::KmerCovIndex(const KmerCovIndex& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod) { - v_blocks = vector*>(o.v_blocks.size()); + v_blocks = std::vector*>(o.v_blocks.size()); for (size_t i = 0; i < v_blocks.size(); ++i) { @@ -31,7 +31,7 @@ inline KmerCovIndex::KmerCovIndex(const KmerCovIndex& o) : sz(o.sz), shift } template -KmerCovIndex::KmerCovIndex(KmerCovIndex&& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod), v_blocks(move(o.v_blocks)) { +KmerCovIndex::KmerCovIndex(KmerCovIndex&& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod), v_blocks(std::move(o.v_blocks)) { o.clear(); } @@ -53,7 +53,7 @@ KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex& o) { shift_div = o.shift_div; mask_mod = o.mask_mod; - v_blocks = vector*>(o.v_blocks.size()); + v_blocks = std::vector*>(o.v_blocks.size()); for (size_t i = 0; i < v_blocks.size(); ++i) { @@ -75,14 +75,14 @@ KmerCovIndex& KmerCovIndex::toData(KmerCovIndex&& o, const size_t nb shift_div = o.shift_div; mask_mod = o.mask_mod; - v_blocks = vector*>(o.v_blocks.size(), nullptr); + v_blocks = std::vector*>(o.v_blocks.size(), nullptr); auto copyBlock = [&](const size_t start, const size_t end){ for (size_t i = start; i < end; ++i) { v_blocks[i] = new Block; - v_blocks[i]->bc_cov = move(o.v_blocks[i]->bc_cov); + v_blocks[i]->bc_cov = std::move(o.v_blocks[i]->bc_cov); std::copy(o.v_blocks[i]->km_block, o.v_blocks[i]->km_block + block_sz, v_blocks[i]->km_block); @@ -95,7 +95,7 @@ KmerCovIndex& KmerCovIndex::toData(KmerCovIndex&& o, const size_t nb if ((nb_threads == 1) || (v_blocks.size() < nb_threads)) copyBlock(0, v_blocks.size()); else { - vector workers; + std::vector workers; const size_t slice = (v_blocks.size() / nb_threads) + 1; @@ -106,7 +106,7 @@ KmerCovIndex& KmerCovIndex::toData(KmerCovIndex&& o, const size_t nb [&, t]{ const size_t start = t * slice; - const size_t end = min(start + slice, v_blocks.size()); + const size_t end = std::min(start + slice, v_blocks.size()); if (start < v_blocks.size()) copyBlock(start, end); } @@ -132,7 +132,7 @@ inline KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex*>(o.v_blocks.size()); + v_blocks = std::vector*>(o.v_blocks.size()); for (size_t i = 0; i < v_blocks.size(); ++i) { @@ -238,7 +238,7 @@ bool KmerCovIndex::set(const size_t idx, const Kmer& km, const size_t cov) { if (cov_ != cov) { if (cov_ != 0) block->bc_cov.remove(idx_mod * cov_full + cov_ - 1); - if (cov != 0) block->bc_cov.add(idx_mod * cov_full + min(cov, static_cast(2)) - 1); + if (cov != 0) block->bc_cov.add(idx_mod * cov_full + std::min(cov, static_cast(2)) - 1); block->bc_cov.runOptimize(); } @@ -417,7 +417,7 @@ void KmerCovIndex::resize(const size_t new_sz) { Kmer km_empty; const size_t new_v_block_sz = (new_sz >> shift_div) + ((new_sz & mask_mod) != 0); - const size_t rounded_sz = min(new_v_block_sz << shift_div, sz); + const size_t rounded_sz = std::min(new_v_block_sz << shift_div, sz); const size_t nb_last_block = new_sz & mask_mod; for (size_t i = new_v_block_sz; i < v_blocks.size(); ++i) { @@ -486,7 +486,7 @@ inline void KmerCovIndex::resize(const size_t new_sz) { Kmer km_empty; const size_t new_v_block_sz = (new_sz >> shift_div) + ((new_sz & mask_mod) != 0); - const size_t rounded_sz = min(new_v_block_sz << shift_div, sz); + const size_t rounded_sz = std::min(new_v_block_sz << shift_div, sz); for (size_t i = new_v_block_sz; i < v_blocks.size(); ++i) { diff --git a/src/KmerHashTable.hpp b/src/KmerHashTable.hpp index b923620..9ee5082 100755 --- a/src/KmerHashTable.hpp +++ b/src/KmerHashTable.hpp @@ -145,7 +145,7 @@ struct KmerHashTable { const size_t sz_with_empty = static_cast((1.0 + (1.0 - ratio_occupancy)) * sz); - init_tables(max(sz_with_empty, static_cast(BIFROST_KHT_INIT_SZ))); + init_tables(std::max(sz_with_empty, static_cast(BIFROST_KHT_INIT_SZ))); } } @@ -450,14 +450,14 @@ struct KmerHashTable { } // Insert with Robin Hood hashing - pair insert(const Kmer& key, const T& val) { + std::pair insert(const Kmer& key, const T& val) { if (size_ == 0) init_tables(BIFROST_KHT_INIT_SZ); else if (pop >= static_cast(size_ * max_ratio_occupancy)) { - size_t resize = max(1.2 * size_, static_cast(1 + size_)); + size_t resize = std::max(1.2 * size_, static_cast(1 + size_)); - while (pop >= static_cast(resize * max_ratio_occupancy)) resize = max(1.2 * resize, static_cast(1 + resize)); + while (pop >= static_cast(resize * max_ratio_occupancy)) resize = std::max(1.2 * resize, static_cast(1 + resize)); reserve(resize); } @@ -470,7 +470,7 @@ struct KmerHashTable { size_t h_rich_psl_ins = 0; size_t psl_ins_key = 0, psl_rich_key = 0, psl_curr_key = 0; - pair it_ret; + std::pair it_ret; Kmer l_key = key; T l_val = val; @@ -503,7 +503,7 @@ struct KmerHashTable { if (!cascade_ins) it_ret = {iterator(this, h, psl_rich_key), true}; - max_psl = max(max_psl, psl_rich_key + 1); + max_psl = std::max(max_psl, psl_rich_key + 1); sum_psl -= psl_curr_key; sum_psl += psl_rich_key; @@ -516,7 +516,7 @@ struct KmerHashTable { table_keys[h] = std::move(l_key); table_values[h] = std::move(l_val); - max_psl = max(max_psl, psl_ins_key + 1); + max_psl = std::max(max_psl, psl_ins_key + 1); sum_psl += psl_ins_key; if (!cascade_ins) it_ret = {iterator(this, h, psl_ins_key), true}; @@ -550,7 +550,7 @@ struct KmerHashTable { } // Insert with Robin Hood hashing - pair insert(Kmer&& key, T&& val) { + std::pair insert(Kmer&& key, T&& val) { if (size_ == 0) init_tables(BIFROST_KHT_INIT_SZ); else if (pop >= static_cast(size_ * max_ratio_occupancy)) { @@ -570,7 +570,7 @@ struct KmerHashTable { size_t h_rich_psl_ins = 0; size_t psl_ins_key = 0, psl_rich_key = 0, psl_curr_key = 0; - pair it_ret; + std::pair it_ret; Kmer l_key = std::move(key); T l_val = std::move(val); @@ -603,7 +603,7 @@ struct KmerHashTable { if (!cascade_ins) it_ret = {iterator(this, h, psl_rich_key), true}; - max_psl = max(max_psl, psl_rich_key + 1); + max_psl = std::max(max_psl, psl_rich_key + 1); sum_psl -= psl_curr_key; sum_psl += psl_rich_key; @@ -616,7 +616,7 @@ struct KmerHashTable { table_keys[h] = std::move(l_key); table_values[h] = std::move(l_val); - max_psl = max(max_psl, psl_ins_key + 1); + max_psl = std::max(max_psl, psl_ins_key + 1); sum_psl += psl_ins_key; if (!cascade_ins) it_ret = {iterator(this, h, psl_ins_key), true}; @@ -664,7 +664,7 @@ struct KmerHashTable { const size_t h = fastmod::fastmod_u64(table_keys[i].hash(), M_u64, size_); const size_t psl = ((size_ - h + i) & (static_cast(i >= h) - 1)) + ((i - h) & (static_cast(i < h) - 1)); - max_psl = max(max_psl, psl + 1); + max_psl = std::max(max_psl, psl + 1); } } } @@ -672,9 +672,9 @@ struct KmerHashTable { const size_t chunk_per_thread = (size_ + nb_threads - 1) / nb_threads; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mtx_max_psl; + std::mutex mtx_max_psl; for (size_t t = 0; t < nb_threads; ++t){ @@ -683,7 +683,7 @@ struct KmerHashTable { [&, t]{ const size_t chunk_start = t * chunk_per_thread; - const size_t chunk_end = min(((t+1) * chunk_per_thread), size_); + const size_t chunk_end = std::min(((t+1) * chunk_per_thread), size_); size_t l_max_psl = 1; @@ -694,14 +694,14 @@ struct KmerHashTable { const size_t h = fastmod::fastmod_u64(table_keys[i].hash(), M_u64, size_); const size_t psl = ((size_ - h + i) & (static_cast(i >= h) - 1)) + ((i - h) & (static_cast(i < h) - 1)); - l_max_psl = max(l_max_psl, psl + 1); + l_max_psl = std::max(l_max_psl, psl + 1); } } { - unique_lock lock(mtx_max_psl); + std::unique_lock lock(mtx_max_psl); - max_psl = max(max_psl, l_max_psl); + max_psl = std::max(max_psl, l_max_psl); } } ); diff --git a/src/KmerIterator.cpp b/src/KmerIterator.cpp index d3679e7..60315a1 100755 --- a/src/KmerIterator.cpp +++ b/src/KmerIterator.cpp @@ -3,6 +3,8 @@ #include "Kmer.hpp" #include "KmerIterator.hpp" +using namespace std; + KmerIterator& KmerIterator::operator++() { if (!invalid) { diff --git a/src/KmerIterator.hpp b/src/KmerIterator.hpp index 016f869..62524b9 100755 --- a/src/KmerIterator.hpp +++ b/src/KmerIterator.hpp @@ -54,12 +54,12 @@ class KmerIterator : public std::iterator& operator*() const { + BFG_INLINE const std::pair& operator*() const { return p; } - BFG_INLINE const pair* operator->() const { + BFG_INLINE const std::pair* operator->() const { return &p; } @@ -68,7 +68,7 @@ class KmerIterator : public std::iterator p; + std::pair p; int pos_s, pos_e; }; diff --git a/src/KmerStream.hpp b/src/KmerStream.hpp index fd93a8e..03cbbc3 100755 --- a/src/KmerStream.hpp +++ b/src/KmerStream.hpp @@ -25,11 +25,10 @@ #define NB_STREAMCOUNTER_PER_READHASHER 1 -using namespace std; struct KmerStream_Build_opt { - vector files; + std::vector files; bool verbose; @@ -112,7 +111,7 @@ class ReadQualityHasherMinimizer { // create hashes for all k-mers // operate on hashes - pair update(const char* s, const size_t l, const char* q, const size_t ql) { + std::pair update(const char* s, const size_t l, const char* q, const size_t ql) { if (l < k) return {0, 0}; @@ -181,7 +180,7 @@ class ReadQualityHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update(const char* seq_buf, const char* qual_buf, const size_t buf_sz) { + std::pair update(const char* seq_buf, const char* qual_buf, const size_t buf_sz) { const char q_base_cut = static_cast(q_base + q_cutoff); @@ -263,7 +262,7 @@ class ReadQualityHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update_p(const char* s, const size_t l, const char* q, const size_t ql) { + std::pair update_p(const char* s, const size_t l, const char* q, const size_t ql) { if (l < k) return {0,0}; @@ -346,7 +345,7 @@ class ReadQualityHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update_p(const char* seq_buf, const char* qual_buf, const size_t buf_sz) { + std::pair update_p(const char* seq_buf, const char* qual_buf, const size_t buf_sz) { const char q_base_cut = static_cast(q_base + q_cutoff); @@ -532,7 +531,7 @@ class ReadHasherMinimizer { ReadHasherMinimizer(const ReadHasherMinimizer& o) : k(o.k), g(o.g), sc_min(o.sc_min), sc_km(o.sc_km) {} - ReadHasherMinimizer(ReadQualityHasherMinimizer&& o) : k(o.k), g(o.g), sc_min(move(o.sc_min)), sc_km(move(o.sc_km)) {} + ReadHasherMinimizer(ReadQualityHasherMinimizer&& o) : k(o.k), g(o.g), sc_min(std::move(o.sc_min)), sc_km(std::move(o.sc_km)) {} ReadHasherMinimizer(const ReadQualityHasherMinimizer& o) : k(o.k), g(o.g), sc_min(o.sc_min), sc_km(o.sc_km) {} @@ -570,7 +569,7 @@ class ReadHasherMinimizer { // create hashes for all k-mers // operate on hashes - pair update(const char *s, const size_t l, const char *q, const size_t ql) { + std::pair update(const char *s, const size_t l, const char *q, const size_t ql) { if (l < k) return {0,0}; @@ -637,7 +636,7 @@ class ReadHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update(const char* seq_buf, const size_t seq_buf_sz) { + std::pair update(const char* seq_buf, const size_t seq_buf_sz) { const char* str = seq_buf; const char* str_end = seq_buf + seq_buf_sz; @@ -715,7 +714,7 @@ class ReadHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update_p(const char *s, const size_t l, const char *q, const size_t ql) { + std::pair update_p(const char *s, const size_t l, const char *q, const size_t ql) { if (l < k) return {0,0}; @@ -800,7 +799,7 @@ class ReadHasherMinimizer { return {l_sumCount_min_F1, l_sumCount_km_F1}; } - pair update_p(const char* seq_buf, const size_t seq_buf_sz) { + std::pair update_p(const char* seq_buf, const size_t seq_buf_sz) { const char* str = seq_buf; const char* str_end = seq_buf + seq_buf_sz; @@ -999,49 +998,49 @@ class KmerStream { if (nb_threads <= 0){ - cerr << "KmerStream::KmerStream(): Number of threads cannot be less than or equal to 0" << endl; + std::cerr << "KmerStream::KmerStream(): Number of threads cannot be less than or equal to 0" << std::endl; invalid = true; } if (nb_threads > max_threads){ - cerr << "KmerStream::KmerStream(): Number of threads cannot be greater than or equal to " << max_threads << endl; + std::cerr << "KmerStream::KmerStream(): Number of threads cannot be greater than or equal to " << max_threads << std::endl; invalid = true; } if (k == 0){ - cerr << "KmerStream::KmerStream(): Length k of k-mers cannot be less than or equal to 0" << endl; + std::cerr << "KmerStream::KmerStream(): Length k of k-mers cannot be less than or equal to 0" << std::endl; invalid = true; } if (g <= 0){ - cerr << "KmerStream::KmerStream(): Length g of minimizers cannot be less than or equal to 0" << endl; + std::cerr << "KmerStream::KmerStream(): Length g of minimizers cannot be less than or equal to 0" << std::endl; invalid = true; } if (g > k){ - cerr << "KmerStream::KmerStream(): Length g of minimizers cannot be greater than length k of k-mers" << endl; + std::cerr << "KmerStream::KmerStream(): Length g of minimizers cannot be greater than length k of k-mers" << std::endl; invalid = true; } if (e <= 0){ - cerr << "KmerStream::KmerStream(): Guaranteed error rate cannot be less than or equal to 0" << endl; + std::cerr << "KmerStream::KmerStream(): Guaranteed error rate cannot be less than or equal to 0" << std::endl; invalid = true; } if ((q_base != 33) && (q_base != 64)){ - cerr << "KmerStream::KmerStream(): Quality score can only be PHREAD+64 (q_base=64) or PHREAD+33 (q_base=33)" << endl; + std::cerr << "KmerStream::KmerStream(): Quality score can only be PHREAD+64 (q_base=64) or PHREAD+33 (q_base=33)" << std::endl; invalid = true; } if (opt.files.size() == 0) { - cerr << "KmerStream::KmerStream(): Missing input files" << endl; + std::cerr << "KmerStream::KmerStream(): Missing input files" << std::endl; invalid = true; } else { @@ -1055,7 +1054,7 @@ class KmerStream { if (intStat != 0) { - cerr << "KmerStream::KmerStream(): File not found: " << s << endl; + std::cerr << "KmerStream::KmerStream(): File not found: " << s << std::endl; invalid = true; } else { @@ -1064,7 +1063,7 @@ class KmerStream { if (format == -1){ - cerr << "KmerStream::KmerStream(): Input file " << s << " does not exist, is ill-formed or is not in FASTA/FASTQ/GFA format." << endl; + std::cerr << "KmerStream::KmerStream(): Input file " << s << " does not exist, is ill-formed or is not in FASTA/FASTQ/GFA format." << std::endl; invalid = true; } @@ -1078,19 +1077,19 @@ class KmerStream { if (invalid) exit(1); { - if (verbose) cout << "KmerStream::KmerStream(): Start computing k-mer cardinality estimations (1/2)" << endl; + if (verbose) std::cout << "KmerStream::KmerStream(): Start computing k-mer cardinality estimations (1/2)" << std::endl; rqh.initialize(e, q, q_base, k, g); if (files_with_quality.size() != 0) nb_threads > 1 ? RunThreadedQualityStream() : RunQualityStream(); - rsh = move(rqh); + rsh = std::move(rqh); - if (verbose) cout << "KmerStream::KmerStream(): Start computing k-mer cardinality estimations (1/2)" << endl; + if (verbose) std::cout << "KmerStream::KmerStream(): Start computing k-mer cardinality estimations (1/2)" << std::endl; if (files_no_quality.size() != 0) nb_threads > 1 ? RunThreadedSequenceStream() : RunSequenceStream(); - if (verbose) cout << "KmerStream::KmerStream(): Finished" << endl; + if (verbose) std::cout << "KmerStream::KmerStream(): Finished" << std::endl; //rsh.join(rqh); } @@ -1116,7 +1115,7 @@ class KmerStream { size_t file_id = 0; - string seq; + std::string seq; while (fp.read(seq, file_id)){ @@ -1124,7 +1123,7 @@ class KmerStream { std::transform(seq.begin(), seq.end(), seq.begin(), ::toupper); - const pair F1 = rqh.update(seq.c_str(), seq.length(), qss, strlen(qss)); + const std::pair F1 = rqh.update(seq.c_str(), seq.length(), qss, strlen(qss)); min_F1 += F1.first; km_F1 += F1.second; @@ -1141,11 +1140,11 @@ class KmerStream { const size_t max_len_seq = rndup(static_cast(1024 + k - 1)); const size_t thread_seq_buf_sz = BUFFER_SIZE; - string seq, qual; + std::string seq, qual; FileParser fp(files_with_quality); - auto reading_function = [&](char* seq_buf, char* qual_buf, size_t& buf_sz) { + auto reading_function = [&](char* seq_buf, char* qual_buf, size_t& buf_sz) -> bool { size_t file_id = 0; @@ -1202,11 +1201,11 @@ class KmerStream { }; { - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them bool stop = false; - mutex mutex_file; + std::mutex mutex_file; for (size_t t = 0; t < nb_threads; ++t){ @@ -1225,7 +1224,7 @@ class KmerStream { while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop){ @@ -1243,7 +1242,7 @@ class KmerStream { for (char* s = buffer_seq; s != (buffer_seq + thread_seq_buf_sz); ++s) *s &= 0xDF; - const pair F1 = rqh.update_p(buffer_seq, buffer_qual, buffer_sz); + const std::pair F1 = rqh.update_p(buffer_seq, buffer_qual, buffer_sz); l_min_F1 += F1.first; l_km_F1 += F1.second; @@ -1265,7 +1264,7 @@ class KmerStream { size_t file_id = 0; - string seq; + std::string seq; FileParser fp(files_no_quality); @@ -1273,7 +1272,7 @@ class KmerStream { std::transform(seq.begin(), seq.end(), seq.begin(), ::toupper); - const pair F1 = rsh.update(seq.c_str(), seq.length()); + const std::pair F1 = rsh.update(seq.c_str(), seq.length()); min_F1 += F1.first; km_F1 += F1.second; @@ -1291,9 +1290,9 @@ class KmerStream { FileParser fp(files_no_quality); - string s; + std::string s; - auto reading_function = [&](char* seq_buf, size_t& seq_buf_sz) { + auto reading_function = [&](char* seq_buf, size_t& seq_buf_sz) -> bool { size_t file_id = 0; @@ -1344,9 +1343,9 @@ class KmerStream { }; { - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mutex_file; + std::mutex mutex_file; bool stop = false; @@ -1365,7 +1364,7 @@ class KmerStream { while (true) { { - unique_lock lock(mutex_file); + std::unique_lock lock(mutex_file); if (stop) { @@ -1382,7 +1381,7 @@ class KmerStream { for (char* s = buffer_seq; s != (buffer_seq + thread_seq_buf_sz); ++s) *s &= 0xDF; - const pair F1 = rsh.update_p(buffer_seq, buffer_seq_sz); + const std::pair F1 = rsh.update_p(buffer_seq, buffer_seq_sz); l_min_F1 += F1.first; l_km_F1 += F1.second; @@ -1412,8 +1411,8 @@ class KmerStream { ReadQualityHasherMinimizer rqh; ReadHasherMinimizer rsh; - vector files_no_quality; - vector files_with_quality; + std::vector files_no_quality; + std::vector files_with_quality; bool verbose; bool invalid; diff --git a/src/MinimizerIndex.cpp b/src/MinimizerIndex.cpp index b86e25b..26d28bc 100755 --- a/src/MinimizerIndex.cpp +++ b/src/MinimizerIndex.cpp @@ -1,5 +1,7 @@ #include "MinimizerIndex.hpp" +using namespace std; + MinimizerIndex::MinimizerIndex() : table_keys(nullptr), table_tinyv(nullptr), table_tinyv_sz(nullptr) { clear_tables(); @@ -355,9 +357,9 @@ pair MinimizerIndex::insert(const Minimizer& key std::swap(table_keys[h], l_key); - l_ptv_swap.move(l_flag_swap, move(table_tinyv[h]), move(table_tinyv_sz[h])); - table_tinyv[h].move(table_tinyv_sz[h], move(l_ptv), move(l_flag)); - l_ptv.move(l_flag, move(l_ptv_swap), move(l_flag_swap)); + l_ptv_swap.move(l_flag_swap, std::move(table_tinyv[h]), std::move(table_tinyv_sz[h])); + table_tinyv[h].move(table_tinyv_sz[h], std::move(l_ptv), std::move(l_flag)); + l_ptv.move(l_flag, std::move(l_ptv_swap), std::move(l_flag_swap)); if (!cascade_ins) it_ret = {iterator(this, h, psl_rich_key), true}; @@ -373,7 +375,7 @@ pair MinimizerIndex::insert(const Minimizer& key table_keys[h] = l_key; table_tinyv_sz[h] = packed_tiny_vector::FLAG_EMPTY; - table_tinyv[h].move(table_tinyv_sz[h], move(l_ptv), move(l_flag)); + table_tinyv[h].move(table_tinyv_sz[h], std::move(l_ptv), std::move(l_flag)); max_psl = max(max_psl, psl_ins_key + 1); sum_psl += psl_ins_key; @@ -601,9 +603,9 @@ void MinimizerIndex::swap(const size_t i, const size_t j) { packed_tiny_vector ptv; - ptv.move(ptv_sz, move(table_tinyv[i]), move(table_tinyv_sz[i])); - table_tinyv[i].move(table_tinyv_sz[i], move(table_tinyv[j]), move(table_tinyv_sz[j])); - table_tinyv[j].move(table_tinyv_sz[j], move(ptv), move(ptv_sz)); + ptv.move(ptv_sz, std::move(table_tinyv[i]), std::move(table_tinyv_sz[i])); + table_tinyv[i].move(table_tinyv_sz[i], std::move(table_tinyv[j]), std::move(table_tinyv_sz[j])); + table_tinyv[j].move(table_tinyv_sz[j], std::move(ptv), std::move(ptv_sz)); std::swap(table_keys[i], table_keys[j]); } diff --git a/src/MinimizerIndex.hpp b/src/MinimizerIndex.hpp index 0df326d..4253d9d 100755 --- a/src/MinimizerIndex.hpp +++ b/src/MinimizerIndex.hpp @@ -188,7 +188,7 @@ class MinimizerIndex { return erase(it); } - pair insert(const Minimizer& key, const packed_tiny_vector& v, const uint8_t& flag); + std::pair insert(const Minimizer& key, const packed_tiny_vector& v, const uint8_t& flag); iterator begin(); const_iterator begin() const; diff --git a/src/RepHash.hpp b/src/RepHash.hpp index 30ace74..46853f4 100755 --- a/src/RepHash.hpp +++ b/src/RepHash.hpp @@ -93,7 +93,7 @@ class RepHash { uint64_t hashes[2] = {h, ht}; - if (hashes[1] < hashes[0]) swap(hashes[0], hashes[1]); + if (hashes[1] < hashes[0]) std::swap(hashes[0], hashes[1]); return wyhash(hashes, sizeof(uint64_t) + sizeof(uint64_t), 0, _wyp); } @@ -140,7 +140,7 @@ class RepHash { size_t k; uint64_t h, ht; - string str; + std::string str; }; #else @@ -203,7 +203,7 @@ class RepHash { uint64_t hashes[2] = {h.lo, ht.lo}; - if (hashes[1] < hashes[0]) swap(hashes[0], hashes[1]); + if (hashes[1] < hashes[0]) std::swap(hashes[0], hashes[1]); return wyhash(hashes, sizeof(uint64_t) + sizeof(uint64_t), 0, _wyp); } @@ -275,7 +275,7 @@ class RepHash { x.hi = (x.hi << k) | ((x.lo & lastkmask) >> (64 - k)); x.lo = (x.lo << k) | (upper >> (64 - k)); - if (full_k & 64) swap(x.hi, x.lo); + if (full_k & 64) std::swap(x.hi, x.lo); } inline void fastrightshiftk(rep_state_t& x) const { @@ -285,7 +285,7 @@ class RepHash { x.hi = (x.hi >> k) | ((x.lo & firstkmask) << (64 - k)); x.lo = (x.lo >> k) | (lower << (64 - k)); - if (full_k & 64) swap(x.hi, x.lo); + if (full_k & 64) std::swap(x.hi, x.lo); } inline void fastleftshift1(rep_state_t& x) const { diff --git a/src/Search.tcc b/src/Search.tcc index 3f52e29..bcdcf70 100755 --- a/src/Search.tcc +++ b/src/Search.tcc @@ -2,13 +2,13 @@ #define BIFROST_SEARCH_CDBG_TCC template -vector>> CompactedDBG::searchSequence( const string& s, const bool exact, const bool insertion, +std::vector>> CompactedDBG::searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match) { struct hash_pair { - size_t operator()(const pair& p) const { + size_t operator()(const std::pair& p) const { return wyhash(&(p.first), sizeof(size_t), 0, _wyp) ^ p.second.hash(); } @@ -16,27 +16,27 @@ vector>> CompactedDBG::searchSequence( cons if (invalid){ - cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << std::endl; - return vector>>(); + return std::vector>>(); } if (s.length() < k_){ - cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; + std::cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << std::endl; - return vector>>(); + return std::vector>>(); } Roaring rpos; - vector>> v_um; + std::vector>> v_um; - string s_inexact; + std::string s_inexact; - unordered_set, hash_pair> us_pos_km; + std::unordered_set, hash_pair> us_pos_km; - auto comp_pair = [](const pair>& p1, const pair>& p2) { + auto comp_pair = [](const std::pair>& p1, const std::pair>& p2) -> bool { return (p1.first < p2.first); }; @@ -109,7 +109,7 @@ vector>> CompactedDBG::searchSequence( cons Minimizer minz; - pair minz_pres = {0xffffffffffffffffULL, true}; + std::pair minz_pres = {0xffffffffffffffffULL, true}; while (ki_s != ki_e) { @@ -247,13 +247,13 @@ vector>> CompactedDBG::searchSequence( cons } template -vector>> CompactedDBG::searchSequence( const string& s, const bool exact, const bool insertion, +std::vector>> CompactedDBG::searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match) { struct hash_pair { - size_t operator()(const pair& p) const { + size_t operator()(const std::pair& p) const { return wyhash(&(p.first), sizeof(size_t), 0, _wyp) ^ p.second.hash(); } @@ -261,43 +261,43 @@ vector>> CompactedDBG::searchSequence( cons if (invalid){ - cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << std::endl; - return vector>>(); + return std::vector>>(); } if (ratio_kmers <= 0.0){ - cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than or equal to 0.0" << endl; + std::cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than or equal to 0.0" << std::endl; - return vector>>(); + return std::vector>>(); } if (ratio_kmers > 1.0){ - cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << endl; + std::cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << std::endl; - return vector>>(); + return std::vector>>(); } if (s.length() < k_){ - cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; + std::cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << std::endl; - return vector>>(); + return std::vector>>(); } - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(s.length() - k_ + 1) * ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(s.length() - k_ + 1) * ratio_kmers))); Roaring rpos; - vector>> v_um; + std::vector>> v_um; - string s_inexact; + std::string s_inexact; - unordered_set, hash_pair> us_pos_km; + std::unordered_set, hash_pair> us_pos_km; - auto comp_pair = [](const pair>& p1, const pair>& p2) { + auto comp_pair = [](const std::pair>& p1, const std::pair>& p2) -> bool { return (p1.first < p2.first); }; @@ -378,7 +378,7 @@ vector>> CompactedDBG::searchSequence( cons Minimizer minz; - pair minz_pres = {0xffffffffffffffffULL, true}; + std::pair minz_pres = {0xffffffffffffffffULL, true}; while (ki_s != ki_e) { @@ -523,13 +523,13 @@ vector>> CompactedDBG::searchSequence( cons } template -vector>> CompactedDBG::searchSequence( const string& s, const bool exact, const bool insertion, +std::vector>> CompactedDBG::searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match) const { struct hash_pair { - size_t operator()(const pair& p) const { + size_t operator()(const std::pair& p) const { return wyhash(&(p.first), sizeof(size_t), 0, _wyp) ^ p.second.hash(); } @@ -537,27 +537,27 @@ vector>> CompactedDBG::searchSequence( if (invalid){ - cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << std::endl; - return vector>>(); + return std::vector>>(); } if (s.length() < k_){ - cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; + std::cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << std::endl; - return vector>>(); + return std::vector>>(); } Roaring rpos; - vector>> v_um; + std::vector>> v_um; - string s_inexact; + std::string s_inexact; - unordered_set, hash_pair> us_pos_km; + std::unordered_set, hash_pair> us_pos_km; - auto comp_pair = [](const pair>& p1, const pair>& p2) { + auto comp_pair = [](const std::pair>& p1, const std::pair>& p2) -> bool { return (p1.first < p2.first); }; @@ -630,7 +630,7 @@ vector>> CompactedDBG::searchSequence( Minimizer minz; - pair minz_pres = {0xffffffffffffffffULL, true}; + std::pair minz_pres = {0xffffffffffffffffULL, true}; while (ki_s != ki_e) { @@ -768,13 +768,13 @@ vector>> CompactedDBG::searchSequence( } template -vector>> CompactedDBG::searchSequence( const string& s, const bool exact, const bool insertion, +std::vector>> CompactedDBG::searchSequence( const std::string& s, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match) const { struct hash_pair { - size_t operator()(const pair& p) const { + size_t operator()(const std::pair& p) const { return wyhash(&(p.first), sizeof(size_t), 0, _wyp) ^ p.second.hash(); } @@ -782,43 +782,43 @@ vector>> CompactedDBG::searchSequence( if (invalid){ - cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << std::endl; - return vector>>(); + return std::vector>>(); } if (ratio_kmers <= 0.0){ - cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than or equal to 0.0" << endl; + std::cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than or equal to 0.0" << std::endl; - return vector>>(); + return std::vector>>(); } if (ratio_kmers > 1.0){ - cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << endl; + std::cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << std::endl; - return vector>>(); + return std::vector>>(); } if (s.length() < k_){ - cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; + std::cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << std::endl; - return vector>>(); + return std::vector>>(); } - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(s.length() - k_ + 1) * ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(s.length() - k_ + 1) * ratio_kmers))); Roaring rpos; - vector>> v_um; + std::vector>> v_um; - string s_inexact; + std::string s_inexact; - unordered_set, hash_pair> us_pos_km; + std::unordered_set, hash_pair> us_pos_km; - auto comp_pair = [](const pair>& p1, const pair>& p2) { + auto comp_pair = [](const std::pair>& p1, const std::pair>& p2) -> bool { return (p1.first < p2.first); }; @@ -899,7 +899,7 @@ vector>> CompactedDBG::searchSequence( Minimizer minz; - pair minz_pres = {0xffffffffffffffffULL, true}; + std::pair minz_pres = {0xffffffffffffffffULL, true}; while (ki_s != ki_e) { @@ -1044,19 +1044,19 @@ vector>> CompactedDBG::searchSequence( } template -bool CompactedDBG::searchMinRatioKmer(const vector& query_filenames, const string& out_filename_prefix, +bool CompactedDBG::searchMinRatioKmer(const std::vector& query_filenames, const std::string& out_filename_prefix, const double min_ratio_kmers, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const size_t verbose) const { - const string out_tmp = out_filename_prefix + ".tsv"; + const std::string out_tmp = out_filename_prefix + ".tsv"; { FILE* fp_tmp = fopen(out_tmp.c_str(), "w"); if (fp_tmp == NULL) { - cerr << "CompactedDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Could not open file " << out_tmp << " for writing." << std::endl; return false; } else { @@ -1065,13 +1065,13 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename if (std::remove(out_tmp.c_str()) != 0) { - cerr << "CompactedDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Could not remove temporary file " << out_tmp << std::endl; } } } - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(out_tmp.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1085,18 +1085,18 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename } template -bool CompactedDBG::search(const vector& query_filenames, const string& out_filename_prefix, +bool CompactedDBG::search(const std::vector& query_filenames, const std::string& out_filename_prefix, const bool found_km_ratio_out, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { - const string out_tmp = out_filename_prefix + ".tsv"; + const std::string out_tmp = out_filename_prefix + ".tsv"; { FILE* fp_tmp = fopen(out_tmp.c_str(), "w"); if (fp_tmp == NULL) { - cerr << "CompactedDBG::search(): Could not open file " << out_tmp << " for writing." << endl; + std::cerr << "CompactedDBG::search(): Could not open file " << out_tmp << " for writing." << std::endl; return false; } else { @@ -1105,13 +1105,13 @@ bool CompactedDBG::search(const vector& query_filenames, const str if (std::remove(out_tmp.c_str()) != 0) { - cerr << "CompactedDBG::search(): Could not remove temporary file " << out_tmp << endl; + std::cerr << "CompactedDBG::search(): Could not remove temporary file " << out_tmp << std::endl; } } } - ofstream outfile; - ostream out(0); + std::ofstream outfile; + std::ostream out(0); outfile.open(out_tmp.c_str()); out.rdbuf(outfile.rdbuf()); @@ -1125,51 +1125,51 @@ bool CompactedDBG::search(const vector& query_filenames, const str } template -bool CompactedDBG::searchMinRatioKmer(const vector& query_filenames, ostream& out, const double min_ratio_kmers, +bool CompactedDBG::searchMinRatioKmer(const std::vector& query_filenames, std::ostream& out, const double min_ratio_kmers, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const size_t verbose) const { if (invalid){ - cerr << "CompactedDBG::searchMinRatioKmer(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Graph is invalid and cannot be searched" << std::endl; return false; } if (nb_threads > std::thread::hardware_concurrency()){ - cerr << "CompactedDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << endl; + std::cerr << "CompactedDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << std::endl; return false; } if (nb_threads <= 0){ - cerr << "CompactedDBG::searchMinRatioKmer(): Number of threads cannot be less than or equal to 0." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Number of threads cannot be less than or equal to 0." << std::endl; return false; } if (min_ratio_kmers <= 0.0){ - cerr << "CompactedDBG::searchMinRatioKmer(): Ratio of k-mers is less than or equal to 0.0." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Ratio of k-mers is less than or equal to 0.0." << std::endl; return false; } if (min_ratio_kmers > 1.0){ - cerr << "CompactedDBG::searchMinRatioKmer(): Ratio of k-mers is greater than 1.0." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Ratio of k-mers is greater than 1.0." << std::endl; return false; } if (out.fail()) { - cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to." << endl; + std::cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to." << std::endl; return false; } - if (verbose) cout << "CompactedDBG::searchMinRatioKmer(): Querying graph." << endl; + if (verbose) std::cout << "CompactedDBG::searchMinRatioKmer(): Querying graph." << std::endl; const CompactedDBG& dbg = *this; - string s; + std::string s; bool write_success = true; bool query_success = true; @@ -1213,7 +1213,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename auto writeBinaryOutput = [&]() { - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); const size_t len_query_name = strlen(query_name); const bool is_found = (nb_km_found >= nb_km_min); @@ -1279,7 +1279,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename for (auto& c : s) c &= 0xDF; // Set all characters in uppercase - const vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, + const std::vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, inexact_search, ratio, true); if (inexact_search){ @@ -1314,8 +1314,8 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename if (write_success && verbose) { - cout << "CompactedDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries. " << endl; - cout << "CompactedDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries. " << endl; + std::cout << "CompactedDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries. " << std::endl; + std::cout << "CompactedDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries. " << std::endl; } } else { @@ -1333,30 +1333,30 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mtx_files_in, mtx_file_out; + std::mutex mtx_files_in, mtx_file_out; std::atomic nb_queries_found; std::atomic nb_queries_processed; - unordered_map um_file_id; + std::unordered_map um_file_id; nb_queries_found = 0; nb_queries_processed = 0; - auto writeBinaryOutput = [&]( const string& query_name, + auto writeBinaryOutput = [&]( const std::string& query_name, const size_t nb_km_found, const size_t nb_km_query, size_t& pos_buffer_out, char* buffer_res) { - const size_t nb_km_min = max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); + const size_t nb_km_min = std::max(static_cast(1), static_cast(round(static_cast(nb_km_query) * min_ratio_kmers))); const size_t len_query_name = query_name.length(); const bool is_found = (nb_km_found >= nb_km_min); if (pos_buffer_out + len_query_name + l_query_res >= thread_seq_buf_sz){ // If next result cannot fit in the buffer - unique_lock lock(mtx_file_out); // Get the output lock + std::unique_lock lock(mtx_file_out); // Get the output lock out.write(buffer_res, pos_buffer_out); // Write result buffer @@ -1388,11 +1388,11 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename char* buffer_res = new char[thread_seq_buf_sz]; - vector buffer_seq; - vector buffer_name; - vector>> buffer_file_id; + std::vector buffer_seq; + std::vector buffer_name; + std::vector>> buffer_file_id; - vector> v_res_to_write; + std::vector> v_res_to_write; while (true) { @@ -1401,7 +1401,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename { size_t buffer_sz = 0; - unique_lock lock(mtx_files_in); + std::unique_lock lock(mtx_files_in); l_stop = stop; @@ -1411,7 +1411,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename // If all queries have completed for this file, push result to buffer for (const auto& p : buffer_file_id) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(p.first); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(p.first); if (it_um_file_id == um_file_id.end()) { @@ -1453,8 +1453,8 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename buffer_seq.push_back(std::move(s)); - if (files_as_queries) buffer_file_id.push_back(pair>(file_id, pair(0, 0))); - else buffer_name.push_back(string(fp.getNameString())); + if (files_as_queries) buffer_file_id.push_back(std::pair>(file_id, std::pair(0, 0))); + else buffer_name.push_back(std::string(fp.getNameString())); } else break; } @@ -1463,13 +1463,13 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename for (const auto p : buffer_file_id) { - pair::iterator, bool> p_it_um_file_id = um_file_id.insert(pair(p.first, ResultFileQuery())); + std::pair::iterator, bool> p_it_um_file_id = um_file_id.insert(std::pair(p.first, ResultFileQuery())); p_it_um_file_id.first->second.nb_queries += 1; if ((p.first != prev_file_id) && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -1485,7 +1485,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename // This thread is the last one reading from input file(s), make sure we annotate last query file as fully read if (query_success && stop && !l_stop && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) query_success = false; else it_um_file_id->second.is_read = true; @@ -1511,7 +1511,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename for (auto& c : buffer_seq[i]) c &= 0xDF; - const vector>> v = dbg.searchSequence( buffer_seq[i], true, inexact_search, inexact_search, + const std::vector>> v = dbg.searchSequence( buffer_seq[i], true, inexact_search, inexact_search, inexact_search, ratio, true); if (inexact_search){ @@ -1540,7 +1540,7 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename if (write_success && (pos_buffer_out > 0)) { // Flush unresult written to final output - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); @@ -1558,54 +1558,54 @@ bool CompactedDBG::searchMinRatioKmer(const vector& query_filename if (write_success && query_success && verbose) { - cout << "CompactedDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries. " << endl; - cout << "CompactedDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries. " << endl; + std::cout << "CompactedDBG::searchMinRatioKmer(): Processed " << nb_queries_processed << " queries. " << std::endl; + std::cout << "CompactedDBG::searchMinRatioKmer(): Found " << nb_queries_found << " queries. " << std::endl; } } } fp.close(); - if (!query_success) cerr << "CompactedDBG::searchMinRatioKmer(): Unexpected error encountered. Please file an issue. Operation aborted." << endl; - if (!write_success) cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to. Operation aborted." << endl; + if (!query_success) std::cerr << "CompactedDBG::searchMinRatioKmer(): Unexpected error encountered. Please file an issue. Operation aborted." << std::endl; + if (!write_success) std::cerr << "CompactedDBG::searchMinRatioKmer(): Output stream is in a failed state and cannot be written to. Operation aborted." << std::endl; return query_success && write_success; } template -bool CompactedDBG::search(const vector& query_filenames, ostream& out, +bool CompactedDBG::search(const std::vector& query_filenames, std::ostream& out, const bool found_km_ratio_out, const bool inexact_search, const bool files_as_queries, const size_t nb_threads, const bool verbose) const { if (invalid){ - cerr << "CompactedDBG::search(): Graph is invalid and cannot be searched" << endl; + std::cerr << "CompactedDBG::search(): Graph is invalid and cannot be searched" << std::endl; return false; } if (nb_threads > std::thread::hardware_concurrency()){ - cerr << "CompactedDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << endl; + std::cerr << "CompactedDBG::search(): Number of threads cannot be greater than or equal to " << std::thread::hardware_concurrency() << "." << std::endl; return false; } if (nb_threads <= 0){ - cerr << "CompactedDBG::search(): Number of threads cannot be less than or equal to 0." << endl; + std::cerr << "CompactedDBG::search(): Number of threads cannot be less than or equal to 0." << std::endl; return false; } if (out.fail()) { - cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to." << endl; + std::cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to." << std::endl; return false; } - if (verbose) cout << "CompactedDBG::search(): Querying graph." << endl; + if (verbose) std::cout << "CompactedDBG::search(): Querying graph." << std::endl; const CompactedDBG& dbg = *this; - string s; + std::string s; bool write_success = true; bool query_success = true; @@ -1648,7 +1648,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& auto writeQuantifiedOutput = [&]() { - const string nb_found_str = to_string(found_km_ratio_out ? (static_cast(nb_km_found) / static_cast(nb_km_query)) : nb_km_found); + const std::string nb_found_str = std::to_string(found_km_ratio_out ? (static_cast(nb_km_found) / static_cast(nb_km_query)) : nb_km_found); const size_t len_nb_found_str = nb_found_str.length(); const size_t len_query_name = strlen(query_name); @@ -1719,7 +1719,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& for (auto& c : s) c &= 0xDF; // Set all characters in uppercase - const vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, + const std::vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, inexact_search, 1.0, true); if (inexact_search){ @@ -1752,7 +1752,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& delete[] buffer_res; - if (write_success && verbose) cout << "CompactedDBG::search(): Processed " << nb_queries_processed << " queries. " << endl; + if (write_success && verbose) std::cout << "CompactedDBG::search(): Processed " << nb_queries_processed << " queries. " << std::endl; } else { @@ -1769,28 +1769,28 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& bool stop = false; - vector workers; // need to keep track of threads so we can join them + std::vector workers; // need to keep track of threads so we can join them - mutex mtx_files_in, mtx_file_out; + std::mutex mtx_files_in, mtx_file_out; std::atomic nb_queries_processed; - unordered_map um_file_id; + std::unordered_map um_file_id; nb_queries_processed = 0; - auto writeQuantifiedOutput = [&]( const string& query_name, + auto writeQuantifiedOutput = [&]( const std::string& query_name, const size_t nb_km_found, const size_t nb_km_query, size_t& pos_buffer_out, char* buffer_res) { - const string nb_found_str = to_string(found_km_ratio_out ? (static_cast(nb_km_found) / static_cast(nb_km_query)) : nb_km_found); + const std::string nb_found_str = std::to_string(found_km_ratio_out ? (static_cast(nb_km_found) / static_cast(nb_km_query)) : nb_km_found); const size_t len_nb_found_str = nb_found_str.length(); const size_t len_query_name = query_name.length(); if (pos_buffer_out + len_query_name + len_nb_found_str + 2 >= thread_seq_buf_sz){ // If next result cannot fit in the buffer - unique_lock lock(mtx_file_out); // Get the output lock + std::unique_lock lock(mtx_file_out); // Get the output lock out.write(buffer_res, pos_buffer_out); // Write result buffer @@ -1827,11 +1827,11 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& char* buffer_res = new char[thread_seq_buf_sz]; - vector buffer_seq; - vector buffer_name; - vector>> buffer_file_id; + std::vector buffer_seq; + std::vector buffer_name; + std::vector>> buffer_file_id; - vector> v_res_to_write; + std::vector> v_res_to_write; while (true) { @@ -1840,7 +1840,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& { size_t buffer_sz = 0; - unique_lock lock(mtx_files_in); + std::unique_lock lock(mtx_files_in); l_stop = stop; @@ -1850,7 +1850,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& // If all queries have completed for this file, push result to buffer for (const auto& p : buffer_file_id) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(p.first); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(p.first); if (it_um_file_id == um_file_id.end()) { @@ -1892,8 +1892,8 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& buffer_seq.push_back(std::move(s)); - if (files_as_queries) buffer_file_id.push_back(pair>(file_id, pair(0, 0))); - else buffer_name.push_back(string(fp.getNameString())); + if (files_as_queries) buffer_file_id.push_back(std::pair>(file_id, std::pair(0, 0))); + else buffer_name.push_back(std::string(fp.getNameString())); } else break; } @@ -1902,13 +1902,13 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& for (const auto p : buffer_file_id) { - pair::iterator, bool> p_it_um_file_id = um_file_id.insert(pair(p.first, ResultFileQuery())); + std::pair::iterator, bool> p_it_um_file_id = um_file_id.insert(std::pair(p.first, ResultFileQuery())); p_it_um_file_id.first->second.nb_queries += 1; if ((p.first != prev_file_id) && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) { @@ -1924,7 +1924,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& // This thread is the last one reading from input file(s), make sure we annotate last query file as fully read if (query_success && stop && !l_stop && (prev_file_id != 0xffffffffffffffffULL)) { - typename unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); + typename std::unordered_map::iterator it_um_file_id = um_file_id.find(prev_file_id); if (it_um_file_id == um_file_id.end()) query_success = false; else it_um_file_id->second.is_read = true; @@ -1950,7 +1950,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& for (auto& c : buffer_seq[i]) c &= 0xDF; - const vector>> v = dbg.searchSequence( buffer_seq[i], true, inexact_search, inexact_search, + const std::vector>> v = dbg.searchSequence( buffer_seq[i], true, inexact_search, inexact_search, inexact_search, 1.0, true); if (inexact_search){ @@ -1979,7 +1979,7 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& if (write_success && (pos_buffer_out > 0)) { // Flush unresult written to final output - unique_lock lock(mtx_file_out); + std::unique_lock lock(mtx_file_out); out.write(buffer_res, pos_buffer_out); @@ -1995,14 +1995,14 @@ bool CompactedDBG::search(const vector& query_filenames, ostream& if (files_as_queries && !um_file_id.empty()) query_success = false; - if (write_success && query_success && verbose) cout << "CompactedDBG::search(): Processed " << nb_queries_processed << " queries. " << endl; + if (write_success && query_success && verbose) std::cout << "CompactedDBG::search(): Processed " << nb_queries_processed << " queries. " << std::endl; } } fp.close(); - if (!query_success) cerr << "CompactedDBG::search(): Unexpected error encountered. Please file an issue. Operation aborted." << endl; - if (!write_success) cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to. Operation aborted." << endl; + if (!query_success) std::cerr << "CompactedDBG::search(): Unexpected error encountered. Please file an issue. Operation aborted." << std::endl; + if (!write_success) std::cerr << "CompactedDBG::search(): Output stream is in a failed state and cannot be written to. Operation aborted." << std::endl; return query_success && write_success; } diff --git a/src/StreamCounter.hpp b/src/StreamCounter.hpp index 8a5be15..abb84c6 100755 --- a/src/StreamCounter.hpp +++ b/src/StreamCounter.hpp @@ -107,7 +107,7 @@ class StreamCounter { e = e_; seed = seed_; - const size_t numcounts = max(static_cast(48.0/(e*e) + 1), static_cast(8192)); + const size_t numcounts = std::max(static_cast(48.0/(e*e) + 1), static_cast(8192)); sz = rndup((numcounts + countsPerLong - 1) / countsPerLong); mask = (sz * countsPerLong) - 1; diff --git a/src/TinyBitmap.cpp b/src/TinyBitmap.cpp index 4013545..2ac6e11 100755 --- a/src/TinyBitmap.cpp +++ b/src/TinyBitmap.cpp @@ -1,5 +1,7 @@ #include "TinyBitmap.hpp" +using namespace std; + TinyBitmap::TinyBitmap() : tiny_bmp(nullptr) {} TinyBitmap::TinyBitmap(const TinyBitmap& o) : tiny_bmp(nullptr) { diff --git a/src/TinyBitmap.hpp b/src/TinyBitmap.hpp index f3c7772..9456d4e 100755 --- a/src/TinyBitmap.hpp +++ b/src/TinyBitmap.hpp @@ -21,8 +21,6 @@ * - CRoaring has a lot more functions (set intersection, union, etc.). */ -using namespace std; - class TinyBitmap { class TinyBitmapIterator : public std::iterator { @@ -96,8 +94,8 @@ class TinyBitmap { uint32_t maximum() const; - bool write(ostream& stream_out) const; - bool read(istream& stream_in); + bool write(std::ostream& stream_out) const; + bool read(std::istream& stream_in); inline void toArray(uint32_t* values) const { diff --git a/src/Unitig.hpp b/src/Unitig.hpp index 9a18a4d..ce7bcd0 100755 --- a/src/Unitig.hpp +++ b/src/Unitig.hpp @@ -25,7 +25,7 @@ class Unitig { Unitig() {} Unitig(const CompressedSequence& s, const CompressedCoverage& c) : seq(s), cov(c) {} - Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(move(s)), cov(move(c)) {} + Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(std::move(s)), cov(std::move(c)) {} Unitig(const char* s, bool full = false) : seq(s), cov(seq.size() - Kmer::k + 1, full) {} BFG_INLINE size_t numKmers() const { @@ -84,7 +84,7 @@ class Unitig { Unitig() {} Unitig(const CompressedSequence& s, const CompressedCoverage& c) : seq(s), cov(c) {} - Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(move(s)), cov(move(c)) {} + Unitig(CompressedSequence&& s, CompressedCoverage&& c) : seq(std::move(s)), cov(std::move(c)) {} Unitig(const char* s, bool full = false) : seq(s), cov(seq.size() - Kmer::k + 1, full) {} BFG_INLINE size_t numKmers() const { diff --git a/src/UnitigMap.cpp b/src/UnitigMap.cpp index 279a147..849529c 100755 --- a/src/UnitigMap.cpp +++ b/src/UnitigMap.cpp @@ -1,5 +1,7 @@ #include "UnitigMap.hpp" + + UnitigMapBase::UnitigMapBase(const size_t length) : len(length), dist(0), size(0), strand(true), isEmpty(true) {} UnitigMapBase::UnitigMapBase(const size_t start, const size_t length, const size_t unitig_sz, const bool strand) : diff --git a/src/UnitigMap.hpp b/src/UnitigMap.hpp index a15859f..6de76ee 100755 --- a/src/UnitigMap.hpp +++ b/src/UnitigMap.hpp @@ -144,13 +144,13 @@ class UnitigMap : public UnitigMapBase { * @return a string containing the sequence corresponding to the mapping or * an empty string if there is no mapping (UnitigMap::isEmpty = true). */ - string mappedSequenceToString() const; + std::string mappedSequenceToString() const; /** Create a string containing the sequence of the reference unitig used the mapping. * @return a string containing the sequence of the reference unitig used the mapping or * an empty string if there is no mapping (UnitigMap::isEmpty = true). */ - string referenceUnitigToString() const; + std::string referenceUnitigToString() const; /** Compute the length of the longest common prefix between a given sequence and * the reference unitig used in the mapping. diff --git a/src/UnitigMap.tcc b/src/UnitigMap.tcc index 25d7cd6..e76d402 100755 --- a/src/UnitigMap.tcc +++ b/src/UnitigMap.tcc @@ -34,9 +34,9 @@ bool UnitigMap::isSameReferenceUnitig(const UnitigMap& o) const } template -string UnitigMap::mappedSequenceToString() const { +std::string UnitigMap::mappedSequenceToString() const { - if (isEmpty) return string(); + if (isEmpty) return std::string(); if (strand){ @@ -55,9 +55,9 @@ string UnitigMap::mappedSequenceToString() const { } template -string UnitigMap::referenceUnitigToString() const { +std::string UnitigMap::referenceUnitigToString() const { - if (isEmpty) return string(); + if (isEmpty) return std::string(); if (isShort) return cdbg->km_unitigs.getKmer(pos_unitig).toString(); if (isAbundant) return cdbg->h_kmers_ccov.find(pos_unitig).getKey().toString(); @@ -250,7 +250,7 @@ UnitigMap UnitigMap::getKmerMapping(const size_t template typename UnitigMap::Unitig_data_ptr_t UnitigMap::getData() const { - return getData_::value>(); + return getData_::value>(); } template @@ -305,7 +305,7 @@ typename std::enable_if>::type UnitigMap::spl template Unitig UnitigMap::splitData(const bool last_split) const { - return splitData_::value>(last_split); + return splitData_::value>(last_split); } template diff --git a/src/minHashIterator.hpp b/src/minHashIterator.hpp index 432a9ea..8d7efc0 100755 --- a/src/minHashIterator.hpp +++ b/src/minHashIterator.hpp @@ -9,8 +9,6 @@ #include "Kmer.hpp" -using namespace std; - struct minHashResult { minHashResult() : hash((uint64_t) -1),pos(-1) {} @@ -209,7 +207,7 @@ class minHashIterator { int k; // Length of k-mers int g; // Length of minimizers HF hf; // Rolling hash function - deque v; //Hash values and positions of a same minimizer with k-mer at position p + std::deque v; //Hash values and positions of a same minimizer with k-mer at position p int p; // Position of current k-mer traversed in the sequence bool invalid; // If sequence is invalid (iterating on k-mers out of bounds, etc.) bool nh; // If true, minimizer of k-mers km cannot start at position 0 or k-g @@ -340,7 +338,7 @@ class preAllocMinHashIterator { invalid = false; - v = vector(n - g + 1); + v = std::vector(n - g + 1); hf.setK(g); operator++(); @@ -486,7 +484,7 @@ class preAllocMinHashIterator { int k; // Length of k-mers int g; // Length of minimizers HF hf; // Rolling hash function - vector v; //Hash values and positions of a same minimizer with k-mer at position p + std::vector v; //Hash values and positions of a same minimizer with k-mer at position p size_t p_cur_start; size_t p_cur_end; int p; // Position of current k-mer traversed in the sequence @@ -502,9 +500,9 @@ class preAllocMinHashIterator { if (!invalid && (o.p + n <= o.n)){ - vector v_tmp(o.v.begin() + o.p_cur_start, o.v.begin() + o.p_cur_end); + std::vector v_tmp(o.v.begin() + o.p_cur_start, o.v.begin() + o.p_cur_end); - v = move(v_tmp); + v = std::move(v_tmp); for (auto& min_h : v) min_h.pos -= o.p; } diff --git a/src/rw_spin_lock.h b/src/rw_spin_lock.h index 6a66a32..09c0219 100755 --- a/src/rw_spin_lock.h +++ b/src/rw_spin_lock.h @@ -166,7 +166,7 @@ class SpinLockRW { if ((prev_bits < HAS_WRITER_WAITING) && _bits.compare_exchange_weak(prev_bits, prev_bits + 1)) return; - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); } } @@ -187,7 +187,7 @@ class SpinLockRW { if (((prev_bits & MASK_READER) == 0) && _bits.compare_exchange_weak(prev_bits, prev_bits | HAS_WRITER)) return; - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); } } @@ -256,7 +256,7 @@ class SpinLockRW_MCS { while (lock_pool[prev_reader_id].is_locked){ - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -282,7 +282,7 @@ class SpinLockRW_MCS { while (lock_pool[prev_reader_id].is_locked){ - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -290,7 +290,7 @@ class SpinLockRW_MCS { while (load_lock_pool){ - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -348,8 +348,8 @@ class Hybrid_SpinLockRW_MCS { if (nb_threads <= std::thread::hardware_concurrency()) lcks[mask_id].bits = mask_full; else { - cerr << "Hybrid_SpinLockRW_MCS(): Number of threads required is greater than number of threads possible on this machine (" << - std::thread::hardware_concurrency() << ")" << endl; + std::cerr << "Hybrid_SpinLockRW_MCS(): Number of threads required is greater than number of threads possible on this machine (" << + std::thread::hardware_concurrency() << ")" << std::endl; } } @@ -365,7 +365,7 @@ class Hybrid_SpinLockRW_MCS { while (lcks[prev_].bits != mask_full){ - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -407,7 +407,7 @@ class Hybrid_SpinLockRW_MCS { // Skipping this step and just spinning on *load* would make all writers access the same ressource at the same moment while (lcks[prev_].bits != mask_full){ - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -421,7 +421,7 @@ class Hybrid_SpinLockRW_MCS { if (++retry > RETRY_THRESHOLD){ - this_thread::yield(); + std::this_thread::yield(); if ((retry & RETRY_THRESHOLD_MAX) == 0) { @@ -445,7 +445,7 @@ class Hybrid_SpinLockRW_MCS { while (load){ // Wait that all readers are done reading -> GLOBAL SPIN - if (++retry > RETRY_THRESHOLD) this_thread::yield(); + if (++retry > RETRY_THRESHOLD) std::this_thread::yield(); //#if defined(__SSE2__) //else _mm_pause(); //#endif @@ -480,9 +480,9 @@ class Hybrid_SpinLockRW_MCS { }; Lock lcks[M]; - atomic load; + std::atomic load; const int padding1[14]; - atomic id; + std::atomic id; const int padding2[14]; size_t id_w; const int padding3[14];