1 #ifndef _TRIVIAL_FILTER_HPP_
2 #define _TRIVIAL_FILTER_HPP_
6 //! symbolic constants used to inidicate numeric values for nucleotides
7 /*! the ordering comes from the very simple bit-wise operator
8 * used to convert ascii values to the range 0..7
10 enum nucleotide { X, A, C=3, T, U, N, G };
12 //! convert a nucleotide ascii encoding to value in the range 0..7
13 inline enum nucleotide nt_map(char c)
15 return static_cast<nucleotide>(c & 0x07);
18 //! generates our transition table
19 class TSFLookupTable {
21 //! create transition table using DNA symbols
22 /*! generate all the dna patterns of n base pairs and
23 * require length copies of the pattern.
25 * e.g. n=2, length=2 would match things like
29 TSFLookupTable(int n, int length);
31 //! return the next state
32 int next(int current, enum nucleotide symbol);
34 //! how many states are there in our table?
35 int states() { return table.size(); }
37 static const int start_state = 0;
38 static const int accept_state = -1;
39 static const int failed_state = -2;
42 typedef std::vector<enum nucleotide> symbol_vec;
44 //! generate length copies of a pattern n bases long
45 void generate_dna_pattern(int n, int length);
47 std::vector<std::vector<int> > table;
51 class TrivialSequenceFilter {
58 #endif // _TRIVIAL_FILTER_HPP_