also modified the fltk gui code to report the exception text.
}
}
+Nway_Paths& Mussa::get_paths()
+{
+ return the_paths;
+}
+
// takes a string and sets it as the next seq
void
Mussa::add_a_seq(string a_seq)
}
-string
+void
Mussa::analyze(int w, int t, enum Mussa::analysis_modes the_ana_mode, double new_ent_thres)
{
- string err_msg;
time_t t1, t2, begin, end;
double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
-
- cout << "nway ana: sequence count = " << the_seqs.size() << endl;
-
begin = time(NULL);
- // now loading parameters from file must be done separately
- //t1 = time(NULL);
- //err_msg = load_mupa_file(para_file_path);
- //t2 = time(NULL);
- //setuptime = difftime(t2, t1);
-
ana_mode = the_ana_mode;
ent_thres = new_ent_thres;
if (w > 0)
soft_thres = t;
}
- //if (err_msg == "")
- //{
- cout << "fee\n";
- t1 = time(NULL);
- try {
- load_sequence_data();
- } catch(sequence_load_error e) {
- cerr << "Unable to load sequence" << endl;
- cerr << e.what() << endl;
- }
+ t1 = time(NULL);
+ try {
+ load_sequence_data();
+ } catch(sequence_load_error e) {
+ cerr << "Unable to load sequence" << endl;
+ cerr << e.what() << endl;
+ }
- t2 = time(NULL);
- seqloadtime = difftime(t2, t1);
+ if (the_seqs.size() < 2) {
+ throw mussa_analysis_error("you need to have at least 2 sequences to "
+ "do an analysis.");
+ }
+ cout << "nway ana: seq_num = " << the_seqs.size() << endl;
+ t2 = time(NULL);
+ seqloadtime = difftime(t2, t1);
- if (err_msg == "")
- {
- t1 = time(NULL);
- seqcomp();
- t2 = time(NULL);
- seqcomptime = difftime(t2, t1);
+ t1 = time(NULL);
+ seqcomp();
+ t2 = time(NULL);
+ seqcomptime = difftime(t2, t1);
- t1 = time(NULL);
- the_paths.setup(the_seqs.size(), window, threshold);
- nway();
- t2 = time(NULL);
- nwaytime = difftime(t2, t1);
+ t1 = time(NULL);
+ the_paths.setup(the_seqs.size(), window, threshold);
+ nway();
+ t2 = time(NULL);
+ nwaytime = difftime(t2, t1);
+ t1 = time(NULL);
+ save();
+ t2 = time(NULL);
+ savetime = difftime(t2, t1);
- cout << "fum\n";
- t1 = time(NULL);
- save();
- t2 = time(NULL);
- savetime = difftime(t2, t1);
-
- end = time(NULL);
- totaltime = difftime(end, begin);
-
-
- cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
- //setup\t
- //cout << setuptime << "\t";
- cout << seqloadtime << "\t";
- cout << seqcomptime << "\t";
- cout << nwaytime << "\t";
- cout << savetime << "\t";
- cout << totaltime << "\n";
- }
- else
- return err_msg;
- //}
- //else
- //return err_msg;
+ end = time(NULL);
+ totaltime = difftime(end, begin);
+
+
+ cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
+ //setup\t
+ //cout << setuptime << "\t";
+ cout << seqloadtime << "\t";
+ cout << seqcomptime << "\t";
+ cout << nwaytime << "\t";
+ cout << savetime << "\t";
+ cout << totaltime << "\n";
}
Mussa();
- // parameters need to be set before calling this
- // w & t are for command line override functionality, set to 0 to ignore
- std::string analyze(int w=0,
- int t=0,
- enum analysis_modes ana_mode=TransitiveNway,
- double ent_thres=0.0);
void save();
void save_muway(std::string save_path);
std::string load(std::string ana_file);
enum analysis_modes get_analysis_mode() const;
//! return a string name for an analysis mode
std::string get_analysis_mode_name() const;
- //! actually run the nway comparison
+
+ //! return the refined paths found by the nway analysis.
+ Nway_Paths& get_paths();
+
+ //! run seqcomp and the nway filtering algorithm.
+ /*!analyze will run seqcomp and then the nway algorithm
+ * on whatever sequences have been loaded into this mussa instance.
+ * w & t are for command line override functionality, set to 0 to ignore
+ * \throws mussa_analysis_error
+ */
+ void analyze(int w=0, int t=0,
+ enum analysis_modes ana_mode=TransitiveNway,
+ double ent_thres=0.0);
+ /*! Run the nway filtering algorithm,
+ * this might be used when changing the soft threshhold?
+ */
void nway();
//! appends a string sequence to the list of the_seqs
#include "ConnWindow.hh"
+#include "mussa_exceptions.hh"
#include <iostream>
using namespace std;
an_analysis = new Mussa();
err_msg = an_analysis->load_mupa_file(a_file_path);
- if (err_msg == "")
- {
- err_msg = an_analysis->analyze(0, 0, Mussa::TransitiveNway, 0.0);
- }
-
- if (err_msg == "")
- {
+ try {
+ an_analysis->analyze(0, 0, Mussa::TransitiveNway, 0.0);
// relabel window with the analysis name
window_name = "Mussa: " + an_analysis->get_name();
label((const char*)window_name.c_str());
an_analysis->get_window(), &(an_analysis->the_seqs),
&(an_analysis->the_paths));
conn_box->scale_paths();
- }
- else
- {
- fl_alert(err_msg.c_str());
- cout << err_msg;
+ } catch (mussa_analysis_error e) {
+ fl_alert(e.what());
}
}
}
#include "SetupWindow.hh"
#include "alg/mussa_class.hh"
+#include "mussa_exceptions.hh"
#include <iostream>
#include <FL/Fl_File_Chooser.H>
an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
sub_seq_starts[i], sub_seq_ends[i]);
- err_msg = an_analysis->analyze();
- //cout << "Feel the tribal beat\n";
- if (!(err_msg == ""))
- {
- //fl_alert(err_msg.c_str());
- cout << err_msg;
+ try {
+ an_analysis->analyze();
+ } catch (mussa_analysis_error e) {
+ fl_alert(e.what());
}
all_done = true;
#include "SubAnalysisWindow.hh"
#include "alg/mussa_class.hh"
+#include "mussa_exceptions.hh"
#include <iostream>
using namespace std;
an_analysis->add_a_seq(a_sequence);
}
- err_msg = an_analysis->analyze();
-
- cout << "Feel the tribal beat\n";
- if (!(err_msg == ""))
- {
- //fl_alert(err_msg.c_str());
- cout << err_msg;
+ try {
+ an_analysis->analyze();
+ } catch( mussa_analysis_error e) {
+ fl_alert( e.what() );
}
all_done = true;
if ((run_mode == 'f') || (run_mode == 'n'))
{
err_msg = an_analysis.load_mupa_file(a_file_path);
- err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
+ an_analysis.analyze(window, threshold, ana_mode, ent_thres);
//an_overlord.do_analysis();
}
explicit sequence_load_error(const std::string& msg) :
std::runtime_error(msg) {};
};
+
+//! failure running analysis
+class mussa_analysis_error : public std::runtime_error
+{
+public:
+ explicit mussa_analysis_error(const std::string& msg) :
+ std::runtime_error(msg) {};
+};
#endif