There can be only one (filename convention)
[mussa.git] / alg / mussa.hpp
1 #ifndef _MUSSA_CLASS_H_
2 #define _MUSSA_CLASS_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_class.hh -----------
15 //                        ----------------------------------------
16
17 #include <list>
18 #include <string>
19 #include <vector>
20
21 #include "alg/nway_paths.hpp"
22 #include "alg/sequence.hpp"
23
24 std::string int_to_str(int an_int);
25
26 class Mussa
27 {
28   friend class ConnWindow;
29   public:
30     enum analysis_modes { TransitiveNway, RadialNway, EntropyNway, 
31                           RecursiveNway };
32
33     Mussa();  
34
35     void save();
36     void save_muway(std::string save_path);
37     //! load a saved analysis directory
38     void load(std::string ana_path);
39
40     //! clear parameters and initialize data lists
41     void clear();
42
43     // set parameters from a file - 'mupa' ~ mussa parameters
44     void load_mupa_file(std::string para_file_path);
45
46     // set parameters individually (eg from user input into gui classes)
47     //! set analysis name
48     void set_name(std::string a_name);
49     //! return name for this analysis
50     std::string get_name();
51
52     //! return number of sequences in this analyzis
53     /*! this returns either the_seqs.size() or seq_files.size()
54      *  depending on which has data loaded in
55      *  (silly delayed loading of sequence data)
56      */
57     int size() const;
58     //! set number of bases for this window size
59     void set_window(int a_window);
60     //! get number of bases for the sliding window
61     int get_window() const;
62     //! set number of bases that must match for a window to be saved
63     void set_threshold(int a_threshold);
64     //! get number of bases that must match for a window to be saved
65     int get_threshold() const;
66     void set_soft_thres(int sft_thres);
67     
68     void set_analysis_mode(enum analysis_modes new_ana_mode);
69     enum analysis_modes get_analysis_mode() const;
70     //! return a string name for an analysis mode
71     std::string get_analysis_mode_name() const;
72
73     //! return the refined paths found by the nway analysis.
74     const NwayPaths& paths() const;
75
76     //! run seqcomp and the nway filtering algorithm.
77     /*!analyze will run seqcomp and then the nway algorithm
78      * on whatever sequences have been loaded into this mussa instance.
79      * w & t are for command line override functionality, set to 0 to ignore
80      * \throws mussa_analysis_error 
81      */
82     void analyze(int w=0, int t=0, 
83                  enum analysis_modes ana_mode=TransitiveNway,
84                  double ent_thres=0.0);
85     /*! Run the nway filtering algorithm, 
86      *  this might be used when changing the soft threshhold?
87      */
88     void nway();
89
90     //! appends a string sequence to the list of the_seqs
91     void add_a_seq(std::string a_seq);
92     // sets info to load a seq and annotations from a fasta file 
93     void set_seq_info(std::string seq_file, std::string annot_file, 
94                       int fa_i, int a_start, int the_end);
95     //! allow examining the sequences we have loaded
96     const std::vector<Sequence>& sequences() const;
97
98     // deprecated - support bridge for python version of mussa
99     // these save & load from the old file format
100     void save_old();
101     void load_old(char * load_file_path, int s_num);
102
103   private:
104     // Private variables
105     // parameters needed for a mussa analysis
106     std::string analysis_name;
107     std::string file_path_base;
108     int window, threshold, soft_thres;
109     enum analysis_modes ana_mode;
110     double ent_thres;
111     std::list<std::string> seq_files, annot_files;
112     std::list<int> fasta_indices, sub_seq_starts, sub_seq_ends;
113     bool win_override, thres_override;
114     bool win_append, thres_append;
115
116     //! sequence data
117     std::vector<Sequence> the_seqs;
118     //! the seqcomp data
119     std::vector<std::vector<FLPs> > all_comps;
120     //! N-way data, ie the mussa results  
121     NwayPaths the_paths;
122
123     // Private methods
124     //! loads sequence and annotations from fasta and annotation file
125     void load_sequence_data();
126     void seqcomp();
127
128 };
129 #endif