vdj_pipe
pipeline for processing DNA sequence data
pattern_iterator.hpp
Go to the documentation of this file.
1 
7 #ifndef PATTERN_ITERATOR_HPP_
8 #define PATTERN_ITERATOR_HPP_
9 #include "boost/assert.hpp"
10 #include "vdj_pipe/config.hpp"
14 
15 namespace vdj_pipe{ namespace gdst{
16 class Gdst;
17 
21 public:
23  Gdst const& t,
24  const boost::string_ref suff,
25  const Branch_id bid
26  ) : t_(t), patt_(suff), curr_(bid)
27  {
28  BOOST_ASSERT(curr_);
29  check_state();
30  }
31 
32  Branch_id current() const {return curr_;}
33 
35  bool at_end() const {return at_end_;}
36 
37  Branch_id next_id() const {return next_;}
38  bool at_pattern_end() const {return at_pattern_end_;}
39  bool at_mismatch() const {return mismatch_;}
40  unsigned index() const {return pi_;}
41  Nucleotide pattern_char() const {return nucleotide_index(patt_[pi_]);}
42  Nucleotide edge_char() const {return ec_;}
43  Nucleotide node_char() const {return nc_;}
44 
45  bool has_next() const {
46  return
47  ! at_end() &&
48  next_id() &&
49  ! at_pattern_end() &&
50  ! at_mismatch()
51  ;
52  }
53 
54  void next() {
55  BOOST_ASSERT(has_next());
56  curr_ = next_id();
57  check_state();
58  }
59 
60 private:
61  Gdst const& t_;
62  const boost::string_ref patt_;
63  Branch_id curr_;
64  bool at_end_;
65  Branch_id next_;
67  bool mismatch_;
68  unsigned pi_;
71 
72  void check_state();
73 };
74 
75 }//namespace gdst
76 }//namespace vdj_pipe
77 #endif /* PATTERN_ITERATOR_HPP_ */
Branch_id next_id() const
Definition: pattern_iterator.hpp:37
bool has_next() const
Definition: pattern_iterator.hpp:45
bool mismatch_
Definition: pattern_iterator.hpp:67
Branch_id current() const
Definition: pattern_iterator.hpp:32
const boost::string_ref patt_
Definition: pattern_iterator.hpp:62
bool at_end_
Definition: pattern_iterator.hpp:64
Pattern_iter(Gdst const &t, const boost::string_ref suff, const Branch_id bid)
Definition: pattern_iterator.hpp:22
Branch_id next_
Definition: pattern_iterator.hpp:65
Nucleotide
Definition: nucleotide_index.hpp:24
bool at_end() const
Definition: pattern_iterator.hpp:35
Branch_id curr_
Definition: pattern_iterator.hpp:63
Nucleotide edge_char() const
Definition: pattern_iterator.hpp:42
unsigned index() const
Definition: pattern_iterator.hpp:40
Gdst const & t_
Definition: pattern_iterator.hpp:61
Nucleotide nc_
Definition: pattern_iterator.hpp:70
Navigate suffix tree according to pattern.
Definition: pattern_iterator.hpp:20
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
void next()
Definition: pattern_iterator.hpp:54
Nucleotide ec_
Definition: pattern_iterator.hpp:69
#define VDJ_PIPE_DECL
Definition: config.hpp:23
unsigned pi_
Definition: pattern_iterator.hpp:68
bool at_mismatch() const
Definition: pattern_iterator.hpp:39
Nucleotide pattern_char() const
Definition: pattern_iterator.hpp:41
bool at_pattern_end_
Definition: pattern_iterator.hpp:66
bool has_next(Parser const &p1, Parser const &p2)
Definition: pipe_paired_read.cpp:109
Nucleotide nucleotide_index(const char c)
Definition: nucleotide_index.hpp:45
Generalized DNA suffix tree.
Definition: gdst.hpp:66
bool at_pattern_end() const
Definition: pattern_iterator.hpp:38
Nucleotide node_char() const
Definition: pattern_iterator.hpp:43