Bifrost
NeighborIterator.hpp
Go to the documentation of this file.
1 #ifndef BIFROST_NEIGHBOR_ITERATOR_HPP
2 #define BIFROST_NEIGHBOR_ITERATOR_HPP
3 
4 #include "Kmer.hpp"
5 
11 template<typename U, typename G> class CompactedDBG;
12 template<typename U, typename G, bool is_const> class UnitigMap;
13 
33 template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
34 class neighborIterator : public std::iterator<std::input_iterator_tag, UnitigMap<Unitig_data_t, Graph_data_t, is_const>, int> {
35 
36  typedef Unitig_data_t U;
37  typedef Graph_data_t G;
38 
39  public:
40 
41  typedef typename std::conditional<is_const, const CompactedDBG<U, G>*, CompactedDBG<U, G>*>::type CompactedDBG_ptr_t;
42 
47 
53  neighborIterator(const UnitigMap<U, G, is_const>& um_, const bool is_forward_);
54 
59 
64 
69 
74  bool operator==(const neighborIterator& o) const;
75 
80  bool operator!=(const neighborIterator& o) const;
81 
86 
91 
92  private:
93 
94  int i;
95 
96  bool is_fw;
97 
98  Kmer km_head;
99  Kmer km_tail;
100 
102 
103  CompactedDBG_ptr_t cdbg;
104 };
105 
115 template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
117 
118  typedef Unitig_data_t U;
119  typedef Graph_data_t G;
120 
121  public:
122 
127 
131  bool hasPredecessors() const;
132 
133  size_t cardinality() const;
134 
141 
146 
147  private:
148 
150 };
151 
161 template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
162 class ForwardCDBG {
163 
164  typedef Unitig_data_t U;
165  typedef Graph_data_t G;
166 
167  public:
168 
173 
177  bool hasSuccessors() const;
178 
179  size_t cardinality() const;
180 
187 
192 
193  private:
194 
196 };
197 
198 #include "NeighborIterator.tcc"
199 
200 #endif
neighborIterator::neighborIterator
neighborIterator(const neighborIterator &o)
Copy constructor.
neighborIterator::operator->
const UnitigMap< U, G, is_const > * operator->() const
Dereference operator.
Kmer
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:42
ForwardCDBG::end
neighborIterator< U, G, is_const > end() const
Return an iterator over the past-the-last successor of a reference unitig.
neighborIterator::operator++
neighborIterator & operator++()
Prefix increment, iterate over the next neighbor (predecessor or successor).
ForwardCDBG::hasSuccessors
bool hasSuccessors() const
Check if the unitig has at least one successor.
UnitigMap
Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Br...
Definition: UnitigMap.hpp:92
BackwardCDBG
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:116
BackwardCDBG::hasPredecessors
bool hasPredecessors() const
Check if the unitig has at least one predecessor.
BackwardCDBG::begin
neighborIterator< U, G, is_const > begin() const
Return an iterator over the predecessors of a reference unitig.
neighborIterator::operator++
neighborIterator operator++(int)
Postfix increment, iterate over the next neighbor (predecessor or successor).
ForwardCDBG
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:162
neighborIterator::operator!=
bool operator!=(const neighborIterator &o) const
Inequality operator: check if two neighborIterator are different.
neighborIterator::neighborIterator
neighborIterator()
Constructor.
neighborIterator
Iterator for the neighbors (predecessors or successors) of a reference unitig used in a UnitigMap obj...
Definition: NeighborIterator.hpp:34
neighborIterator::operator*
const UnitigMap< U, G, is_const > & operator*() const
Indirection operator.
neighborIterator::neighborIterator
neighborIterator(const UnitigMap< U, G, is_const > &um_, const bool is_forward_)
Constructor.
ForwardCDBG::ForwardCDBG
ForwardCDBG(const UnitigMap< U, G, is_const > &um_)
Constructor.
Kmer.hpp
Interface for the class Kmer:
neighborIterator::operator==
bool operator==(const neighborIterator &o) const
Equality operator: check if two neighborIterator are the same.
BackwardCDBG::BackwardCDBG
BackwardCDBG(const UnitigMap< U, G, is_const > &um_)
Constructor.
ForwardCDBG::begin
neighborIterator< U, G, is_const > begin() const
Return an iterator over the successors of a reference unitig.
CompactedDBG
Represent a Compacted de Bruijn graph.
Definition: CompactedDBG.hpp:313
BackwardCDBG::end
neighborIterator< U, G, is_const > end() const
Return an iterator over the past-the-last predecessor of a reference unitig.