3259116675aed4fff16796fd10d781a51f14073f
[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 <QObject>
17
18 #include <boost/filesystem/path.hpp>
19
20 #include <list>
21 #include <string>
22 #include <vector>
23
24 #include "alg/conserved_path.hpp"
25 #include "alg/flp.hpp"
26 #include "alg/sequence.hpp"
27
28 class NwayPaths : public QObject
29 {
30   Q_OBJECT
31
32 signals:
33   //! emit to indicate how much progress we've made
34   void progress(const std::string& description, int cur, int max);
35
36 public:
37     NwayPaths();
38     NwayPaths(const NwayPaths&);
39
40     //! setup an nway comparison, initialize # of species, window size, 
41     //! threshold
42     void setup(int w, int t);
43     void setup_ent(double new_entropy_thres, std::vector<Sequence> some_Seqs);
44     //! clear out our path
45     void clear();
46     //! set the score that a match must exceed inorder to be recorded as a path
47     void set_soft_threshold(int soft_thres);
48     //! return minimum threshold for this analysis
49     int get_threshold() const;
50     //! return window size used for this analysis
51     int get_window() const;
52
53     void radiate_path_search(std::vector<std::vector<FLPs> > all_comparisons);
54     void trans_path_search(std::vector<std::vector<FLPs> > all_comparisons);
55     void entropy_path_search(std::vector<std::vector<FLPs> > all_comparisons);
56     double path_entropy(std::vector<int> path);
57
58   // old recursive transitive nway ... has issues checking all links?
59     void find_paths_r(std::vector<std::vector<FLPs> > all_comparisons);
60     void path_search(std::vector<std::vector<FLPs> > all_comparisons, ConservedPath path, size_t depth);
61
62     void simple_refine();
63     void save(boost::filesystem::path save_file_path);
64     //! load a muway file, \throws mussa_load_error
65     void load(boost::filesystem::path load_file_path);
66     void add_path(int threshold, std::vector<int>& loaded_path);
67     void add_path(ConservedPath loaded_path);
68     //! how many sequences are in our comparison
69     size_t sequence_count();
70
71     void find_paths(std::vector<std::vector<FLPs> > all_comparisons);
72     void refine();
73
74     void save_old(boost::filesystem::path save_file_path);
75     void print(std::list<std::vector<int> >&);
76
77     // The following iterator functions are mostly for the python interface
78     // they'll have problems when being called from within a const object
79     std::list<ConservedPath>::iterator pbegin() { return pathz.begin() ; }
80     std::list<ConservedPath>::iterator pend() { return pathz.end() ; }
81     size_t path_size() const { return refined_pathz.size(); }
82     std::list<ConservedPath>::iterator rpbegin() { return refined_pathz.begin() ; }
83     std::list<ConservedPath>::iterator rpend() { return refined_pathz.end() ; }
84     size_t refined_path_size() const { return refined_pathz.size(); }
85
86     // these probably shouldn't be public, but lets start 
87     // simple
88     std::list<ConservedPath> pathz;
89     std::list<ConservedPath > refined_pathz;
90
91 protected:
92     int threshold;
93     size_t win_size;
94     int soft_thres;
95
96     double ent_thres;
97     std::vector<char *> c_sequences; //used by entropy_path_search
98
99 };
100 #endif