diff --git a/src/Bifrost.cpp b/src/Bifrost.cpp index 51fd745..4b113fc 100644 --- a/src/Bifrost.cpp +++ b/src/Bifrost.cpp @@ -2,6 +2,7 @@ #include "ColoredCDBG.hpp" using namespace std; +using namespace Bifrost; void PrintVersion() { diff --git a/src/BitContainer.cpp b/src/BitContainer.cpp index 261875a..60c9483 100644 --- a/src/BitContainer.cpp +++ b/src/BitContainer.cpp @@ -1,5 +1,9 @@ #include "BitContainer.hpp" +using namespace Bifrost; + +namespace Bifrost { + BitContainer::BitContainer() : setBits(localBitVector) {} BitContainer::BitContainer(const BitContainer& o) { @@ -1043,3 +1047,5 @@ const size_t BitContainer::shiftMaskBits = 3; const uintptr_t BitContainer::flagMask = 0x7; const uintptr_t BitContainer::pointerMask = 0xFFFFFFFFFFFFFFF8; + +} diff --git a/src/BitContainer.hpp b/src/BitContainer.hpp index 5fc7b7e..ec62406 100644 --- a/src/BitContainer.hpp +++ b/src/BitContainer.hpp @@ -4,6 +4,7 @@ #include "roaring.hh" #include "TinyBitmap.hpp" +namespace Bifrost { class BitContainer { @@ -200,4 +201,6 @@ class BitContainer { uintptr_t setBits; }; +} + #endif diff --git a/src/BlockedBloomFilter.cpp b/src/BlockedBloomFilter.cpp index 3f0fa87..fabefee 100644 --- a/src/BlockedBloomFilter.cpp +++ b/src/BlockedBloomFilter.cpp @@ -1,5 +1,9 @@ #include "BlockedBloomFilter.hpp" +using namespace Bifrost; + +namespace Bifrost { + #if defined(__AVX2__) BlockedBloomFilter::BlockedBloomFilter() : table_(nullptr), blocks_(0), k_(0) { @@ -1152,3 +1156,5 @@ bool BlockedBloomFilter::insert_unpar(uint64_t kmer_hash, const uint64_t min_has } #endif + +} diff --git a/src/BlockedBloomFilter.hpp b/src/BlockedBloomFilter.hpp index b14f3e4..c490995 100644 --- a/src/BlockedBloomFilter.hpp +++ b/src/BlockedBloomFilter.hpp @@ -24,6 +24,8 @@ #include #endif +namespace Bifrost { + class BlockedBloomFilter { public: @@ -120,4 +122,6 @@ class BlockedBloomFilter { bool insert_unpar(const uint64_t kmer_hash, const uint64_t min_hash); }; +} + #endif // BFG_BLOCKEDBLOOMFILTER_HPP diff --git a/src/ColorSet.cpp b/src/ColorSet.cpp index 160cede..a362364 100644 --- a/src/ColorSet.cpp +++ b/src/ColorSet.cpp @@ -1,5 +1,7 @@ #include "ColorSet.hpp" +using namespace Bifrost; + UnitigColors::UnitigColors() : setBits(localBitVector) {} UnitigColors::UnitigColors(const UnitigColors& o) { diff --git a/src/ColorSet.hpp b/src/ColorSet.hpp index 102fe90..cb8547a 100644 --- a/src/ColorSet.hpp +++ b/src/ColorSet.hpp @@ -6,6 +6,8 @@ #include "CompactedDBG.hpp" #include "TinyBitmap.hpp" +namespace Bifrost { + /** @file src/ColorSet.hpp * Interface for UnitigColors, the unitig container of k-mer color sets used in ColoredCDBG. * Code snippets using this interface are provided in snippets/test.cpp. @@ -473,4 +475,6 @@ struct UnitigColorsHash { } }; +} + #endif diff --git a/src/ColoredCDBG.hpp b/src/ColoredCDBG.hpp index 9449b03..6eb22a0 100644 --- a/src/ColoredCDBG.hpp +++ b/src/ColoredCDBG.hpp @@ -11,6 +11,8 @@ #include "getRSS.h" +namespace Bifrost { + /** @file src/ColoredCDBG.hpp * Interface for the Colored and Compacted de Bruijn graph API. * Code snippets using this interface are provided in test/snippets.hpp. @@ -356,6 +358,8 @@ class ColoredCDBG : public CompactedDBG, DataStorage bool invalid; }; +} + #include "ColoredCDBG.tcc" #endif diff --git a/src/ColoredCDBG.tcc b/src/ColoredCDBG.tcc index b887c0b..73dcd3a 100644 --- a/src/ColoredCDBG.tcc +++ b/src/ColoredCDBG.tcc @@ -2,25 +2,25 @@ #define BIFROST_COLOREDCDBG_TCC template -ColoredCDBG::ColoredCDBG(int kmer_length) : CompactedDBG, DataStorage>(kmer_length){ +Bifrost::ColoredCDBG::ColoredCDBG(int kmer_length) : CompactedDBG, DataStorage>(kmer_length){ invalid = this->isInvalid(); } template -ColoredCDBG::ColoredCDBG(int kmer_length, int minimizer_length) : CompactedDBG, DataStorage>(kmer_length, minimizer_length){ +Bifrost::ColoredCDBG::ColoredCDBG(int kmer_length, int minimizer_length) : CompactedDBG, DataStorage>(kmer_length, minimizer_length){ invalid = this->isInvalid(); } template -ColoredCDBG::ColoredCDBG(const ColoredCDBG& o) : CompactedDBG, DataStorage>(o), invalid(o.invalid) {} +Bifrost::ColoredCDBG::ColoredCDBG(const ColoredCDBG& o) : CompactedDBG, DataStorage>(o), invalid(o.invalid) {} template -ColoredCDBG::ColoredCDBG(ColoredCDBG&& o) : CompactedDBG, DataStorage>(move(o)), invalid(o.invalid) {} +Bifrost::ColoredCDBG::ColoredCDBG(ColoredCDBG&& o) : CompactedDBG, DataStorage>(move(o)), invalid(o.invalid) {} template -void ColoredCDBG::clear(){ +void Bifrost::ColoredCDBG::clear(){ invalid = true; @@ -29,7 +29,7 @@ void ColoredCDBG::clear(){ } template -ColoredCDBG& ColoredCDBG::operator=(const ColoredCDBG& o) { +Bifrost::ColoredCDBG& Bifrost::ColoredCDBG::operator=(const ColoredCDBG& o) { CompactedDBG, DataStorage>::operator=(o); @@ -39,7 +39,7 @@ ColoredCDBG& ColoredCDBG::operator=(const ColoredCDBG& o) { } template -ColoredCDBG& ColoredCDBG::operator=(ColoredCDBG&& o) { +Bifrost::ColoredCDBG& Bifrost::ColoredCDBG::operator=(ColoredCDBG&& o) { if (this != &o) { @@ -54,7 +54,7 @@ ColoredCDBG& ColoredCDBG::operator=(ColoredCDBG&& o) { } template -ColoredCDBG& ColoredCDBG::operator+=(const ColoredCDBG& o) { +Bifrost::ColoredCDBG& Bifrost::ColoredCDBG::operator+=(const ColoredCDBG& o) { if (this != &o) merge(o, 1, false); @@ -62,7 +62,7 @@ ColoredCDBG& ColoredCDBG::operator+=(const ColoredCDBG& o) { } template -bool ColoredCDBG::operator==(const ColoredCDBG& o) const { +bool Bifrost::ColoredCDBG::operator==(const ColoredCDBG& o) const { if (!invalid && !this->isInvalid() && !o.isInvalid() && (this->getK() == o.getK()) && (this->size() == o.size())){ @@ -102,13 +102,13 @@ bool ColoredCDBG::operator==(const ColoredCDBG& o) const { } template -inline bool ColoredCDBG::operator!=(const ColoredCDBG& o) const { +inline bool Bifrost::ColoredCDBG::operator!=(const ColoredCDBG& o) const { return !operator==(o); } template -bool ColoredCDBG::merge(const ColoredCDBG& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::ColoredCDBG::merge(const ColoredCDBG& o, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -172,7 +172,7 @@ bool ColoredCDBG::merge(const ColoredCDBG& o, const size_t nb_threads, const } template -bool ColoredCDBG::merge(ColoredCDBG&& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::ColoredCDBG::merge(ColoredCDBG&& o, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -240,7 +240,7 @@ 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 Bifrost::ColoredCDBG::merge(const vector& v, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -317,7 +317,7 @@ 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 Bifrost::ColoredCDBG::merge(vector&& v, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -396,7 +396,7 @@ bool ColoredCDBG::merge(vector&& v, const size_t nb_threads, con } template -bool ColoredCDBG::buildGraph(const CCDBG_Build_opt& opt){ +bool Bifrost::ColoredCDBG::buildGraph(const CCDBG_Build_opt& opt){ if (!invalid){ @@ -410,7 +410,7 @@ bool ColoredCDBG::buildGraph(const CCDBG_Build_opt& opt){ } template -bool ColoredCDBG::buildColors(const CCDBG_Build_opt& opt){ +bool Bifrost::ColoredCDBG::buildColors(const CCDBG_Build_opt& opt){ if (!invalid){ @@ -423,7 +423,7 @@ bool ColoredCDBG::buildColors(const CCDBG_Build_opt& opt){ } template -bool ColoredCDBG::write(const string& prefix_output_filename, const size_t nb_threads, const bool verbose) const { +bool Bifrost::ColoredCDBG::write(const string& prefix_output_filename, const size_t nb_threads, const bool verbose) const { if (!CompactedDBG, DataStorage>::write(prefix_output_filename, nb_threads, true, verbose)) return false; // Write graph @@ -431,7 +431,7 @@ bool ColoredCDBG::write(const string& prefix_output_filename, const size_t nb } template -bool ColoredCDBG::read(const string& input_graph_filename, const string& input_colors_filename, const size_t nb_threads, const bool verbose) { +bool Bifrost::ColoredCDBG::read(const string& input_graph_filename, const string& input_colors_filename, const size_t nb_threads, const bool verbose) { bool valid_input_files = true; @@ -619,7 +619,7 @@ bool ColoredCDBG::read(const string& input_graph_filename, const string& inpu } template -void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t max_nb_hash){ +void Bifrost::ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t max_nb_hash){ vector v_files(opt.filename_seq_in); @@ -636,8 +636,8 @@ void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t m 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(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -647,7 +647,7 @@ void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t m [&]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -679,7 +679,7 @@ void ColoredCDBG::initUnitigColors(const CCDBG_Build_opt& opt, const size_t m } template -void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, const size_t max_nb_hash){ +void Bifrost::ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, const size_t max_nb_hash){ DataStorage* ds = this->getData(); @@ -689,8 +689,8 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons 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(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -700,7 +700,7 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons [&]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -745,7 +745,7 @@ void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, cons } template<> -inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, const size_t max_nb_hash){ +inline void Bifrost::ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_threads, const size_t max_nb_hash){ DataStorage* ds = this->getData(); @@ -755,8 +755,8 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr 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(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -766,7 +766,7 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr [&]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -808,7 +808,7 @@ inline void ColoredCDBG::resizeDataUC(const size_t sz, const size_t nb_thr } template -void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ +void Bifrost::ColoredCDBG::buildUnitigColors(const size_t nb_threads){ DataStorage* ds = this->getData(); @@ -1016,8 +1016,8 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ const size_t chunk = 1000; - typename ColoredCDBG::iterator g_a = this->begin(); - typename ColoredCDBG::iterator g_b = this->end(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -1027,7 +1027,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ [&]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -1075,7 +1075,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ vector workers; - auto add_hash_function = [&](typename ColoredCDBG::iterator it_a, typename ColoredCDBG::iterator it_b) { + auto add_hash_function = [&](typename Bifrost::ColoredCDBG::iterator it_a, typename Bifrost::ColoredCDBG::iterator it_b) { while (it_a != it_b) { @@ -1104,7 +1104,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ } }; - auto add_shared_function = [&](typename ColoredCDBG::iterator it_a, typename ColoredCDBG::iterator it_b) { + auto add_shared_function = [&](typename Bifrost::ColoredCDBG::iterator it_a, typename Bifrost::ColoredCDBG::iterator it_b) { while (it_a != it_b) { @@ -1154,8 +1154,8 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ { const size_t chunk = 1000; - typename ColoredCDBG::iterator g_a = this->begin(); - typename ColoredCDBG::iterator g_b = this->end(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -1165,7 +1165,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ [&, t]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -1207,8 +1207,8 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ { const size_t chunk = 1000; - typename ColoredCDBG::iterator g_a = this->begin(); - typename ColoredCDBG::iterator g_b = this->end(); + typename Bifrost::ColoredCDBG::iterator g_a = this->begin(); + typename Bifrost::ColoredCDBG::iterator g_b = this->end(); mutex mutex_it; @@ -1218,7 +1218,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ [&, t]{ - typename ColoredCDBG::iterator l_a, l_b; + typename Bifrost::ColoredCDBG::iterator l_a, l_b; while (true) { @@ -1250,7 +1250,7 @@ void ColoredCDBG::buildUnitigColors(const size_t nb_threads){ } template -string ColoredCDBG::getColorName(const size_t color_id) const { +string Bifrost::ColoredCDBG::getColorName(const size_t color_id) const { if (invalid){ @@ -1272,7 +1272,7 @@ string ColoredCDBG::getColorName(const size_t color_id) const { } template -vector ColoredCDBG::getColorNames() const { +vector Bifrost::ColoredCDBG::getColorNames() const { if (invalid){ @@ -1284,7 +1284,7 @@ vector ColoredCDBG::getColorNames() const { } template -bool ColoredCDBG::search(const vector& query_filenames, const string& out_filename_prefix, +bool Bifrost::ColoredCDBG::search(const vector& query_filenames, const string& out_filename_prefix, const double ratio_kmers, const bool inexact_search, const size_t nb_threads, const bool verbose) const { @@ -1733,7 +1733,7 @@ bool ColoredCDBG::search(const vector& query_filenames, const string& } template -void ColoredCDBG::checkColors(const vector& filename_seq_in) const { +void Bifrost::ColoredCDBG::checkColors(const vector& filename_seq_in) const { cout << "ColoredCDBG::checkColors(): Start" << endl; diff --git a/src/Common.hpp b/src/Common.hpp index a9beff2..5a5b57e 100644 --- a/src/Common.hpp +++ b/src/Common.hpp @@ -34,6 +34,8 @@ using namespace std; +namespace Bifrost { + static const char alpha[4] = {'A','C','G','T'}; BFG_INLINE bool isDNA(const char c) { @@ -229,4 +231,6 @@ template<> class wrapperData { BFG_INLINE void* getData() { return nullptr; } }; +} + #endif // BFG_COMMON_HPP diff --git a/src/CompactedDBG.hpp b/src/CompactedDBG.hpp index fd5c3ae..7337202 100644 --- a/src/CompactedDBG.hpp +++ b/src/CompactedDBG.hpp @@ -59,6 +59,8 @@ using namespace std; +namespace Bifrost { + /** @struct CDBG_Build_opt * @brief Most members of this structure are parameters for CompactedDBG::build(), except for: * - CDBG_Build_opt::k and CDBG_Build_opt::g as they are parameters of the graph constructor. @@ -760,6 +762,8 @@ class CompactedDBG { wrapperData data; }; +} + #include "CompactedDBG.tcc" #include "Search.tcc" diff --git a/src/CompactedDBG.tcc b/src/CompactedDBG.tcc index ca404e6..a60c0f2 100644 --- a/src/CompactedDBG.tcc +++ b/src/CompactedDBG.tcc @@ -21,19 +21,19 @@ static const uint8_t bits[256] = { }; template -CompactedDBG::CompactedDBG(const int kmer_length) : invalid(false) { +Bifrost::CompactedDBG::CompactedDBG(const int kmer_length) : invalid(false) { setKmerGmerLength(kmer_length); } template -CompactedDBG::CompactedDBG(const int kmer_length, const int minimizer_length) : invalid(false) { +Bifrost::CompactedDBG::CompactedDBG(const int kmer_length, const int minimizer_length) : invalid(false) { setKmerGmerLength(kmer_length, minimizer_length); } template -CompactedDBG::CompactedDBG(const CompactedDBG& o) : k_(o.k_), g_(o.g_), invalid(o.invalid), +Bifrost::CompactedDBG::CompactedDBG(const Bifrost::CompactedDBG& o) : k_(o.k_), g_(o.g_), invalid(o.invalid), bf(o.bf), km_unitigs(o.km_unitigs), v_unitigs(o.v_unitigs.size(), nullptr), data(o.data), h_kmers_ccov(o.h_kmers_ccov), hmap_min_unitigs(o.hmap_min_unitigs){ @@ -46,7 +46,7 @@ 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), +Bifrost::CompactedDBG::CompactedDBG(Bifrost::CompactedDBG&& o) : k_(o.k_), g_(o.g_), invalid(o.invalid), bf(std::move(o.bf)), 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)){ @@ -55,13 +55,13 @@ CompactedDBG::CompactedDBG(CompactedDBG&& o) : k_(o.k_), g_(o.g_), } template -CompactedDBG::~CompactedDBG() { +Bifrost::CompactedDBG::~CompactedDBG() { clear(); } template -CompactedDBG& CompactedDBG::operator=(const CompactedDBG& o){ +Bifrost::CompactedDBG& Bifrost::CompactedDBG::operator=(const Bifrost::CompactedDBG& o){ clear(); @@ -91,7 +91,7 @@ CompactedDBG& CompactedDBG::operator=(const CompactedDBG& o){ } template -CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o, const size_t nb_threads) { +Bifrost::CompactedDBG& Bifrost::CompactedDBG::toDataGraph(Bifrost::CompactedDBG&& o, const size_t nb_threads) { clear(); @@ -165,7 +165,7 @@ CompactedDBG& CompactedDBG::toDataGraph(CompactedDBG&& o } template -CompactedDBG& CompactedDBG::operator=(CompactedDBG&& o){ +Bifrost::CompactedDBG& Bifrost::CompactedDBG::operator=(Bifrost::CompactedDBG&& o){ if (this != &o) { @@ -193,7 +193,7 @@ CompactedDBG& CompactedDBG::operator=(CompactedDBG&& o){ } template -CompactedDBG& CompactedDBG::operator+=(const CompactedDBG& o){ +Bifrost::CompactedDBG& Bifrost::CompactedDBG::operator+=(const Bifrost::CompactedDBG& o){ merge(o, false); @@ -201,7 +201,7 @@ CompactedDBG& CompactedDBG::operator+=(const CompactedDBG& o){ } template -bool CompactedDBG::operator==(const CompactedDBG& o) const { +bool Bifrost::CompactedDBG::operator==(const Bifrost::CompactedDBG& o) const { if ((!invalid && !o.invalid) && (k_ == o.k_) && (size() == o.size())){ @@ -228,13 +228,13 @@ bool CompactedDBG::operator==(const CompactedDBG& o) const { } template -inline bool CompactedDBG::operator!=(const CompactedDBG& o) const { +inline bool Bifrost::CompactedDBG::operator!=(const Bifrost::CompactedDBG& o) const { return !operator==(o); } template -void CompactedDBG::clear(){ +void Bifrost::CompactedDBG::clear(){ k_ = 0; g_ = 0; @@ -251,7 +251,7 @@ void CompactedDBG::clear(){ } /*template -bool CompactedDBG::build(CDBG_Build_opt& opt){ +bool Bifrost::CompactedDBG::build(CDBG_Build_opt& opt){ size_t max_threads = std::thread::hardware_concurrency(); @@ -383,8 +383,8 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if ((opt.filename_seq_in.size() != 0) && (opt.filename_ref_in.size() != 0)){ - CompactedDBG graph_seq(k_, g_); - CompactedDBG graph_ref(k_, g_); + Bifrost::CompactedDBG graph_seq(k_, g_); + Bifrost::CompactedDBG graph_ref(k_, g_); CDBG_Build_opt opt_seq(opt); CDBG_Build_opt opt_ref(opt); @@ -499,7 +499,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ }*/ template -bool CompactedDBG::build(CDBG_Build_opt& opt){ +bool Bifrost::CompactedDBG::build(CDBG_Build_opt& opt){ size_t max_threads = std::thread::hardware_concurrency(); @@ -631,8 +631,8 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ if ((opt.filename_seq_in.size() != 0) && (opt.filename_ref_in.size() != 0)){ - CompactedDBG graph_seq(k_, g_); - CompactedDBG graph_ref(k_, g_); + Bifrost::CompactedDBG graph_seq(k_, g_); + Bifrost::CompactedDBG graph_ref(k_, g_); CDBG_Build_opt opt_seq(opt); CDBG_Build_opt opt_ref(opt); @@ -664,7 +664,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ } else if (!is_void::value) { - CompactedDBG graph(k_, g_); + Bifrost::CompactedDBG graph(k_, g_); construct_finished = graph.build(opt); @@ -760,7 +760,7 @@ bool CompactedDBG::build(CDBG_Build_opt& opt){ } template -bool CompactedDBG::simplify(const bool delete_short_isolated_unitigs, const bool clip_short_tips, const bool verbose){ +bool Bifrost::CompactedDBG::simplify(const bool delete_short_isolated_unitigs, const bool clip_short_tips, const bool verbose){ if (invalid){ @@ -795,7 +795,7 @@ bool CompactedDBG::simplify(const bool delete_short_isolated_unitigs, cons } template -bool CompactedDBG::write(const string& output_filename, const size_t nb_threads, const bool GFA_output, const bool verbose) const { +bool Bifrost::CompactedDBG::write(const string& output_filename, const size_t nb_threads, const bool GFA_output, const bool verbose) const { if (invalid){ @@ -838,7 +838,7 @@ bool CompactedDBG::write(const string& output_filename, const size_t nb_th } template -bool CompactedDBG::read(const string& input_filename, const size_t nb_threads, const bool verbose){ +bool Bifrost::CompactedDBG::read(const string& input_filename, const size_t nb_threads, const bool verbose){ if (verbose) cout << endl << "CompactedDBG::read(): Reading graph from disk" << endl; @@ -970,7 +970,7 @@ bool CompactedDBG::read(const string& input_filename, const size_t nb_thre } template -const_UnitigMap CompactedDBG::find(const char* s, const size_t pos_km, const minHashIterator& it_min, const bool extremities_only) const { +Bifrost::const_UnitigMap Bifrost::CompactedDBG::find(const char* s, const size_t pos_km, const minHashIterator& it_min, const bool extremities_only) const { if (invalid){ @@ -1093,7 +1093,7 @@ const_UnitigMap CompactedDBG::find(const char* s, const size_t pos_k } template -UnitigMap CompactedDBG::find(const char* s, const size_t pos_km, const minHashIterator& it_min, const bool extremities_only) { +Bifrost::UnitigMap Bifrost::CompactedDBG::find(const char* s, const size_t pos_km, const minHashIterator& it_min, const bool extremities_only) { if (invalid){ @@ -1216,7 +1216,7 @@ UnitigMap CompactedDBG::find(const char* s, const size_t pos_km, con } template -const_UnitigMap CompactedDBG::find(const Kmer& km, const bool extremities_only) const { +Bifrost::const_UnitigMap Bifrost::CompactedDBG::find(const Kmer& km, const bool extremities_only) const { if (invalid){ @@ -1338,7 +1338,7 @@ const_UnitigMap CompactedDBG::find(const Kmer& km, const bool extrem } template -UnitigMap CompactedDBG::find(const Kmer& km, const bool extremities_only) { +Bifrost::UnitigMap Bifrost::CompactedDBG::find(const Kmer& km, const bool extremities_only) { if (invalid){ @@ -1460,7 +1460,7 @@ UnitigMap CompactedDBG::find(const Kmer& km, const bool extremities_ } template -vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) const { +vector> Bifrost::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()}; @@ -1610,7 +1610,7 @@ vector> CompactedDBG::findPredecessors(const Kmer& k } template -vector> CompactedDBG::findPredecessors(const Kmer& km, const bool extremities_only) { +vector> Bifrost::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()}; @@ -1760,7 +1760,7 @@ vector> CompactedDBG::findPredecessors(const Kmer& km, con } template -vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) const { +vector> Bifrost::CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) const { vector> v_um(4, const_UnitigMap(1, this)); @@ -1945,7 +1945,7 @@ vector> CompactedDBG::findSuccessors(const Kmer& km, } template -vector> CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) { +vector> Bifrost::CompactedDBG::findSuccessors(const Kmer& km, const size_t limit, const bool extremities_only) { vector> v_um(4, UnitigMap(1, this)); @@ -2130,7 +2130,7 @@ vector> CompactedDBG::findSuccessors(const Kmer& km, const } template -bool CompactedDBG::add(const string& seq, const bool verbose){ +bool Bifrost::CompactedDBG::add(const string& seq, const bool verbose){ if (invalid){ @@ -2178,7 +2178,7 @@ bool CompactedDBG::add(const string& seq, const bool verbose){ } template -bool CompactedDBG::remove(const const_UnitigMap& um, const bool verbose){ +bool Bifrost::CompactedDBG::remove(const const_UnitigMap& um, const bool verbose){ if (invalid){ @@ -2229,7 +2229,7 @@ bool CompactedDBG::remove(const const_UnitigMap& um, const bool verb } template -bool CompactedDBG::merge(const CompactedDBG& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::CompactedDBG::merge(const CompactedDBG& o, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -2293,7 +2293,7 @@ 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 Bifrost::CompactedDBG::merge(const vector& v, const size_t nb_threads, const bool verbose){ bool ret = true; @@ -2370,7 +2370,7 @@ bool CompactedDBG::merge(const vector& v, const size_t nb_th } template -bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::CompactedDBG::annotateSplitUnitigs(const Bifrost::CompactedDBG& o, const size_t nb_threads, const bool verbose){ if ((this != &o) && !invalid && !o.invalid) { // TODO: Check if k_ and g_ are the same @@ -2392,8 +2392,8 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const 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()); + typename Bifrost::CompactedDBG::const_iterator g_a(o.begin()); + typename Bifrost::CompactedDBG::const_iterator g_b(o.end()); LockGraph lck_g(nb_locks); @@ -2405,7 +2405,7 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const [&/*, t*/]{ - typename CompactedDBG::const_iterator l_a, l_b; + typename Bifrost::CompactedDBG::const_iterator l_a, l_b; while (true) { @@ -2443,7 +2443,7 @@ bool CompactedDBG::annotateSplitUnitigs(const CompactedDBG& o, const } template -bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::CompactedDBG::mergeData(const Bifrost::CompactedDBG& o, const size_t nb_threads, const bool verbose){ if ((this != &o) && !invalid && !o.invalid){ // TODO: Check if k_ and g_ are the same @@ -2455,7 +2455,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ for (size_t i = 0; i < nb_locks; ++i) locks_unitig[i].clear(); - auto worker_function = [&](typename CompactedDBG::const_iterator it_a, typename CompactedDBG::const_iterator it_b) { + auto worker_function = [&](typename Bifrost::CompactedDBG::const_iterator it_a, typename Bifrost::CompactedDBG::const_iterator it_b) { while (it_a != it_b) { @@ -2496,8 +2496,8 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ 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(); + typename Bifrost::CompactedDBG::const_iterator g_a = o.begin(); + typename Bifrost::CompactedDBG::const_iterator g_b = o.end(); mutex mutex_it; @@ -2507,7 +2507,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ [&]{ - typename CompactedDBG::const_iterator l_a, l_b; + typename Bifrost::CompactedDBG::const_iterator l_a, l_b; while (true) { @@ -2543,7 +2543,7 @@ bool CompactedDBG::mergeData(const CompactedDBG& o, const size_t nb_ } template -bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threads, const bool verbose){ +bool Bifrost::CompactedDBG::mergeData(Bifrost::CompactedDBG&& o, const size_t nb_threads, const bool verbose){ if ((this != &o) && !invalid && !o.invalid){ // TODO: Check if k_ and g_ are the same @@ -2555,7 +2555,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa for (size_t i = 0; i < nb_locks; ++i) locks_unitig[i].clear(); - auto worker_function = [&](typename CompactedDBG::iterator it_a, typename CompactedDBG::iterator it_b) { + auto worker_function = [&](typename Bifrost::CompactedDBG::iterator it_a, typename Bifrost::CompactedDBG::iterator it_b) { while (it_a != it_b) { @@ -2598,8 +2598,8 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa 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(); + typename Bifrost::CompactedDBG::iterator g_a = o.begin(); + typename Bifrost::CompactedDBG::iterator g_b = o.end(); mutex mutex_it; @@ -2609,7 +2609,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa [&, t]{ - typename CompactedDBG::iterator l_a, l_b; + typename Bifrost::CompactedDBG::iterator l_a, l_b; while (true) { @@ -2645,7 +2645,7 @@ bool CompactedDBG::mergeData(CompactedDBG&& o, const size_t nb_threa } template -typename CompactedDBG::iterator CompactedDBG::begin() { +typename Bifrost::CompactedDBG::iterator Bifrost::CompactedDBG::begin() { if (invalid) return iterator(); @@ -2656,7 +2656,7 @@ typename CompactedDBG::iterator CompactedDBG::begin() { } template -typename CompactedDBG::const_iterator CompactedDBG::begin() const { +typename Bifrost::CompactedDBG::const_iterator Bifrost::CompactedDBG::begin() const { if (invalid) return const_iterator(); @@ -2667,13 +2667,13 @@ typename CompactedDBG::const_iterator CompactedDBG::begin() const { } template -typename CompactedDBG::iterator CompactedDBG::end() { return iterator(); } +typename Bifrost::CompactedDBG::iterator Bifrost::CompactedDBG::end() { return iterator(); } template -typename CompactedDBG::const_iterator CompactedDBG::end() const { return const_iterator(); } +typename Bifrost::CompactedDBG::const_iterator Bifrost::CompactedDBG::end() const { return const_iterator(); } template -size_t CompactedDBG::length() const { +size_t Bifrost::CompactedDBG::length() const { size_t len = 0; @@ -2688,7 +2688,7 @@ size_t CompactedDBG::length() const { } template -size_t CompactedDBG::nbKmers() const { +size_t Bifrost::CompactedDBG::nbKmers() const { size_t nb = 0; @@ -2703,7 +2703,7 @@ size_t CompactedDBG::nbKmers() const { } template -bool CompactedDBG::filter(const CDBG_Build_opt& opt, const size_t nb_unique_kmers, const size_t nb_non_unique_kmers) { +bool Bifrost::CompactedDBG::filter(const CDBG_Build_opt& opt, const size_t nb_unique_kmers, const size_t nb_non_unique_kmers) { if (invalid){ @@ -2926,7 +2926,7 @@ bool CompactedDBG::filter(const CDBG_Build_opt& opt, const size_t nb_uniqu } template -bool CompactedDBG::construct(const CDBG_Build_opt& opt, const size_t nb_unique_minimizers, const size_t nb_non_unique_minimizers){ +bool Bifrost::CompactedDBG::construct(const CDBG_Build_opt& opt, const size_t nb_unique_minimizers, const size_t nb_non_unique_minimizers){ if (invalid){ @@ -3257,7 +3257,7 @@ bool CompactedDBG::construct(const CDBG_Build_opt& opt, const size_t nb_un } template -bool CompactedDBG::addUnitigSequenceBBF(const Kmer km, const string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g) { +bool Bifrost::CompactedDBG::addUnitigSequenceBBF(const Kmer km, const string& seq, const size_t pos_match_km, const size_t len_match_km, LockGraph& lck_g) { bool isAbundant = false; @@ -3304,7 +3304,7 @@ bool CompactedDBG::addUnitigSequenceBBF(const Kmer km, const string& seq, // than the last kmer // selfLoop is true of the unitig is a loop or hairpin template -size_t CompactedDBG::findUnitigSequenceBBF(Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip) { +size_t Bifrost::CompactedDBG::findUnitigSequenceBBF(Kmer km, string& s, bool& isIsolated, vector& l_ignored_km_tip) { string fw_s, bw_s; @@ -3370,7 +3370,7 @@ size_t CompactedDBG::findUnitigSequenceBBF(Kmer km, string& s, bool& isIso } template -bool CompactedDBG::bwStepBBF(const Kmer km, Kmer& front, char& c, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +bool Bifrost::CompactedDBG::bwStepBBF(const Kmer km, Kmer& front, char& c, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -3549,7 +3549,7 @@ bool CompactedDBG::bwStepBBF(const Kmer km, Kmer& front, char& c, bool& ha } template -bool CompactedDBG::fwStepBBF(const Kmer km, Kmer& end, char& c, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { +bool Bifrost::CompactedDBG::fwStepBBF(const Kmer km, Kmer& end, char& c, bool& has_no_neighbor, vector& l_ignored_km_tip, const bool check_fp_cand) const { char km_tmp[MAX_KMER_SIZE]; @@ -3732,7 +3732,7 @@ bool CompactedDBG::fwStepBBF(const Kmer km, Kmer& end, char& c, bool& has_ // post: cc contains either the reference to the unitig position // or empty if none found template -UnitigMap CompactedDBG::findUnitig(const Kmer& km, const char* s, const size_t pos) { +Bifrost::UnitigMap Bifrost::CompactedDBG::findUnitig(const Kmer& km, const char* s, const size_t pos) { // need to check if we find it right away, need to treat this common case UnitigMap um = find(km); @@ -3749,7 +3749,7 @@ UnitigMap CompactedDBG::findUnitig(const Kmer& km, const char* s, co } template -UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len) { +Bifrost::UnitigMap Bifrost::CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len) { if ((len < k_) || (pos > len - k_)) return UnitigMap(); @@ -3773,7 +3773,7 @@ UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, } template -const_UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len) const { +Bifrost::const_UnitigMap Bifrost::CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len) const { if ((len < k_) || (pos > len - k_)) return const_UnitigMap(); @@ -3797,7 +3797,7 @@ const_UnitigMap CompactedDBG::findUnitig(const char* s, const size_t } template -UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min) { +Bifrost::UnitigMap Bifrost::CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min) { if ((len < k_) || (pos > len - k_)) return UnitigMap(); @@ -3821,7 +3821,7 @@ UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, } template -const_UnitigMap CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min) const { +Bifrost::const_UnitigMap Bifrost::CompactedDBG::findUnitig(const char* s, const size_t pos, const size_t len, const minHashIterator& it_min) const { if ((len < k_) || (pos > len - k_)) return const_UnitigMap(); @@ -3845,7 +3845,7 @@ const_UnitigMap CompactedDBG::findUnitig(const char* s, const size_t } template -UnitigMap CompactedDBG::findUnitig(const Kmer& km, const char* s, const size_t pos, const preAllocMinHashIterator& it_min_h) { +Bifrost::UnitigMap Bifrost::CompactedDBG::findUnitig(const Kmer& km, const char* s, const size_t pos, const preAllocMinHashIterator& it_min_h) { // need to check if we find it right away, need to treat this common case UnitigMap um = find(km, it_min_h); @@ -3862,7 +3862,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 Bifrost::CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig){ int pos; @@ -4017,7 +4017,7 @@ bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_uni } template -void CompactedDBG::moveToAbundant() { +void Bifrost::CompactedDBG::moveToAbundant() { MinimizerIndex::iterator it = hmap_min_unitigs.begin(); MinimizerIndex::iterator it_end = hmap_min_unitigs.end(); @@ -4102,7 +4102,7 @@ void CompactedDBG::moveToAbundant() { } template -bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer){ +bool Bifrost::CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig, SpinLock& lck_unitig, SpinLock& lck_kmer){ int pos; @@ -4229,7 +4229,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 Bifrost::CompactedDBG::addUnitig(const string& str_unitig, const size_t id_unitig, const size_t id_unitig_r, const size_t is_short_r){ int pos; @@ -4412,7 +4412,7 @@ bool CompactedDBG::addUnitig(const string& str_unitig, const size_t id_uni } template -void CompactedDBG::swapUnitigs(const bool isShort, const size_t id_a, const size_t id_b){ +void Bifrost::CompactedDBG::swapUnitigs(const bool isShort, const size_t id_a, const size_t id_b){ size_t shift_id_unitig_a = id_a << 32; size_t shift_id_unitig_b = id_b << 32; @@ -4631,7 +4631,7 @@ 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 Bifrost::CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ if (invalid){ @@ -4855,7 +4855,7 @@ bool CompactedDBG::mergeUnitig(const string& seq, const bool verbose){ } template -bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbose){ +bool Bifrost::CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbose){ if (invalid){ @@ -5009,7 +5009,7 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, const bool verbo } template -bool CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g, const bool verbose){ +bool Bifrost::CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g, const bool verbose){ if (invalid){ @@ -5171,7 +5171,7 @@ bool CompactedDBG::annotateSplitUnitig(const string& seq, LockGraph& lck_g template template -typename std::enable_if::type CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant, +typename std::enable_if::type Bifrost::CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const bool delete_data){ if (isAbundant){ @@ -5328,7 +5328,7 @@ typename std::enable_if::type CompactedDBG::deleteUnitig_( template template -typename std::enable_if::type CompactedDBG::deleteUnitig_( const bool isShort, const bool isAbundant, +typename std::enable_if::type Bifrost::CompactedDBG::deleteUnitig_( const bool isShort, const bool isAbundant, const size_t id_unitig, const bool delete_data){ if (isAbundant){ @@ -5477,7 +5477,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 Bifrost::CompactedDBG::deleteUnitig_(const bool isShort, const bool isAbundant, const size_t id_unitig, const string& str){ const char* s = str.c_str(); const size_t len = str.size(); @@ -5594,7 +5594,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, +typename std::enable_if::type Bifrost::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){ bool deleted = true; @@ -5702,7 +5702,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, +typename std::enable_if::type Bifrost::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){ bool deleted = true; @@ -5764,7 +5764,7 @@ typename std::enable_if::type CompactedDBG::extractUnitig_( } template -UnitigMap CompactedDBG::find(const Kmer& km, const preAllocMinHashIterator& it_min_h) { +Bifrost::UnitigMap Bifrost::CompactedDBG::find(const Kmer& km, const preAllocMinHashIterator& it_min_h) { const Kmer km_twin = km.twin(); const Kmer& km_rep = km < km_twin ? km : km_twin; @@ -5879,7 +5879,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() { +pair Bifrost::CompactedDBG::extractAllUnitigs() { size_t i; size_t split = 0, deleted = 0; @@ -5938,7 +5938,7 @@ 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() { +pair Bifrost::CompactedDBG::splitAllUnitigs() { pair p = {0, 0}; @@ -5986,7 +5986,7 @@ pair CompactedDBG::splitAllUnitigs() { } template -pair CompactedDBG::getSplitInfoAllUnitigs() const { +pair Bifrost::CompactedDBG::getSplitInfoAllUnitigs() const { pair p = {0, 0}; @@ -6019,7 +6019,7 @@ pair CompactedDBG::getSplitInfoAllUnitigs() const { } template -void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { +void Bifrost::CompactedDBG::createJoinHT(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(); @@ -6338,7 +6338,7 @@ void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable } template -void CompactedDBG::createJoinHT(vector* v_joins, KmerHashTable& joins, const size_t nb_threads) const { +void Bifrost::CompactedDBG::createJoinHT(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(); @@ -6663,7 +6663,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 Bifrost::CompactedDBG::joinUnitigs_(vector* v_joins, const size_t nb_threads) { size_t joined = 0; size_t cov_full = CompressedCoverage::getFullCoverage(); @@ -6865,7 +6865,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 Bifrost::CompactedDBG::joinUnitigs_(vector* v_joins, const size_t nb_threads) { size_t joined = 0; size_t cov_full = CompressedCoverage::getFullCoverage(); @@ -7053,7 +7053,7 @@ typename std::enable_if::type CompactedDBG::joinUnitigs_( } template -bool CompactedDBG::checkJoin(const Kmer& a, const const_UnitigMap& cm_a, Kmer& b) const { +bool Bifrost::CompactedDBG::checkJoin(const Kmer& a, const const_UnitigMap& cm_a, Kmer& b) const { size_t i, j, count_succ; @@ -7102,7 +7102,7 @@ bool CompactedDBG::checkJoin(const Kmer& a, const const_UnitigMap& c } template -void CompactedDBG::check_fp_tips(KmerHashTable& ignored_km_tips){ +void Bifrost::CompactedDBG::check_fp_tips(KmerHashTable& ignored_km_tips){ uint64_t nb_real_short_tips = 0; @@ -7177,7 +7177,7 @@ void CompactedDBG::check_fp_tips(KmerHashTable& ignored_km_tips){ } template -size_t CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, vector& v){ +size_t Bifrost::CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, vector& v){ if (!rmIsolated && !clipTips) return 0; @@ -7347,7 +7347,7 @@ size_t CompactedDBG::removeUnitigs(bool rmIsolated, bool clipTips, vector< } template -void CompactedDBG::writeFASTA(const string& graphfilename) const { +void Bifrost::CompactedDBG::writeFASTA(const string& graphfilename) const { const size_t v_unitigs_sz = v_unitigs.size(); const size_t v_kmers_sz = km_unitigs.size(); @@ -7376,7 +7376,7 @@ void CompactedDBG::writeFASTA(const string& graphfilename) const { template template -typename std::enable_if::type CompactedDBG::writeGFA_sequence_(GFA_Parser& graph, KmerHashTable& idmap) const { +typename std::enable_if::type Bifrost::CompactedDBG::writeGFA_sequence_(GFA_Parser& graph, KmerHashTable& idmap) const { size_t labelA = 1; @@ -7394,7 +7394,7 @@ typename std::enable_if::type CompactedDBG::writeGFA_seque template template -typename std::enable_if::type CompactedDBG::writeGFA_sequence_(GFA_Parser& graph, KmerHashTable& idmap) const { +typename std::enable_if::type Bifrost::CompactedDBG::writeGFA_sequence_(GFA_Parser& graph, KmerHashTable& idmap) const { size_t labelA = 1; @@ -7411,7 +7411,7 @@ typename std::enable_if::type CompactedDBG::writeGFA_sequen } template -void CompactedDBG::writeGFA(const string& graphfilename, const size_t nb_threads) const { +void Bifrost::CompactedDBG::writeGFA(const string& graphfilename, const size_t nb_threads) const { const size_t v_unitigs_sz = v_unitigs.size(); const size_t v_kmers_sz = km_unitigs.size(); @@ -7820,7 +7820,7 @@ void CompactedDBG::writeGFA(const string& graphfilename, const size_t nb_t } template -void CompactedDBG::readGFA(const string& graphfilename, const size_t nb_threads) { +void Bifrost::CompactedDBG::readGFA(const string& graphfilename, const size_t nb_threads) { size_t graph_file_id = 0; @@ -7903,7 +7903,7 @@ void CompactedDBG::readGFA(const string& graphfilename, const size_t nb_th } template -void CompactedDBG::readFASTA(const string& graphfilename, const size_t nb_threads) { +void Bifrost::CompactedDBG::readFASTA(const string& graphfilename, const size_t nb_threads) { size_t graph_file_id = 0; @@ -7974,7 +7974,7 @@ void CompactedDBG::readFASTA(const string& graphfilename, const size_t nb_ } template -void CompactedDBG::mapRead(const const_UnitigMap& um) { +void Bifrost::CompactedDBG::mapRead(const const_UnitigMap& um) { if (um.isEmpty) return; // nothing maps, move on @@ -7984,7 +7984,7 @@ void CompactedDBG::mapRead(const const_UnitigMap& um) { } template -void CompactedDBG::mapRead(const const_UnitigMap& um, LockGraph& lck_g) { +void Bifrost::CompactedDBG::mapRead(const const_UnitigMap& um, LockGraph& lck_g) { if (um.isEmpty) return; // nothing maps, move on @@ -8006,7 +8006,7 @@ void CompactedDBG::mapRead(const const_UnitigMap& um, LockGraph& lck } template -void CompactedDBG::unmapRead(const const_UnitigMap& um) { +void Bifrost::CompactedDBG::unmapRead(const const_UnitigMap& um) { if (um.isEmpty) return; // nothing maps, move on @@ -8016,7 +8016,7 @@ void CompactedDBG::unmapRead(const const_UnitigMap& um) { } template -void CompactedDBG::unmapRead(const const_UnitigMap& um, LockGraph& lck_g) { +void Bifrost::CompactedDBG::unmapRead(const const_UnitigMap& um, LockGraph& lck_g) { if (um.isEmpty) return; // nothing maps, move on @@ -8038,7 +8038,7 @@ void CompactedDBG::unmapRead(const const_UnitigMap& um, LockGraph& l } template -vector CompactedDBG::extractMercyKmers(BlockedBloomFilter& bf_uniq_km, const size_t nb_threads, const bool verbose) { +vector Bifrost::CompactedDBG::extractMercyKmers(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(); @@ -8282,7 +8282,7 @@ vector CompactedDBG::extractMercyKmers(BlockedBloomFilter& bf_uniq_k } template -size_t CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_t nb_threads, const bool verbose) { +size_t Bifrost::CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_t nb_threads, const bool verbose) { if (invalid){ @@ -8309,13 +8309,13 @@ size_t CompactedDBG::joinTips(string filename_MBBF_uniq_kmers, const size_ 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) cout << "Bifrost::CompactedDBG::joinTips(): " << nb_join << " unitigs have been joined using mercy k-mers" << endl; return nb_join; } template -void CompactedDBG::setKmerGmerLength(const int kmer_length, const int minimizer_length){ +void Bifrost::CompactedDBG::setKmerGmerLength(const int kmer_length, const int minimizer_length){ invalid = false; @@ -8364,14 +8364,14 @@ void CompactedDBG::setKmerGmerLength(const int kmer_length, const int mini } template -void CompactedDBG::setFullCoverage(const size_t cov) const { +void Bifrost::CompactedDBG::setFullCoverage(const size_t cov) const { CompressedCoverage::setFullCoverage(cov); KmerCovIndex::setFullCoverage(cov); } template -void CompactedDBG::print() const { +void Bifrost::CompactedDBG::print() const { cout << "CompactedDBG::print(): v_unitigs.size() = " << v_unitigs.size() << endl; cout << "CompactedDBG::print(): v_kmers.size() = " << km_unitigs.size() << endl; diff --git a/src/CompressedCoverage.cpp b/src/CompressedCoverage.cpp index 9003c58..08e80f7 100644 --- a/src/CompressedCoverage.cpp +++ b/src/CompressedCoverage.cpp @@ -8,6 +8,7 @@ #include "CompressedCoverage.hpp" using namespace std; +using namespace Bifrost; // use: cc = CompressedCoverage(sz, full); // post: if (sz > 0) then initialize the instance else skip initializing, if full is true, initialize as full regardlesss of sz. diff --git a/src/CompressedCoverage.hpp b/src/CompressedCoverage.hpp index c2c5ae5..69c93fc 100644 --- a/src/CompressedCoverage.hpp +++ b/src/CompressedCoverage.hpp @@ -9,6 +9,8 @@ #include "BitContainer.hpp" #include "Common.hpp" +namespace Bifrost { + /* Short description: * - Tagged pointer union that is either * - a pointer to a char array that stores 2-bit integers @@ -187,4 +189,6 @@ template<> struct CompressedCoverage_t { CompressedCoverage ccov; }; +} + #endif // BFG_COMPRESSED_COVERAGE_HPP diff --git a/src/CompressedSequence.cpp b/src/CompressedSequence.cpp index 2a03c64..7c57805 100644 --- a/src/CompressedSequence.cpp +++ b/src/CompressedSequence.cpp @@ -4,6 +4,8 @@ #include "CompressedSequence.hpp" #include "Kmer.hpp" +using namespace Bifrost; + CompressedSequence::CompressedSequence() { initShort(); diff --git a/src/CompressedSequence.hpp b/src/CompressedSequence.hpp index 6a985de..5462a6b 100644 --- a/src/CompressedSequence.hpp +++ b/src/CompressedSequence.hpp @@ -7,6 +7,7 @@ #include "Kmer.hpp" +namespace Bifrost { /* Short description: * - Compress a DNA string by using 2 bits per base instead of 8 * - Easily get the DNA string back from the compressed format @@ -138,4 +139,7 @@ class CompressedSequence { }; }; +} + #endif // BFG_COMPRESSED_SEQUENCE_HPP + diff --git a/src/DataAccessor.hpp b/src/DataAccessor.hpp index 7b7863f..75dd6dc 100644 --- a/src/DataAccessor.hpp +++ b/src/DataAccessor.hpp @@ -4,6 +4,8 @@ #include "CompactedDBG.hpp" #include "ColorSet.hpp" +namespace Bifrost { + /** @file src/DataAccessor.hpp * Interface for the class DataAccessor. The purpose of a DataAccessor object is to provide access * to the colors and the data associated with a unitig of a ColoredCDBG. Code snippets using this @@ -139,4 +141,6 @@ class DataAccessor : public CDBG_Data_t, DataStorage uint8_t da_id; }; +} + #endif diff --git a/src/DataAccessor.tcc b/src/DataAccessor.tcc index c4014be..089b5e1 100644 --- a/src/DataAccessor.tcc +++ b/src/DataAccessor.tcc @@ -2,10 +2,10 @@ #define BIFROST_HASHID_TCC template -DataAccessor::DataAccessor(const uint8_t id) : da_id(id) {} +Bifrost::DataAccessor::DataAccessor(const uint8_t id) : da_id(id) {} template -void DataAccessor::clear(const UnitigColorMap& um) { +void Bifrost::DataAccessor::clear(const UnitigColorMap& um) { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -21,7 +21,7 @@ void DataAccessor::clear(const UnitigColorMap& um) { } template -const U* DataAccessor::getData(const const_UnitigColorMap& um) const { +const U* Bifrost::DataAccessor::getData(const const_UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -34,13 +34,13 @@ const U* DataAccessor::getData(const const_UnitigColorMap& um) const { } template<> -inline const void* DataAccessor::getData(const const_UnitigColorMap& um) const { +inline const void* Bifrost::DataAccessor::getData(const const_UnitigColorMap& um) const { return nullptr; } template -U* DataAccessor::getData(const UnitigColorMap& um) const { +U* Bifrost::DataAccessor::getData(const UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -53,13 +53,13 @@ U* DataAccessor::getData(const UnitigColorMap& um) const { } template<> -inline void* DataAccessor::getData(const UnitigColorMap& um) const { +inline void* Bifrost::DataAccessor::getData(const UnitigColorMap& um) const { return nullptr; } template -const UnitigColors* DataAccessor::getUnitigColors(const const_UnitigColorMap& um) const { +const Bifrost::UnitigColors* Bifrost::DataAccessor::getUnitigColors(const const_UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -72,7 +72,7 @@ const UnitigColors* DataAccessor::getUnitigColors(const const_UnitigColorMap< } template -UnitigColors* DataAccessor::getUnitigColors(const UnitigColorMap& um) const { +Bifrost::UnitigColors* Bifrost::DataAccessor::getUnitigColors(const UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -85,7 +85,7 @@ UnitigColors* DataAccessor::getUnitigColors(const UnitigColorMap& um) cons } template -UnitigColors DataAccessor::getSubUnitigColors(const const_UnitigColorMap& um) const { +Bifrost::UnitigColors Bifrost::DataAccessor::getSubUnitigColors(const const_UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -98,7 +98,7 @@ UnitigColors DataAccessor::getSubUnitigColors(const const_UnitigColorMap& } template -vector DataAccessor::getSubUnitigColorNames(const const_UnitigColorMap& um) const { +vector Bifrost::DataAccessor::getSubUnitigColorNames(const const_UnitigColorMap& um) const { if (!um.isEmpty && (um.getGraph() != nullptr)){ @@ -111,16 +111,16 @@ vector DataAccessor::getSubUnitigColorNames(const const_UnitigColorMa } template -void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColorMap& um_src){ +void Bifrost::DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColorMap& um_src){ DataStorage* ds = um_dest.getGraph()->getData(); - DataAccessor* da_dest = um_dest.getData(); - UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); + Bifrost::DataAccessor* da_dest = um_dest.getData(); + Bifrost::UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); U* data_dest = da_dest->getData(um_dest); - DataAccessor* da_src = um_src.getData(); - UnitigColors* uc_src = da_src->getUnitigColors(um_src); + Bifrost::DataAccessor* da_src = um_src.getData(); + Bifrost::UnitigColors* uc_src = da_src->getUnitigColors(um_src); U* data_src = da_src->getData(um_src); if ((uc_dest != nullptr) || (uc_src != nullptr)){ // If a colorset exists for um_dest @@ -128,17 +128,17 @@ void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColor const Kmer head = um_dest.getUnitigHead(); const Kmer new_head = um_dest.strand ? head : um_dest.getUnitigTail().twin(); - UnitigColors* uc_ptr = uc_dest; + Bifrost::UnitigColors* uc_ptr = uc_dest; U* data_ptr = data_dest; - UnitigColors uc_ = ds->joinUnitigColors(um_dest, um_src); // Join the color sets + Bifrost::UnitigColors uc_ = ds->joinUnitigColors(um_dest, um_src); // Join the color sets U data_; if ((data_dest != nullptr) || (data_src != nullptr)) data_.concat(um_dest, um_src); 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 pair, 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; @@ -147,7 +147,7 @@ void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColor else { *this = *da_dest; // UnitigColors of um_dest is recycled - *da_dest = DataAccessor(0); + *da_dest = Bifrost::DataAccessor(0); } *uc_ptr = move(uc_); @@ -156,24 +156,24 @@ void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColor } template<> -inline void DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColorMap& um_src){ +inline void Bifrost::DataAccessor::concat(const UnitigColorMap& um_dest, const UnitigColorMap& um_src){ DataStorage* ds = um_dest.getGraph()->getData(); - DataAccessor* da_dest = um_dest.getData(); - UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); + Bifrost::DataAccessor* da_dest = um_dest.getData(); + Bifrost::UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); - DataAccessor* da_src = um_src.getData(); - UnitigColors* uc_src = da_src->getUnitigColors(um_src); + Bifrost::DataAccessor* da_src = um_src.getData(); + Bifrost::UnitigColors* uc_src = da_src->getUnitigColors(um_src); if ((uc_dest != nullptr) || (uc_src != nullptr)){ // If a UnitigColors exists for at least one of the two unitigs const Kmer head = um_dest.getUnitigHead(); // Get head k-mer of reference unitig of um_dest const Kmer new_head = um_dest.strand ? head : um_dest.getUnitigTail().twin(); // Compute new head k-mer after concatenation - UnitigColors uc_ = ds->joinUnitigColors(um_dest, um_src); // Join the UnitigColors of the two reference unitigs + Bifrost::UnitigColors uc_ = ds->joinUnitigColors(um_dest, um_src); // Join the UnitigColors of the two reference unitigs - UnitigColors* uc_ptr = uc_dest; + Bifrost::UnitigColors* uc_ptr = uc_dest; // If reference unitig of um_dest has no UnitigColors associated // OR if the new head k-mer (after concat.) is not the same has the current head k-mer (before concat.) @@ -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 pair, 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; @@ -191,7 +191,7 @@ inline void DataAccessor::concat(const UnitigColorMap& um_dest, cons *this = *da_dest; // UnitigColors associated with reference unitig of um_dest is recycled // Set the DataAccessor of um_dest to 0 (means inserted into overflow system of DataStorage) // to ensure the (recycled) UnitigColors is not deleted after concatenation - *da_dest = DataAccessor(0); + *da_dest = Bifrost::DataAccessor(0); } *uc_ptr = move(uc_); @@ -199,16 +199,16 @@ inline void DataAccessor::concat(const UnitigColorMap& um_dest, cons } template -void DataAccessor::merge(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src){ +void Bifrost::DataAccessor::merge(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src){ DataStorage* ds = um_dest.getGraph()->getData(); // Get DataStorage where the UnitigColors and data are stored - DataAccessor* da_dest = um_dest.getData(); // Get DataAccessor stored with reference unitig of um_dest - UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); // Get UnitigColors associated with reference unitig of um_dest + Bifrost::DataAccessor* da_dest = um_dest.getData(); // Get DataAccessor stored with reference unitig of um_dest + Bifrost::UnitigColors* uc_dest = da_dest->getUnitigColors(um_dest); // Get UnitigColors associated with reference unitig of um_dest U* data_dest = da_dest->getData(um_dest); // Get data associated with reference unitig of um_dest - const DataAccessor* da_src = um_src.getData(); // Get DataAccessor stored with reference unitig of um_src - const UnitigColors* uc_src = da_src->getUnitigColors(um_src); // Get UnitigColors associated with reference unitig of um_src + const Bifrost::DataAccessor* da_src = um_src.getData(); // Get DataAccessor stored with reference unitig of um_src + const Bifrost::UnitigColors* uc_src = da_src->getUnitigColors(um_src); // Get UnitigColors associated with reference unitig of um_src const U* data_src = da_src->getData(um_src); // Get data associated with reference unitig of um_src // If reference unitig of um_dest has no UnitigColors but reference unitig of um_src has one @@ -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 pair, pair> p = ds->insert(um); uc_dest = p.second.first; // Set the new UnitigColors data_dest = p.second.second; // Set the new data @@ -235,12 +235,12 @@ void DataAccessor::merge(const UnitigColorMap& um_dest, const const_Unitig } template<> -inline void DataAccessor::merge(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src){ +inline void Bifrost::DataAccessor::merge(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src){ DataStorage* ds = um_dest.getGraph()->getData(); // Get DataStorage where the UnitigColors are stored - UnitigColors* uc_dest = um_dest.getData()->getUnitigColors(um_dest); // Get UnitigColors associated with reference unitig of um_dest - const UnitigColors* uc_src = um_src.getData()->getUnitigColors(um_src); // Get UnitigColors associated with reference unitig of um_src + Bifrost::UnitigColors* uc_dest = um_dest.getData()->getUnitigColors(um_dest); // Get UnitigColors associated with reference unitig of um_dest + const Bifrost::UnitigColors* uc_src = um_src.getData()->getUnitigColors(um_src); // Get UnitigColors associated with reference unitig of um_src // If reference unitig of um_dest has no UnitigColors but reference unitig of um_src has one if ((uc_dest == nullptr) && (uc_src != nullptr)){ @@ -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 pair, 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 @@ -263,15 +263,15 @@ inline void DataAccessor::merge(const UnitigColorMap& um_dest, const } template -void DataAccessor::extract(const UnitigColorMap& um_src, const bool last_extraction) { +void Bifrost::DataAccessor::extract(const UnitigColorMap& um_src, const bool last_extraction) { 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 pair, 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 + Bifrost::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 } @@ -284,17 +284,17 @@ void DataAccessor::extract(const UnitigColorMap& um_src, const bool last_e } template<> -inline void DataAccessor::extract(const UnitigColorMap& um_src, const bool last_extraction) { +inline void Bifrost::DataAccessor::extract(const UnitigColorMap& um_src, const bool last_extraction) { DataStorage* ds = um_src.getGraph()->getData(); // Get DataStorage where the UnitigColors are stored 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-mers with positions matching mapping given in um_src + Bifrost::UnitigColors new_cs = ds->getSubUnitigColors(um_src); // Extract colors for k-mers with positions matching mapping given in um_src 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 pair, 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 *this = p.first; // Set the new DataAccessor to locate new UnitigColors @@ -303,7 +303,7 @@ inline void DataAccessor::extract(const UnitigColorMap& um_src, cons } template -string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { +string Bifrost::DataAccessor::serialize(const const_UnitigColorMap& um_src) const { string da_str("DA:Z:" + std::to_string(da_id)); @@ -320,7 +320,7 @@ string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { } template<> -inline string DataAccessor::serialize(const const_UnitigColorMap& um_src) const { +inline string Bifrost::DataAccessor::serialize(const const_UnitigColorMap& um_src) const { return string("DA:Z:" + std::to_string(da_id)); } diff --git a/src/DataStorage.hpp b/src/DataStorage.hpp index 016775f..3359264 100644 --- a/src/DataStorage.hpp +++ b/src/DataStorage.hpp @@ -8,25 +8,27 @@ #define BFG_COLOREDCDBG_FORMAT_VERSION 2 -template class ColoredCDBG; -template class DataAccessor; -template class DataStorage; - -template using UnitigColorMap = UnitigMap, DataStorage>; -template using const_UnitigColorMap = const_UnitigMap, DataStorage>; - namespace std { template<> - struct hash> { + struct hash> { - size_t operator()(pair const& p) const { + size_t operator()(pair const& p) const { return (2 * p.second + 1) * p.first.hash(); } }; } +namespace Bifrost { + +template class ColoredCDBG; +template class DataAccessor; +template class DataStorage; + +template using UnitigColorMap = UnitigMap, DataStorage>; +template using const_UnitigColorMap = const_UnitigMap, DataStorage>; + template class DataStorage { @@ -108,4 +110,6 @@ class DataStorage { vector color_names; }; +} + #endif diff --git a/src/DataStorage.tcc b/src/DataStorage.tcc index 02929d9..7ae4965 100644 --- a/src/DataStorage.tcc +++ b/src/DataStorage.tcc @@ -2,7 +2,7 @@ #define BIFROST_DATA_STORAGE_TCC template -DataStorage::DataStorage() : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), +Bifrost::DataStorage::DataStorage() : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), nb_seeds(0), nb_cs(0), sz_cs(0), sz_shared_cs(0), pos_empty_cs(0) { std::random_device rd; //Seed @@ -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_) : +Bifrost::DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const 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_) { @@ -34,7 +34,7 @@ DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const v } template<> -inline DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const vector& color_names_) : +inline Bifrost::DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs_, const 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_) { @@ -54,7 +54,7 @@ inline DataStorage::DataStorage(const size_t nb_seeds_, const size_t sz_cs } template -DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), +Bifrost::DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), overflow(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(o.color_names) { @@ -90,7 +90,7 @@ DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_ } template<> -inline DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), +inline Bifrost::DataStorage::DataStorage(const DataStorage& o) : color_sets(nullptr), shared_color_sets(nullptr), unitig_cs_link(nullptr), data(nullptr), overflow(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(o.color_names) { @@ -119,7 +119,7 @@ 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), +Bifrost::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), 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)) { @@ -135,7 +135,7 @@ DataStorage::DataStorage(DataStorage&& o) : color_sets(o.color_sets), shared } template -void DataStorage::clear() { +void Bifrost::DataStorage::clear() { nb_seeds = 0; nb_cs = 0; @@ -147,7 +147,7 @@ void DataStorage::clear() { } template -void DataStorage::releaseMemory() { +void Bifrost::DataStorage::releaseMemory() { if (color_sets != nullptr){ @@ -178,7 +178,7 @@ void DataStorage::releaseMemory() { } template<> -inline void DataStorage::releaseMemory() { +inline void Bifrost::DataStorage::releaseMemory() { if (color_sets != nullptr){ @@ -205,13 +205,13 @@ inline void DataStorage::releaseMemory() { } template -DataStorage::~DataStorage() { +Bifrost::DataStorage::~DataStorage() { releaseMemory(); } template -DataStorage& DataStorage::operator=(const DataStorage& o) { +Bifrost::DataStorage& Bifrost::DataStorage::operator=(const DataStorage& o) { releaseMemory(); @@ -256,7 +256,7 @@ DataStorage& DataStorage::operator=(const DataStorage& o) { } template<> -inline DataStorage& DataStorage::operator=(const DataStorage& o) { +inline Bifrost::DataStorage& Bifrost::DataStorage::operator=(const DataStorage& o) { releaseMemory(); @@ -295,7 +295,7 @@ inline DataStorage& DataStorage::operator=(const DataStorage& o) { } template -DataStorage& DataStorage::operator=(DataStorage&& o) { +Bifrost::DataStorage& Bifrost::DataStorage::operator=(DataStorage&& o) { if (this != &o) { @@ -330,7 +330,7 @@ DataStorage& DataStorage::operator=(DataStorage&& o) { } template<> -inline DataStorage& DataStorage::operator=(DataStorage&& o) { +inline Bifrost::DataStorage& Bifrost::DataStorage::operator=(DataStorage&& o) { if (this != &o) { @@ -363,7 +363,7 @@ inline DataStorage& DataStorage::operator=(DataStorage&& o) { } template -const UnitigColors* DataStorage::getUnitigColors(const const_UnitigColorMap& um) const { +const Bifrost::UnitigColors* Bifrost::DataStorage::getUnitigColors(const const_UnitigColorMap& um) const { if (!um.isEmpty && (color_sets != nullptr)){ @@ -384,7 +384,7 @@ const UnitigColors* DataStorage::getUnitigColors(const const_UnitigColorMap -UnitigColors* DataStorage::getUnitigColors(const UnitigColorMap& um) { +Bifrost::UnitigColors* Bifrost::DataStorage::getUnitigColors(const UnitigColorMap& um) { if (!um.isEmpty && (color_sets != nullptr)){ @@ -405,7 +405,7 @@ UnitigColors* DataStorage::getUnitigColors(const UnitigColorMap& um) { } template -const U* DataStorage::getData(const const_UnitigColorMap& um) const { +const U* Bifrost::DataStorage::getData(const const_UnitigColorMap& um) const { if (!um.isEmpty && (data != nullptr)){ @@ -425,13 +425,13 @@ const U* DataStorage::getData(const const_UnitigColorMap& um) const { return nullptr; } -template<> inline const void* DataStorage::getData(const const_UnitigColorMap& um) const { +template<> inline const void* Bifrost::DataStorage::getData(const const_UnitigColorMap& um) const { return nullptr; } template -U* DataStorage::getData(const UnitigColorMap& um) { +U* Bifrost::DataStorage::getData(const UnitigColorMap& um) { if (!um.isEmpty && (data != nullptr)){ @@ -451,13 +451,13 @@ U* DataStorage::getData(const UnitigColorMap& um) { return nullptr; } -template<> inline void* DataStorage::getData(const UnitigColorMap& um) { +template<> inline void* Bifrost::DataStorage::getData(const UnitigColorMap& um) { return nullptr; } template -UnitigColors DataStorage::getSubUnitigColors(const const_UnitigColorMap& um) const { +Bifrost::UnitigColors Bifrost::DataStorage::getSubUnitigColors(const const_UnitigColorMap& um) const { UnitigColors new_cs; @@ -510,7 +510,7 @@ UnitigColors DataStorage::getSubUnitigColors(const const_UnitigColorMap& u } template -vector DataStorage::getSubUnitigColorNames(const const_UnitigColorMap& um) const { +vector Bifrost::DataStorage::getSubUnitigColorNames(const const_UnitigColorMap& um) const { vector v_out; @@ -531,7 +531,7 @@ vector DataStorage::getSubUnitigColorNames(const const_UnitigColorMap } template -bool DataStorage::write(const string& prefix_output_filename, const bool verbose) const { +bool Bifrost::DataStorage::write(const string& prefix_output_filename, const bool verbose) const { if (verbose) cout << endl << "DataStorage::write(): Writing colors to disk" << endl; @@ -659,7 +659,7 @@ bool DataStorage::write(const string& prefix_output_filename, const bool verb } template<> -inline bool DataStorage::write(const string& prefix_output_filename, const bool verbose) const { +inline bool Bifrost::DataStorage::write(const string& prefix_output_filename, const bool verbose) const { if (verbose) cout << endl << "DataStorage::write(): Writing colors to disk" << endl; @@ -787,7 +787,7 @@ inline bool DataStorage::write(const string& prefix_output_filename, const } template -bool DataStorage::read(const string& filename_colors, const size_t nb_threads, const bool verbose) { +bool Bifrost::DataStorage::read(const string& filename_colors, const size_t nb_threads, const bool verbose) { if (verbose) cout << endl << "DataStorage::read(): Reading color sets from disk" << endl; @@ -1042,7 +1042,7 @@ bool DataStorage::read(const string& filename_colors, const size_t nb_threads } template<> -inline bool DataStorage::read(const string& filename_colors, const size_t nb_threads, const bool verbose) { +inline bool Bifrost::DataStorage::read(const string& filename_colors, const size_t nb_threads, const bool verbose) { if (verbose) cout << endl << "DataStorage::read(): Reading color sets from disk" << endl; @@ -1296,7 +1296,7 @@ inline bool DataStorage::read(const string& filename_colors, const size_t } template -bool DataStorage::addUnitigColors(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src) { +bool Bifrost::DataStorage::addUnitigColors(const UnitigColorMap& um_dest, const const_UnitigColorMap& um_src) { if (!um_dest.isEmpty && !um_src.isEmpty && (um_src.len == um_dest.len) && (color_sets != nullptr)){ @@ -1354,7 +1354,7 @@ bool DataStorage::addUnitigColors(const UnitigColorMap& um_dest, const con } template -UnitigColors DataStorage::joinUnitigColors(const const_UnitigColorMap& um_dest, const const_UnitigColorMap& um_src) const { +Bifrost::UnitigColors Bifrost::DataStorage::joinUnitigColors(const const_UnitigColorMap& um_dest, const const_UnitigColorMap& um_src) const { UnitigColors new_cs; @@ -1474,7 +1474,7 @@ UnitigColors DataStorage::joinUnitigColors(const const_UnitigColorMap& um_ } template -void DataStorage::remove(const UnitigColorMap& um) { +void Bifrost::DataStorage::remove(const UnitigColorMap& um) { if (!um.isEmpty && (color_sets != nullptr) && (data != nullptr)){ @@ -1517,7 +1517,7 @@ void DataStorage::remove(const UnitigColorMap& um) { } template<> -inline void DataStorage::remove(const UnitigColorMap& um) { +inline void Bifrost::DataStorage::remove(const UnitigColorMap& um) { if (!um.isEmpty && (color_sets != nullptr)){ @@ -1555,7 +1555,7 @@ inline void DataStorage::remove(const UnitigColorMap& um) { } template -size_t DataStorage::getUnitigColorsSize(const size_t nb_threads) const { +size_t Bifrost::DataStorage::getUnitigColorsSize(const size_t nb_threads) const { if (color_sets != nullptr){ @@ -1589,7 +1589,7 @@ size_t DataStorage::getUnitigColorsSize(const size_t nb_threads) const { } template -uint64_t DataStorage::getHash(const UnitigColorMap& um) const { +uint64_t Bifrost::DataStorage::getHash(const UnitigColorMap& um) const { if (!um.isEmpty && (color_sets != nullptr)){ @@ -1610,7 +1610,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) { +pair, Bifrost::UnitigColors*> Bifrost::DataStorage::insert_(const Kmer head, const size_t unitig_sz, const bool force_overflow) { if (color_sets == nullptr) return {DataAccessor(0), nullptr}; @@ -1670,51 +1670,51 @@ 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) { +pair, pair> Bifrost::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 pair, Bifrost::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 pair, pair> Bifrost::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 pair, Bifrost::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) { +pair, pair> Bifrost::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 Bifrost::Kmer head(um.getMappedHead()); + const pair, Bifrost::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 pair, pair> Bifrost::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 Bifrost::Kmer head(um.getMappedHead()); + const pair, Bifrost::UnitigColors*> p(insert_(head, um.len + um.getGraph()->getK() - 1, force_overflow)); return {p.first, {p.second, nullptr}}; } template -void DataStorage::resize(const double growth) { +void Bifrost::DataStorage::resize(const double growth) { - UnitigColors* old_color_sets = color_sets; + Bifrost::UnitigColors* old_color_sets = color_sets; atomic* old_unitig_cs_link = unitig_cs_link; U* old_data = data; @@ -1726,7 +1726,7 @@ void DataStorage::resize(const double growth) { const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); // Reallocate UnitigColors - color_sets = new UnitigColors[sz_cs]; + color_sets = new Bifrost::UnitigColors[sz_cs]; move(old_color_sets, old_color_sets + old_sz_cs, color_sets); delete[] old_color_sets; @@ -1747,9 +1747,9 @@ void DataStorage::resize(const double growth) { } template<> -inline void DataStorage::resize(const double growth) { +inline void Bifrost::DataStorage::resize(const double growth) { - UnitigColors* old_color_sets = color_sets; + Bifrost::UnitigColors* old_color_sets = color_sets; atomic* old_unitig_cs_link = unitig_cs_link; const size_t old_sz_cs = sz_cs; @@ -1759,7 +1759,7 @@ inline void DataStorage::resize(const double growth) { const size_t sz_link = (sz_cs >> 6) + ((sz_cs & 0x3F) != 0); - color_sets = new UnitigColors[sz_cs]; + color_sets = new Bifrost::UnitigColors[sz_cs]; move(old_color_sets, old_color_sets + old_sz_cs, color_sets); delete[] old_color_sets; diff --git a/src/FASTX_Parser.cpp b/src/FASTX_Parser.cpp index 81888f4..b29c1fe 100644 --- a/src/FASTX_Parser.cpp +++ b/src/FASTX_Parser.cpp @@ -1,5 +1,7 @@ #include "FASTX_Parser.hpp" +using namespace Bifrost; + 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..13fab96 100644 --- a/src/FASTX_Parser.hpp +++ b/src/FASTX_Parser.hpp @@ -18,6 +18,8 @@ KSEQ_INIT(gzFile, gzread); #endif +namespace Bifrost { + class FastqFile { public: @@ -54,4 +56,6 @@ class FastqFile { kseq_t* kseq; }; +} + #endif // FASTQ_H diff --git a/src/File_Parser.hpp b/src/File_Parser.hpp index 359a6f3..f3f6472 100644 --- a/src/File_Parser.hpp +++ b/src/File_Parser.hpp @@ -15,6 +15,8 @@ KSEQ_INIT(gzFile, gzread); #endif +namespace Bifrost { + class FileParser { public: @@ -248,4 +250,6 @@ class FileParser { GFA_Parser gfap; }; +} + #endif diff --git a/src/GFA_Parser.cpp b/src/GFA_Parser.cpp index 852d1a6..1925ba2 100644 --- a/src/GFA_Parser.cpp +++ b/src/GFA_Parser.cpp @@ -1,5 +1,7 @@ #include "GFA_Parser.hpp" +using namespace Bifrost; + GFA_Parser::GFA_Parser() : file_open_write(false), file_open_read(false), file_no(0), v_gfa(0), graph_out(nullptr), graph_in(nullptr), graphfile_in(nullptr), graphfile_out(nullptr) {} diff --git a/src/GFA_Parser.hpp b/src/GFA_Parser.hpp index 89034db..46f8901 100644 --- a/src/GFA_Parser.hpp +++ b/src/GFA_Parser.hpp @@ -14,6 +14,8 @@ using namespace std; +namespace Bifrost { + class GFA_Parser { struct Sequence { @@ -128,4 +130,6 @@ class GFA_Parser { Edge e; }; +} + #endif diff --git a/src/Kmer.cpp b/src/Kmer.cpp index a52f4e9..7549411 100644 --- a/src/Kmer.cpp +++ b/src/Kmer.cpp @@ -1,6 +1,7 @@ #include "Kmer.hpp" using namespace std; +using namespace Bifrost; static const uint64_t twin_table[256] = { 0xFF, 0xBF, 0x7F, 0x3F, 0xEF, 0xAF, 0x6F, 0x2F, diff --git a/src/Kmer.hpp b/src/Kmer.hpp index c3dba83..b4c1595 100644 --- a/src/Kmer.hpp +++ b/src/Kmer.hpp @@ -1,10 +1,6 @@ #ifndef BIFROST_KMER_HPP #define BIFROST_KMER_HPP -#ifndef MAX_KMER_SIZE -#define MAX_KMER_SIZE 32 -#endif - #include #include #include @@ -18,6 +14,13 @@ #include "Common.hpp" +namespace Bifrost { + +#ifndef MAX_KMER_SIZE +#define MAX_KMER_SIZE 32 +#endif + + /** @file src/Kmer.hpp * Interface for the class Kmer: * - Store k-mer strings by using 2 bits per base @@ -290,4 +293,6 @@ struct MinimizerHash { }; ///@endcond +} + #endif // BFG_KMER_HPP diff --git a/src/KmerCovIndex.hpp b/src/KmerCovIndex.hpp index 8f7e210..e819cf6 100644 --- a/src/KmerCovIndex.hpp +++ b/src/KmerCovIndex.hpp @@ -8,6 +8,8 @@ #include "Kmer.hpp" #include "rw_spin_lock.h" +namespace Bifrost { + template class KmerCovIndex { @@ -150,6 +152,8 @@ template<> inline void KmerCovIndex::resize(const size_t new_sz); template<> inline const void* KmerCovIndex::getData(const size_t idx) const; template<> inline void* KmerCovIndex::getData(const size_t idx); +} + #include "KmerCovIndex.tcc" #endif diff --git a/src/KmerCovIndex.tcc b/src/KmerCovIndex.tcc index 1b1b679..03cff65 100644 --- a/src/KmerCovIndex.tcc +++ b/src/KmerCovIndex.tcc @@ -1,8 +1,8 @@ template -KmerCovIndex::KmerCovIndex() : sz(0), shift_div(__builtin_ffsll(block_sz) - 1), mask_mod(block_sz - 1) {} +Bifrost::KmerCovIndex::KmerCovIndex() : sz(0), shift_div(__builtin_ffsll(block_sz) - 1), mask_mod(block_sz - 1) {} template -KmerCovIndex::KmerCovIndex(const KmerCovIndex& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod) { +Bifrost::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()); @@ -17,7 +17,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) { +inline Bifrost::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()); @@ -31,19 +31,19 @@ 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)) { +Bifrost::KmerCovIndex::KmerCovIndex(KmerCovIndex&& o) : sz(o.sz), shift_div(o.shift_div), mask_mod(o.mask_mod), v_blocks(move(o.v_blocks)) { o.clear(); } template -KmerCovIndex::~KmerCovIndex() { +Bifrost::KmerCovIndex::~KmerCovIndex() { clear(); } template -KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex& o) { +Bifrost::KmerCovIndex& Bifrost::KmerCovIndex::operator=(const Bifrost::KmerCovIndex& o) { if (this != &o) { @@ -69,7 +69,7 @@ KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex& o) { } template -KmerCovIndex& KmerCovIndex::toData(KmerCovIndex&& o, const size_t nb_threads) { +Bifrost::KmerCovIndex& Bifrost::KmerCovIndex::toData(Bifrost::KmerCovIndex&& o, const size_t nb_threads) { sz = o.sz; shift_div = o.shift_div; @@ -122,7 +122,7 @@ KmerCovIndex& KmerCovIndex::toData(KmerCovIndex&& o, const size_t nb } template<> -inline KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex& o) { +inline Bifrost::KmerCovIndex& Bifrost::KmerCovIndex::operator=(const Bifrost::KmerCovIndex& o) { if (this != &o) { @@ -147,7 +147,7 @@ inline KmerCovIndex& KmerCovIndex::operator=(const KmerCovIndex -KmerCovIndex& KmerCovIndex::operator=(KmerCovIndex&& o) { +Bifrost::KmerCovIndex& Bifrost::KmerCovIndex::operator=(Bifrost::KmerCovIndex&& o) { if (this != &o) { @@ -166,7 +166,7 @@ KmerCovIndex& KmerCovIndex::operator=(KmerCovIndex&& o) { } template -void KmerCovIndex::clear() { +void Bifrost::KmerCovIndex::clear() { sz = 0; @@ -179,7 +179,7 @@ void KmerCovIndex::clear() { } template -void KmerCovIndex::push_back(const Kmer& km) { +void Bifrost::KmerCovIndex::push_back(const Kmer& km) { const size_t mod = sz & mask_mod; @@ -195,7 +195,7 @@ void KmerCovIndex::push_back(const Kmer& km) { } template -bool KmerCovIndex::set(const size_t idx, const Kmer& km) { +bool Bifrost::KmerCovIndex::set(const size_t idx, const Kmer& km) { if (idx >= sz) return false; @@ -217,7 +217,7 @@ bool KmerCovIndex::set(const size_t idx, const Kmer& km) { } template -bool KmerCovIndex::set(const size_t idx, const Kmer& km, const size_t cov) { +bool Bifrost::KmerCovIndex::set(const size_t idx, const Kmer& km, const size_t cov) { if (idx >= sz) return false; @@ -241,7 +241,7 @@ bool KmerCovIndex::set(const size_t idx, const Kmer& km, const size_t cov) { } template -void KmerCovIndex::setFull(const size_t idx) { +void Bifrost::KmerCovIndex::setFull(const size_t idx) { if (idx < sz){ @@ -259,7 +259,7 @@ void KmerCovIndex::setFull(const size_t idx) { } template -int KmerCovIndex::covAt(const size_t idx) const { +int Bifrost::KmerCovIndex::covAt(const size_t idx) const { if (idx < sz){ @@ -281,7 +281,7 @@ int KmerCovIndex::covAt(const size_t idx) const { } template -void KmerCovIndex::cover(const size_t idx) { +void Bifrost::KmerCovIndex::cover(const size_t idx) { if (idx < sz){ @@ -302,7 +302,7 @@ void KmerCovIndex::cover(const size_t idx) { } template -void KmerCovIndex::uncover(const size_t idx) { +void Bifrost::KmerCovIndex::uncover(const size_t idx) { if (idx < sz){ @@ -324,7 +324,7 @@ void KmerCovIndex::uncover(const size_t idx) { } template -bool KmerCovIndex::swap(const size_t idx1, const size_t idx2) { +bool Bifrost::KmerCovIndex::swap(const size_t idx1, const size_t idx2) { if ((idx1 < sz) && (idx2 < sz)) { @@ -361,7 +361,7 @@ bool KmerCovIndex::swap(const size_t idx1, const size_t idx2) { } template<> -inline bool KmerCovIndex::swap(const size_t idx1, const size_t idx2) { +inline bool Bifrost::KmerCovIndex::swap(const size_t idx1, const size_t idx2) { if ((idx1 < sz) && (idx2 < sz)) { @@ -397,12 +397,12 @@ inline bool KmerCovIndex::swap(const size_t idx1, const size_t idx2) { } template -void KmerCovIndex::resize(const size_t new_sz) { +void Bifrost::KmerCovIndex::resize(const size_t new_sz) { if (new_sz == 0) clear(); else if (new_sz < sz){ // resize down - Kmer km_empty; + Bifrost::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); @@ -432,7 +432,7 @@ void KmerCovIndex::resize(const size_t new_sz) { } else if (new_sz > sz){ - Kmer km_empty; + Bifrost::Kmer km_empty; const size_t old_v_km_sz = v_blocks.size(); const size_t new_v_block_sz = (new_sz >> shift_div) + ((new_sz & mask_mod) != 0); @@ -463,12 +463,12 @@ void KmerCovIndex::resize(const size_t new_sz) { } template<> -inline void KmerCovIndex::resize(const size_t new_sz) { +inline void Bifrost::KmerCovIndex::resize(const size_t new_sz) { if (new_sz == 0) clear(); else if (new_sz < sz){ // resize down - Kmer km_empty; + Bifrost::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); @@ -495,7 +495,7 @@ inline void KmerCovIndex::resize(const size_t new_sz) { } else if (new_sz > sz){ - Kmer km_empty; + Bifrost::Kmer km_empty; const size_t old_v_km_sz = v_blocks.size(); const size_t new_v_block_sz = (new_sz >> shift_div) + ((new_sz & mask_mod) != 0); @@ -519,7 +519,7 @@ inline void KmerCovIndex::resize(const size_t new_sz) { } template -const T* KmerCovIndex::getData(const size_t idx) const { +const T* Bifrost::KmerCovIndex::getData(const size_t idx) const { if (idx < sz) return &(v_blocks[idx >> shift_div]->data_block[idx & mask_mod]); @@ -527,13 +527,13 @@ const T* KmerCovIndex::getData(const size_t idx) const { } template<> -inline const void* KmerCovIndex::getData(const size_t idx) const { +inline const void* Bifrost::KmerCovIndex::getData(const size_t idx) const { return nullptr; } template -T* KmerCovIndex::getData(const size_t idx) { +T* Bifrost::KmerCovIndex::getData(const size_t idx) { if (idx < sz) return &(v_blocks[idx >> shift_div]->data_block[idx & mask_mod]); @@ -541,17 +541,17 @@ T* KmerCovIndex::getData(const size_t idx) { } template<> -inline void* KmerCovIndex::getData(const size_t idx) { +inline void* Bifrost::KmerCovIndex::getData(const size_t idx) { return nullptr; } template -Kmer KmerCovIndex::getKmer(const size_t idx) const { +Bifrost::Kmer Bifrost::KmerCovIndex::getKmer(const size_t idx) const { if (idx < sz) return v_blocks[idx >> shift_div]->km_block[idx & mask_mod]; - Kmer empty_km; + Bifrost::Kmer empty_km; empty_km.set_empty(); @@ -559,7 +559,7 @@ Kmer KmerCovIndex::getKmer(const size_t idx) const { } template -void KmerCovIndex::remove(const size_t idx) { +void Bifrost::KmerCovIndex::remove(const size_t idx) { if (idx < sz){ @@ -581,7 +581,7 @@ void KmerCovIndex::remove(const size_t idx) { } template<> -inline void KmerCovIndex::remove(const size_t idx) { +inline void Bifrost::KmerCovIndex::remove(const size_t idx) { if (idx < sz){ diff --git a/src/KmerHashTable.hpp b/src/KmerHashTable.hpp index ed14224..dc5bd89 100644 --- a/src/KmerHashTable.hpp +++ b/src/KmerHashTable.hpp @@ -717,6 +717,8 @@ struct MinimizerHashTable { const_iterator end() const { return const_iterator(this); } };*/ +namespace Bifrost { + template struct KmerHashTable { @@ -1485,4 +1487,6 @@ struct MinimizerHashTable { const_iterator end() const { return const_iterator(this); } }; +} + #endif diff --git a/src/KmerIterator.cpp b/src/KmerIterator.cpp index f5cf588..d76a1ec 100644 --- a/src/KmerIterator.cpp +++ b/src/KmerIterator.cpp @@ -3,6 +3,7 @@ #include "Kmer.hpp" #include "KmerIterator.hpp" +using namespace Bifrost; /* Note: That an iter is exhausted means that (iter._invalid == true) */ @@ -138,3 +139,7 @@ void KmerIterator::find_next(size_t i, size_t j, bool last_valid) { invalid_ = true; } } + +void KmerIterator::jumpTo(int pos) { + find_next(pos - 1, (pos - 1) + Kmer::k - 1, false); +} diff --git a/src/KmerIterator.hpp b/src/KmerIterator.hpp index 2cb59e9..8ed4d64 100644 --- a/src/KmerIterator.hpp +++ b/src/KmerIterator.hpp @@ -5,6 +5,7 @@ #include #include "Kmer.hpp" +namespace Bifrost { /* Short description: * - Easily iterate through kmers in a read @@ -25,6 +26,7 @@ class KmerIterator : public std::iteratoroperator==(o);} @@ -162,4 +164,6 @@ class KmerHashIterator { bool invalid; // If sequence is invalid (iterating on k-mers out of bounds, etc.) }; +} + #endif // BFG_KMER_ITERATOR_HPP diff --git a/src/KmerStream.hpp b/src/KmerStream.hpp index 3043b75..662aa52 100644 --- a/src/KmerStream.hpp +++ b/src/KmerStream.hpp @@ -22,6 +22,8 @@ using namespace std; +namespace Bifrost { + struct KmerStream_Build_opt { vector files; @@ -1121,4 +1123,6 @@ class KmerStream { size_t chunksize; }; +} + #endif diff --git a/src/Lock.hpp b/src/Lock.hpp index 71c2415..dbdad0d 100644 --- a/src/Lock.hpp +++ b/src/Lock.hpp @@ -5,6 +5,8 @@ #include "rw_spin_lock.h" +namespace Bifrost { + class LockGraph : public SpinLockRW { public: @@ -99,4 +101,6 @@ class LockGraph : public SpinLockRW { std::vector spinlocks_unitigs; };*/ +} + #endif diff --git a/src/MinimizerIndex.cpp b/src/MinimizerIndex.cpp index be0bb8e..4a8db8f 100644 --- a/src/MinimizerIndex.cpp +++ b/src/MinimizerIndex.cpp @@ -1,5 +1,7 @@ #include "MinimizerIndex.hpp" +using namespace Bifrost; + MinimizerIndex::MinimizerIndex() : table_keys(nullptr), table_tinyv(nullptr), table_tinyv_sz(nullptr), size_(0), pop(0), num_empty(0) { diff --git a/src/MinimizerIndex.hpp b/src/MinimizerIndex.hpp index c0de078..55bdd29 100644 --- a/src/MinimizerIndex.hpp +++ b/src/MinimizerIndex.hpp @@ -10,6 +10,8 @@ #include "Lock.hpp" #include "TinyVector.hpp" +namespace Bifrost { + class MinimizerIndex { template @@ -186,4 +188,6 @@ class MinimizerIndex { static const size_t lck_block_div_shift; }; +} + #endif diff --git a/src/NeighborIterator.hpp b/src/NeighborIterator.hpp index 5cacd36..e649a2f 100644 --- a/src/NeighborIterator.hpp +++ b/src/NeighborIterator.hpp @@ -3,6 +3,8 @@ #include "Kmer.hpp" +namespace Bifrost { + /** @file src/NeighborIterator.hpp * The neighborIterator, BackwardCDBG and ForwardCDBG type interfaces. * Code snippets using these interfaces are provided in snippets/test.cpp. @@ -195,6 +197,8 @@ class ForwardCDBG { UnitigMap um; }; +} + #include "NeighborIterator.tcc" #endif diff --git a/src/NeighborIterator.tcc b/src/NeighborIterator.tcc index 6817653..13b7cd4 100644 --- a/src/NeighborIterator.tcc +++ b/src/NeighborIterator.tcc @@ -5,10 +5,10 @@ #include "UnitigMap.hpp" template -neighborIterator::neighborIterator() : i(4), is_fw(true), cdbg(nullptr) {} +Bifrost::neighborIterator::neighborIterator() : i(4), is_fw(true), cdbg(nullptr) {} template -neighborIterator::neighborIterator(const UnitigMap& um_, const bool is_forward_) : i(-1), is_fw(is_forward_), cdbg(um_.getGraph()) { +Bifrost::neighborIterator::neighborIterator(const UnitigMap& um_, const bool is_forward_) : i(-1), is_fw(is_forward_), cdbg(um_.getGraph()) { if (um_.isEmpty || (cdbg == nullptr) || cdbg->invalid) i = 4; else { @@ -19,10 +19,10 @@ neighborIterator::neighborIterator(const UnitigMap -neighborIterator::neighborIterator(const neighborIterator& o) : i(o.i), is_fw(o.is_fw), um(o.um), km_head(o.km_head), km_tail(o.km_tail), cdbg(o.cdbg) {} +Bifrost::neighborIterator::neighborIterator(const neighborIterator& o) : i(o.i), is_fw(o.is_fw), um(o.um), km_head(o.km_head), km_tail(o.km_tail), cdbg(o.cdbg) {} template -neighborIterator& neighborIterator::operator++() { +Bifrost::neighborIterator& Bifrost::neighborIterator::operator++() { if ((cdbg == NULL) || cdbg->invalid || (i >= 4)) return *this; @@ -47,7 +47,7 @@ neighborIterator& neighborIterator::operator++() } template -neighborIterator neighborIterator::operator++(int) { +Bifrost::neighborIterator Bifrost::neighborIterator::operator++(int) { neighborIterator tmp(*this); operator++(); @@ -56,35 +56,35 @@ neighborIterator neighborIterator::operator++(in } template -bool neighborIterator::operator==(const neighborIterator& o) const { +bool Bifrost::neighborIterator::operator==(const neighborIterator& o) const { if ((i >= 4) || (o.i >= 4)) return (i >= 4) && (o.i >= 4); return (is_fw == o.is_fw) && (km_head == o.km_head) && (km_tail == o.km_tail) && (cdbg == o.cdbg) && (um == o.um); } template -bool neighborIterator::operator!=(const neighborIterator& o) const { return !operator==(o); } +bool Bifrost::neighborIterator::operator!=(const neighborIterator& o) const { return !operator==(o); } template -const UnitigMap& neighborIterator::operator*() const { return um; } +const Bifrost::UnitigMap& Bifrost::neighborIterator::operator*() const { return um; } template -const UnitigMap* neighborIterator::operator->() const { return &um; } +const Bifrost::UnitigMap* Bifrost::neighborIterator::operator->() const { return &um; } template -BackwardCDBG::BackwardCDBG(const UnitigMap& um_) : um(um_) {} +Bifrost::BackwardCDBG::BackwardCDBG(const UnitigMap& um_) : um(um_) {} template -bool BackwardCDBG::hasPredecessors() const { return (um.bw_begin() != um.bw_end()); } +bool Bifrost::BackwardCDBG::hasPredecessors() const { return (um.bw_begin() != um.bw_end()); } template -size_t BackwardCDBG::cardinality() const { +size_t Bifrost::BackwardCDBG::cardinality() const { - neighborIterator it_start = begin(); - neighborIterator it_end = end(); + Bifrost::neighborIterator it_start = begin(); + Bifrost::neighborIterator it_end = end(); size_t card = 0; @@ -98,25 +98,25 @@ size_t BackwardCDBG::cardinality() const { } template -neighborIterator BackwardCDBG::begin() const { return um.bw_begin(); } +Bifrost::neighborIterator Bifrost::BackwardCDBG::begin() const { return um.bw_begin(); } template -neighborIterator BackwardCDBG::end() const { return um.bw_end(); } +Bifrost::neighborIterator Bifrost::BackwardCDBG::end() const { return um.bw_end(); } template -ForwardCDBG::ForwardCDBG(const UnitigMap& um_) : um(um_) {} +Bifrost::ForwardCDBG::ForwardCDBG(const UnitigMap& um_) : um(um_) {} template -bool ForwardCDBG::hasSuccessors() const { return (um.fw_begin() != um.fw_end()); } +bool Bifrost::ForwardCDBG::hasSuccessors() const { return (um.fw_begin() != um.fw_end()); } template -size_t ForwardCDBG::cardinality() const { +size_t Bifrost::ForwardCDBG::cardinality() const { - neighborIterator it_start = begin(); - neighborIterator it_end = end(); + Bifrost::neighborIterator it_start = begin(); + Bifrost::neighborIterator it_end = end(); size_t card = 0; @@ -130,9 +130,9 @@ size_t ForwardCDBG::cardinality() const { } template -neighborIterator ForwardCDBG::begin() const { return um.fw_begin(); } +Bifrost::neighborIterator Bifrost::ForwardCDBG::begin() const { return um.fw_begin(); } template -neighborIterator ForwardCDBG::end() const { return um.fw_end(); } +Bifrost::neighborIterator Bifrost::ForwardCDBG::end() const { return um.fw_end(); } #endif diff --git a/src/RepHash.hpp b/src/RepHash.hpp index 8a11c3a..634ae1f 100644 --- a/src/RepHash.hpp +++ b/src/RepHash.hpp @@ -7,6 +7,8 @@ #include "Kmer.hpp" +namespace Bifrost { + static const unsigned char twin[32] = { 0, 20, 2, 7, 4, 5, 6, 3, 8, 9, 10, 11, 12, 13, 14, 15, @@ -311,4 +313,6 @@ class RepHash { #endif +} + #endif diff --git a/src/Search.tcc b/src/Search.tcc index da80d52..879c8f5 100644 --- a/src/Search.tcc +++ b/src/Search.tcc @@ -3,7 +3,7 @@ template -vector>> CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, +vector>> Bifrost::CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match) { @@ -11,17 +11,17 @@ vector>> CompactedDBG::searchSequence( cons cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; - return vector>>(); + return vector>>(); } if (seq.length() < k_){ cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; - return vector>>(); + return vector>>(); } - vector>> v_um; + vector>> v_um; string seqs; @@ -38,7 +38,7 @@ vector>> CompactedDBG::searchSequence( cons const size_t end = 1ULL << ((static_cast(!subst_or_ind) - 1) & 0x2ULL); const size_t seq_len = seq.length(); - auto processUnitigMap = [&](const UnitigMap& um, const size_t pos_seq){ + auto processUnitigMap = [&](const Bifrost::UnitigMap& um, const size_t pos_seq){ if (um.strand){ @@ -105,7 +105,7 @@ vector>> CompactedDBG::searchSequence( cons if (minz_pres.second){ // If at least one minimizer was present, search the kmer - const UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -149,7 +149,7 @@ vector>> CompactedDBG::searchSequence( cons if (minz_pres.second) { // If the k-mer has already been searched in the past, discard - const UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -172,7 +172,7 @@ vector>> CompactedDBG::searchSequence( cons for (size_t i = 0; i < seq.length() - k_ + 1; ++i) { - const UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); + const Bifrost::UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); if (!um.isEmpty) { // Read maps to a Unitig @@ -248,7 +248,7 @@ vector>> CompactedDBG::searchSequence( cons } template -vector>> CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, +vector>> Bifrost::CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match) { @@ -256,33 +256,33 @@ vector>> CompactedDBG::searchSequence( cons cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; - return vector>>(); + return vector>>(); } if (ratio_kmers < 0.0){ cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than 0.0" << endl; - return vector>>(); + return vector>>(); } if (ratio_kmers > 1.0){ cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << endl; - return vector>>(); + return vector>>(); } if (seq.length() < k_){ cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; - return vector>>(); + return vector>>(); } const size_t nb_km_min = static_cast(seq.length() - k_ + 1) * ratio_kmers; - vector>> v_um; + vector>> v_um; string seqs; @@ -299,7 +299,7 @@ vector>> CompactedDBG::searchSequence( cons const size_t end = 1ULL << ((static_cast(!subst_or_ind) - 1) & 0x2ULL); const size_t seq_len = seq.length(); - auto processUnitigMap = [&](const UnitigMap& um, const size_t pos_seq){ + auto processUnitigMap = [&](const Bifrost::UnitigMap& um, const size_t pos_seq){ if (um.strand){ @@ -374,7 +374,7 @@ vector>> CompactedDBG::searchSequence( cons if (minz_pres.second){ // If at least one minimizer was present, search the kmer - const UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -420,7 +420,7 @@ vector>> CompactedDBG::searchSequence( cons if (minz_pres.second) { // If the k-mer has already been searched in the past, discard - const UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -445,7 +445,7 @@ vector>> CompactedDBG::searchSequence( cons for (size_t i = 0; i < seq.length() - k_ + 1; ++i) { - const UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); + const Bifrost::UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); if (!um.isEmpty) { // Read maps to a Unitig @@ -538,7 +538,7 @@ vector>> CompactedDBG::searchSequence( cons } template -vector>> CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, +vector>> Bifrost::CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const bool or_exclusive_match) const { @@ -546,17 +546,17 @@ vector>> CompactedDBG::searchSequence( cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; - return vector>>(); + return vector>>(); } if (seq.length() < k_){ cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; - return vector>>(); + return vector>>(); } - vector>> v_um; + vector>> v_um; string seqs; @@ -573,7 +573,7 @@ vector>> CompactedDBG::searchSequence( const size_t end = 1ULL << ((static_cast(!subst_or_ind) - 1) & 0x2ULL); const size_t seq_len = seq.length(); - auto processUnitigMap = [&](const const_UnitigMap& um, const size_t pos_seq){ + auto processUnitigMap = [&](const Bifrost::const_UnitigMap& um, const size_t pos_seq){ if (um.strand){ @@ -640,7 +640,7 @@ vector>> CompactedDBG::searchSequence( if (minz_pres.second){ // If at least one minimizer was present, search the kmer - const const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -684,7 +684,7 @@ vector>> CompactedDBG::searchSequence( if (minz_pres.second) { // If the k-mer has already been searched in the past, discard - const const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -707,7 +707,7 @@ vector>> CompactedDBG::searchSequence( for (size_t i = 0; i < seq.length() - k_ + 1; ++i) { - const const_UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); + const Bifrost::const_UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); if (!um.isEmpty) { // Read maps to a Unitig @@ -783,7 +783,7 @@ vector>> CompactedDBG::searchSequence( } template -vector>> CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, +vector>> Bifrost::CompactedDBG::searchSequence( const string& seq, const bool exact, const bool insertion, const bool deletion, const bool substitution, const double ratio_kmers, const bool or_exclusive_match) const { @@ -791,33 +791,33 @@ vector>> CompactedDBG::searchSequence( cerr << "CompactedDBG::searchSequence(): Graph is invalid and cannot be searched" << endl; - return vector>>(); + return vector>>(); } if (ratio_kmers < 0.0){ cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is less than 0.0" << endl; - return vector>>(); + return vector>>(); } if (ratio_kmers > 1.0){ cerr << "CompactedDBG::searchSequence(): Ratio of k-mers is greater than 1.0" << endl; - return vector>>(); + return vector>>(); } if (seq.length() < k_){ cerr << "CompactedDBG::searchSequence(): Query length is shorter than k-mer size" << endl; - return vector>>(); + return vector>>(); } const size_t nb_km_min = static_cast(seq.length() - k_ + 1) * ratio_kmers; - vector>> v_um; + vector>> v_um; string seqs; @@ -834,7 +834,7 @@ vector>> CompactedDBG::searchSequence( const size_t end = 1ULL << ((static_cast(!subst_or_ind) - 1) & 0x2ULL); const size_t seq_len = seq.length(); - auto processUnitigMap = [&](const const_UnitigMap& um, const size_t pos_seq){ + auto processUnitigMap = [&](const Bifrost::const_UnitigMap& um, const size_t pos_seq){ if (um.strand){ @@ -909,7 +909,7 @@ vector>> CompactedDBG::searchSequence( if (minz_pres.second){ // If at least one minimizer was present, search the kmer - const const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -955,7 +955,7 @@ vector>> CompactedDBG::searchSequence( if (minz_pres.second) { // If the k-mer has already been searched in the past, discard - const const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); + const Bifrost::const_UnitigMap um = findUnitig(seqs.c_str(), pos_seq, seqs.length(), mhi); if (!um.isEmpty){ @@ -980,7 +980,7 @@ vector>> CompactedDBG::searchSequence( for (size_t i = 0; i < seq.length() - k_ + 1; ++i) { - const const_UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); + const Bifrost::const_UnitigMap um = findUnitig(seq.c_str(), i, seq.length()); if (!um.isEmpty) { // Read maps to a Unitig @@ -1073,7 +1073,7 @@ vector>> CompactedDBG::searchSequence( } template -bool CompactedDBG::search(const vector& query_filenames, const string& out_filename_prefix, +bool Bifrost::CompactedDBG::search(const vector& query_filenames, const string& out_filename_prefix, const double ratio_kmers, const bool inexact_search, const size_t nb_threads, const size_t verbose) const { @@ -1113,7 +1113,7 @@ bool CompactedDBG::search(const vector& query_filenames, const str if (verbose) cout << "CompactedDBG::search(): Querying graph." << endl; - const CompactedDBG& dbg = *this; + const Bifrost::CompactedDBG& dbg = *this; string s; @@ -1156,7 +1156,7 @@ bool CompactedDBG::search(const vector& query_filenames, const str for (auto& c : s) c &= 0xDF; - const vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, + const vector>> v = dbg.searchSequence( s, true, inexact_search, inexact_search, inexact_search, ratio_kmers, true); if (inexact_search){ @@ -1261,7 +1261,7 @@ bool CompactedDBG::search(const vector& query_filenames, const str for (auto& c : buffers_seq[i]) c &= 0xDF; - const vector>> v = dbg.searchSequence( buffers_seq[i], true, inexact_search, inexact_search, + const vector>> v = dbg.searchSequence( buffers_seq[i], true, inexact_search, inexact_search, inexact_search, ratio_kmers, true); if (inexact_search){ diff --git a/src/StreamCounter.hpp b/src/StreamCounter.hpp index 35d325b..4791300 100644 --- a/src/StreamCounter.hpp +++ b/src/StreamCounter.hpp @@ -10,6 +10,8 @@ #include "Common.hpp" +namespace Bifrost { + class StreamCounter { public: @@ -704,4 +706,6 @@ class StreamCounter { const uint64_t maxVal; // has to be a power of 2-1 };*/ +} + #endif diff --git a/src/TinyVector.hpp b/src/TinyVector.hpp index 2eb310d..b71cbb6 100644 --- a/src/TinyVector.hpp +++ b/src/TinyVector.hpp @@ -5,6 +5,8 @@ #include #include +namespace Bifrost { + template class tiny_vector { @@ -473,4 +475,6 @@ class packed_tiny_vector { } }; +} + #endif diff --git a/src/Unitig.hpp b/src/Unitig.hpp index 9a18a4d..ce82172 100644 --- a/src/Unitig.hpp +++ b/src/Unitig.hpp @@ -6,6 +6,8 @@ #include "CompressedSequence.hpp" #include "CompressedCoverage.hpp" +namespace Bifrost { + /** @file src/Unitig.hpp * The Unitig interface. * Code snippets using these interface are provided in snippets/test.cpp. @@ -134,4 +136,6 @@ class Unitig { }; ///@endcond +} + #endif // BFG_CONTIG_HPP diff --git a/src/UnitigIterator.hpp b/src/UnitigIterator.hpp index 9ed83fd..5a79079 100644 --- a/src/UnitigIterator.hpp +++ b/src/UnitigIterator.hpp @@ -5,6 +5,8 @@ #include "KmerHashTable.hpp" #include "CompressedCoverage.hpp" +namespace Bifrost { + /** @file src/UnitigIterator.hpp * The unitigIterator type interface. * Code snippets using this interface are provided in snippets/test.cpp. @@ -109,6 +111,8 @@ class unitigIterator : public std::iterator -unitigIterator::unitigIterator() : i(0), v_unitigs_sz(0), v_kmers_sz(0), h_kmers_ccov_sz(0), sz(0), invalid(true), cdbg(nullptr) {} +Bifrost::unitigIterator::unitigIterator() : i(0), v_unitigs_sz(0), v_kmers_sz(0), h_kmers_ccov_sz(0), sz(0), invalid(true), cdbg(nullptr) {} template -unitigIterator::unitigIterator(CompactedDBG_ptr_t cdbg_) : +Bifrost::unitigIterator::unitigIterator(CompactedDBG_ptr_t cdbg_) : i(0), v_unitigs_sz(0), v_kmers_sz(0), h_kmers_ccov_sz(0), sz(0), invalid(true), cdbg(cdbg_), it_h_kmers_ccov((cdbg_ == nullptr) || cdbg_->invalid ? typename KmerHashTable>::const_iterator() : cdbg_->h_kmers_ccov.begin()){ @@ -24,12 +24,12 @@ unitigIterator::unitigIterator(CompactedDBG_ptr_t cdbg_) : } template -unitigIterator::unitigIterator(const unitigIterator& o) : i(o.i), v_unitigs_sz(o.v_unitigs_sz), v_kmers_sz(o.v_kmers_sz), +Bifrost::unitigIterator::unitigIterator(const unitigIterator& o) : i(o.i), v_unitigs_sz(o.v_unitigs_sz), v_kmers_sz(o.v_kmers_sz), it_h_kmers_ccov(o.it_h_kmers_ccov), h_kmers_ccov_sz(o.h_kmers_ccov_sz), sz(o.sz), invalid(o.invalid), um(o.um), cdbg(o.cdbg) {} template -unitigIterator& unitigIterator::operator++() { +Bifrost::unitigIterator& Bifrost::unitigIterator::operator++() { if (invalid) return *this; @@ -61,16 +61,16 @@ unitigIterator& unitigIterator::operator++() { } template -unitigIterator unitigIterator::operator++(int) { +Bifrost::unitigIterator Bifrost::unitigIterator::operator++(int) { - unitigIterator tmp(*this); + Bifrost::unitigIterator tmp(*this); operator++(); return tmp; } template -bool unitigIterator::operator==(const unitigIterator& o) const { +bool Bifrost::unitigIterator::operator==(const unitigIterator& o) const { if (invalid || o.invalid) return invalid && o.invalid; return (i == o.i) && (v_unitigs_sz == o.v_unitigs_sz) && (v_kmers_sz == o.v_kmers_sz) && @@ -79,12 +79,12 @@ bool unitigIterator::operator==(const unitigIterator& o) const { } template -bool unitigIterator::operator!=(const unitigIterator& o) const { return !operator==(o); } +bool Bifrost::unitigIterator::operator!=(const unitigIterator& o) const { return !operator==(o); } template -const UnitigMap& unitigIterator::operator*() const { return um; } +const Bifrost::UnitigMap& Bifrost::unitigIterator::operator*() const { return um; } template -const UnitigMap* unitigIterator::operator->() const { return &um; } +const Bifrost::UnitigMap* Bifrost::unitigIterator::operator->() const { return &um; } #endif diff --git a/src/UnitigMap.cpp b/src/UnitigMap.cpp index 279a147..c640b3a 100644 --- a/src/UnitigMap.cpp +++ b/src/UnitigMap.cpp @@ -1,5 +1,7 @@ #include "UnitigMap.hpp" +using namespace Bifrost; + 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 7aaf3ba..2508772 100644 --- a/src/UnitigMap.hpp +++ b/src/UnitigMap.hpp @@ -5,6 +5,8 @@ #include "Common.hpp" #include "Kmer.hpp" +namespace Bifrost { + /** @file src/UnitigMap.hpp * UnitigMap type interface. * Code snippets using this interface are provided in snippets/test.cpp. @@ -320,6 +322,8 @@ struct UnitigMapHash { } }; +} + #include "UnitigMap.tcc" #endif diff --git a/src/UnitigMap.tcc b/src/UnitigMap.tcc index 25d7cd6..4d40c35 100644 --- a/src/UnitigMap.tcc +++ b/src/UnitigMap.tcc @@ -5,36 +5,36 @@ #include "NeighborIterator.hpp" template -UnitigMap::UnitigMap(const size_t length, CompactedDBG_ptr_t cdbg_) : UnitigMapBase(length), pos_unitig(0), isShort(false), +Bifrost::UnitigMap::UnitigMap(const size_t length, CompactedDBG_ptr_t cdbg_) : UnitigMapBase(length), pos_unitig(0), isShort(false), isAbundant(false), cdbg(cdbg_) {} template -UnitigMap::UnitigMap(const size_t start, const size_t length, const size_t unitig_sz, const bool strand) : +Bifrost::UnitigMap::UnitigMap(const size_t start, const size_t length, const size_t unitig_sz, const bool strand) : UnitigMapBase(start, length, unitig_sz, strand), pos_unitig(0), isShort(false), isAbundant(false), cdbg(nullptr) {} template -bool UnitigMap::operator==(const UnitigMap& o) const { +bool Bifrost::UnitigMap::operator==(const UnitigMap& o) const { return UnitigMapBase::operator==(o) && (pos_unitig == o.pos_unitig) && (isShort == o.isShort) && (isAbundant == o.isAbundant) && (cdbg == o.cdbg); } template -bool UnitigMap::operator!=(const UnitigMap& o) const { +bool Bifrost::UnitigMap::operator!=(const UnitigMap& o) const { return UnitigMapBase::operator!=(o) || (pos_unitig != o.pos_unitig) || (isShort != o.isShort) || (isAbundant != o.isAbundant) || (cdbg != o.cdbg); } template -bool UnitigMap::isSameReferenceUnitig(const UnitigMap& o) const { +bool Bifrost::UnitigMap::isSameReferenceUnitig(const UnitigMap& o) const { return (pos_unitig == o.pos_unitig) && (isShort == o.isShort) && (isAbundant == o.isAbundant) && (cdbg == o.cdbg); } template -string UnitigMap::mappedSequenceToString() const { +string Bifrost::UnitigMap::mappedSequenceToString() const { if (isEmpty) return string(); @@ -55,7 +55,7 @@ string UnitigMap::mappedSequenceToString() const { } template -string UnitigMap::referenceUnitigToString() const { +string Bifrost::UnitigMap::referenceUnitigToString() const { if (isEmpty) return string(); if (isShort) return cdbg->km_unitigs.getKmer(pos_unitig).toString(); @@ -65,7 +65,7 @@ string UnitigMap::referenceUnitigToString() const { } template -size_t UnitigMap::lcp(const char* s, const size_t pos_s, const size_t pos_um_seq, const bool um_reversed) const { +size_t Bifrost::UnitigMap::lcp(const char* s, const size_t pos_s, const size_t pos_um_seq, const bool um_reversed) const { if (isEmpty || (pos_s >= strlen(s))) return 0; @@ -75,7 +75,7 @@ size_t UnitigMap::lcp(const char* s, const size_t pos_s, const s char km_str[MAX_KMER_SIZE]; - const Kmer km = isShort ? cdbg->km_unitigs.getKmer(pos_unitig) : cdbg->h_kmers_ccov.find(pos_unitig).getKey(); + const Bifrost::Kmer km = isShort ? cdbg->km_unitigs.getKmer(pos_unitig) : cdbg->h_kmers_ccov.find(pos_unitig).getKey(); um_reversed ? km.twin().toString(km_str) : km.toString(km_str); @@ -88,7 +88,7 @@ size_t UnitigMap::lcp(const char* s, const size_t pos_s, const s } template -Kmer UnitigMap::getUnitigHead() const { +Bifrost::Kmer Bifrost::UnitigMap::getUnitigHead() const { if (!isEmpty){ @@ -98,7 +98,7 @@ Kmer UnitigMap::getUnitigHead() const { return cdbg->v_unitigs[pos_unitig]->getSeq().getKmer(0); } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -106,7 +106,7 @@ Kmer UnitigMap::getUnitigHead() const { } template -Kmer UnitigMap::getUnitigTail() const { +Bifrost::Kmer Bifrost::UnitigMap::getUnitigTail() const { if (!isEmpty){ @@ -116,7 +116,7 @@ Kmer UnitigMap::getUnitigTail() const { return cdbg->v_unitigs[pos_unitig]->getSeq().getKmer(cdbg->v_unitigs[pos_unitig]->numKmers() - 1); } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -124,7 +124,7 @@ Kmer UnitigMap::getUnitigTail() const { } template -Kmer UnitigMap::getUnitigKmer(const size_t pos) const { +Bifrost::Kmer Bifrost::UnitigMap::getUnitigKmer(const size_t pos) const { if (!isEmpty){ @@ -137,7 +137,7 @@ Kmer UnitigMap::getUnitigKmer(const size_t pos) const { } } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -145,7 +145,7 @@ Kmer UnitigMap::getUnitigKmer(const size_t pos) const { } template -Kmer UnitigMap::getMappedHead() const { +Bifrost::Kmer Bifrost::UnitigMap::getMappedHead() const { if (!isEmpty){ @@ -165,7 +165,7 @@ Kmer UnitigMap::getMappedHead() const { } } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -173,7 +173,7 @@ Kmer UnitigMap::getMappedHead() const { } template -Kmer UnitigMap::getMappedTail() const { +Bifrost::Kmer Bifrost::UnitigMap::getMappedTail() const { if (!isEmpty){ @@ -193,7 +193,7 @@ Kmer UnitigMap::getMappedTail() const { } } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -201,7 +201,7 @@ Kmer UnitigMap::getMappedTail() const { } template -Kmer UnitigMap::getMappedKmer(const size_t pos) const { +Bifrost::Kmer Bifrost::UnitigMap::getMappedKmer(const size_t pos) const { if (!isEmpty && (pos < len)){ @@ -227,7 +227,7 @@ Kmer UnitigMap::getMappedKmer(const size_t pos) const { } } - Kmer km; + Bifrost::Kmer km; km.set_empty(); @@ -235,9 +235,9 @@ Kmer UnitigMap::getMappedKmer(const size_t pos) const { } template -UnitigMap UnitigMap::getKmerMapping(const size_t pos) const { +Bifrost::UnitigMap Bifrost::UnitigMap::getKmerMapping(const size_t pos) const { - UnitigMap um(*this); + Bifrost::UnitigMap um(*this); um.dist = pos; um.len = 1; @@ -248,26 +248,26 @@ UnitigMap UnitigMap::getKmerMapping(const size_t } template -typename UnitigMap::Unitig_data_ptr_t UnitigMap::getData() const { +typename Bifrost::UnitigMap::Unitig_data_ptr_t Bifrost::UnitigMap::getData() const { return getData_::value>(); } template -typename UnitigMap::UnitigMap_BW UnitigMap::getPredecessors() const { +typename Bifrost::UnitigMap::UnitigMap_BW Bifrost::UnitigMap::getPredecessors() const { return BackwardCDBG(*this); } template -typename UnitigMap::UnitigMap_FW UnitigMap::getSuccessors() const { +typename Bifrost::UnitigMap::UnitigMap_FW Bifrost::UnitigMap::getSuccessors() const { return ForwardCDBG(*this); } template template -typename std::enable_if::Unitig_data_ptr_t>::type UnitigMap::getData_() const { +typename std::enable_if::Unitig_data_ptr_t>::type Bifrost::UnitigMap::getData_() const { if (isEmpty) return nullptr; if (isShort) return cdbg->km_unitigs.getData(pos_unitig); @@ -278,7 +278,7 @@ typename std::enable_if::Unitig_dat template template -typename std::enable_if::Unitig_data_ptr_t>::type UnitigMap::getData_() const { +typename std::enable_if::Unitig_data_ptr_t>::type Bifrost::UnitigMap::getData_() const { return nullptr; } @@ -286,7 +286,7 @@ typename std::enable_if::Unitig_data template template -typename std::enable_if>::type UnitigMap::splitData_(const bool last_split) const { +typename std::enable_if>::type Bifrost::UnitigMap::splitData_(const bool last_split) const { Unitig unitig; @@ -297,19 +297,19 @@ typename std::enable_if>::type UnitigMap::sp template template -typename std::enable_if>::type UnitigMap::splitData_(const bool last_split) const { +typename std::enable_if>::type Bifrost::UnitigMap::splitData_(const bool last_split) const { return Unitig(); } template -Unitig UnitigMap::splitData(const bool last_split) const { +Bifrost::Unitig Bifrost::UnitigMap::splitData(const bool last_split) const { return splitData_::value>(last_split); } template -neighborIterator UnitigMap::bw_begin() const { +Bifrost::neighborIterator Bifrost::UnitigMap::bw_begin() const { neighborIterator it(*this, false); it++; @@ -317,21 +317,21 @@ neighborIterator UnitigMap::bw_begin() const { } template -neighborIterator UnitigMap::bw_end() const { return neighborIterator(); } +Bifrost::neighborIterator Bifrost::UnitigMap::bw_end() const { return neighborIterator(); } template -neighborIterator UnitigMap::fw_begin() const { +Bifrost::neighborIterator Bifrost::UnitigMap::fw_begin() const { - neighborIterator it(*this, true); + Bifrost::neighborIterator it(*this, true); it++; return it; } template -neighborIterator UnitigMap::fw_end() const { return neighborIterator(); } +Bifrost::neighborIterator Bifrost::UnitigMap::fw_end() const { return neighborIterator(); } template -void UnitigMap::partialCopy(const UnitigMap& o) { +void Bifrost::UnitigMap::partialCopy(const Bifrost::UnitigMap& o) { pos_unitig = o.pos_unitig; dist = o.dist; @@ -346,7 +346,7 @@ void UnitigMap::partialCopy(const UnitigMap& o) } template -void UnitigMap::setFullCoverage() const { +void Bifrost::UnitigMap::setFullCoverage() const { if (!isEmpty){ @@ -357,7 +357,7 @@ void UnitigMap::setFullCoverage() const { } template -void UnitigMap::increaseCoverage() const { +void Bifrost::UnitigMap::increaseCoverage() const { if (isEmpty) return; // nothing maps, move on @@ -367,7 +367,7 @@ void UnitigMap::increaseCoverage() const { } template -void UnitigMap::decreaseCoverage() const { +void Bifrost::UnitigMap::decreaseCoverage() const { if (isEmpty) return; // nothing maps, move on @@ -377,7 +377,7 @@ void UnitigMap::decreaseCoverage() const { } template -bool UnitigMap::isCoverageFull() const { +bool Bifrost::UnitigMap::isCoverageFull() const { if (isEmpty) return false; // nothing maps, move on @@ -387,7 +387,7 @@ bool UnitigMap::isCoverageFull() const { } template -size_t UnitigMap::getCoverage(const size_t pos) const { +size_t Bifrost::UnitigMap::getCoverage(const size_t pos) const { if (isEmpty || (pos > size - cdbg->getK())) return 0; // nothing maps, move on @@ -398,7 +398,7 @@ size_t UnitigMap::getCoverage(const size_t pos) const { template -UnitigMap::UnitigMap(size_t p_unitig, size_t i, size_t l, size_t sz, bool short_, bool abundance, bool strd, +Bifrost::UnitigMap::UnitigMap(size_t p_unitig, size_t i, size_t l, size_t sz, bool short_, bool abundance, bool strd, CompactedDBG_ptr_t cdbg_) : UnitigMapBase(i, l, sz, strd), pos_unitig(p_unitig), isShort(short_), isAbundant(abundance), cdbg(cdbg_) {} diff --git a/src/minHashIterator.hpp b/src/minHashIterator.hpp index 6a3a115..c4cff4d 100644 --- a/src/minHashIterator.hpp +++ b/src/minHashIterator.hpp @@ -11,6 +11,8 @@ using namespace std; +namespace Bifrost { + struct minHashResult { minHashResult() : hash((uint64_t) -1),pos(-1) {} @@ -764,4 +766,6 @@ struct minHashKmer { bool nh; }; +} + #endif // MINHASHITERATOR_H diff --git a/src/rw_spin_lock.h b/src/rw_spin_lock.h index 3e749b2..85748a3 100644 --- a/src/rw_spin_lock.h +++ b/src/rw_spin_lock.h @@ -55,6 +55,8 @@ const int padding[15]; };*/ +namespace Bifrost { + class SpinLock { public: @@ -436,4 +438,6 @@ class Hybrid_SpinLockRW_MCS { const size_t mask_bits; }; +} + #endif