store motifs as sequences instead of strings
authorDiane Trout <diane@caltech.edu>
Fri, 30 Jun 2006 01:22:50 +0000 (01:22 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 30 Jun 2006 01:22:50 +0000 (01:22 +0000)
this gives me a place to store at least some annotation information
about a motif.

alg/mussa.cpp
alg/mussa.hpp
alg/sequence.cpp
alg/sequence.hpp
alg/test/test_mussa.cpp
alg/test/test_sequence.cpp
qui/motif_editor/MotifEditor.cpp

index af704e8e696d64250b7b12fe9a954dda4596b089..44f9adb47b0726fd10874febad5a9fc6b1fef65e 100644 (file)
@@ -714,13 +714,13 @@ Mussa::load_old(char * load_file_path, int s_num)
   //the_paths.save("tmp.save");
 }
 
-void Mussa::add_motif(const string& motif, const Color& color)
+void Mussa::add_motif(const Sequence& motif, const Color& color)
 {
   motif_sequences.insert(motif);
   color_mapper->appendInstanceColor("motif", motif, color);
 }
 
-void Mussa::set_motifs(const vector<string>& motifs, 
+void Mussa::set_motifs(const vector<Sequence>& motifs, 
                        const vector<Color>& colors)
 {
   if (motifs.size() != colors.size()) {
@@ -804,7 +804,7 @@ void Mussa::update_sequences_motifs()
     // clear out old motifs
     (*seq_i)->clear_motifs();
     // for all the motifs in our set, attach them to the current sequence
-    for(set<string>::iterator motif_i = motif_sequences.begin();
+    for(set<Sequence>::iterator motif_i = motif_sequences.begin();
         motif_i != motif_sequences.end();
         ++motif_i)
     {
@@ -813,7 +813,7 @@ void Mussa::update_sequences_motifs()
   }
 }
 
-const set<string>& Mussa::motifs() const
+const set<Sequence>& Mussa::motifs() const
 {
   return motif_sequences;
 }
index 2d497f7c4bd0c9b9d7d31b232e6f7ae9c8719485..5713a6dd9f0523bc8a71968c6ba09c0596f6f14f 100644 (file)
@@ -146,14 +146,14 @@ public:
 
     // manage motif lists 
     //! add a motif it wont be applied until update_sequences_motif is called
-    void add_motif(const std::string& motifs, const Color& colors);
+    void add_motif(const Sequence& motifs, const Color& colors);
     //! add vector of motifs and colors to our motif collection 
     /*! this will automatically call update_sequences_motif
      *  this depends on sets and color maps being unique
      *  (aka if you add the same item more than once it doesn't
      *  increase the size of the data structure)
      */
-    void set_motifs(const std::vector<std::string>& motifs, 
+    void set_motifs(const std::vector<Sequence>& motifs, 
                     const std::vector<Color>& colors);
     //! load motifs from an ifstream
     /*! The file should look something like
@@ -166,7 +166,7 @@ public:
     //! load a list of motifs from a file named filename
     void load_motifs(boost::filesystem::path filename);
     //! return our motifs;
-    const std::set<std::string>& motifs() const;
+    const std::set<Sequence>& motifs() const;
 
     //! return color mapper
     boost::shared_ptr<AnnotationColors> colorMapper();
@@ -200,7 +200,7 @@ public:
     NwayPaths the_paths;
 
     //! motif list
-    std::set<std::string> motif_sequences;
+    std::set<Sequence> motif_sequences;
     //! color manager
     boost::shared_ptr<AnnotationColors> color_mapper;
 
index b9163c0c6b17dc103fae39e9487850c08328de49..b8488dcbc70042551362f90655949189897eca2e 100644 (file)
@@ -778,7 +778,7 @@ Sequence::motif_normalize(std::string a_motif)
   return valid_motif;
 }
 
-void Sequence::add_motif(std::string a_motif)
+void Sequence::add_motif(const Sequence& a_motif)
 {
   std::vector<int> motif_starts = find_motif(a_motif);
 
index f3a93fa931316e4bbcf8756abbf7c532ed0fe160..407168ebc0d5e298dccc86fbd6f29771e07f95f9 100644 (file)
@@ -118,7 +118,7 @@ class Sequence : public std::string
     std::string get_header() const;
     //! add a motif to our list of motifs
     //! \throws motif_normalize_error if there's something wrong with a_motif
-    void add_motif(std::string a_motif);
+    void add_motif(const Sequence& a_motif);
     //! clear our list of found motifs
     void clear_motifs();
     //! search a sequence for a_motif
index 2cf19c0c4226bfb0a3f5f5747dc535a3764f205f..8961a1c3f17578b0a66a76de9137acb15833e9c5 100644 (file)
@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE( mussa_load_motif )
 
 BOOST_AUTO_TEST_CASE( mussa_add_motif )
 {
-  vector<string> motifs;
+  vector<Sequence> motifs;
   motifs.push_back("AAGG");
   vector<Color> colors;
   colors.push_back(Color(1.0, 0.0, 0.0));
index cf543fd00c603bce8b0286ed5ffafb08ef8a91c2..812a7a3cd7f87888d7610c4b5d32c22cc7532ee7 100644 (file)
@@ -246,6 +246,23 @@ BOOST_AUTO_TEST_CASE( sequence_motifs )
 
   s1.clear_motifs();
   BOOST_CHECK( s1.motifs().begin() == s1.motifs().end() );
+
+  /* FIXME: enable this when i find a way of passing storing the motif name
+  // does our annotation travel?
+  Sequence motif_seq(m);
+  motif_seq.set_header("hi");
+  s1.add_motif(motif_seq);
+
+  BOOST_CHECK_EQUAL(s1.motifs().size(), 2);
+  for(motif_i = s1.motifs().begin(); 
+      motif_i != s1.motifs().end(); 
+      ++motif_i)
+  {
+    BOOST_CHECK_EQUAL( motif_i->type, "motif" );
+    BOOST_CHECK_EQUAL( motif_i->name, "hi");
+    BOOST_CHECK_EQUAL( motif_i->sequence, m);
+  }
+  */
 }
 
 BOOST_AUTO_TEST_CASE( annot_test )
index 288f7134b0a2b1acdd43ea4a558e223a94c54bea..12a1e9e2e291cf58bbd46d1f1196c20fbf4203c8 100644 (file)
@@ -12,7 +12,7 @@ MotifEditor::MotifEditor(Mussa *m, QWidget *parent)
     applyButton("set motifs")
 {
   assert (m != 0);
-  const set<string> &motif = analysis->motifs();
+  const set<Sequence> &motif = analysis->motifs();
   vector<string> motif_seq(motif.begin(), motif.end());
 
   connect(&applyButton, SIGNAL(clicked()), this, SLOT(updateMotifs()));
@@ -47,7 +47,7 @@ void MotifEditor::updateMotifs()
   analysis->colorMapper()->appendTypeColor("motif", motif_default);
 
   // add our motifs back
-  vector<string> motifs;
+  vector<Sequence> motifs;
   vector<Color> colors;
 
   for(std::vector<MotifDetail *>::iterator md_i =  motif_details.begin();
@@ -55,6 +55,8 @@ void MotifEditor::updateMotifs()
       ++md_i)
   {
     if ((*md_i)->motif().size() > 0 && (*md_i)->enabled()) {
+      Sequence new_motif((*md_i)->motif());
+      new_motif.set_header((*md_i)->name());
       motifs.push_back((*md_i)->motif());
       colors.push_back((*md_i)->color());
     }