From: Diane Trout Date: Fri, 13 Apr 2007 18:44:48 +0000 (+0000) Subject: Mark real sequence instead of Ns X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=55f0a3e9612b3e1df2c588682d7f605203eab421 Mark real sequence instead of Ns Since Mussa forces all annotations to be at least 1 pixel, marking where the real sequence is located is visually clearer. --- diff --git a/alg/glseqbrowser.cpp b/alg/glseqbrowser.cpp index 5accb2c..107099b 100644 --- a/alg/glseqbrowser.cpp +++ b/alg/glseqbrowser.cpp @@ -355,8 +355,8 @@ void GlSeqBrowser::push_sequence(GlSequence gs) void GlSeqBrowser::push_sequence(GlSequenceRef gs) { GlSequenceRef new_gs(new GlSequence(gs)); - // mark where the undefined sequence is - new_gs->add_annotations_for_undefined_sequence(draw_narrow_track); + // mark where the sequence is + new_gs->add_annotations_for_defined_sequence(draw_track); clear_links(); track_container.push_back(new_gs); diff --git a/alg/glsequence.cpp b/alg/glsequence.cpp index 6c8b12b..c77c29b 100644 --- a/alg/glsequence.cpp +++ b/alg/glsequence.cpp @@ -85,7 +85,7 @@ SeqSpanRef GlSequence::make_undefined_sequence_annotation( return empty_seq; } -void GlSequence::add_annotations_for_undefined_sequence(Drawable::draw_func_ptr draw) +void GlSequence::add_annotations_for_defined_sequence(Drawable::draw_func_ptr draw) { Sequence::const_iterator start_i = begin(); Sequence::const_iterator seq_i = begin(); @@ -95,7 +95,7 @@ void GlSequence::add_annotations_for_undefined_sequence(Drawable::draw_func_ptr for(; seq_i != end_i; ++seq_i) { // need a better set of characters to serch for - if (*seq_i == 'N' or *seq_i == 'n') { + if (not (*seq_i == 'N' or *seq_i == 'n')) { if (start_block_i == end_i) { start_block_i = seq_i; } @@ -280,7 +280,8 @@ void GlSequence::draw(GLfloat left, GLfloat right) const void GlSequence::draw_box(GLfloat world_left, GLfloat world_right, GLfloat left, GLfloat right, - GLfloat height, GLfloat y, GLfloat z) + GLfloat height, GLfloat y, GLfloat z, + GLint primitive) { GLfloat pixel_width = pixelWidth(world_left, world_right); GLfloat offset = height/2.0; @@ -291,7 +292,7 @@ void GlSequence::draw_box(GLfloat world_left, GLfloat world_right, if ((right-left) < pixel_width) { right = left + pixel_width; } - glBegin(GL_QUADS); + glBegin(primitive); glVertex3f(left, top, z); glVertex3f(left, bottom, z); glVertex3f(right, bottom, z); @@ -303,7 +304,7 @@ void GlSequence::draw_track(GLfloat left, GLfloat right) const { glColor3fv(color()->get()); // draw main sequence track - draw_box(left, right, x(), x()+Sequence::size(), height(), y(), 0.0); + draw_box(left, right, x(), x()+Sequence::size(), height(), y(), 0.0, GL_LINE_LOOP); } void GlSequence::draw_annotations(GLfloat left, GLfloat right) const @@ -465,8 +466,22 @@ void draw_narrow_track(SeqSpanRef s, float left, float right) float z( (parent_draw) ? parent_draw->z() : 10 ); float height( (parent_draw) ? parent_draw->height() : default_height ); - glColor3f(1.0, 1.0, 1.0); - float hsmall = height * 3.0/4.0; + glColor3f(0.0, 0.0, 0.0); + float hsmall = height * 0.5; GlSequence::draw_box(left, right, x+s->start(), x+s->stop(), hsmall, y, z+10); +} + +void draw_track(SeqSpanRef s, float left, float right) +{ + SeqSpanRef parent(s->parent()); + DrawableRef parent_draw(parent->drawable()); + float x( (parent_draw) ? parent_draw->x() : 0); + float y( (parent_draw) ? parent_draw->y() : 0); + float z( (parent_draw) ? parent_draw->z() : 10 ); + float height( (parent_draw) ? parent_draw->height() : default_height ); + + glColor3f(0.0, 0.0, 0.0); + GlSequence::draw_box(left, right, x+s->start(), x+s->stop(), + height, y, z+10); } \ No newline at end of file diff --git a/alg/glsequence.hpp b/alg/glsequence.hpp index 190401a..b772cd2 100644 --- a/alg/glsequence.hpp +++ b/alg/glsequence.hpp @@ -36,7 +36,7 @@ public: static DrawableRef copy_drawable(DrawableRef s); //! search through sequence and add an annotation highlighting all the non AGCT characters - void add_annotations_for_undefined_sequence(Drawable::draw_func_ptr draw=0); + void add_annotations_for_defined_sequence(Drawable::draw_func_ptr draw=0); //! set our starting x (horizontal) coordinate void setX(float x); //! get our starting x (horizontal) coordinate @@ -63,7 +63,8 @@ public: static void draw_box(GLfloat world_left, GLfloat world_right, GLfloat left, GLfloat right, GLfloat height, - GLfloat y, GLfloat z); + GLfloat y, GLfloat z, + GLint primitive=GL_QUADS); //! draw a track /*! left and right are the edges of the current viewport */ @@ -129,5 +130,6 @@ protected: void draw_sequence(GLfloat, GLfloat) const; }; +void draw_track(SeqSpanRef ref, float left, float right); void draw_narrow_track(SeqSpanRef ref, float left, float right); #endif diff --git a/alg/test/test_glsequence.cpp b/alg/test/test_glsequence.cpp index 0c00fb1..120a3f6 100644 --- a/alg/test/test_glsequence.cpp +++ b/alg/test/test_glsequence.cpp @@ -74,18 +74,18 @@ BOOST_AUTO_TEST_CASE( glsequence_color ) BOOST_CHECK_EQUAL( *(s.color()), *c ); } -BOOST_AUTO_TEST_CASE( glsequence_find_null_sequence ) +BOOST_AUTO_TEST_CASE( glsequence_find_real_sequence ) { boost::shared_ptr cm(new AnnotationColors); - GlSequence s("AAAAAAAAAANNNNNANAN", cm); + GlSequence s("AAAAAAAAAANNNNNANNA", cm); // 0123456789012345678 - s.add_annotations_for_undefined_sequence(); + s.add_annotations_for_defined_sequence(); BOOST_CHECK_EQUAL(s.annotations().size(), 3); std::vector annot(s.annotations().begin(), s.annotations().end()); - BOOST_CHECK_EQUAL(annot[0]->start(), 10); - BOOST_CHECK_EQUAL(annot[0]->stop(), 15); - BOOST_CHECK_EQUAL(annot[1]->start(), 16); + BOOST_CHECK_EQUAL(annot[0]->start(), 0); + BOOST_CHECK_EQUAL(annot[0]->stop(), 10); + BOOST_CHECK_EQUAL(annot[1]->start(), 15); BOOST_CHECK_EQUAL(annot[1]->size(), 1); BOOST_CHECK_EQUAL(annot[2]->start(), 18); BOOST_CHECK_EQUAL(annot[2]->size(), 1); diff --git a/qui/seqbrowser/test/TestSequenceBrowserWidget.hpp b/qui/seqbrowser/test/TestSequenceBrowserWidget.hpp index cf60757..d810f7b 100644 --- a/qui/seqbrowser/test/TestSequenceBrowserWidget.hpp +++ b/qui/seqbrowser/test/TestSequenceBrowserWidget.hpp @@ -132,14 +132,16 @@ private slots: SequenceBrowserWidget *b1 = new SequenceBrowserWidget(d); b1->setSequences(seqs, cm ); QVERIFY( b1->sequences().size() == 2); - QVERIFY( b1->sequences()[0]->annotations().size() == 1 ); + // annotations().size() now always has the base + // where is the sequence annotation + QVERIFY( b1->sequences()[0]->annotations().size() == 2 ); QVERIFY( b1->sequences()[0]->seqspan() == b1->sequences()[0]->annotations().front()->parent() ); SequenceBrowserWidget *b2 = new SequenceBrowserWidget(d); b2->setSequences(seqs, cm); - QVERIFY( b2->sequences()[0]->annotations().size() == 1 ); + QVERIFY( b2->sequences()[0]->annotations().size() == 2 ); QVERIFY( b2->sequences()[0]->seqspan() == b2->sequences()[0]->annotations().front()->parent() ); }