1 #include "trivial_filter.hpp"
3 #include <boost/assign.hpp>
4 using namespace boost::assign;
8 TSFLookupTable::TSFLookupTable(int nmer, int length)
10 generate_dna_pattern(nmer, length);
13 int TSFLookupTable::next(int state, enum nucleotide symbol)
16 // dump what row we're looking at
17 std::cout << "[" << state << "]: ";
18 for(int i=0; i != table[state].size(); ++i) {
19 std::cout << table[state][i] << " ";
21 std::cout << "lookup(" << symbol << ")" << std::endl;
23 return table[state][symbol];
26 void TSFLookupTable::generate_dna_pattern(int nmer, int length)
28 // currently we can only handle single nucleotides
32 symbols += A, T, G, C;
34 // add the start state
35 std::vector<int> transitions(8, failed_state);
36 table.push_back(transitions);
38 for (symbol_vec::iterator pattern_itor = symbols.begin();
39 pattern_itor != symbols.end();
42 // update the start state to point at the state we're adding
43 table[0][*pattern_itor] = table.size();
45 // add the counting states
46 for(int i = 0; i != length-nmer; ++ i)
48 std::vector<int> transitions(8, failed_state);
49 transitions[*pattern_itor] = table.size()+1; //point to next state
50 table.push_back(transitions);
53 // add the accept state
54 std::vector<int> transitions(8, accept_state);
55 transitions[*pattern_itor] = table.size();
56 table.push_back(transitions);