load a mupa file and test it
authorDiane Trout <diane@caltech.edu>
Wed, 22 Feb 2006 08:27:24 +0000 (08:27 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 22 Feb 2006 08:27:24 +0000 (08:27 +0000)
Start trying to isolate ConnWindow from the mussa_class object by using
accessors.
Try to get rid of seq_num and make mussa_class a bit more dynamic,
unfortunately when I killed a bit more in mussa_class than what's gone in
this patch the test cases noticed trying to free an invalid pointer.

alg/mussa_class.cxx
alg/mussa_class.hh
gui/ConnWindow.cxx
gui/SetupWindow.cxx
gui/SubAnalysisWindow.cxx
test/test_mussa.cxx

index deebe231a5916f849d3e61cf36b85e9546aae6ad..3481cd2be00ef1f212fe306b508eb1e35378bf5d 100644 (file)
@@ -268,8 +268,10 @@ Mussa::load_mupa_file(string para_file_path)
     para_file.close();
 
     soft_thres = threshold;
-    cout << "nway mupa: analysis_name = " << analysis_name << " seq_num = " << seq_num;
-    cout << " window = " << window << " threshold = " << threshold << endl;
+    cout << "nway mupa: analysis_name = " << analysis_name 
+         << " seq_num = " << seq_num
+         << " window = " << window 
+         << " threshold = " << threshold << endl;
 
     return "";
   }
@@ -400,7 +402,8 @@ Mussa::load_sequence_data()
           */
   {
     aSeq.load_fasta(*seq_files_i, *fasta_indices_i,*seq_starts_i, *seq_ends_i);
-    aSeq.load_annot(*annot_files_i, *seq_starts_i, *seq_ends_i); 
+    if (annot_files_i->size() > 0) 
+      aSeq.load_annot(*annot_files_i, *seq_starts_i, *seq_ends_i); 
     
     the_Seqs.push_back(aSeq);
     cout << aSeq.get_header() << endl;
@@ -425,17 +428,17 @@ Mussa::seqcomp()
   string save_file_string;
 
   empty_FLP_vector.clear();
-  for(i = 0; i < seq_num; i++)
+  for(i = 0; i < the_Seqs.size(); i++)
   {
     all_comps.push_back(empty_FLP_vector); 
-    for(i2 = 0; i2 < seq_num; i2++)
+    for(i2 = 0; i2 < the_Seqs.size(); i2++)
       all_comps[i].push_back(dummy_comp);
   }
-  for(i = 0; i < seq_num; i++)
+  for(i = 0; i < the_Seqs.size(); i++)
     seq_lens.push_back(the_Seqs[i].len());
 
-  for(i = 0; i < seq_num; i++)
-    for(i2 = i+1; i2 < seq_num; i2++)
+  for(i = 0; i < the_Seqs.size(); i++)
+    for(i2 = i+1; i2 < the_Seqs.size(); i2++)
     {
       cout << "seqcomping: " << i << " v. " << i2 << endl;
       all_comps[i][i2].setup("m", window, threshold, seq_lens[i],seq_lens[i2]);
@@ -444,8 +447,6 @@ Mussa::seqcomp()
     }
 }
 
