resolve complicated merge conflict
authorDiane Trout <diane@caltech.edu>
Thu, 9 Mar 2006 00:09:49 +0000 (00:09 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 9 Mar 2006 00:09:49 +0000 (00:09 +0000)
Ok so trac-darcs doesn't handle renaming directories that have stuff
in them, so I made a new version of that patch, and then pulled
a the original version on top.

needless to say this led to some merge conflicts. hopefully this patch
resolves those conflicts.

12 files changed:
Makefile.noqt
alg/glsequence.cxx [new file with mode: 0644]
alg/glsequence.h [new file with mode: 0644]
alg/test-conflict/test_conserved_path.cxx [deleted file]
alg/test/module.mk
alg/test/test_conserved_path.cxx [new file with mode: 0644]
alg/test/test_glsequence.cxx
mussagl.pro
qui/GlSequence.cxx [deleted file]
qui/GlSequence.h [deleted file]
qui/PathScene.cxx
qui/PathScene.h

index 0c9e60e6eb47bab264fe3ae1e7e79ba04dc9d332..b2aaecc34477b5d7fff56234022cd81088e2fb2f 100644 (file)
@@ -20,8 +20,9 @@ SRC :=
 all: targets
 
 include alg/module.mk
+include alg/test/module.mk
+include py/module.mk
 include gui/module.mk
-include test/module.mk
 include module.mk
 
 # process what the module.mks defined
diff --git a/alg/glsequence.cxx b/alg/glsequence.cxx
new file mode 100644 (file)
index 0000000..d883a4f
--- /dev/null
@@ -0,0 +1,221 @@
+#include "alg/glsequence.h"
+
+#include <iostream>
+#include <cassert>
+#include <math.h>
+#include <stdexcept>
+using namespace std;
+
+GlSequence::GlSequence(const Sequence &s) 
+  : seq(s),
+    seq_x(0.0), 
+    seq_y(0.0), 
+    seq_z(1.0), 
+    seq_width(s.size()),
+    seq_height(gl_track_height)
+{
+  assert (seq.size() == seq_width);
+}
+
+GlSequence::GlSequence(const GlSequence &s) 
+  : seq(s.seq),
+    seq_x(s.seq_x),
+    seq_y(s.seq_y),
+    seq_z(s.seq_z),
+    seq_width(s.seq_width),
+    seq_height(s.seq_height)
+{
+  assert (seq.size() == seq_width);
+}
+
+GlSequence &GlSequence::operator=(const GlSequence & s)
+{
+  if (this != &s) {
+    const_cast<Sequence &>(seq) = s.seq;
+    seq_x = s.seq_x;
+    seq_y = s.seq_y;
+    seq_z = s.seq_z;
+    seq_width = s.seq_width;
+    seq_height = s.seq_height;
+  }
+  return *this;
+}
+
+const Sequence& GlSequence::sequence() const
+{
+  return seq;
+}
+
+void GlSequence::setX(GLfloat value)
+{
+  seq_x = value;
+}
+
+GLfloat GlSequence::x() const
+{
+  return seq_x;
+}
+
+void GlSequence::setY(GLfloat value)
+{
+  seq_y = value;
+}
+
+GLfloat GlSequence::y() const
+{
+  return seq_y;
+}
+
+void GlSequence::setWidth(GLfloat value)
+{
+  seq_width = value;
+}
+
+GLfloat GlSequence::width() const
+{
+  return seq_width;
+}
+
+
+void GlSequence::draw(GLfloat left, GLfloat right) const
+{
+  glLineWidth(seq_height);
+  glColor3f(0.0, 0.0, 0.0);
+  // draw main sequence track
+  glBegin(GL_LINES);
+    glVertex3f(seq_x,           seq_y, seq_z);
+    glVertex3f(seq_x+seq_width, seq_y, seq_z);
+    //clog << "drawing " << seq_x << " " << seq_y << " " << seq_width
+    //     << std::endl;
+  glEnd();
+  // draw annotations
+  GLfloat annotation_z = seq_z + 1.0;
+  std::list<annot> annots = seq.annotations();
+  for (std::list<annot>::const_iterator annot_itor = annots.begin();
+       annot_itor != annots.end();
+       ++annot_itor, ++annotation_z)
+  {
+    glColor3f(0.0, 0.5, 0.0);
+    glBegin(GL_LINES);
+      glVertex3f(annot_itor->start, seq_y, annotation_z);
+      glVertex3f(annot_itor->end  , seq_y, annotation_z);
+    glEnd();
+  }
+  draw_sequence(left, right);
+}
+
+const int PT = 1;
+const int STROKE = 2;
+const int END =3;
+
+typedef struct charpoint {
+  GLfloat x, y;
+  int type;
+} CP;
+
+CP Adata[] = {
+  {0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT}, 
+  {5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END}
+};
+
+CP Tdata[] = {
+  {2.5, 0, PT}, {2.5,10, STROKE}, {0, 10, PT}, {5,10, END}
+};
+
+CP Gdata[] = {
+  {5, 9, PT}, {4, 10, PT}, {1, 10, PT}, {0, 9, PT}, {0, 1, PT},
+  {1, 0, PT}, {5, 0, PT}, {5, 4, PT}, {3.5, 4, END}
+};
+
+CP Cdata[] = {
+  {5, 8, PT}, {3, 10, PT}, {2, 10, PT}, {0, 8, PT}, {0, 2, PT},
+  {2, 0, PT}, {3, 0, PT}, {5, 2, END}
+};
+
+CP Xdata[] = {{ 0, 10, PT}, {5,0,STROKE},{0,0,PT},{5,10,END}};
+CP Ndata[] = {{ 0, 0, PT}, {0, 10, PT}, {5, 0, PT}, {5, 10, END}};
+
+static void drawLetter(CP *l)
+{
+  glBegin(GL_LINE_STRIP);
+  while(1) {
+    switch (l->type) {
+      case PT:
+        glVertex2fv(&l->x);
+        break;
+      case STROKE:
+        glVertex2fv(&l->x);
+        glEnd();
+        glBegin(GL_LINE_STRIP);
+        break;
+      case END:
+        glVertex2fv(&l->x);
+        glEnd();
+        return;
+        break;
+      default:
+         throw runtime_error("data structure failure");
+    }
+    l++;
+  }
+}
+
+void GlSequence::draw_sequence(GLfloat left, GLfloat right) const
+{
+  int viewport[4];
+  glGetIntegerv(GL_VIEWPORT, viewport);
+  int port_width = viewport[3]; // grab the viewport width
+  GLfloat world_width = right - left;
+  int left_base = (left > 0) ? (int)ceil(left) : 0;
+  int right_base = (int)floor(right);
+  int render_count = (right_base < seq.size()) ? right_base : seq.size(); 
+  render_count -= left_base;
+
+  glLineWidth(0.01);
+  GLfloat char_width = 1.1;
+  GLfloat pixels_needed = char_width * world_width;
+
+  cout << "seq width needed " << pixels_needed 
+       << " port width " << port_width 
+       << " count " << render_count 
+       << " left " << left_base 
+       << " right " << right_base 
+       << " size " << seq.size() << endl;
+  // if the number of pixels taken up by rendering the characters 
+  // that'd show up in the current ortho width is less than the window
+  // width we can actually draw something 
+  if (pixels_needed < port_width and render_count > 0) {
+    cout << "rendering: ";
+    string bases = seq.subseq(left_base, render_count);
+    glColor3f(0.1, 0.1, 0.1);
+    for (string::size_type basepair = 0; basepair != bases.size(); ++basepair) 
+    {
+      glPushMatrix();
+      glTranslatef( left_base + basepair, seq_y+20, 1.0 );
+      glScalef(0.1, 1.0, 1.0);
+      switch (bases[basepair]) {
+        case 'A': case 'a':
+          drawLetter(Adata);
+        break;
+        case 'T': case 't':
+          drawLetter(Tdata);
+        break;
+        case 'G': case 'g':
+          drawLetter(Gdata);
+        break;
+        case 'C': case 'c':
+          drawLetter(Cdata);
+        break;
+        case 'N': case 'n':
+          drawLetter(Ndata);
+        break;
+        default:
+          drawLetter(Xdata);
+        break;
+      }
+      cout << bases[basepair];
+      glPopMatrix();
+    }
+    cout << endl;
+  }
+}
diff --git a/alg/glsequence.h b/alg/glsequence.h
new file mode 100644 (file)
index 0000000..343f9ff
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _GL_SEQUENCE_H_
+#define _GL_SEQUENCE_H_
+
+#include "alg/sequence.hh"
+#include <GL/gl.h>
+
+//! Manage rendering a mussa sequence track
+/*! The idea is this will keep track of the location of where the sequence
+ *  is being rendered, and handle displaying annotations on that track
+ */
+class GlSequence
+{
+public: 
+  GlSequence(const Sequence & s);
+  GlSequence(const GlSequence & s);
+  GlSequence &operator=(const GlSequence &s);
+
+  //! draw a track 
+  /*! left and right are the current edges of the viewable world
+   */
+  void draw(GLfloat left, GLfloat right) const;
+
+  const Sequence& sequence() const;
+  void setX(GLfloat);
+  GLfloat x() const;
+  void setY(GLfloat);
+  GLfloat y() const;
+  void setWidth(GLfloat);
+  GLfloat width() const;
+
+protected:
+  const Sequence& seq;
+  GLfloat seq_x;
+  GLfloat seq_y;
+  GLfloat seq_z;
+  GLfloat seq_width;
+  GLfloat seq_height;
+
+  //! render a sequence (if we have enough space
+  /*! left and right are the current edges of the viewable world
+   */
+  void draw_sequence(GLfloat, GLfloat) const;
+};
+
+const float gl_track_height = 10.0;
+
+#endif
diff --git a/alg/test-conflict/test_conserved_path.cxx b/alg/test-conflict/test_conserved_path.cxx
deleted file mode 100644 (file)
index b248470..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-#include <boost/test/auto_unit_test.hpp>
-#include <boost/assign/std/vector.hpp>
-using namespace boost::assign;
-
-#include <vector>
-using namespace std;
-
-#include "alg/conserved_path.h"
-
-//! write tests for our conserved path types (just to make sure they
-//! don't change on us.
-BOOST_AUTO_TEST_CASE ( conserved_path_simple ) 
-{
-  vector<int> path;
-  path += 3,4,5,1; // magic from boost assign
-
-  ConservedPath cp1;
-  BOOST_CHECK_EQUAL( cp1.size(), 0 ); //empty
-  BOOST_CHECK( cp1.begin() == cp1.end() );
-  
-  cp1.score = 18;
-  cp1.track_indexes = path;
-  BOOST_CHECK_EQUAL( cp1.size(), path.size() );
-
-  ConservedPath cp2(18, path);
-  BOOST_CHECK_EQUAL (cp1, cp2);
-  BOOST_CHECK_EQUAL( cp2.size(), path.size() );
-
-  ConservedPath::iterator cp2_itor;
-  vector<int>::iterator path_itor;
-  for (cp2_itor = cp2.begin(), path_itor = path.begin();
-       cp2_itor != cp2.end() && path_itor != path.end();
-       ++cp2_itor, ++path_itor)
-  {
-    BOOST_CHECK_EQUAL( *cp2_itor, *path_itor );
-  }
-
-  ConservedPath cp3( cp2 );
-  BOOST_CHECK_EQUAL( cp3.size(), cp2.size() );
-  ConservedPath::iterator cp3_itor;
-  for (cp2_itor = cp2.begin(), cp3_itor = cp3.begin();
-       cp2_itor != cp2.end() && cp3_itor != cp3.end();
-       ++cp2_itor, ++cp3_itor)
-  {
-    BOOST_CHECK_EQUAL( *cp2_itor, *cp3_itor );
-  }
-}
-
-//! do vector like operations work?
-BOOST_AUTO_TEST_CASE ( conserved_path_vector )
-{
-  ConservedPath cp;
-  cp.score = 21.0;
-  
-  BOOST_CHECK_EQUAL( cp.size(), 0 );
-  cp.push_back( 3 );
-  BOOST_CHECK_EQUAL( cp.size(), 1);
-  BOOST_CHECK_EQUAL( cp[0], 3 );
-  cp.push_back( 4 );
-  BOOST_CHECK_EQUAL( cp.size(), 2);
-  BOOST_CHECK_EQUAL( cp[1], 4 );
-  cp.pop_back();
-  BOOST_CHECK_EQUAL( cp.size(), 1 );
-}
-
-BOOST_AUTO_TEST_CASE ( extended_conserved_path_simple ) 
-{
-  vector<int> path;
-  path += 3,4,5,1; // magic from boost assign
-
-  ExtendedConservedPath ecp1;
-  ecp1.window_size = 30;
-  ecp1.score = 18;
-  ecp1.track_indexes = path;
-  BOOST_CHECK_EQUAL ( ecp1.size(), path.size() );
-
-  ExtendedConservedPath ecp2(30, 18.0, path);
-  BOOST_CHECK_EQUAL ( ecp1, ecp2 );
-  BOOST_CHECK_EQUAL ( ecp2.size(), path.size() );
-
-  ExtendedConservedPath ecp_ne(35, 20.0, path);
-  BOOST_CHECK(ecp2 != ecp_ne);
-
-  ConservedPath cp1;
-  cp1.score = 18;
-  cp1.track_indexes = path;
-
-  ExtendedConservedPath ecp3(30, cp1);
-  BOOST_CHECK_EQUAL( ecp2, ecp3 );
-  BOOST_CHECK_EQUAL( ecp3.size(), path.size() );
-}
-
-//! Can we grow succesfully?
-BOOST_AUTO_TEST_CASE ( extended_conserved_path_growth )
-{
-  vector<int> path_base;
-  path_base += 3,4,5,1; // magic from boost assign
-  vector<int> path_next;
-  path_next += 4,5,6,2; 
-  vector<int> path_next_reversed;
-  path_next_reversed += 4,5,6,-2; 
-  vector<int> path_not_next;
-  path_not_next += 4,5,6,5; 
-  const int window_size = 4;
-
-  ExtendedConservedPath ecp_base(window_size, 20, path_base);
-  ConservedPath cp_next(25, path_next);
-  ConservedPath cp_next_reversed(25, path_next_reversed);
-  ConservedPath cp_not_next(22, path_not_next);
-
-  BOOST_CHECK(ecp_base.nextTo(cp_next));
-  BOOST_CHECK(!ecp_base.nextTo(cp_not_next));
-  // FIXME: should something like this actually extend?
-  BOOST_CHECK(!ecp_base.nextTo(cp_next_reversed));
-
-  const int growth = 2;
-  ecp_base.extend(growth);
-  BOOST_CHECK_EQUAL( ecp_base.window_size, window_size + growth );
-}
index cee1601234c19d79deff40d5cdde0b2870f18771..964ab34af5c5da1b07d2cd18d23abbe281bb69d7 100644 (file)
@@ -1,4 +1,4 @@
-CURDIR := $(BASEDIR)test/
+CURDIR := $(BASEDIR)alg/test/
 
 SOURCES.cxx := test_conserved_path.cxx \
                test_flp.cxx \
@@ -6,8 +6,7 @@ SOURCES.cxx := test_conserved_path.cxx \
                test_main.cxx \
                test_mussa.cxx \
                test_nway.cxx \
-               test_sequence.cxx \
-               ../qui/GlSequence.cxx
+               test_sequence.cxx 
 
 TESTSRC := $(addprefix $(CURDIR), $(SOURCES.cxx))
 TESTOBJ := $(TESTSRC:.cxx=$(OBJEXT))
diff --git a/alg/test/test_conserved_path.cxx b/alg/test/test_conserved_path.cxx
new file mode 100644 (file)
index 0000000..b248470
--- /dev/null
@@ -0,0 +1,119 @@
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/assign/std/vector.hpp>
+using namespace boost::assign;
+
+#include <vector>
+using namespace std;
+
+#include "alg/conserved_path.h"
+
+//! write tests for our conserved path types (just to make sure they
+//! don't change on us.
+BOOST_AUTO_TEST_CASE ( conserved_path_simple ) 
+{
+  vector<int> path;
+  path += 3,4,5,1; // magic from boost assign
+
+  ConservedPath cp1;
+  BOOST_CHECK_EQUAL( cp1.size(), 0 ); //empty
+  BOOST_CHECK( cp1.begin() == cp1.end() );
+  
+  cp1.score = 18;
+  cp1.track_indexes = path;
+  BOOST_CHECK_EQUAL( cp1.size(), path.size() );
+
+  ConservedPath cp2(18, path);
+  BOOST_CHECK_EQUAL (cp1, cp2);
+  BOOST_CHECK_EQUAL( cp2.size(), path.size() );
+
+  ConservedPath::iterator cp2_itor;
+  vector<int>::iterator path_itor;
+  for (cp2_itor = cp2.begin(), path_itor = path.begin();
+       cp2_itor != cp2.end() && path_itor != path.end();
+       ++cp2_itor, ++path_itor)
+  {
+    BOOST_CHECK_EQUAL( *cp2_itor, *path_itor );
+  }
+
+  ConservedPath cp3( cp2 );
+  BOOST_CHECK_EQUAL( cp3.size(), cp2.size() );
+  ConservedPath::iterator cp3_itor;
+  for (cp2_itor = cp2.begin(), cp3_itor = cp3.begin();
+       cp2_itor != cp2.end() && cp3_itor != cp3.end();
+       ++cp2_itor, ++cp3_itor)
+  {
+    BOOST_CHECK_EQUAL( *cp2_itor, *cp3_itor );
+  }
+}
+
+//! do vector like operations work?
+BOOST_AUTO_TEST_CASE ( conserved_path_vector )
+{
+  ConservedPath cp;
+  cp.score = 21.0;
+  
+  BOOST_CHECK_EQUAL( cp.size(), 0 );
+  cp.push_back( 3 );
+  BOOST_CHECK_EQUAL( cp.size(), 1);
+  BOOST_CHECK_EQUAL( cp[0], 3 );
+  cp.push_back( 4 );
+  BOOST_CHECK_EQUAL( cp.size(), 2);
+  BOOST_CHECK_EQUAL( cp[1], 4 );
+  cp.pop_back();
+  BOOST_CHECK_EQUAL( cp.size(), 1 );
+}
+
+BOOST_AUTO_TEST_CASE ( extended_conserved_path_simple ) 
+{
+  vector<int> path;
+  path += 3,4,5,1; // magic from boost assign
+
+  ExtendedConservedPath ecp1;
+  ecp1.window_size = 30;
+  ecp1.score = 18;
+  ecp1.track_indexes = path;
+  BOOST_CHECK_EQUAL ( ecp1.size(), path.size() );
+
+  ExtendedConservedPath ecp2(30, 18.0, path);
+  BOOST_CHECK_EQUAL ( ecp1, ecp2 );
+  BOOST_CHECK_EQUAL ( ecp2.size(), path.size() );
+
+  ExtendedConservedPath ecp_ne(35, 20.0, path);
+  BOOST_CHECK(ecp2 != ecp_ne);
+
+  ConservedPath cp1;
+  cp1.score = 18;
+  cp1.track_indexes = path;
+
+  ExtendedConservedPath ecp3(30, cp1);
+  BOOST_CHECK_EQUAL( ecp2, ecp3 );
+  BOOST_CHECK_EQUAL( ecp3.size(), path.size() );
+}
+
+//! Can we grow succesfully?
+BOOST_AUTO_TEST_CASE ( extended_conserved_path_growth )
+{
+  vector<int> path_base;
+  path_base += 3,4,5,1; // magic from boost assign
+  vector<int> path_next;
+  path_next += 4,5,6,2; 
+  vector<int> path_next_reversed;
+  path_next_reversed += 4,5,6,-2; 
+  vector<int> path_not_next;
+  path_not_next += 4,5,6,5; 
+  const int window_size = 4;
+
+  ExtendedConservedPath ecp_base(window_size, 20, path_base);
+  ConservedPath cp_next(25, path_next);
+  ConservedPath cp_next_reversed(25, path_next_reversed);
+  ConservedPath cp_not_next(22, path_not_next);
+
+  BOOST_CHECK(ecp_base.nextTo(cp_next));
+  BOOST_CHECK(!ecp_base.nextTo(cp_not_next));
+  // FIXME: should something like this actually extend?
+  BOOST_CHECK(!ecp_base.nextTo(cp_next_reversed));
+
+  const int growth = 2;
+  ecp_base.extend(growth);
+  BOOST_CHECK_EQUAL( ecp_base.window_size, window_size + growth );
+}
index 0c4681200380c89a04a0c3c927354e6c26eb5a24..f0369c930630d880e852d669caea9a16feb15881 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <string>
 
-#include "qui/GlSequence.h"
+#include "alg/glsequence.h"
 #include "alg/sequence.hh"
 
 using namespace std;
index 9823fec5cbd4386bbfdf0e2f6087081a9bf3008a..eb93b39f2e2da14f39553a64e62d1d970dbfe398 100644 (file)
@@ -12,7 +12,6 @@ INCLUDEPATH += . alg qui
 
 # Input
 HEADERS += mussa_exceptions.hh \
-           qui/GlSequence.h \
            qui/PathWindow.h \
            qui/PathScene.h \
            qui/ThresholdWidget.h \
@@ -20,12 +19,12 @@ HEADERS += mussa_exceptions.hh \
            qui/ImageSaveDialog.h \
            alg/conserved_path.h \
            alg/flp.hh \
+           alg/glsequence.h \
            alg/mussa_class.hh \
            alg/nway_paths.hh \
            alg/parse_options.h \
            alg/sequence.hh
 SOURCES += mussagl.cxx \
-           qui/GlSequence.cxx \
            qui/PathWindow.cxx \
            qui/PathScene.cxx \
            qui/ThresholdWidget.cxx \
@@ -34,6 +33,7 @@ SOURCES += mussagl.cxx \
            alg/conserved_path.cxx \
            alg/flp.cxx \
            alg/flp_seqcomp.cxx \
+           alg/glsequence.cxx \
            alg/mussa_class.cxx \
            alg/nway_entropy.cxx \
            alg/nway_other.cxx \
diff --git a/qui/GlSequence.cxx b/qui/GlSequence.cxx
deleted file mode 100644 (file)
index de9dfd9..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-#include "qui/GlSequence.h"
-
-#include <iostream>
-#include <cassert>
-#include <math.h>
-#include <stdexcept>
-using namespace std;
-
-GlSequence::GlSequence(const Sequence &s) 
-  : seq(s),
-    seq_x(0.0), 
-    seq_y(0.0), 
-    seq_z(1.0), 
-    seq_width(s.size()),
-    seq_height(gl_track_height)
-{
-  assert (seq.size() == seq_width);
-}
-
-GlSequence::GlSequence(const GlSequence &s) 
-  : seq(s.seq),
-    seq_x(s.seq_x),
-    seq_y(s.seq_y),
-    seq_z(s.seq_z),
-    seq_width(s.seq_width),
-    seq_height(s.seq_height)
-{
-  assert (seq.size() == seq_width);
-}
-
-GlSequence &GlSequence::operator=(const GlSequence & s)
-{
-  if (this != &s) {
-    const_cast<Sequence &>(seq) = s.seq;
-    seq_x = s.seq_x;
-    seq_y = s.seq_y;
-    seq_z = s.seq_z;
-    seq_width = s.seq_width;
-    seq_height = s.seq_height;
-  }
-  return *this;
-}
-
-const Sequence& GlSequence::sequence() const
-{
-  return seq;
-}
-
-void GlSequence::setX(GLfloat value)
-{
-  seq_x = value;
-}
-
-GLfloat GlSequence::x() const
-{
-  return seq_x;
-}
-
-void GlSequence::setY(GLfloat value)
-{
-  seq_y = value;
-}
-
-GLfloat GlSequence::y() const
-{
-  return seq_y;
-}
-
-void GlSequence::setWidth(GLfloat value)
-{
-  seq_width = value;
-}
-
-GLfloat GlSequence::width() const
-{
-  return seq_width;
-}
-
-
-void GlSequence::draw(GLfloat left, GLfloat right) const
-{
-  glLineWidth(seq_height);
-  glColor3f(0.0, 0.0, 0.0);
-  // draw main sequence track
-  glBegin(GL_LINES);
-    glVertex3f(seq_x,           seq_y, seq_z);
-    glVertex3f(seq_x+seq_width, seq_y, seq_z);
-    //clog << "drawing " << seq_x << " " << seq_y << " " << seq_width
-    //     << std::endl;
-  glEnd();
-  // draw annotations
-  GLfloat annotation_z = seq_z + 1.0;
-  std::list<annot> annots = seq.annotations();
-  for (std::list<annot>::const_iterator annot_itor = annots.begin();
-       annot_itor != annots.end();
-       ++annot_itor, ++annotation_z)
-  {
-    glColor3f(0.0, 0.5, 0.0);
-    glBegin(GL_LINES);
-      glVertex3f(annot_itor->start, seq_y, annotation_z);
-      glVertex3f(annot_itor->end  , seq_y, annotation_z);
-    glEnd();
-  }
-  draw_sequence(left, right);
-}
-
-const int PT = 1;
-const int STROKE = 2;
-const int END =3;
-
-typedef struct charpoint {
-  GLfloat x, y;
-  int type;
-} CP;
-
-CP Adata[] = {
-  {0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT}, 
-  {5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END}
-};
-
-CP Tdata[] = {
-  {2.5, 0, PT}, {2.5,10, STROKE}, {0, 10, PT}, {5,10, END}
-};
-
-CP Gdata[] = {
-  {5, 9, PT}, {4, 10, PT}, {1, 10, PT}, {0, 9, PT}, {0, 1, PT},
-  {1, 0, PT}, {5, 0, PT}, {5, 4, PT}, {3.5, 4, END}
-};
-
-CP Cdata[] = {
-  {5, 8, PT}, {3, 10, PT}, {2, 10, PT}, {0, 8, PT}, {0, 2, PT},
-  {2, 0, PT}, {3, 0, PT}, {5, 2, END}
-};
-
-CP Xdata[] = {{ 0, 10, PT}, {5,0,STROKE},{0,0,PT},{5,10,END}};
-CP Ndata[] = {{ 0, 0, PT}, {0, 10, PT}, {5, 0, PT}, {5, 10, END}};
-
-static void drawLetter(CP *l)
-{
-  glBegin(GL_LINE_STRIP);
-  while(1) {
-    switch (l->type) {
-      case PT:
-        glVertex2fv(&l->x);
-        break;
-      case STROKE:
-        glVertex2fv(&l->x);
-        glEnd();
-        glBegin(GL_LINE_STRIP);
-        break;
-      case END:
-        glVertex2fv(&l->x);
-        glEnd();
-        return;
-        break;
-      default:
-         throw runtime_error("data structure failure");
-    }
-    l++;
-  }
-}
-
-void GlSequence::draw_sequence(GLfloat left, GLfloat right) const
-{
-  int viewport[4];
-  glGetIntegerv(GL_VIEWPORT, viewport);
-  int port_width = viewport[3]; // grab the viewport width
-  GLfloat world_width = right - left;
-  int left_base = (left > 0) ? (int)ceil(left) : 0;
-  int right_base = (int)floor(right);
-  int render_count = (right_base < seq.size()) ? right_base : seq.size(); 
-  render_count -= left_base;
-
-  glLineWidth(0.01);
-  GLfloat char_width = 1.1;
-  GLfloat pixels_needed = char_width * world_width;
-
-  cout << "seq width needed " << pixels_needed 
-       << " port width " << port_width 
-       << " count " << render_count 
-       << " left " << left_base 
-       << " right " << right_base 
-       << " size " << seq.size() << endl;
-  // if the number of pixels taken up by rendering the characters 
-  // that'd show up in the current ortho width is less than the window
-  // width we can actually draw something 
-  if (pixels_needed < port_width and render_count > 0) {
-    cout << "rendering: ";
-    string bases = seq.subseq(left_base, render_count);
-    glColor3f(0.1, 0.1, 0.1);
-    for (string::size_type basepair = 0; basepair != bases.size(); ++basepair) 
-    {
-      glPushMatrix();
-      glTranslatef( left_base + basepair, seq_y+20, 1.0 );
-      glScalef(0.1, 1.0, 1.0);
-      switch (bases[basepair]) {
-        case 'A': case 'a':
-          drawLetter(Adata);
-        break;
-        case 'T': case 't':
-          drawLetter(Tdata);
-        break;
-        case 'G': case 'g':
-          drawLetter(Gdata);
-        break;
-        case 'C': case 'c':
-          drawLetter(Cdata);
-        break;
-        case 'N': case 'n':
-          drawLetter(Ndata);
-        break;
-        default:
-          drawLetter(Xdata);
-        break;
-      }
-      cout << bases[basepair];
-      glPopMatrix();
-    }
-    cout << endl;
-  }
-}
diff --git a/qui/GlSequence.h b/qui/GlSequence.h
deleted file mode 100644 (file)
index 343f9ff..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef _GL_SEQUENCE_H_
-#define _GL_SEQUENCE_H_
-
-#include "alg/sequence.hh"
-#include <GL/gl.h>
-
-//! Manage rendering a mussa sequence track
-/*! The idea is this will keep track of the location of where the sequence
- *  is being rendered, and handle displaying annotations on that track
- */
-class GlSequence
-{
-public: 
-  GlSequence(const Sequence & s);
-  GlSequence(const GlSequence & s);
-  GlSequence &operator=(const GlSequence &s);
-
-  //! draw a track 
-  /*! left and right are the current edges of the viewable world
-   */
-  void draw(GLfloat left, GLfloat right) const;
-
-  const Sequence& sequence() const;
-  void setX(GLfloat);
-  GLfloat x() const;
-  void setY(GLfloat);
-  GLfloat y() const;
-  void setWidth(GLfloat);
-  GLfloat width() const;
-
-protected:
-  const Sequence& seq;
-  GLfloat seq_x;
-  GLfloat seq_y;
-  GLfloat seq_z;
-  GLfloat seq_width;
-  GLfloat seq_height;
-
-  //! render a sequence (if we have enough space
-  /*! left and right are the current edges of the viewable world
-   */
-  void draw_sequence(GLfloat, GLfloat) const;
-};
-
-const float gl_track_height = 10.0;
-
-#endif
index 17efa5cf7167f62233c8d791a392914e2d341e4e..224ce5d957ca690a3f01e34d85df975aa4288111 100644 (file)
@@ -13,7 +13,8 @@
 #include <GL/gl.h>
 #include <math.h>
 
-#include "qui/GlSequence.h"
+#include "alg/glsequence.h"
+#include "mussa_exceptions.hh"
 
 using namespace std;
 
index f25c1cd617c404cc9c995c0335bc97a9086c7e8e..4fc639a8fbc4687bb98366289d06519acf02ee1b 100644 (file)
@@ -7,7 +7,8 @@
 #include <vector>
 
 #include "alg/mussa_class.hh"
-#include "qui/GlSequence.h"
+#include "alg/glsequence.h"
+#include "GL/gl.h"
 
 class QMouseEvent;
 class QRubberBand;