4 #include <boost/test/auto_unit_test.hpp>
5 #include <boost/filesystem/operations.hpp>
6 #include <boost/filesystem/path.hpp>
9 #include "alg/sequence.hpp"
13 BOOST_AUTO_TEST_CASE( flp_simple )
17 f.seqcomp("AAGGTAAGGT", "AAGGTAAGGT", false);
19 // are the match_locations correct?
20 for (int i=0; i != f.size(); i++)
22 std::list<int> window_locations = f.match_locations(i);
23 std::list<FLPs::match> window_matches = f.matches(i);
24 std::list<int>::iterator loc_i = window_locations.begin();
25 std::list<FLPs::match>::iterator match_i = window_matches.begin();
26 for (; loc_i != window_locations.end(); ++loc_i, ++match_i)
28 // I'm missing pythons easy lists and in operator here.
29 if (i == 0) BOOST_CHECK( *loc_i == 0 || *loc_i == 5);
30 else if (i == 1) BOOST_CHECK( *loc_i == 1 || *loc_i == 6);
31 else if (i == 2) BOOST_CHECK( *loc_i == 2 );
32 else if (i == 3) BOOST_CHECK( *loc_i == 3 );
33 else if (i == 4) BOOST_CHECK( *loc_i == 4 );
34 else if (i == 6) BOOST_CHECK( *loc_i == 5 || *loc_i == 0);
35 BOOST_CHECK_EQUAL( *loc_i, match_i->index );
40 BOOST_AUTO_TEST_CASE( flp_save )
42 std::string seq("AAGGCCTTAAGGCCTT");
47 f1.seqcomp(seq, seq, false);
48 std::string fname("flp_save_this_is_a_horrible_filename_because_"
49 "im_too_lazy_to_write_a_portable_mktmp.flp");
53 boost::filesystem::remove( boost::filesystem::path(fname) );
55 BOOST_CHECK_EQUAL( f1.size(), seq.size()-win_size+1);
56 BOOST_CHECK_EQUAL( f2.size(), seq.size()-win_size+1);
57 BOOST_CHECK_EQUAL( f1.size(), f2.size() );
58 for (int win=0; win < f1.size(); ++win)
60 std::list<FLPs::match> f1_matches = f1.matches(win);
61 std::list<FLPs::match> f2_matches = f2.matches(win);
62 std::list<FLPs::match>::const_iterator f1_match_i = f1_matches.begin();
63 std::list<FLPs::match>::const_iterator f2_match_i = f2_matches.begin();
65 f1_match_i != f1_matches.end() && f2_match_i != f2_matches.end();
66 ++f1_match_i, ++f2_match_i)
68 BOOST_CHECK_EQUAL( *f1_match_i, *f2_match_i);
73 /*! Apparently when we run multiple seqcomps we want to
74 * save all the FLPs generated
76 BOOST_AUTO_TEST_CASE( flp_reverse_compliment )
79 Sequence s1("AAAATTTT");
80 Sequence s2("AACAGGGG");
82 f1.seqcomp(s1.get_seq(), s2.get_seq(), false);
83 f1.seqcomp(s1.get_seq(), s2.rev_comp(), true);
87 f2.seqcomp(s1.get_seq(), s2.rev_comp(), true);
88 f2.seqcomp(s1.get_seq(), s2.get_seq(), false);
90 // The order of doing the reverse compliment search shouldn't matter
91 // when we're using exactly the same sequence
92 BOOST_CHECK_EQUAL( f1.size(), f2.size() );
93 for (int i = 0; i < f1.size(); ++i )
95 BOOST_CHECK_EQUAL( f1.matches(i).size(), f2.matches(i).size() );
96 // FIXME: should we test the individual lists?