move glsequence into "alg" comonent
authorDiane Trout <diane@caltech.edu>
Wed, 8 Mar 2006 09:21:38 +0000 (09:21 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 8 Mar 2006 09:21:38 +0000 (09:21 +0000)
decided to try to make the opengl rendering code toolkit independent
this makes it easier to test some of these components as then I can
just use boost.unittest to verify them.

Also when I python wrap parts it might make sense for the gl components
to be the part that ends up getting exported as the python package.

this is actually a hacked version of the original patch that moves
the test directory a file at a time.

23 files changed:
Makefile.noqt
alg/glsequence.cxx [new file with mode: 0644]
alg/glsequence.h [new file with mode: 0644]
alg/module.mk
alg/test/module.mk [new file with mode: 0644]
alg/test/test_flp.cxx [new file with mode: 0644]
alg/test/test_glsequence.cxx [new file with mode: 0644]
alg/test/test_main.cxx [new file with mode: 0644]
alg/test/test_mussa.cxx [new file with mode: 0644]
alg/test/test_nway.cxx [new file with mode: 0644]
alg/test/test_sequence.cxx [new file with mode: 0644]
mussagl.pro
qui/GlSequence.cxx [deleted file]
qui/GlSequence.h [deleted file]
qui/PathScene.cxx
qui/PathScene.h
test/module.mk [deleted file]
test/test_flp.cxx [deleted file]
test/test_glsequence.cxx [deleted file]
test/test_main.cxx [deleted file]
test/test_mussa.cxx [deleted file]
test/test_nway.cxx [deleted file]
test/test_sequence.cxx [deleted file]

index 572619fdd83c70e24f13bac05120d7d77fa67ad1..0db92db9ed9bcff779d87b3ca636ca3e08f967cf 100644 (file)
@@ -20,8 +20,8 @@ SRC :=
 all: targets
 
 include alg/module.mk
+include alg/test/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..e9f8600
--- /dev/null
@@ -0,0 +1,98 @@
+#include "alg/glsequence.h"
+
+#include <iostream>
+using namespace std;
+
+GlSequence::GlSequence(const Sequence &s) 
+  : seq(s),
+    seq_x(0), 
+    seq_y(0), 
+    seq_z(0), 
+    seq_width(s.size()),
+    seq_height(gl_track_height) 
+{
+}
+
+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)
+{
+}
+
+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() 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
+  std::list<annot> annots = seq.annotations();
+  for (std::list<annot>::const_iterator annot_itor = annots.begin();
+       annot_itor != annots.end();
+       ++annot_itor)
+  {
+    glColor3f(0.0, 0.5, 0.0);
+    glBegin(GL_LINES);
+      glVertex3f(annot_itor->start, seq_y, seq_z);
+      glVertex3f(annot_itor->end  , seq_y, seq_z);
+    glEnd();
+  }
+}
diff --git a/alg/glsequence.h b/alg/glsequence.h
new file mode 100644 (file)
index 0000000..798ac53
--- /dev/null
@@ -0,0 +1,39 @@
+#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);
+
+  void draw() const;
+
+  const Sequence &sequence() const;
+  void setX(GLfloat);
+  GLfloat x() const;
+  void setY(GLfloat);
+  GLfloat y() const;
+  void setWidth(GLfloat);
+  GLfloat width() const;
+
+private:
+  const Sequence& seq;
+  GLfloat seq_x;
+  GLfloat seq_y;
+  GLfloat seq_z;
+  GLfloat seq_width;
+  GLfloat seq_height;
+};
+
+const float gl_track_height = 5.0;
+
+#endif
index 338fd4b434f1fe3783ba1c1caafb017454e7f9ce..b4458fa28b26b040cf65b47eed5c598ec34cdb2d 100644 (file)
@@ -2,6 +2,7 @@ CURDIR := $(BASEDIR)alg/
 
 SOURCES.cxx := flp.cxx \
                flp_seqcomp.cxx \
+               glsequence.cxx \
                mussa_class.cxx \
                nway_paths.cxx \
                nway_entropy.cxx \
