just load the sequence
[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     //! Load a sequence from a fasta file and any annotations
93     /*! \param[in] seq_file the full path to the fasta file
94      *  \param[in] annot_file the full path to an annotation file,
95      *             if is an empty string, we won't bother loading anything
96      *  \param[in] fasta_index specify which sequence in a multisequence fasta
97      *             file
98      *  \param[in] sub_seq_start starting slice index to select a subsequence
99      *             use 0 start from the beginning.
100      *  \param[in] sub_seq_end ending slice index to select a subsequence
101      *             use 0 to go to the end.
102      */
103     void load_sequence(std::string seq_file, std::string annot_file, 
104                        int fasta_index, int sub_seq_start=0, int sub_seq_end=0);
105     //! allow examining the sequences we have loaded
106     const std::vector<Sequence>& sequences() const;
107
108     // deprecated - support bridge for python version of mussa
109     // these save & load from the old file format
110     void save_old();
111     void load_old(char * load_file_path, int s_num);
112
113   private:
114     // Private variables
115     // parameters needed for a mussa analysis
116     std::string analysis_name;
117     int window, threshold, soft_thres;
118     enum analysis_modes ana_mode;
119     double ent_thres;
120     bool win_override, thres_override;
121     bool win_append, thres_append;
122
123     //! sequence data
124     std::vector<Sequence> the_seqs;
125     //! the seqcomp data
126     std::vector<std::vector<FLPs> > all_comps;
127     //! N-way data, ie the mussa results  
128     NwayPaths the_paths;
129
130     // Private methods
131     //! loads sequence and annotations from fasta and annotation file
132     void seqcomp();
133
134 };
135 #endif