Debian Codegraph @

ext/bifrost/src/KmerIterator.cpp

raw symbols SCIP
1 #include <iterator>
2 #include <utility>
3 #include "Kmer.hpp"
4 #include "KmerIterator.hpp"
5
6 KmerIterator& KmerIterator::operator++() {
7
8 if (!invalid) {
9
10 while (str[pos_e] != '\0') {
11
12 const char c = str[pos_e] & 0xDF; // mask lowercase bit
13
14 if (isDNA(c)) {
15
16 if (pos_s + Kmer::k - 1 == pos_e){
17
18 if (pos_s == p.second + 1 && !p.first.isEmpty()) p.first.selfForwardBase(c);
19 else p.first = Kmer(str + pos_s);
20
21 p.second = pos_s;
22
23 ++pos_s;
24 ++pos_e;
25
26 return *this;
27 }
28 }
29 else pos_s = pos_e + 1;
30
31 ++pos_e;
32 }
33
34 invalid = true;
35 }
36
37 return *this;
38 }
39
40 KmerIterator& KmerIterator::operator+=(const int len){
41
42 if (!invalid) {
43
44 if (len == 1) operator++();
45 else if (len > 1) {
46
47 const int next_pos_e = pos_e + len - 1;
48
49 while ((pos_e < next_pos_e) && (str[pos_e] != '\0')) ++pos_e;
50
51 if (str[pos_e] != '\0') {
52
53 pos_s = pos_e - Kmer::k + 1;
54 pos_e = pos_s;
55
56 operator++();
57 }
58 else invalid = true;
59 }
60 }
61
62 return *this;
63 }