diff --git a/alg/test/module.mk b/alg/test/module.mk
new file mode 100644 (file)
index 0000000..97f1ed1
--- /dev/null
@@ -0,0 +1,20 @@
+CURDIR := $(BASEDIR)alg/test/
+
+SOURCES.cxx := test_flp.cxx \
+               test_glsequence.cxx \
+               test_main.cxx \
+               test_mussa.cxx \
+               test_nway.cxx \
+               test_sequence.cxx 
+
+TESTSRC := $(addprefix $(CURDIR), $(SOURCES.cxx))
+
+SRC += $(TESTSRC)
+CXXFLAGS += 
+
+TEST := $(BASEDIR)/unittests$(BINEXT) 
+TARGETBINS += $(TEST)
+
+$(TEST): $(TESTSRC:.cxx=$(OBJEXT))  $(MUSSA_ALG_LIB)
+       g++ $(CXXFLAGS) -lGL -lboost_unit_test_framework -lboost_filesystem -o $@ $^
+
diff --git a/alg/test/test_flp.cxx b/alg/test/test_flp.cxx
new file mode 100644 (file)
index 0000000..fc03452
--- /dev/null
@@ -0,0 +1,95 @@
+#include <iostream>
+#include <list>
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+
+#include "alg/flp.hh"
+#include "alg/sequence.hh"
+#include <iostream>
+#include <list>
+
+BOOST_AUTO_TEST_CASE( flp_simple )
+{
+  FLPs f;
+  f.setup(5, 4);
+  f.seqcomp("AAGGTAAGGT", "AAGGTAAGGT", false);
+  
+  for (int i=0; i < f.size(); i++)
+  {
+    std::list<int> window_matches = f.matches(i);
+    for (std::list<int>::iterator matches_i = window_matches.begin();
+         matches_i != window_matches.end();
+         ++matches_i)
+    {
+      // I'm missing pythons easy lists and in operator here.
+      if (i == 0) BOOST_CHECK( *matches_i == 0 || *matches_i == 5);
+      else if (i == 1) BOOST_CHECK( *matches_i == 1 || *matches_i == 6);
+      else if (i == 2) BOOST_CHECK( *matches_i == 2 );
+      else if (i == 3) BOOST_CHECK( *matches_i == 3 );
+      else if (i == 4) BOOST_CHECK( *matches_i == 4 );
+      else if (i == 6) BOOST_CHECK( *matches_i == 5 || *matches_i == 0);
+    }
+  }
+}
+
+BOOST_AUTO_TEST_CASE( flp_save )
+{
+  std::string seq("AAGGCCTTAAGGCCTT");
+  int win_size = 4;
+  FLPs f1;
+  FLPs f2;
+  f1.setup(win_size,3);
+  f1.seqcomp(seq, seq, false);
+  std::string fname("flp_save_this_is_a_horrible_filename_because_"
+                    "im_too_lazy_to_write_a_portable_mktmp.flp");
+                    
+  f1.save(fname);
+  f2.load(fname);
+  boost::filesystem::remove( boost::filesystem::path(fname) );
+
+  BOOST_CHECK_EQUAL( f1.size(), seq.size()-win_size+1);
+  BOOST_CHECK_EQUAL( f2.size(), seq.size()-win_size+1);
+  BOOST_CHECK_EQUAL( f1.size(), f2.size() );
+  for (int win=0; win < f1.size(); ++win)
+  {
+    std::list<int> f1_matches = f1.matches(win);
+    std::list<int> f2_matches = f2.matches(win);
+    std::list<int>::const_iterator f1_match_i = f1_matches.begin();
+    std::list<int>::const_iterator f2_match_i = f2_matches.begin();
+    for( ; 
+         f1_match_i != f1_matches.end() && f2_match_i != f2_matches.end();
+         ++f1_match_i, ++f2_match_i)
+    {
+      BOOST_CHECK_EQUAL( *f1_match_i, *f2_match_i);
+    }
+  }
+}
+
+/*! Apparently when we run multiple seqcomps we want to 
+ *  save all the FLPs generated
+ */
+BOOST_AUTO_TEST_CASE( flp_reverse_compliment )
+{
+  FLPs f1;
+  Sequence s1("AAAATTTT");
+  Sequence s2("AACAGGGG");
+  f1.setup(4,3);
+  f1.seqcomp(s1.get_seq(), s2.get_seq(), false);
+  f1.seqcomp(s1.get_seq(), s2.rev_comp(), true);
+
+  FLPs f2;
+  f2.setup(4,3);
+  f2.seqcomp(s1.get_seq(), s2.rev_comp(), true);
+  f2.seqcomp(s1.get_seq(), s2.get_seq(), false);
+
+  // The order of doing the reverse compliment search shouldn't matter
+  // when we're using exactly the same sequence
+  BOOST_CHECK_EQUAL( f1.size(), f2.size() );
+  for (int i = 0; i < f1.size(); ++i )
+  {
+    BOOST_CHECK_EQUAL( f1.matches(i).size(), f2.matches(i).size() );
+    // FIXME: should we test the individual lists?
+  }
+}
diff --git a/alg/test/test_glsequence.cxx b/alg/test/test_glsequence.cxx
new file mode 100644 (file)
index 0000000..f0369c9
--- /dev/null
@@ -0,0 +1,31 @@
+#include <boost/test/auto_unit_test.hpp>
+
+#include <string>
+
+#include "alg/glsequence.h"
+#include "alg/sequence.hh"
+
+using namespace std;
+
+BOOST_AUTO_TEST_CASE ( glsequence_operator_equal )
+{
+  // I don't trust my operator = hack so lets make sure it works.
+  string s0("AAGGCCTT");
+  string s1("TTGGCCAA");
+  Sequence seq0(s0);
+  Sequence seq1(s1);
+
+  GlSequence glseq0(seq0);
+  BOOST_CHECK (glseq0.sequence().get_seq() == s0);
+  // width of a sequence should be number of base pairs (aka chars)
+  BOOST_CHECK (glseq0.width() == s0.size());
+  GlSequence glseq1(seq1);
+  GlSequence glseq_copy0(glseq0);
+
+  BOOST_CHECK(glseq_copy0.sequence().get_seq() == glseq0.sequence().get_seq());
+  BOOST_CHECK( &(glseq_copy0.sequence()) == &(glseq0.sequence()));
+
+  glseq0 = glseq1;
+
+  BOOST_CHECK( glseq0.sequence().get_seq() == s1 );
+}
diff --git a/alg/test/test_main.cxx b/alg/test/test_main.cxx
new file mode 100644 (file)
index 0000000..39987f2
--- /dev/null
@@ -0,0 +1,3 @@
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+
diff --git a/alg/test/test_mussa.cxx b/alg/test/test_mussa.cxx
new file mode 100644 (file)
index 0000000..645fe3e
--- /dev/null
@@ -0,0 +1,69 @@
+#include <boost/test/auto_unit_test.hpp>
+
+#include <string>
+
+#include "alg/mussa_class.hh"
+
+//! can we initialize a mussa object?
+BOOST_AUTO_TEST_CASE( mussa_simple )
+{
+  Mussa m;
+  BOOST_CHECK_EQUAL(m.get_name(), "" );
+  BOOST_CHECK_EQUAL(m.get_window(), 0);
+  BOOST_CHECK_EQUAL(m.get_threshold(), 0);
+  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::TransitiveNway);
+  m.set_name( "hello" );
+  BOOST_CHECK_EQUAL(m.get_name(), "hello" );
+  m.set_window(30);
+  BOOST_CHECK_EQUAL(m.get_window(), 30);
+  m.set_threshold(21);
+  BOOST_CHECK_EQUAL(m.get_threshold(), 21);
+  m.set_analysis_mode(Mussa::RadialNway);
+  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::RadialNway);
+    
+  m.clear();
+  BOOST_CHECK_EQUAL(m.get_name(), "" );
+  BOOST_CHECK_EQUAL(m.get_window(), 0);
+  BOOST_CHECK_EQUAL(m.get_threshold(), 0);
+  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::TransitiveNway);
+}
+
+BOOST_AUTO_TEST_CASE( mussa_analysis_name )
+{
+  Mussa m;
+  m.set_analysis_mode( Mussa::TransitiveNway );
+  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Transitive" );
+  m.set_analysis_mode( Mussa::RadialNway );
+  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Radial" );
+  m.set_analysis_mode( Mussa::EntropyNway );
+  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Entropy" );
+  m.set_analysis_mode( Mussa::RecursiveNway);
+  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "[deprecated] Recursive" );
+}
+
+BOOST_AUTO_TEST_CASE( mussa_sequences )
+{
+  std::string s0("AAAANNNN");
+  std::string s1("GGGGNNNN");
+  std::string s2("TTTTNNNN");
+
+  Mussa analysis;
+  analysis.add_a_seq(s0);
+  analysis.add_a_seq(s1);
+  analysis.add_a_seq(s2);
+
+  BOOST_CHECK_EQUAL( analysis.sequences().size(), 3 );
+  BOOST_CHECK_EQUAL( analysis.sequences()[0].get_seq(), s0);
+  BOOST_CHECK_EQUAL( analysis.sequences()[1].get_seq(), s1);
+  BOOST_CHECK_EQUAL( analysis.sequences()[2].get_seq(), s2);
+}
+
+#include <unistd.h>
+BOOST_AUTO_TEST_CASE( mussa_load_mupa )
+{
+  Mussa m;
+  chdir( "examples" );
+  m.load_mupa_file( "mck3test.mupa" );
+  m.analyze(30, 25);
+  chdir( ".." );
+}
diff --git a/alg/test/test_nway.cxx b/alg/test/test_nway.cxx
new file mode 100644 (file)
index 0000000..e72714c
--- /dev/null
@@ -0,0 +1,57 @@
+#include <boost/test/auto_unit_test.hpp>
+
+#include <string>
+#include <iostream>
+
+#include "alg/mussa_class.hh"
+#include "alg/nway_paths.hh"
+#include "alg/sequence.hh"
+
+using namespace std;
+
+//! there should be no matches
+BOOST_AUTO_TEST_CASE( nway_null )
+{
+  string s0("AAAANNNN");
+  string s1("GGGGNNNN");
+  string s2("TTTTNNNN");
+
+  Mussa analysis;
+  analysis.add_a_seq(s0);
+  analysis.add_a_seq(s1);
+  analysis.add_a_seq(s2);
+  analysis.analyze(4,3);
+  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();
+       ++pathz_i)
+  {
+    BOOST_CHECK_EQUAL( pathz_i->size(), 0);
+  }
+}
+
+BOOST_AUTO_TEST_CASE( nway_test )
+{
+  string s0("ATATGCGC");
+  string s1("GGGGGGGC");
+  Sequence seq1(s1);
+  cout << "seq1 rev = " << seq1.rev_comp() << endl;
+
+  Mussa analysis;
+  analysis.add_a_seq(s0);
+  analysis.add_a_seq(s1);
+  analysis.analyze(4,3);
+  Nway_Paths npath = analysis.paths();
+  for (std::list<std::vector<int> >::iterator pathz_i = npath.pathz.begin();
+       pathz_i != npath.pathz.end();
+       ++pathz_i)
+  {
+    for( std::vector<int>::iterator path_i = pathz_i->begin();
+         path_i != pathz_i->end();
+         ++path_i)
+    {      
+      BOOST_CHECK( *path_i == 4 || *path_i == -4);
+    }
+  }
+}
diff --git a/alg/test/test_sequence.cxx b/alg/test/test_sequence.cxx
new file mode 100644 (file)
index 0000000..cc9a9a3
--- /dev/null
@@ -0,0 +1,51 @@
+#include <boost/test/auto_unit_test.hpp>
+
+#include "alg/sequence.hh"
+#include "mussa_exceptions.hh"
+
+//! when we try to load a missing file, do we get an error?
+BOOST_AUTO_TEST_CASE( sequence_load_exception )
+{
+  Sequence s;
+  // there should be errors when we try to load something that doesn't exist
+  BOOST_CHECK_THROW( s.load_fasta("alkejralk", 1, 0, 0), sequence_load_error);
+  BOOST_CHECK_THROW( s.load_annot("alkejralk", 0, 0), sequence_load_error);
+}
+
+//! Do simple operations work correctly?
+BOOST_AUTO_TEST_CASE( sequence_filter )
+{
+  Sequence s1("AATTGGCC");
+  BOOST_CHECK_EQUAL(s1.get_seq(), "AATTGGCC");
+
+  Sequence s2("aattggcc");
+  BOOST_CHECK_EQUAL(s2.get_seq(), "AATTGGCC");
+  BOOST_CHECK_EQUAL(s2.rev_comp(), "GGCCAATT");
+  BOOST_CHECK_EQUAL(s2.size(), s2.get_seq().size());
+  BOOST_CHECK_EQUAL(s2.c_seq(), s2.get_seq().c_str());
+
+  Sequence s3("asdfg");
+  BOOST_CHECK_EQUAL(s3.get_seq(), "ANNNG");
+  BOOST_CHECK_EQUAL(s3.subseq(0,2), "AN");
+
+  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 0, 2), "AA");
+  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 2, 2), "GG");
+  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 4), "CCTT");
+  
+  s3.clear();
+  BOOST_CHECK_EQUAL(s3.get_seq(), "");
+
+  s3.set_seq("AAGGFF");
+  BOOST_CHECK_EQUAL(s3.get_seq(), "AAGGNN");
+}
+
+//! Can we load data from a file
+BOOST_AUTO_TEST_CASE( sequence_load )
+{
+  Sequence s;
+  s.load_fasta("examples/seq/human_mck_pro.fa");
+  BOOST_CHECK_EQUAL(s.subseq(0, 5), "GGATC"); // first few chars of fasta file
+  BOOST_CHECK_EQUAL(s.get_header(), "gi|180579|gb|M21487.1|HUMCKMM1 Human "
+                                    "muscle creatine kinase gene (CKMM), "
+                                    "5' flank");
+}
index 3fe90529553854b2b0f43df7d6b4f6ec1d27c1e7..33f71fe8fab8445efa410f4661419a20c5c297ac 100644 (file)
@@ -12,21 +12,21 @@ INCLUDEPATH += . alg qui
 
 # Input
 HEADERS += mussa_exceptions.hh \
