4 #include <boost/test/auto_unit_test.hpp>
5 #include <boost/filesystem/operations.hpp>
6 #include <boost/filesystem/path.hpp>
7 namespace fs = boost::filesystem;
10 #include "alg/sequence.hpp"
14 #include "mussa_exceptions.hpp"
16 BOOST_AUTO_TEST_CASE( flp_simple )
20 f.seqcomp("AAGGTAAGGT", "AAGGTAAGGT", false);
22 // are the match_locations correct?
23 for (int i=0; i != f.size(); i++)
25 std::list<int> window_locations = f.match_locations(i);
26 std::list<FLPs::match> window_matches = f.matches(i);
27 std::list<int>::iterator loc_i = window_locations.begin();
28 std::list<FLPs::match>::iterator match_i = window_matches.begin();
29 for (; loc_i != window_locations.end(); ++loc_i, ++match_i)
31 // I'm missing pythons easy lists and in operator here.
32 if (i == 0) BOOST_CHECK( *loc_i == 0 || *loc_i == 5);
33 else if (i == 1) BOOST_CHECK( *loc_i == 1 || *loc_i == 6);
34 else if (i == 2) BOOST_CHECK( *loc_i == 2 );
35 else if (i == 3) BOOST_CHECK( *loc_i == 3 );
36 else if (i == 4) BOOST_CHECK( *loc_i == 4 );
37 else if (i == 6) BOOST_CHECK( *loc_i == 5 || *loc_i == 0);
38 BOOST_CHECK_EQUAL( *loc_i, match_i->index );
43 BOOST_AUTO_TEST_CASE( flp_save )
45 std::string seq("AAGGCCTTAAGGCCTT");
50 f1.seqcomp(seq, seq, false);
51 std::string fname("flp_save_this_is_a_horrible_filename_because_"
52 "im_too_lazy_to_write_a_portable_mktmp.flp");
56 boost::filesystem::remove( boost::filesystem::path(fname) );
58 BOOST_CHECK_EQUAL( f1.size(), seq.size()-win_size+1);
59 BOOST_CHECK_EQUAL( f2.size(), seq.size()-win_size+1);
60 BOOST_CHECK_EQUAL( f1.size(), f2.size() );
61 for (int win=0; win < f1.size(); ++win)
63 std::list<FLPs::match> f1_matches = f1.matches(win);
64 std::list<FLPs::match> f2_matches = f2.matches(win);
65 std::list<FLPs::match>::const_iterator f1_match_i = f1_matches.begin();
66 std::list<FLPs::match>::const_iterator f2_match_i = f2_matches.begin();
68 f1_match_i != f1_matches.end() && f2_match_i != f2_matches.end();
69 ++f1_match_i, ++f2_match_i)
71 BOOST_CHECK_EQUAL( *f1_match_i, *f2_match_i);
76 /*! Apparently when we run multiple seqcomps we want to
77 * save all the FLPs generated
79 BOOST_AUTO_TEST_CASE( flp_reverse_compliment )
82 Sequence s1("AAAATTTT");
83 Sequence s2("AACAGGGG");
85 f1.seqcomp(s1.get_seq(), s2.get_seq(), false);
86 f1.seqcomp(s1.get_seq(), s2.rev_comp(), true);
90 f2.seqcomp(s1.get_seq(), s2.rev_comp(), true);
91 f2.seqcomp(s1.get_seq(), s2.get_seq(), false);
93 // The order of doing the reverse compliment search shouldn't matter
94 // when we're using exactly the same sequence
95 BOOST_CHECK_EQUAL( f1.size(), f2.size() );
96 for (int i = 0; i < f1.size(); ++i )
98 BOOST_CHECK_EQUAL( f1.matches(i).size(), f2.matches(i).size() );
99 // FIXME: should we test the individual lists?
103 BOOST_AUTO_TEST_CASE( flp_file_check )
105 fs::path filename = "Thy_micturations_are_to_me_as_plurdled_gabbleblotchits";
107 BOOST_CHECK_THROW( f1.load(filename), mussa_load_error);