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