attach motifs to a sequence object
[mussa.git] / alg / test / test_sequence.cpp
index 6b06b46010467b74b5c85afdb35d61a6bc829991..0a5cab28e87d11c06430b8cb7bd7d2dee64c683f 100644 (file)
@@ -1,8 +1,12 @@
 #include <boost/test/auto_unit_test.hpp>
+#include <list>
+#include <iostream>
 
 #include "alg/sequence.hpp"
 #include "mussa_exceptions.hpp"
 
+using namespace std;
+
 //! when we try to load a missing file, do we get an error?
 BOOST_AUTO_TEST_CASE( sequence_load_exception )
 {
@@ -88,3 +92,51 @@ BOOST_AUTO_TEST_CASE ( sequence_iterators )
   BOOST_CHECK_EQUAL( s.size(), count );
   BOOST_CHECK_EQUAL( cs.size(), count );
 }
+
+BOOST_AUTO_TEST_CASE( sequence_motifs )
+{
+  string m("AAAA");
+  string bogus("AATTGGAA");
+  Sequence s1("AAAAGGGGCCCCTTTT");
+
+  list<motif>::const_iterator motif_i = s1.motifs().begin();
+  list<motif>::const_iterator motif_end = s1.motifs().end();
+
+  // do our iterators work?
+  BOOST_CHECK( motif_i == s1.motifs().begin() );
+  BOOST_CHECK( motif_end == s1.motifs().end() );
+  BOOST_CHECK( motif_i == motif_end );
+
+
+  s1.add_motif(bogus);
+  BOOST_CHECK( s1.motifs().begin() == s1.motifs().end() );
+  s1.add_motif(m);
+  BOOST_CHECK( s1.motifs().begin() != s1.motifs().end() );
+  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, m);
+    BOOST_CHECK_EQUAL( motif_i->sequence, m);
+  }
+
+}
+
+BOOST_AUTO_TEST_CASE( annot_test )
+{
+  annot a(0, 10, "test", "thing");
+
+  BOOST_CHECK_EQUAL( a.start, 0 );
+  BOOST_CHECK_EQUAL( a.end,   10 );
+  BOOST_CHECK_EQUAL( a.type,  "test" );
+  BOOST_CHECK_EQUAL( a.name,  "thing" );
+
+  motif m(10, "AAGGCC");
+  BOOST_CHECK_EQUAL( m.start, 10 );
+  BOOST_CHECK_EQUAL( m.type, "motif" );
+  BOOST_CHECK_EQUAL( m.name, "AAGGCC" );
+  BOOST_CHECK_EQUAL( m.end,  10+6 );
+}