define window for showing a mussa alignment
[mussa.git] / alg / conserved_path.hpp
1 #ifndef _CONSERVED_PATH_H
2 #define _CONSERVED_PATH_H
3 #include <vector>
4 #include <ostream>
5
6 struct ConservedPath
7 {
8   typedef int path_element;
9   typedef std::vector<path_element> path_type;
10   typedef path_type::iterator iterator;
11   typedef path_type::const_iterator const_iterator;
12   typedef path_type::size_type size_type;
13
14   ConservedPath();
15   ConservedPath(const ConservedPath& );
16   ConservedPath(double score, path_type path);
17
18   //! reset our path to be empty (including setting threshold to 0)
19   void clear();
20   path_element& operator[](size_type index);
21   void push_back(const path_element& );
22   void pop_back();
23
24   size_type size() const;
25   iterator begin();
26   const_iterator begin() const;
27   iterator end();
28   const_iterator end() const;
29
30   friend bool operator==(const ConservedPath& a, const ConservedPath &b);
31   friend bool operator!=(const ConservedPath& a, const ConservedPath &b);
32   friend std::ostream& operator<<(std::ostream&, const ConservedPath&);
33
34   //! return true if all elements of the path are "next to" our current path.
35   /*! Next to is defined as being window index + 1
36    *  that definition may not properly track reverse compliment
37    */
38   bool nextTo(const ConservedPath& next) const;
39   //! indicate which elements of the path are reversed
40   std::vector<bool> reverseComplimented() const;
41
42   //! either number of conserved bases or average entropy
43   double score;
44   //! offsets into each of our sequences representing the start of our window
45   std::vector<path_element> track_indexes;
46 };
47
48 struct ExtendedConservedPath : public ConservedPath
49 {
50   ExtendedConservedPath();
51   ExtendedConservedPath(const ExtendedConservedPath& other);
52   ExtendedConservedPath(int win_size, ConservedPath conserved_path);
53   ExtendedConservedPath(int win_size, double score, std::vector<int> path);
54
55   //! extend our current path
56   /*! (aka increment our window size  by growth)
57    */
58   ExtendedConservedPath& extend(int growth=1);
59
60   //! size of extended window
61   int window_size;
62 };
63 #endif