View sequence alignment at non default thresholds
[mussa.git] / alg / test / test_nway.cpp
1 #include <boost/test/auto_unit_test.hpp>
2
3 #include <string>
4 #include <iostream>
5
6 #include "alg/mussa.hpp"
7 #include "alg/nway_paths.hpp"
8 #include "alg/sequence.hpp"
9
10 using namespace std;
11
12 //! there should be no matches
13 BOOST_AUTO_TEST_CASE( nway_null )
14 {
15   string s0("AAAANNNN");
16   string s1("GGGGNNNN");
17   string s2("TTTTNNNN");
18
19   Mussa analysis;
20   analysis.add_a_seq(s0);
21   analysis.add_a_seq(s1);
22   analysis.add_a_seq(s2);
23   analysis.analyze(4,3);
24   NwayPaths npath = analysis.paths();
25   // there should be no paths for these sequences
26   for (std::list<ConservedPath >::iterator pathz_i = npath.pathz.begin();
27        pathz_i != npath.pathz.end();
28        ++pathz_i)
29   {
30     BOOST_CHECK_EQUAL( pathz_i->size(), 0);
31   }
32 }
33
34 BOOST_AUTO_TEST_CASE( nway_test )
35 {
36   string s0("ATATGCGC");
37   string s1("GGGGGGGC");
38   Sequence seq1(s1);
39
40   Mussa analysis;
41   analysis.add_a_seq(s0);
42   analysis.add_a_seq(s1);
43   analysis.analyze(4,3);
44   NwayPaths npath = analysis.paths();
45   for (std::list<ConservedPath >::iterator pathz_i = npath.pathz.begin();
46        pathz_i != npath.pathz.end();
47        ++pathz_i)
48   {
49     for( ConservedPath::iterator path_i = pathz_i->begin();
50          path_i != pathz_i->end();
51          ++path_i)
52     {      
53       BOOST_CHECK( *path_i == 4 || *path_i == -4);
54     }
55   }
56 }
57
58 #include <unistd.h>
59 BOOST_AUTO_TEST_CASE( nway_refine )
60 {
61   Mussa m1;
62   m1.load_mupa_file( "examples/mck3test.mupa" );
63   m1.analyze(0, 0);
64   const NwayPaths& npath = m1.paths();
65   BOOST_CHECK_EQUAL (npath.path_size(), npath.refined_path_size());
66   size_t first_refined_size = npath.refined_path_size();
67   BOOST_CHECK( first_refined_size > 0 );
68
69   // we're using a window size 30 (threshold 20) example
70   m1.set_soft_thres(22);
71   m1.nway();
72   BOOST_CHECK( npath.refined_path_size() > 0);
73   BOOST_CHECK( npath.refined_path_size() < first_refined_size);
74
75   m1.set_soft_thres(20);
76   m1.nway();
77   BOOST_CHECK_EQUAL(npath.refined_path_size(), first_refined_size);
78 }