-           qui/GlSequence.h \
            qui/PathWindow.h \
            qui/PathScene.h \
            qui/ThresholdWidget.h \
            alg/flp.hh \
+           alg/glsequence.h \
            alg/mussa_class.hh \
            alg/nway_paths.hh \
            alg/sequence.hh
 SOURCES += mussagl.cxx \
-           qui/GlSequence.cxx \
            qui/PathWindow.cxx \
            qui/PathScene.cxx \
            qui/ThresholdWidget.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 4b3e461..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "qui/GlSequence.h"
-
-#include <iostream>
-using namespace std;
-
-GlSequence::GlSequence(const Sequence &s) 
-  : seq(s),
-    seq_x(0), 
-    seq_y(0), 
-    seq_z(0), 
-    seq_width(s.size()),
-    seq_height(gl_track_height) 
-{
-}
-
-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)
-{
-}
-
-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() 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
-  std::list<annot> annots = seq.annotations();
-  for (std::list<annot>::const_iterator annot_itor = annots.begin();
-       annot_itor != annots.end();
-       ++annot_itor)
-  {
-    glColor3f(0.0, 0.5, 0.0);
-    glBegin(GL_LINES);
-      glVertex3f(annot_itor->start, seq_y, seq_z);
-      glVertex3f(annot_itor->end  , seq_y, seq_z);
-    glEnd();
-  }
-}
diff --git a/qui/GlSequence.h b/qui/GlSequence.h
deleted file mode 100644 (file)
index 798ac53..0000000
+++ /dev/null
@@ -1,39 +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);
-
-  void draw() const;
-
-  const Sequence &sequence() const;
-  void setX(GLfloat);
-  GLfloat x() const;
-  void setY(GLfloat);
-  GLfloat y() const;
-  void setWidth(GLfloat);
-  GLfloat width() const;
-
-private:
-  const Sequence& seq;
-  GLfloat seq_x;
-  GLfloat seq_y;
-  GLfloat seq_z;
-  GLfloat seq_width;
-  GLfloat seq_height;
-};
-
-const float gl_track_height = 5.0;
-
-#endif
index 5016203c019d1bb4e7aa93c261dfea3fa7b99715..9d5d8412d5ce404cde865dfecb36040e6a065ab8 100644 (file)
@@ -8,7 +8,7 @@
 #include <GL/gl.h>
 #include <math.h>
 
