does createLocalAlignment work for a 3 way?
authorDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 09:51:45 +0000 (09:51 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 12 Oct 2006 09:51:45 +0000 (09:51 +0000)
try to test ticket:137
I was hoping that creating a unit test would flush out the case where
a segement isn't part of a path. But unfortunately that doesn't seem
to happen.

However my draw code is drawing my paths in the wrong place.

alg/conserved_path.hpp
alg/test/test_mussa.cpp

index 8683faf6f3c8e6a27d2f78eed9344ff70d5e51ba..5f7e0033ce208fc6addfcc7e53872cd05bc6e458 100644 (file)
@@ -40,7 +40,7 @@ struct ConservedPath
   //! indicate which elements of the path are reversed
   std::vector<bool> reverseComplimented() const;
   //! return the list of indexes normalized (to the left)
-  std::vector<path_element> normalizedIndexes() const;
+  path_type normalizedIndexes() const;
   //! extend our current path
   //! (aka increment our window size  by growth)
   ConservedPath& extend(int growth=1);
@@ -50,6 +50,6 @@ struct ConservedPath
   //! either number of conserved bases or average entropy
   double score;
   //! offsets into each of our sequences representing the start of our window
-  std::vector<path_element> track_indexes;
+  path_type track_indexes;
 };
 #endif
index cfa873515c7234d3ffbd8646c7d8be9db9ceb6c4..74f8a9c658e55047f7a8b2e24e4502eafd99e423 100644 (file)
@@ -360,9 +360,9 @@ BOOST_AUTO_TEST_CASE( mussa_add_motif )
 }
 
 static void 
-local_align_test(const Mussa::vector_sequence_type &seqs, 
-                 const list<ConservedPath::path_type>& result,
-                 const list<vector<bool> >& reversed)
+two_way_local_align_test(const Mussa::vector_sequence_type &seqs, 
+                         const list<ConservedPath::path_type>& result,
+                         const list<vector<bool> >& reversed)
 {
   map<char, vector <char> >  m;
   assign::insert(m)('A', assign::list_of('A')('T') )
@@ -390,9 +390,8 @@ local_align_test(const Mussa::vector_sequence_type &seqs,
     BOOST_CHECK_EQUAL( first_basepair, complimented_second) ;
   }
 }
-
                  
-BOOST_AUTO_TEST_CASE( local_alignment )
+BOOST_AUTO_TEST_CASE( two_way_local_alignment )
 {
   string s0("GCGCATAT");
   string s1("AAAAAAAT");
@@ -405,6 +404,8 @@ BOOST_AUTO_TEST_CASE( local_alignment )
   analysis.set_window(4);
   analysis.analyze();
   NwayPaths npath = analysis.paths();
+  BOOST_REQUIRE_EQUAL( npath.pathz.size(), 2 );
+  
   list<ConservedPath::path_type> result;
   list<vector<bool> > reversed;
   list<ConservedPath>::iterator pathz_i = npath.pathz.begin();
@@ -416,7 +417,7 @@ BOOST_AUTO_TEST_CASE( local_alignment )
                                 result,
                                 reversed);
 
-  local_align_test(analysis.sequences(), result, reversed);
+  two_way_local_align_test(analysis.sequences(), result, reversed);
 
   ++pathz_i;
   result.clear();
@@ -427,9 +428,54 @@ BOOST_AUTO_TEST_CASE( local_alignment )
                                 selected_paths.end(),
                                 result,
                                 reversed);
-  local_align_test(analysis.sequences(), result, reversed);
-
+  two_way_local_align_test(analysis.sequences(), result, reversed);
+}
 
+BOOST_AUTO_TEST_CASE( three_way_local_alignment )
+{
+  string s0("AGCAGGGAGGGTTTAAATGGCACCCAGCAGTTGGTGTGAGG");
+  string s1("AGCGGGAAGGGTTTAAATGGCACCGGGCAGTTGGCGTGAGG");
+  string s2("CAGCGCCGGGGTTTAAATGGCACCGAGCAGTTGGCGCAGGG");
+  
+  Mussa analysis;
+  analysis.append_sequence(s0);
+  analysis.append_sequence(s1);
+  analysis.append_sequence(s2);
+  analysis.set_threshold(23);
+  analysis.set_window(30);
+  analysis.analyze();
+  NwayPaths npath = analysis.paths();
+  BOOST_CHECK_EQUAL( npath.refined_pathz.size(), 1 );
+  
+  list<ConservedPath::path_type> result;
+  list<vector<bool> > reversed;
+  // grab 1 path (since there's only one)
+  list<ConservedPath>::iterator pathz_i = npath.pathz.begin();
+  list<ConservedPath> selected_paths;
+  selected_paths.push_back(*pathz_i);
+  analysis.createLocalAlignment(selected_paths.begin(), 
+                                selected_paths.end(),
+                                result,
+                                reversed);
+                                
+  for(std::list<ConservedPath::path_type>::iterator result_i = result.begin();
+      result_i != result.end();
+      ++result_i)
+  {
+    std::cout << "path ";
+    ConservedPath::path_element first_element = *(result_i->begin());
+    for (ConservedPath::path_type::iterator element_i = result_i->begin();
+         element_i != result_i->end();
+         ++element_i)
+    {
+      BOOST_CHECK_EQUAL( *element_i, first_element );
+      BOOST_CHECK_EQUAL( s0[*element_i], s1[*element_i] );
+      BOOST_CHECK_EQUAL( s1[*element_i], s2[*element_i] );
+      BOOST_CHECK_EQUAL( s0[*element_i], s2[*element_i] );
+      std::cout << *element_i << " " << s0[*element_i];
+    }
+    std::cout << std::endl;
+  }   
 }
 
 BOOST_AUTO_TEST_CASE( subanalysis )