Bifrost: src/NeighborIterator.hpp Source File

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
46 neighborIterator();
47
53 neighborIterator(const UnitigMap<U, G, is_const>& um_, const bool is_forward_);
54
58 neighborIterator(const neighborIterator& o);
59
63 neighborIterator& operator++();
64
68 neighborIterator operator++(int);
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
90 const UnitigMap<U, G, is_const>* operator->() const;
91
92 private:
93
94 int i;
95
96 bool is_fw;
97
98 Kmer km_head;
99 Kmer km_tail;
100
101 UnitigMap<U, G, is_const> um;
102
103 CompactedDBG_ptr_t cdbg;
104 };
105
115 template<typename Unitig_data_t = void, typename Graph_data_t = void, bool is_const = false>
116 class BackwardCDBG {
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
145 neighborIterator<U, G, is_const> end() const;
146
147 private:
148
149 UnitigMap<U, G, is_const> um;
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
191 neighborIterator<U, G, is_const> end() const;
192
193 private:
194
195 UnitigMap<U, G, is_const> um;
196 };
197
198 #include "NeighborIterator.tcc"
199
200 #endif
neighborIterator::operator!=
bool operator!=(const neighborIterator &o) const
Inequality operator: check if two neighborIterator are different.
neighborIterator::operator++
neighborIterator & operator++()
Prefix increment, iterate over the next neighbor (predecessor or successor).
neighborIterator
Iterator for the neighbors (predecessors or successors) of a reference unitig used in a UnitigMap obj...
Definition: NeighborIterator.hpp:34
CompactedDBG
Represent a Compacted de Bruijn graph.
Definition: CompactedDBG.hpp:297
neighborIterator::neighborIterator
neighborIterator()
Constructor.
Kmer
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:40
neighborIterator::operator==
bool operator==(const neighborIterator &o) const
Equality operator: check if two neighborIterator are the same.
UnitigMap
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
BackwardCDBG
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:116
Kmer.hpp
Interface for the class Kmer:
neighborIterator::operator*
const UnitigMap< U, G, is_const > & operator*() const
Indirection operator.
ForwardCDBG
Wrapper for class neighborIterator to iterate over the predecessors of a reference unitig used in a U...
Definition: NeighborIterator.hpp:162
neighborIterator::operator->
const UnitigMap< U, G, is_const > * operator->() const
Dereference operator.