Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / alg / tsf / trivial_filter.hpp
1 #ifndef _TRIVIAL_FILTER_HPP_
2 #define _TRIVIAL_FILTER_HPP_
3
4 #include <vector>
5
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
9  */
10 enum nucleotide { X, A, C=3, T, U, N, G };
11
12 //! convert a nucleotide ascii encoding to value in the range 0..7
13 inline enum nucleotide nt_map(char c) 
14 {
15   return static_cast<nucleotide>(c & 0x07);
16 }
17
18 //! generates our transition table
19 class TSFLookupTable {
20   public:
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.
24      *
25      * e.g. n=2, length=2 would match things like
26      * ATAT *(AT), 
27      */
28
29     TSFLookupTable(int n, int length);
30
31     //! return the next state
32     int next(int current, enum nucleotide symbol);
33
34     //! how many states are there in our table?
35     int states() { return table.size(); }
36    
37     static const int start_state = 0;
38     static const int accept_state = -1;
39     static const int failed_state = -2;
40
41   private:
42     typedef std::vector<enum nucleotide> symbol_vec;
43
44     //! generate length copies of a pattern n bases long
45     void generate_dna_pattern(int n, int length);
46
47     std::vector<std::vector<int> > table;
48
49 };
50
51 class TrivialSequenceFilter {
52   public:
53   private:
54     TSFLookupTable table;
55 };
56
57
58 #endif // _TRIVIAL_FILTER_HPP_