copy motifs to a new subanalysis
[mussa.git] / qui / SubanalysisWindow.cpp
index 6d5f3ce99e80277181d02150c7492f22fcb3dba8..57dafc9792d4e494599ec1bb9c84e82d0cfb991e 100644 (file)
@@ -84,7 +84,7 @@ void SubanalysisWindow::run()
                              "empty model now.");
   }
 
-  MussaRef m(new Mussa);
+  MussaRef new_m(new Mussa);
   
   for(SequenceLocationModel::iterator itor = model.begin();
       itor != model.end();
@@ -92,14 +92,30 @@ void SubanalysisWindow::run()
   {
     // append_sequence from a const Sequence & will make a copy 
     // for the shared pointer.
-    m->append_sequence(itor->getSelectedSequence());
+    Sequence s = itor->getSelectedSequence();
+    s.clear_motifs();
+    new_m->append_sequence(s);
   }
 
   try {
-    m->set_window(window->value());
-    m->set_threshold(threshold->value());
-    m->analyze();
-    MussaWindow *mw = new MussaWindow(m);
+    new_m->set_window(window->value());
+    new_m->set_threshold(threshold->value());
+    new_m->analyze();
+    
+    // copy over motifs
+    std::vector<Sequence> motifs_copy;
+    std::vector<Color> color_copy;
+    const Mussa::motif_set motifs = analysis->motifs();
+    boost::shared_ptr<AnnotationColors> mapper = analysis->colorMapper();
+    for(Mussa::motif_set::const_iterator motif_i = motifs.begin();
+        motif_i != motifs.end();
+        ++motif_i)
+    {
+      motifs_copy.push_back(*motif_i);
+      color_copy.push_back(mapper->lookup("motif", motif_i->get_sequence()));
+    }
+    new_m->set_motifs(motifs_copy, color_copy);
+    MussaWindow *mw = new MussaWindow(new_m);
     mw->show();
     model.clear();
     hide();