X-Git-Url: http://woldlab.caltech.edu/gitweb/?a=blobdiff_plain;f=alg%2Fmussa.hpp;h=6a0ca4eeca4743df44d7af040233d788c40ed147;hb=2534e631c7aca3a93823ea3dc868808bba6cd824;hp=e53e727cf170b04be7ff642364e5b75e73ffade2;hpb=4f161bfd1e0a558abc59e6429bf805b3c372380f;p=mussa.git diff --git a/alg/mussa.hpp b/alg/mussa.hpp index e53e727..6a0ca4e 100644 --- a/alg/mussa.hpp +++ b/alg/mussa.hpp @@ -13,7 +13,8 @@ // ---------------------------------------- // ---------- mussa_class.hh ----------- // ---------------------------------------- -#include +#include +#include #include #include @@ -31,39 +32,74 @@ std::string int_to_str(int an_int); +class Mussa; +//! provide a simple name to point to our Mussa shared_ptr +typedef boost::shared_ptr MussaRef; + class Mussa : public QObject { Q_OBJECT signals: //! call whatever signaling system we want - void progress(const std::string& description, int cur, int max); + void progress(const QString& description, int cur, int max); + //! triggered when our state changes between unsaved(true) and saved(false) + void isModified(bool); public: + typedef std::set motif_set; enum analysis_modes { TransitiveNway, RadialNway, EntropyNway, RecursiveNway }; Mussa(); Mussa(const Mussa &); - void save(); + //! dynamically construct a new Mussa object and return a reference to it + static MussaRef init(); + + //! save all of mussa + void save(boost::filesystem::path save_path=""); + //! save all of mussa + void save(const std::string& save_path) { + save(boost::filesystem::path(save_path)); + } //! save the nway comparison void save_muway(boost::filesystem::path save_path); //! load a saved analysis directory void load(boost::filesystem::path ana_path); + //! load a saved analysis + void load(const std::string& ana_path) { + load(boost::filesystem::path(ana_path)); + } + // ! return path to the where the analysis is stored + boost::filesystem::path get_analysis_path() const; + //! set analysis path + void set_analysis_path(boost::filesystem::path); //! clear parameters and initialize data lists void clear(); //! set parameters from a file - 'mupa' ~ mussa parameters - void load_mupa_file(std::string para_file_path) { load_mupa_file(boost::filesystem::path(para_file_path));} + void load_mupa_file(const std::string& para_file_path) { + load_mupa_file(boost::filesystem::path(para_file_path)); + } void load_mupa_file(boost::filesystem::path para_file_path); + //! load mussa parameters from a stream, specifing output location + void load_mupa_stream( + std::istream & para_file, + boost::filesystem::path& file_path_base + ); + // set parameters individually (eg from user input into gui classes) //! set analysis name void set_name(std::string a_name); //! return name for this analysis - std::string get_name(); + std::string get_name() const; + //! return a reasonable window title for this analysis + /*! this returns the "variable" portion for a title + */ + std::string get_title() const; //! return number of sequences in this analyzis /*! this returns either the_seqs.size() or seq_files.size() @@ -85,11 +121,27 @@ public: //! must be in range [threshold..window size] void set_soft_threshold(int sft_thres); int get_soft_threshold() const; + + //! should we append the window size to the analysis name + void set_append_window(bool v); + //! should we append the window size to the analysis name + bool get_append_window(); + + //! should we append the threshold to the analysis name + void set_append_threshold(bool v); + //! should we append the threshold to the analysis name + bool get_append_threshold(); void set_analysis_mode(enum analysis_modes new_ana_mode); enum analysis_modes get_analysis_mode() const; //! return a string name for an analysis mode std::string get_analysis_mode_name() const; + //! set our current dirty state + void set_dirty(bool); + //! return if we have unsaved changes + bool is_dirty() const; + //! is there anything loaded into this analysis? + bool empty() const; //! return the refined paths found by the nway analysis. const NwayPaths& paths() const; @@ -108,7 +160,7 @@ public: */ void analyze(); /*! Run the nway filtering algorithm, - * this might be used when changing the soft threshhold? + * automatically called when the soft threshhold has changed? */ void nway(); @@ -144,28 +196,35 @@ public: void save_old(); void load_old(char * load_file_path, int s_num); - // manage motif lists - void add_motif(const std::string& motifs, - const Color& colors); - //! add vector of motifs and colors to our motif collection - /*! this depends on sets and color maps being unique + // manage motif lists + //! add a motif it wont be applied until update_sequences_motif is called + void add_motif(const Sequence& motifs, const Color& colors); + //! add vector of motifs and colors to our motif collection + /*! this will automatically call update_sequences_motif + * this depends on sets and color maps being unique * (aka if you add the same item more than once it doesn't - * increase the size of the data structure + * increase the size of the data structure) */ - void add_motifs(const std::vector& motifs, + void set_motifs(const std::vector& motifs, const std::vector& colors); - //! load motifs from an ifstream /*! The file should look something like * * where sequence is a string of IUPAC symbols * and red,green,blue are a white space separated list of floats * in the range [0.0, 1.0] */ - void load_motifs(std::istream &); //! load a list of motifs from a file named filename void load_motifs(boost::filesystem::path filename); + //! load motifs from an ifstream + /*! \sa Mussa::load_motifs(boost::filesystem::path) + */ + void load_motifs(std::istream &); + //! save motif list to the specified filename + void save_motifs(boost::filesystem::path filename); + //! save motif list to an ostream + void save_motifs(std::ostream &); //! return our motifs; - const std::set& motifs() const; + const motif_set& motifs() const; //! return color mapper boost::shared_ptr colorMapper(); @@ -182,6 +241,7 @@ public: int window; //! how many base pairs need to match order to record a window as conserved int threshold; + //! stores current filter used by GUI to change the connections shown int soft_thres; //! which nway comparison algorithm to use. enum analysis_modes ana_mode; @@ -199,9 +259,13 @@ public: NwayPaths the_paths; //! motif list - std::set motif_sequences; + motif_set motif_sequences; //! color manager boost::shared_ptr color_mapper; + //! path to our analysis + boost::filesystem::path analysis_path; + //! flag indicating if we have unsaved changes + bool dirty; // Private methods //! runs all the seqcomps needed to support the nway comparison