-
-
 void
 Mussa::nway()
 {
@@ -464,7 +465,7 @@ Mussa::nway()
   {
     //unlike other methods, entropy needs to look at the sequence at this stage
     some_Seqs.clear();
-    for(i = 0; i < seq_num; i++)
+    for(i = 0; i < the_Seqs.size(); i++)
       some_Seqs.push_back(the_Seqs[i].get_seq());
 
     the_paths.setup_ent(ent_thres, some_Seqs); // ent analysis extra setup
@@ -526,7 +527,7 @@ Mussa::save()
   save_file << "<Mussa_Sequence>" << endl;
   //save_file.close();
 
-  for(i = 0; i < seq_num; i++)
+  for(i = 0; i < the_Seqs.size(); i++)
     the_Seqs[i].save(save_file);
 
   //save_file.open(save_path.c_str(), ios::app);
@@ -540,8 +541,8 @@ Mussa::save()
   //save_path = file_path_base + save_name + "/" + save_name + ".muway"; //os X
   the_paths.save(save_path);
 
-  for(i = 0; i < seq_num; i++)
-    for(i2 = i+1; i2 < seq_num; i2++)
+  for(i = 0; i < the_Seqs.size(); i++)
+    for(i2 = i+1; i2 < the_Seqs.size(); i2++)
     {
       append_info.str("");
       append_info <<  "_sp_" << i << "v" << i2;
@@ -653,7 +654,7 @@ Mussa::save_old()
 
   save_file.open(analysis_name.c_str(), ios::out);
 
-  for(i = 0; i < seq_num; i++)
+  for(i = 0; i < the_Seqs.size(); i++)
     save_file << the_Seqs[i].get_seq() << endl;
 
   save_file << window << endl;
index 1896a2f50cb324ad43b1b20b9b990f44319e061d..0f551c346a176f998e737866366a452040e994bd 100644 (file)
@@ -69,6 +69,8 @@ class Mussa
     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
+    void nway();
 
     //! appends a string sequence to the list of the_Seqs
     void add_a_seq(std::string a_seq);
@@ -105,12 +107,6 @@ class Mussa
     //! loads sequence and annotations from fasta and annotation file
     void load_sequence_data();
     void seqcomp();
-    /*! actually run the nway comparison
-     *  it appears there are 4 modes, t (trans_path_search), 
-     *  r (radiate_path_search), e (entropy_path_search), and 
-     *  o, (find_paths_r (old recursive analysis))
-     */
-    void nway();
 
 };
 #endif
index 73d26b58c3f4527f64680afd855233c2bdf02149..aae8e053fabe637b7ae27593b00d18f9f0476677 100644 (file)
@@ -45,11 +45,11 @@ ConnWindow::real_load_ana_cb()
     if (err_msg == "")
     {
       // relabel window with the analysis name
-      window_name = "Mussa: " + an_analysis->analysis_name;
+      window_name = "Mussa: " + an_analysis->get_name();
       label((const char*)window_name.c_str());
       // show the user the analysis
-      conn_box->setup(an_analysis->analysis_name, an_analysis->seq_num, 
-                     an_analysis->window, &(an_analysis->the_Seqs), 
+      conn_box->setup(an_analysis->get_name(), an_analysis->seq_num, 
+                     an_analysis->get_window(), &(an_analysis->the_Seqs), 
                      &(an_analysis->the_paths));
       conn_box->scale_paths();
     }
@@ -93,11 +93,11 @@ ConnWindow::real_do_ana_cb()
     if (err_msg == "")
     {
       // relabel window with the analysis name
-      window_name = "Mussa: " + an_analysis->analysis_name;
+      window_name = "Mussa: " + an_analysis->get_name();
       label((const char*)window_name.c_str());
       // show the user the analysis
-      conn_box->setup(an_analysis->analysis_name, an_analysis->seq_num, 
-                     an_analysis->window, &(an_analysis->the_Seqs), 
+      conn_box->setup(an_analysis->get_name(), an_analysis->seq_num, 
+                     an_analysis->get_window(), &(an_analysis->the_Seqs), 
                      &(an_analysis->the_paths));
       conn_box->scale_paths();
     }
@@ -130,11 +130,11 @@ ConnWindow::real_setup_ana_cb()
   if (setup_win->done())
   {
     // relabel window with the analysis name
-    window_name = "Mussa: " + an_analysis->analysis_name;
+    window_name = "Mussa: " + an_analysis->get_name();
     label((const char*)window_name.c_str());
     // is it this easy?  what if setup window encounters an error...??
-    conn_box->setup(an_analysis->analysis_name, an_analysis->seq_num, 
-                   an_analysis->window, &(an_analysis->the_Seqs), 
+    conn_box->setup(an_analysis->get_name(), an_analysis->seq_num, 
+                   an_analysis->get_window(), &(an_analysis->the_Seqs), 
                    &(an_analysis->the_paths));
 
     conn_box->scale_paths();
@@ -164,7 +164,7 @@ ConnWindow::real_subana_cb()
 
   if (subana_win->done())
   {
-    subana_name = "SubMussa: " + sub_analysis->analysis_name
+    subana_name = "SubMussa: " + sub_analysis->get_name()
     sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
     cout << "Like a warm day in may\n";
     sub_conn_win->add_ana(sub_analysis);
@@ -321,8 +321,8 @@ ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
   string save_path;
   ostringstream append_info;
 
-  save_path = an_analysis->analysis_name + "/"
-    + an_analysis->analysis_name.substr(0,an_analysis->analysis_name.find("_t"));
+  save_path = an_analysis->get_name() + "/"
+    + an_analysis->get_name().substr(0,an_analysis->get_name().find("_t"));
   append_info.str("");
   append_info << "_t" << new_soft_thres << ".muway";
   //<<  "_w" << an_analysis->window
@@ -410,11 +410,11 @@ ConnWindow::add_ana(Mussa *the_ana)
   an_analysis = the_ana;
 
   // relabel window with the analysis name
-  window_name = "Mussa: " + an_analysis->analysis_name;
+  window_name = "Mussa: " + an_analysis->get_name();
   label((const char*)window_name.c_str());
 
-  conn_box->setup(an_analysis->analysis_name, an_analysis->seq_num, 
-                  an_analysis->window, &(an_analysis->the_Seqs), 
+  conn_box->setup(an_analysis->get_name(), an_analysis->seq_num, 
+                  an_analysis->get_window(), &(an_analysis->the_Seqs), 
                   &(an_analysis->the_paths));
   conn_box->scale_paths();
 }
index aac5948e286c9582c249d78b91aee75f338fa551..de7c51754709319e6ab9472dcd22d44825bf9481 100644 (file)
@@ -9,7 +9,7 @@
 
 
 #include "SetupWindow.hh"
-#include "mussa_class.hh"
+#include "alg/mussa_class.hh"
 #include <iostream>
 #include <FL/Fl_File_Chooser.H>
 
index 7e39303e2d60c09f0db03845a2baf86284d842f9..97cc2540081620ab071f09ffcb58069bf8c5af8f 100644 (file)
@@ -9,6 +9,7 @@
 
 
 #include "SubAnalysisWindow.hh"
+#include "alg/mussa_class.hh"
 
 #include <iostream>
 using namespace std;
index 6f1b6cea5ae8567110539785f3ef8f99291adcc7..608c6a297eaf464d311513aaab43d2ffca314686 100644 (file)
@@ -39,3 +39,12 @@ BOOST_AUTO_TEST_CASE( mussa_analysis_name )
   BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "[deprecated] Recursive" );
 }
 
+#include <unistd.h>
+BOOST_AUTO_TEST_CASE( mussa_load_mupa )
+{
+  Mussa m;
+  chdir( "examples" );
+  m.load_mupa_file( "mck3test.mupa" );
+  m.analyze(30, 25);
+  chdir( ".." );
+}