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