vdj_pipe
pipeline for processing DNA sequence data
interval_iterator.hpp
Go to the documentation of this file.
1 
7 #ifndef INTERVAL_ITERATOR_HPP_
8 #define INTERVAL_ITERATOR_HPP_
11 
12 namespace vdj_pipe{
13 
17 public:
19  const boost::string_ref seq,
20  const std::size_t min_len
21  )
22  : min_len_(min_len), seq_(seq), pos_(0), len_(0)
23  {
24  next();
25  }
26 
27  void next() {
28  pos_ += len_;
29  for( len_ = 0; ; ) {
30  if( pos_ + len_ == seq_.size() ) {
31  if( len_ < min_len_ ) {
32  pos_ = seq_.size();
33  len_ = 0;
34  }
35  return;
36  }
37  if( is_ambiguous(seq_[pos_ + len_]) ) {
38  if( len_ < min_len_ ) {
39  pos_ += len_ + 1;
40  len_ = 0;
41  continue;
42  }
43  return;
44  }
45  ++len_;
46  }
47  }
48 
49  boost::string_ref subseq() const {
50  return boost::string_ref(seq_.substr(pos_, len_));
51  }
52 
53  bool has_subseq() const {return len_;}
54 private:
55  std::size_t min_len_;
56  boost::string_ref seq_;
57  std::size_t pos_;
58  std::size_t len_;
59 };
60 
61 
62 }//namespace vdj_pipe
63 #endif /* INTERVAL_ITERATOR_HPP_ */
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: interval_iterator.hpp:16