Mark real sequence instead of Ns
authorDiane Trout <diane@caltech.edu>
Fri, 13 Apr 2007 18:44:48 +0000 (18:44 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 13 Apr 2007 18:44:48 +0000 (18:44 +0000)
Since Mussa forces all annotations to be at least 1 pixel, marking where the real
sequence is located is visually clearer.

alg/glseqbrowser.cpp
alg/glsequence.cpp
alg/glsequence.hpp
alg/test/test_glsequence.cpp
qui/seqbrowser/test/TestSequenceBrowserWidget.hpp

index 5accb2cd0dc2bc89342b977c6e810a66409d5306..107099bd824105df653a994699472f3a122cf2fb 100644 (file)
@@ -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);
index 6c8b12b80410418e2e8bc2c0ec537a574724283a..c77c29b5369a4acf5ab72d2981c16e3f2d403d08 100644 (file)
@@ -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
index 190401a956644ddc3aed36af42857be5bba7715f..b772cd2fa75e77510e1c2128fd2f5af5db4f06d9 100644 (file)
@@ -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
index 0c00fb1271857e79c631ad0ab445600eaeacee85..120a3f6d238a664a55678f08bee4a4aa029704f8 100644 (file)
@@ -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<AnnotationColors> 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<SeqSpanRef> 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);
index cf60757b82b1e226134c42144b66cded96711486..d810f7b1d97c276e73f8b4bf0a7f5b826d62fd56 100644 (file)
@@ -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() );
   }