#include <boost/test/auto_unit_test.hpp>
#include <boost/filesystem/operations.hpp>
namespace fs = boost::filesystem;
+#include <boost/assign/list_of.hpp>
+#include <boost/assign/list_inserter.hpp>
+#include <boost/assign.hpp>
+namespace assign = boost::assign;
#include <string>
#include <sstream>
m1.add_motifs(motifs, colors);
BOOST_CHECK_EQUAL( first_size, m1.motifs().size() );
}
+
+static void
+local_align_test(const vector<Sequence> &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') )
+ ('T', assign::list_of('T')('A') )
+ ('G', assign::list_of('G')('C') )
+ ('C', assign::list_of('C')('G') );
+ list<vector<bool> >::const_iterator rc_i = reversed.begin();
+
+ for(list<ConservedPath::path_type>::const_iterator base_i = result.begin();
+ base_i != result.end();
+ ++base_i, ++rc_i)
+ {
+ // since the reverse compliment flag is relative to the first sequence
+ // the first one should always be false
+ BOOST_CHECK_EQUAL( (*rc_i)[0], false );
+ const int first_path_basepair_index = (*base_i)[0];
+ const int second_path_basepair_index = (*base_i)[1];
+ const char first_basepair = seqs[0][first_path_basepair_index];
+ const char second_basepair = seqs[1][second_path_basepair_index];
+ // get our index into our reverse compliment map m
+ const int second_compliment_index = (*rc_i)[1];
+ // lookup the forward or reverse compliment depending on our rc flag
+ const char complimented_second = m[second_basepair][second_compliment_index];
+
+ BOOST_CHECK_EQUAL( first_basepair, complimented_second) ;
+ }
+}
+
+
+BOOST_AUTO_TEST_CASE( local_alignment )
+{
+ string s0("GCGCATAT");
+ string s1("AAAAAAAT");
+ Sequence seq1(s1);
+
+ Mussa analysis;
+ analysis.add_a_seq(s0);
+ analysis.add_a_seq(s1);
+ analysis.analyze(4,3);
+ NwayPaths npath = analysis.paths();
+ list<ConservedPath::path_type> result;
+ list<vector<bool> > reversed;
+ 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);
+
+ local_align_test(analysis.sequences(), result, reversed);
+
+ ++pathz_i;
+ result.clear();
+ reversed.clear();
+ selected_paths.clear();
+ selected_paths.push_back(*pathz_i);
+ analysis.createLocalAlignment(selected_paths.begin(),
+ selected_paths.end(),
+ result,
+ reversed);
+ local_align_test(analysis.sequences(), result, reversed);
+
+
+}
+
+