1 #include <boost/test/auto_unit_test.hpp>
2 #include <boost/assign/std/vector.hpp>
3 using namespace boost::assign;
9 #include "alg/annotation_colors.hpp"
10 #include "alg/glseqbrowser.hpp"
11 #include "alg/sequence.hpp"
15 BOOST_AUTO_TEST_CASE ( gltracks_connect )
17 string s0("AAGGCCTT");
18 string s1("TTGGCCAA");
19 string s2("GATTACAA");
25 gt.push_sequence(seq0);
26 gt.push_sequence(seq1);
27 gt.push_sequence(seq2);
29 // make up some sample data
31 rc += false, false, false;
33 path += 1,1,1; gt.link(path, rc, 1);
34 path.clear(); path += 1,1,3; gt.link(path, rc, 1);
35 path.clear(); path += 2,3,3; gt.link(path, rc, 1);
36 path.clear(); path += 3,3,3; gt.link(path, rc, 1);
38 BOOST_CHECK_EQUAL( gt.path_segments.size(), 2 );
39 GlSeqBrowser::segment_key p(1, 1);
40 GlSeqBrowser::pair_segment_map::iterator psm_i = gt.path_segments[0].find(p);
41 BOOST_CHECK( psm_i != gt.path_segments[0].end() );
42 BOOST_CHECK_EQUAL( psm_i->second.path_ids.size(), 2 );
45 BOOST_CHECK_EQUAL( gt.path_segments.size(), 0 );
48 BOOST_AUTO_TEST_CASE( glseqbrowser_center )
50 string s0("AAGGCCTT");
51 string s1("TTGGCCAA");
52 string s2("GATTACAA");
57 GlSequence glseq0(seq0, cm);
58 GlSequence glseq1(seq1, cm);
59 GlSequence glseq2(seq2, cm);
62 gt.push_sequence(glseq0);
63 gt.push_sequence(glseq1);
64 gt.push_sequence(glseq2);
69 BOOST_CHECK_EQUAL( gt.left(), -gt.border() );
70 BOOST_CHECK_EQUAL( gt.right(), s0.size() + gt.border() );
72 gt.centerOnPath(path);
74 // I didn't bother to compute how the path should shift things
75 // by the magic number 3, i just ran the test and saw how it failed
76 // and hard coded this in.
77 BOOST_CHECK_EQUAL( gt.left(), -3-gt.border() );
78 BOOST_CHECK_EQUAL( gt.right(), 3 + s0.size() + gt.border() );
80 // aparently we end up with a different glsequence in the seqbrowser
81 BOOST_CHECK( glseq1.x() != gt.sequences()[1].x() );
83 BOOST_CHECK_EQUAL( gt.sequences()[0].x(), gt.viewportCenter()-path[0] );
84 BOOST_CHECK_EQUAL( gt.sequences()[1].x(), gt.viewportCenter()-path[1] );
85 BOOST_CHECK_EQUAL( gt.sequences()[2].x(), gt.viewportCenter()-path[2] );