ticket:62 fix local alignment
[mussa.git] / alg / nway_paths.hpp
1 #ifndef _MUSSA_NWAY_H_
2 #define _MUSSA_NWAY_H_
3 //  This file is part of the Mussa source distribution.
4 //  http://mussa.caltech.edu/
5 //  Contact author: Tristan  De Buysscher, tristan@caltech.edu
6
7 // This program and all associated source code files are Copyright (C) 2005
8 // the California Institute of Technology, Pasadena, CA, 91125 USA.  It is
9 // under the GNU Public License; please see the included LICENSE.txt
10 // file for more information, or contact Tristan directly.
11
12
13 //                        ----------------------------------------
14 //                         ----------  mussa_nway.hh  -----------
15 //                        ----------------------------------------
16 #include <boost/filesystem/path.hpp>
17
18 #include <list>
19 #include <string>
20 #include <vector>
21
22 #include "alg/flp.hpp"
23 #include "alg/conserved_path.hpp"
24
25 class NwayPaths
26 {
27   friend class ConnView;
28   friend class SeqView;
29   protected:
30     int threshold;
31     size_t win_size;
32     int soft_thres;
33
34     double ent_thres;
35     std::vector<char *> c_sequences; //used by entropy_path_search
36
37   public:
38     NwayPaths();
39     //! setup an nway comparison, initialize # of species, window size, 
40     //! threshold
41     void setup(int w, int t);
42     void setup_ent(double new_entropy_thres, std::vector<std::string> some_Seqs);
43     void set_soft_thres(int soft_thres);
44     //! return minimum threshold for this analysis
45     int get_threshold() const;
46     //! return window size used for this analysis
47     int get_window() const;
48
49     void radiate_path_search(std::vector<std::vector<FLPs> > all_comparisons);
50     void trans_path_search(std::vector<std::vector<FLPs> > all_comparisons);
51     void entropy_path_search(std::vector<std::vector<FLPs> > all_comparisons);
52     double path_entropy(std::vector<int> path);
53
54   // old recursive transitive nway ... has issues checking all links?
55     void find_paths_r(std::vector<std::vector<FLPs> > all_comparisons);
56     void path_search(std::vector<std::vector<FLPs> > all_comparisons, ConservedPath path, size_t depth);
57
58     void simple_refine();
59     void save(boost::filesystem::path save_file_path);
60     //! load a muway file, \throws mussa_load_error
61     void load(boost::filesystem::path load_file_path);
62     void add_path(int threshold, std::vector<int>& loaded_path);
63     void add_path(ConservedPath loaded_path);
64     //! how many sequences are in our comparison
65     size_t sequence_count();
66
67     void find_paths(std::vector<std::vector<FLPs> > all_comparisons);
68     void refine();
69
70     void save_old(boost::filesystem::path save_file_path);
71     void print(std::list<std::vector<int> >&);
72
73     // The following iterator functions are mostly for the python interface
74     // they'll have problems when being called from within a const object
75     std::list<ConservedPath>::iterator pbegin() { return pathz.begin() ; }
76     std::list<ConservedPath>::iterator pend() { return pathz.end() ; }
77     size_t path_size() const { return refined_pathz.size(); }
78     std::list<ConservedPath>::iterator rpbegin() { return refined_pathz.begin() ; }
79     std::list<ConservedPath>::iterator rpend() { return refined_pathz.end() ; }
80     size_t refined_path_size() const { return refined_pathz.size(); }
81
82     // these probably shouldn't be public, but lets start 
83     // simple
84     std::list<ConservedPath> pathz;
85     std::list<ConservedPath > refined_pathz;
86 };
87 #endif