-#include "qui/GlSequence.h"
+#include "alg/glsequence.h"
 
 using namespace std;
 
index 98cc7a35ebefa182f707ae220370f2c7a391897b..5f4bd7f2d243297e1d70f45ec1a45dc1e0df5c7c 100644 (file)
@@ -7,7 +7,7 @@
 #include <vector>
 
 #include "alg/mussa_class.hh"
-#include "qui/GlSequence.h"
+#include "alg/glsequence.h"
 
 class QMouseEvent;
 class QRubberBand;
diff --git a/test/module.mk b/test/module.mk
deleted file mode 100644 (file)
index d418c41..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-CURDIR := $(BASEDIR)test/
-
-SOURCES.cxx := test_flp.cxx \
-               test_glsequence.cxx \
-               test_main.cxx \
-               test_mussa.cxx \
-               test_nway.cxx \
-               test_sequence.cxx \
-               ../qui/GlSequence.cxx
-
-TESTSRC := $(addprefix $(CURDIR), $(SOURCES.cxx))
-
-SRC += $(TESTSRC)
-CXXFLAGS += 
-
-TEST := $(BASEDIR)/unittests$(BINEXT) 
-TARGETBINS += $(TEST)
-
-$(TEST): $(TESTSRC:.cxx=$(OBJEXT))  $(MUSSA_ALG_LIB)
-       g++ $(CXXFLAGS) -lGL -lboost_unit_test_framework -lboost_filesystem -o $@ $^
-
diff --git a/test/test_flp.cxx b/test/test_flp.cxx
deleted file mode 100644 (file)
index fc03452..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#include <iostream>
-#include <list>
-
-#include <boost/test/auto_unit_test.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
-#include "alg/flp.hh"
-#include "alg/sequence.hh"
-#include <iostream>
-#include <list>
-
-BOOST_AUTO_TEST_CASE( flp_simple )
-{
-  FLPs f;
-  f.setup(5, 4);
-  f.seqcomp("AAGGTAAGGT", "AAGGTAAGGT", false);
-  
-  for (int i=0; i < f.size(); i++)
-  {
-    std::list<int> window_matches = f.matches(i);
-    for (std::list<int>::iterator matches_i = window_matches.begin();
-         matches_i != window_matches.end();
-         ++matches_i)
-    {
-      // I'm missing pythons easy lists and in operator here.
-      if (i == 0) BOOST_CHECK( *matches_i == 0 || *matches_i == 5);
-      else if (i == 1) BOOST_CHECK( *matches_i == 1 || *matches_i == 6);
-      else if (i == 2) BOOST_CHECK( *matches_i == 2 );
-      else if (i == 3) BOOST_CHECK( *matches_i == 3 );
-      else if (i == 4) BOOST_CHECK( *matches_i == 4 );
-      else if (i == 6) BOOST_CHECK( *matches_i == 5 || *matches_i == 0);
-    }
-  }
-}
-
-BOOST_AUTO_TEST_CASE( flp_save )
-{
-  std::string seq("AAGGCCTTAAGGCCTT");
-  int win_size = 4;
-  FLPs f1;
-  FLPs f2;
-  f1.setup(win_size,3);
-  f1.seqcomp(seq, seq, false);
-  std::string fname("flp_save_this_is_a_horrible_filename_because_"
-                    "im_too_lazy_to_write_a_portable_mktmp.flp");
-                    
-  f1.save(fname);
-  f2.load(fname);
-  boost::filesystem::remove( boost::filesystem::path(fname) );
-
-  BOOST_CHECK_EQUAL( f1.size(), seq.size()-win_size+1);
-  BOOST_CHECK_EQUAL( f2.size(), seq.size()-win_size+1);
-  BOOST_CHECK_EQUAL( f1.size(), f2.size() );
-  for (int win=0; win < f1.size(); ++win)
-  {
-    std::list<int> f1_matches = f1.matches(win);
-    std::list<int> f2_matches = f2.matches(win);
-    std::list<int>::const_iterator f1_match_i = f1_matches.begin();
-    std::list<int>::const_iterator f2_match_i = f2_matches.begin();
-    for( ; 
-         f1_match_i != f1_matches.end() && f2_match_i != f2_matches.end();
-         ++f1_match_i, ++f2_match_i)
-    {
-      BOOST_CHECK_EQUAL( *f1_match_i, *f2_match_i);
-    }
-  }
-}
-
-/*! Apparently when we run multiple seqcomps we want to 
- *  save all the FLPs generated
- */
-BOOST_AUTO_TEST_CASE( flp_reverse_compliment )
-{
-  FLPs f1;
-  Sequence s1("AAAATTTT");
-  Sequence s2("AACAGGGG");
-  f1.setup(4,3);
-  f1.seqcomp(s1.get_seq(), s2.get_seq(), false);
-  f1.seqcomp(s1.get_seq(), s2.rev_comp(), true);
-
-  FLPs f2;
-  f2.setup(4,3);
-  f2.seqcomp(s1.get_seq(), s2.rev_comp(), true);
-  f2.seqcomp(s1.get_seq(), s2.get_seq(), false);
-
-  // The order of doing the reverse compliment search shouldn't matter
-  // when we're using exactly the same sequence
-  BOOST_CHECK_EQUAL( f1.size(), f2.size() );
-  for (int i = 0; i < f1.size(); ++i )
-  {
-    BOOST_CHECK_EQUAL( f1.matches(i).size(), f2.matches(i).size() );
-    // FIXME: should we test the individual lists?
-  }
-}
diff --git a/test/test_glsequence.cxx b/test/test_glsequence.cxx
deleted file mode 100644 (file)
index 0c46812..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <boost/test/auto_unit_test.hpp>
-
-#include <string>
-
-#include "qui/GlSequence.h"
-#include "alg/sequence.hh"
-
-using namespace std;
-
-BOOST_AUTO_TEST_CASE ( glsequence_operator_equal )
-{
-  // I don't trust my operator = hack so lets make sure it works.
-  string s0("AAGGCCTT");
-  string s1("TTGGCCAA");
-  Sequence seq0(s0);
-  Sequence seq1(s1);
-
-  GlSequence glseq0(seq0);
-  BOOST_CHECK (glseq0.sequence().get_seq() == s0);
-  // width of a sequence should be number of base pairs (aka chars)
-  BOOST_CHECK (glseq0.width() == s0.size());
-  GlSequence glseq1(seq1);
-  GlSequence glseq_copy0(glseq0);
-
-  BOOST_CHECK(glseq_copy0.sequence().get_seq() == glseq0.sequence().get_seq());
-  BOOST_CHECK( &(glseq_copy0.sequence()) == &(glseq0.sequence()));
-
-  glseq0 = glseq1;
-
-  BOOST_CHECK( glseq0.sequence().get_seq() == s1 );
-}
diff --git a/test/test_main.cxx b/test/test_main.cxx
deleted file mode 100644 (file)
index 39987f2..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#define BOOST_AUTO_TEST_MAIN
-#include <boost/test/auto_unit_test.hpp>
-
diff --git a/test/test_mussa.cxx b/test/test_mussa.cxx
deleted file mode 100644 (file)
index 645fe3e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#include <boost/test/auto_unit_test.hpp>
-
-#include <string>
-
-#include "alg/mussa_class.hh"
-
-//! can we initialize a mussa object?
-BOOST_AUTO_TEST_CASE( mussa_simple )
-{
-  Mussa m;
-  BOOST_CHECK_EQUAL(m.get_name(), "" );
-  BOOST_CHECK_EQUAL(m.get_window(), 0);
-  BOOST_CHECK_EQUAL(m.get_threshold(), 0);
-  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::TransitiveNway);
-  m.set_name( "hello" );
-  BOOST_CHECK_EQUAL(m.get_name(), "hello" );
-  m.set_window(30);
-  BOOST_CHECK_EQUAL(m.get_window(), 30);
-  m.set_threshold(21);
-  BOOST_CHECK_EQUAL(m.get_threshold(), 21);
-  m.set_analysis_mode(Mussa::RadialNway);
-  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::RadialNway);
-    
-  m.clear();
-  BOOST_CHECK_EQUAL(m.get_name(), "" );
-  BOOST_CHECK_EQUAL(m.get_window(), 0);
-  BOOST_CHECK_EQUAL(m.get_threshold(), 0);
-  BOOST_CHECK_EQUAL(m.get_analysis_mode(), Mussa::TransitiveNway);
-}
-
-BOOST_AUTO_TEST_CASE( mussa_analysis_name )
-{
-  Mussa m;
-  m.set_analysis_mode( Mussa::TransitiveNway );
-  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Transitive" );
-  m.set_analysis_mode( Mussa::RadialNway );
-  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Radial" );
-  m.set_analysis_mode( Mussa::EntropyNway );
-  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "Entropy" );
-  m.set_analysis_mode( Mussa::RecursiveNway);
-  BOOST_CHECK_EQUAL( m.get_analysis_mode_name(), "[deprecated] Recursive" );
-}
-
-BOOST_AUTO_TEST_CASE( mussa_sequences )
-{
-  std::string s0("AAAANNNN");
-  std::string s1("GGGGNNNN");
-  std::string s2("TTTTNNNN");
-
-  Mussa analysis;
-  analysis.add_a_seq(s0);
-  analysis.add_a_seq(s1);
-  analysis.add_a_seq(s2);
-
-  BOOST_CHECK_EQUAL( analysis.sequences().size(), 3 );
-  BOOST_CHECK_EQUAL( analysis.sequences()[0].get_seq(), s0);
-  BOOST_CHECK_EQUAL( analysis.sequences()[1].get_seq(), s1);
-  BOOST_CHECK_EQUAL( analysis.sequences()[2].get_seq(), s2);
-}
-
-#include <unistd.h>
-BOOST_AUTO_TEST_CASE( mussa_load_mupa )
-{
-  Mussa m;
-  chdir( "examples" );
-  m.load_mupa_file( "mck3test.mupa" );
-  m.analyze(30, 25);
-  chdir( ".." );
-}
diff --git a/test/test_nway.cxx b/test/test_nway.cxx
deleted file mode 100644 (file)
index e72714c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <boost/test/auto_unit_test.hpp>
-
-#include <string>
-#include <iostream>
-
-#include "alg/mussa_class.hh"
-#include "alg/nway_paths.hh"
-#include "alg/sequence.hh"
-
-using namespace std;
-
-//! there should be no matches
-BOOST_AUTO_TEST_CASE( nway_null )
-{
-  string s0("AAAANNNN");
-  string s1("GGGGNNNN");
-  string s2("TTTTNNNN");
-
-  Mussa analysis;
-  analysis.add_a_seq(s0);
-  analysis.add_a_seq(s1);
-  analysis.add_a_seq(s2);
-  analysis.analyze(4,3);
-  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();
-       ++pathz_i)
-  {
-    BOOST_CHECK_EQUAL( pathz_i->size(), 0);
-  }
-}
-
-BOOST_AUTO_TEST_CASE( nway_test )
-{
-  string s0("ATATGCGC");
-  string s1("GGGGGGGC");
-  Sequence seq1(s1);
-  cout << "seq1 rev = " << seq1.rev_comp() << endl;
-
-  Mussa analysis;
-  analysis.add_a_seq(s0);
-  analysis.add_a_seq(s1);
-  analysis.analyze(4,3);
-  Nway_Paths npath = analysis.paths();
-  for (std::list<std::vector<int> >::iterator pathz_i = npath.pathz.begin();
-       pathz_i != npath.pathz.end();
-       ++pathz_i)
-  {
-    for( std::vector<int>::iterator path_i = pathz_i->begin();
-         path_i != pathz_i->end();
-         ++path_i)
-    {      
-      BOOST_CHECK( *path_i == 4 || *path_i == -4);
-    }
-  }
-}
diff --git a/test/test_sequence.cxx b/test/test_sequence.cxx
deleted file mode 100644 (file)
index cc9a9a3..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <boost/test/auto_unit_test.hpp>
-
-#include "alg/sequence.hh"
-#include "mussa_exceptions.hh"
-
-//! when we try to load a missing file, do we get an error?
-BOOST_AUTO_TEST_CASE( sequence_load_exception )
-{
-  Sequence s;
-  // there should be errors when we try to load something that doesn't exist
-  BOOST_CHECK_THROW( s.load_fasta("alkejralk", 1, 0, 0), sequence_load_error);
-  BOOST_CHECK_THROW( s.load_annot("alkejralk", 0, 0), sequence_load_error);
-}
-
-//! Do simple operations work correctly?
-BOOST_AUTO_TEST_CASE( sequence_filter )
-{
-  Sequence s1("AATTGGCC");
-  BOOST_CHECK_EQUAL(s1.get_seq(), "AATTGGCC");
-
-  Sequence s2("aattggcc");
-  BOOST_CHECK_EQUAL(s2.get_seq(), "AATTGGCC");
-  BOOST_CHECK_EQUAL(s2.rev_comp(), "GGCCAATT");
-  BOOST_CHECK_EQUAL(s2.size(), s2.get_seq().size());
-  BOOST_CHECK_EQUAL(s2.c_seq(), s2.get_seq().c_str());
-
-  Sequence s3("asdfg");
-  BOOST_CHECK_EQUAL(s3.get_seq(), "ANNNG");
-  BOOST_CHECK_EQUAL(s3.subseq(0,2), "AN");
-
-  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 0, 2), "AA");
-  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 2, 2), "GG");
-  BOOST_CHECK_EQUAL(s3.filter_sequence("AAGGCCTT", 4), "CCTT");
-  
-  s3.clear();
-  BOOST_CHECK_EQUAL(s3.get_seq(), "");
-
-  s3.set_seq("AAGGFF");
-  BOOST_CHECK_EQUAL(s3.get_seq(), "AAGGNN");
-}
-
-//! Can we load data from a file
-BOOST_AUTO_TEST_CASE( sequence_load )
-{
-  Sequence s;
-  s.load_fasta("examples/seq/human_mck_pro.fa");
-  BOOST_CHECK_EQUAL(s.subseq(0, 5), "GGATC"); // first few chars of fasta file
-  BOOST_CHECK_EQUAL(s.get_header(), "gi|180579|gb|M21487.1|HUMCKMM1 Human "
-                                    "muscle creatine kinase gene (CKMM), "
-                                    "5' flank");
-}