save motifs with the analysis
authorDiane Trout <diane@caltech.edu>
Fri, 13 Oct 2006 05:48:13 +0000 (05:48 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 13 Oct 2006 05:48:13 +0000 (05:48 +0000)
ticket:133
This is the last part to implement ticket:133 this hooks up the
Mussa::save and Mussa::load code to automatically try saving the motif lists
into the analysis subdirectory.

alg/mussa.cpp

index 18539b83ed44860f8439c5378c39352a2381197c..ae21f5bf736f845ca28a4f5c68d6b320a7687995 100644 (file)
@@ -12,6 +12,7 @@
 //                          ---------- mussa_class.cc -----------
 //                        ----------------------------------------
 
+#include <boost/filesystem/path.hpp>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/fstream.hpp>
 namespace fs = boost::filesystem;
@@ -584,6 +585,11 @@ Mussa::save(fs::path save_path)
   save_file << "</Mussa_Sequence>" << endl;
   save_file.close();
 
+  // if we have any motifs, save them.
+  if (motif_sequences.size()) {
+    save_motifs(save_path/(save_path.leaf()+".mtl"));
+  }
+
   // save nway paths to its mussa save file
   the_paths.save(save_path / (save_path.leaf()+ ".muway"));
 
@@ -595,6 +601,7 @@ Mussa::save(fs::path save_path)
       all_comps[i][i2].save(save_path/(save_path.leaf()+append_info.str()+".flp"));
     }
   }
+
   dirty = false;
   analysis_path = save_path;
 }
@@ -619,12 +626,9 @@ Mussa::load(fs::path ana_file)
   FLPs dummy_comp;
 
   analysis_path = ana_file;
-  //clog << "ana_file name " << ana_file.string() << endl;
   analysis_name = ana_path.leaf();
-  //clog << " ana_name " << analysis_name << endl;
   file_path_base =  ana_path.branch_path() / analysis_name;
   a_file_path = file_path_base / (analysis_name + ".muway");
-  //clog << " loading museq: " << a_file_path.string() << endl;
   the_paths.load(a_file_path);
   // perhaps this could be more elegent, but at least this'll let
   // us know what our threshold and window sizes were when we load a muway
@@ -640,11 +644,14 @@ Mussa::load(fs::path ana_file)
   for (i = 1; i <= seq_num; i++)
   {
     boost::shared_ptr<Sequence> tmp_seq(new Sequence);
-    //clog << "mussa_class: loading museq frag... " << a_file_path.string() << endl;
     tmp_seq->load_museq(a_file_path, i);
     the_seqs.push_back(tmp_seq);
   }
   
+  fs::path motif_file = file_path_base / (analysis_name + ".mtl");
+  if (fs::exists(motif_file)) {
+    load_motifs(motif_file);
+  }
   empty_FLP_vector.clear();
   for(i = 0; i < seq_num; i++)
   {