1 #include "trivial_filter.hpp"
3 #include <boost/assign.hpp>
4 using namespace boost::assign;
9 TSFLookupTable::TSFLookupTable(int nmer, int length)
11 generate_dna_pattern(nmer, length);
14 int TSFLookupTable::next(int state, enum nucleotide symbol)
17 // dump what row we're looking at
18 std::cout << "[" << state << "]: ";
19 for(int i=0; i != table[state].size(); ++i) {
20 std::cout << table[state][i] << " ";
22 std::cout << "lookup(" << symbol << ")" << std::endl;
24 return table[state][symbol];
27 void TSFLookupTable::generate_dna_pattern(int nmer, int length)
29 // currently we can only handle single nucleotides
33 symbols += A, T, G, C;
35 // add the start state
36 std::vector<int> transitions(8, failed_state);
37 table.push_back(transitions);
39 for (symbol_vec::iterator pattern_itor = symbols.begin();
40 pattern_itor != symbols.end();
43 // update the start state to point at the state we're adding
44 table[0][*pattern_itor] = table.size();
46 // add the counting states
47 for(int i = 0; i != length-nmer; ++ i)
49 std::vector<int> transitions(8, failed_state);
50 transitions[*pattern_itor] = table.size()+1; //point to next state
51 table.push_back(transitions);
54 // add the accept state
55 std::vector<int> transitions(8, accept_state);
56 transitions[*pattern_itor] = table.size();
57 table.push_back(transitions);