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 
20 class VDJ_PIPE_DECL Pattern_iter {
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_;
66  bool at_pattern_end_;
67  bool mismatch_;
68  unsigned pi_;
69  Nucleotide ec_;
70  Nucleotide nc_;
71 
72  void check_state();
73 };
74 
75 }//namespace gdst
76 }//namespace vdj_pipe
77 #endif /* PATTERN_ITERATOR_HPP_ */
Nucleotide
Definition: nucleotide_index.hpp:24
bool at_end() const
Definition: pattern_iterator.hpp:35
Navigate suffix tree according to pattern.
Definition: pattern_iterator.hpp:20
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Generalized DNA suffix tree.
Definition: gdst.hpp:66