Bifrost
NeighborIterator.hpp
Go to the documentation of this file.
1 #ifndef NEIGHBOR_ITERATOR_HPP
2 #define 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 
85  const UnitigMap<U, G, is_const>& operator*() const;
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 
126  explicit BackwardCDBG(const UnitigMap<U, G, is_const>& um_);
127 
131  bool hasPredecessors() const;
132 
133  size_t cardinality() const;
134 
140  neighborIterator<U, G, is_const> begin() const;
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 
172  explicit ForwardCDBG(const UnitigMap<U, G, is_const>& um_);
173 
177  bool hasSuccessors() const;
178 
179  size_t cardinality() const;
180 
186  neighborIterator<U, G, is_const> begin() const;
187 
192 
193  private:
194 
196 };
197 
198 #include "NeighborIterator.tcc"
199 
200 #endif
bool operator!=(const neighborIterator &o) const
Inequality operator: check if two neighborIterator are different.
neighborIterator & operator++()
Prefix increment, iterate over the next neighbor (predecessor or successor).
Iterator for the neighbors (predecessors or successors) of a reference unitig used in a UnitigMap obj...
Definition: NeighborIterator.hpp:34
Represent a Compacted de Bruijn graph.
Definition: CompactedDBG.hpp:297
neighborIterator()
Constructor.
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:40
bool operator==(const neighborIterator &o) const
Equality operator: check if two neighborIterator are the same.
Contain all the information for the mapping of a k-mer or a sequence to a unitig of a Compacted de Br...
Definition: NeighborIterator.hpp:12
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:116
Interface for the class Kmer:
const UnitigMap< U, G, is_const > & operator*() const
Indirection operator.
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:162
const UnitigMap< U, G, is_const > * operator->() const
Dereference operator.