load and display a motif list
[mussa.git] / alg / glsequence.cpp
index 62896aaea62674578cdb167848048f2baa13ef9b..674dcb0ea819a319d9b95d3c734e258f0cbf0f04 100644 (file)
@@ -6,23 +6,25 @@
 #include <stdexcept>
 using namespace std;
 
-GlSequence::GlSequence(const Sequence &s) 
+GlSequence::GlSequence(const Sequence &s, AnnotationColors& cm
   : seq(s),
     seq_x(0.0), 
     seq_y(0.0), 
     seq_z(1.0), 
     seq_height(12.0),
+    color_mapper(cm),
     drawColor(0.0, 0.0, 0.0),
     char_pix_per_world_unit(5.0)
 {
 }
 
-GlSequence::GlSequence(const GlSequence &s) 
+GlSequence::GlSequence(const GlSequence &s)
   : seq(s.seq),
     seq_x(s.seq_x),
     seq_y(s.seq_y),
     seq_z(s.seq_z),
     seq_height(s.seq_height),
+    color_mapper(s.color_mapper),
     drawColor(s.drawColor),
     char_pix_per_world_unit(s.char_pix_per_world_unit)
 {
@@ -36,6 +38,7 @@ GlSequence &GlSequence::operator=(const GlSequence & s)
     seq_y = s.seq_y;
     seq_z = s.seq_z;
     seq_height = s.seq_height;
+    color_mapper = s.color_mapper;
     drawColor = s.drawColor;
     assert(char_pix_per_world_unit == s.char_pix_per_world_unit);
   }
@@ -203,7 +206,8 @@ void GlSequence::draw_annotations(GLfloat left, GLfloat right) const
   // draw annotations
   glLineWidth(seq_height);
   GLfloat annotation_z = seq_z + 1.0;
-  std::list<annot> annots = seq.annotations();
+  const std::list<annot>& annots = seq.annotations();
+  const std::list<motif>& motifs = seq.motifs();
   for (std::list<annot>::const_iterator annot_itor = annots.begin();
        annot_itor != annots.end();
        ++annot_itor, ++annotation_z)
@@ -212,8 +216,19 @@ void GlSequence::draw_annotations(GLfloat left, GLfloat right) const
     draw_box(seq_x+annot_itor->start, seq_x+annot_itor->end, 
              seq_height, annotation_z);
   }
+  // if motifs?
+  for (std::list<motif>::const_iterator motifs_itor = motifs.begin();
+       motifs_itor != motifs.end();
+       ++motifs_itor, ++annotation_z)
+  {
+    glColor3fv(color_mapper.lookup("motif", motifs_itor->sequence).get());
+    draw_box(seq_x+motifs_itor->start, seq_x+motifs_itor->end, 
+             seq_height, annotation_z);
+  }
+
 }
 
+
 const int PT = 1;
 const int STROKE = 2;
 const int END =3;