provide a user interface to edit motifs
[mussa.git] / alg / mussa.cpp
index ea3fb23a57d5b34c9ba06ad79ebef288870448e4..09cb297db3d57e4e0d329973a328188b708e89cb 100644 (file)
@@ -649,6 +649,21 @@ Mussa::load_old(char * load_file_path, int s_num)
   //the_paths.save("tmp.save");
 }
 
+void Mussa::add_motifs(const vector<string>& motifs, 
+                       const vector<Color>& colors)
+{
+  if (motifs.size() != colors.size()) {
+    throw mussa_error("motif and color vectors must be the same size");
+  }
+
+  for(size_t i = 0; i != motifs.size(); ++i)
+  {
+    motif_sequences.insert(motifs[i]);
+    color_mapper.appendInstanceColor("motif", motifs[i], colors[i]);
+  }
+  update_sequences_motifs();
+}
+
 // I mostly split the ifstream out so I can use a stringstream to test it.
 void Mussa::load_motifs(std::istream &in)
 {
@@ -697,6 +712,18 @@ void Mussa::load_motifs(std::istream &in)
       continue;
     }
   }
+  update_sequences_motifs();
+}
+
+void Mussa::load_motifs(string filename)
+{
+  ifstream f;
+  f.open(filename.c_str(), ifstream::in);
+  load_motifs(f);
+}
+
+void Mussa::update_sequences_motifs()
+{
   // once we've loaded all the motifs from the file, 
   // lets attach them to the sequences
   for(vector<Sequence>::iterator seq_i = the_seqs.begin();
@@ -715,11 +742,9 @@ void Mussa::load_motifs(std::istream &in)
   }
 }
 
-void Mussa::load_motifs(string filename)
+const set<string>& Mussa::motifs() const
 {
-  ifstream f;
-  f.open(filename.c_str(), ifstream::in);
-  load_motifs(f);
+  return motif_sequences;
 }
 
 AnnotationColors& Mussa::colorMapper()