1 #include <boost/test/auto_unit_test.hpp>
2 #include <boost/assign/std/vector.hpp>
3 using namespace boost::assign;
5 #include <boost/shared_ptr.hpp>
11 #include "alg/annotation_colors.hpp"
12 #include "alg/glseqbrowser.hpp"
13 #include "alg/sequence.hpp"
17 BOOST_AUTO_TEST_CASE ( gltracks_connect )
19 string s0("AAGGCCTT");
20 string s1("TTGGCCAA");
21 string s2("GATTACAA");
27 gt.push_sequence(seq0);
28 gt.push_sequence(seq1);
29 gt.push_sequence(seq2);
31 // make up some sample data
33 rc += false, false, false;
35 path += 1,1,1; gt.link(path, rc, 1);
36 path.clear(); path += 1,1,3; gt.link(path, rc, 1);
37 path.clear(); path += 2,3,3; gt.link(path, rc, 1);
38 path.clear(); path += 3,3,3; gt.link(path, rc, 1);
40 BOOST_CHECK_EQUAL( gt.path_segments.size(), 2 );
41 GlSeqBrowser::segment_key p(1, 1);
42 GlSeqBrowser::pair_segment_map::iterator psm_i = gt.path_segments[0].find(p);
43 BOOST_CHECK( psm_i != gt.path_segments[0].end() );
44 BOOST_CHECK_EQUAL( psm_i->second.path_ids.size(), 2 );
47 BOOST_CHECK_EQUAL( gt.path_segments.size(), 0 );
50 BOOST_AUTO_TEST_CASE( glseqbrowser_center )
52 string s0("AAGGCCTT");
53 string s1("TTGGCCAA");
54 string s2("GATTACAA");
55 boost::shared_ptr<Sequence> seq0(new Sequence(s0));
56 boost::shared_ptr<Sequence> seq1(new Sequence(s1));
57 boost::shared_ptr<Sequence> seq2(new Sequence(s2));
58 boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
59 GlSequence glseq0(seq0, cm);
60 GlSequence glseq1(seq1, cm);
61 GlSequence glseq2(seq2, cm);
64 gt.push_sequence(glseq0);
65 gt.push_sequence(glseq1);
66 gt.push_sequence(glseq2);
71 BOOST_CHECK_EQUAL( gt.left(), -gt.border() );
72 BOOST_CHECK_EQUAL( gt.right(), s0.size() + gt.border() );
74 gt.centerOnPath(path);
76 // I didn't bother to compute how the path should shift things
77 // by the magic number 3, i just ran the test and saw how it failed
78 // and hard coded this in.
79 BOOST_CHECK_EQUAL( gt.left(), -18-gt.border() );
80 BOOST_CHECK_EQUAL( gt.right(), s0.size() + gt.border()-11 );
82 // aparently we end up with a different glsequence in the seqbrowser
83 BOOST_CHECK( glseq1.x() != gt.sequences()[1].x() );
85 BOOST_CHECK_EQUAL( gt.sequences()[0].x(), (gt.viewportCenter()-15)-path[0] );
86 BOOST_CHECK_EQUAL( gt.sequences()[1].x(), (gt.viewportCenter()-15)-path[1] );
87 BOOST_CHECK_EQUAL( gt.sequences()[2].x(), (gt.viewportCenter()-15)-path[2] );