show conservation paths
authorDiane Trout <diane@caltech.edu>
Tue, 28 Feb 2006 09:19:32 +0000 (09:19 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 28 Feb 2006 09:19:32 +0000 (09:19 +0000)
This patch draws the windows of conservation between the various sequences.
Getting this to work also required making a number of member functions
properly const.

alg/mussa_class.cxx
alg/mussa_class.hh
qui/GlSequence.cxx
qui/GlSequence.h
qui/PathScene.cxx
qui/PathScene.h
test/test_nway.cxx

index 64286aa04d07a02496ead24361257de6358928a1..c69b97757b124ef877e587178399412c1fb27fc0 100644 (file)
@@ -126,7 +126,7 @@ string Mussa::get_analysis_mode_name() const
   }
 }
 
-Nway_Paths& Mussa::get_paths()
+const Nway_Paths& Mussa::paths() const
 {
   return the_paths;
 }
index dcbda559abd39022ac9d182ca02870c2ae3841ff..428001c12e1a058f8f76f32521434a295dd8ca65 100644 (file)
@@ -66,7 +66,7 @@ class Mussa
     std::string get_analysis_mode_name() const;
 
     //! return the refined paths found by the nway analysis.
-    Nway_Paths& get_paths();
+    const Nway_Paths& paths() const;
 
     //! run seqcomp and the nway filtering algorithm.
     /*!analyze will run seqcomp and then the nway algorithm
index c206bd43f94f7a837bc707227a7af35e4115c222..4b3e46196581eec04a7345533f4134e405a40e37 100644 (file)
@@ -36,7 +36,7 @@ GlSequence &GlSequence::operator=(const GlSequence & s)
   return *this;
 }
 
-const Sequence &GlSequence::sequence()
+const Sequence &GlSequence::sequence() const
 {
   return seq;
 }
@@ -46,7 +46,7 @@ void GlSequence::setX(GLfloat value)
   seq_x = value;
 }
 
-GLfloat GlSequence::x()
+GLfloat GlSequence::x() const
 {
   return seq_x;
 }
@@ -56,7 +56,7 @@ void GlSequence::setY(GLfloat value)
   seq_y = value;
 }
 
-GLfloat GlSequence::y()
+GLfloat GlSequence::y() const
 {
   return seq_y;
 }
@@ -66,7 +66,7 @@ void GlSequence::setWidth(GLfloat value)
   seq_width = value;
 }
 
-GLfloat GlSequence::width()
+GLfloat GlSequence::width() const
 {
   return seq_width;
 }
index 519465b21ac7633084a5b7ea1d10684fac29a555..798ac53aab4b85f0501548cc14efaafce13b3519 100644 (file)
@@ -17,13 +17,13 @@ public:
 
   void draw() const;
 
-  const Sequence &sequence();
+  const Sequence &sequence() const;
   void setX(GLfloat);
-  GLfloat x();
+  GLfloat x() const;
   void setY(GLfloat);
-  GLfloat y();
+  GLfloat y() const;
   void setWidth(GLfloat);
-  GLfloat width();
+  GLfloat width() const;
 
 private:
   const Sequence& seq;
index b221b7b0502b0181612d260143fccda077c1d2f3..5016203c019d1bb4e7aa93c261dfea3fa7b99715 100644 (file)
@@ -26,9 +26,9 @@ PathScene::PathScene(int frags, int len, QWidget *parent) :
   drawingBand(false)
 { 
   // Hack in loading an analysis 
-  //mussaAnalysis.load_mupa_file( "examples/mck3test.mupa" );
-  //mussaAnalysis.analyze();
-  mussaAnalysis.load("mck3test_w30_t20");
+  mussaAnalysis.load_mupa_file( "examples/mck3test.mupa" );
+  mussaAnalysis.analyze(0, 0, Mussa::TransitiveNway, 0.0);
+  //mussaAnalysis.load("mck3test_w30_t20");
   updateAnalysis();
 }
 
@@ -93,6 +93,15 @@ void PathScene::setClipPlane(int newZ)
   }
 }
 
+void PathScene::setSoftThreshold(int threshold)
+{
+  if (mussaAnalysis.get_threshold() != threshold) {
+    mussaAnalysis.set_soft_thres(threshold);
+    mussaAnalysis.nway();
+    update();
+  }
+}
+
 void PathScene::initializeGL()
 {
   glEnable(GL_DEPTH_TEST|GL_BLEND);
@@ -133,7 +142,7 @@ void PathScene::paintGL()
             previousBand.right(), previousBand.bottom());
   }
   glTranslatef(-X*1000, 0.0, 0.0);
-  mussaesque(fragsize, length);
+  mussaesque();
 
   glPopMatrix();
   glFlush();
@@ -250,7 +259,7 @@ void PathScene::mouseReleaseEvent( QMouseEvent *e)
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
  
-  mussaesque(fragsize,  length);
+  mussaesque();
   glFlush();
 
   glPopMatrix();
@@ -264,17 +273,7 @@ void PathScene::mouseReleaseEvent( QMouseEvent *e)
 //////
 // openGl rendering code
 
-static void seq_track(long length, long height)
-{
-  glLineWidth(5);
-  glColor3f(0.9, 0.6, 0.9);
-  glBegin(GL_LINES);
-    glVertex3f(0.0, (GLfloat)height, -1.0);
-    glVertex3f((GLfloat)length, (GLfloat)height, -1.0);
-  glEnd();
-}
-
-void PathScene::draw_tracks()
+void PathScene::draw_tracks() const
 {
   glPushMatrix();
   for (vector<GlSequence>::size_type i = 0; i != tracks.size(); ++i )
@@ -285,61 +284,66 @@ void PathScene::draw_tracks()
   glPopMatrix();
 }
 
-static void draw_lines(int fragsize, int length)
+void PathScene::draw_lines() const
 {
-  float depth = 30;
-
-  glColor3f(0.3, 0.9, 0.3);
-  glLineWidth(0.001);
   GLfloat x;
-  GLfloat z;
-  const long short_sequence_len = 1800000;
-  long blocks = short_sequence_len / fragsize;
-  for (long base_block=0; base_block < blocks; ++base_block)
+  GLfloat y; 
+  const Nway_Paths& nway = mussaAnalysis.paths();
+
+  glLineWidth(0.1);
+  glColor3f(0.9, 0.0, 0.0);
+  vector<GlSequence>::const_iterator track_itor;
+  // To use the refined_pathz, change pathz to refined_pathz, and
+  // change path_itor->begin() to path_itor->begin()+1
+  for(list<vector<int> >::const_iterator path_itor = nway.pathz.begin();
+      path_itor != nway.pathz.end();
+      ++path_itor)
   {
-    for (long base_offset=0; base_offset < length; ++base_offset)
+    track_itor = tracks.begin();
+    glBegin(GL_LINE_STRIP);
+    for (vector<int>::const_iterator sp_itor = path_itor->begin();
+         sp_itor != path_itor->end();
+         ++sp_itor, ++track_itor)
     {
-      glBegin(GL_LINE_STRIP);
-      x = (GLfloat)(base_block * fragsize +base_offset);
-
-      depth -= 0.1;
-      if (depth < 20.0) depth = 30.0;
-
-      z = -22.0 - (30-ceil(depth));
-
-      //std::cout << "Z: " << z << "\n";
-
-      glVertex3f(x, 0.0, z );
-      glVertex3f(x+200000.0, 100, z );
-      glVertex3f(x+100.0, 200, z );
-      glEnd();
+      x = *sp_itor;
+      y = track_itor->y();
+      // at some point when we modify the pathz data structure to keep
+      // track of the score we can put grab the depth here.
+      if (x >= 0) { 
+        glColor3f(0.9, 0.0, 0.0);
+      } else {
+        x *= -1;
+        glColor3f(0.0, 0.0, 0.9);
+      }
+      glVertex3f(x, y, -1.0);
     }
+    glEnd();
   }
 }
 
-static GLuint make_line_list(int fragsize, int length)
+GLuint PathScene::make_line_list()
 {
   GLuint line_list = glGenLists(1);
   glNewList(line_list, GL_COMPILE);
 
-  draw_lines(fragsize, length);
+  draw_lines();
 
   glEndList();
   return line_list;
 
 }
 
-void PathScene::mussaesque(int fragments, int length)
+void PathScene::mussaesque()
 {
-  static GLuint theLines = make_line_list(fragments, length);
+  //static GLuint theLines = make_line_list();
 
   glInitNames();
   glPushName(0);
   draw_tracks();
   glLoadName(10);
   //glCallList(theLines);
+  draw_lines();
   glPopName();
-  //draw_lines();
 }
 
 
index 7f6b014007a764b570f831bac8869b0ab192a6c3..98cc7a35ebefa182f707ae220370f2c7a391897b 100644 (file)
@@ -30,6 +30,8 @@ public slots:
   void setX(int x);
   void setClipPlane(int z);
   void setZoom(int);
+  //! set the soft threshold used by the Nway_Path algorithm
+  void setSoftThreshold(int thres);
   //! called when we've changed the analysis
   void updateAnalysis();
 
@@ -50,9 +52,11 @@ protected:
   void resizeGL(int width, int height);
   void paintGL();
 
-  void mussaesque(int, int);
+  void mussaesque();
   //! draw all of our sequence tracks
-  void draw_tracks();
+  void draw_tracks() const;
+  void draw_lines() const;
+  GLuint make_line_list();
 
 
   //! \defgroup Selection
index 321e40eb211506f72e87ce651fe7ecdd02d08d2b..e72714c2c7ceadf7f7a553577333b161e8e537fa 100644 (file)
@@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE( nway_null )
   analysis.add_a_seq(s1);
   analysis.add_a_seq(s2);
   analysis.analyze(4,3);
-  Nway_Paths npath = analysis.get_paths();
+  Nway_Paths npath = analysis.paths();
   // there should be no paths for these sequences
   for (std::list<std::vector<int> >::iterator pathz_i = npath.pathz.begin();
        pathz_i != npath.pathz.end();
@@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE( nway_test )
   analysis.add_a_seq(s0);
   analysis.add_a_seq(s1);
   analysis.analyze(4,3);
-  Nway_Paths npath = analysis.get_paths();
+  Nway_Paths npath = analysis.paths();
   for (std::list<std::vector<int> >::iterator pathz_i = npath.pathz.begin();
        pathz_i != npath.pathz.end();
        ++pathz_i)