[project @ 3]
authorDiane Trout <diane@caltech.edu>
Fri, 16 Sep 2005 22:43:01 +0000 (22:43 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 16 Sep 2005 22:43:01 +0000 (22:43 +0000)
checked in mussa_pI.2

14 files changed:
Makefile
flp_seqcomp.cc
mussa.cc
mussa_class.cc
mussa_class.hh
mussa_gui_conn.cc [new file with mode: 0644]
mussa_gui_conn.hh [new file with mode: 0644]
mussa_gui_seq.cc [new file with mode: 0644]
mussa_gui_seq.hh [new file with mode: 0644]
mussa_nway.cc
mussa_nway.hh
mussa_nway_refine.cc [new file with mode: 0644]
sequence.cc
sequence.hh

index 2fcc2337b165661ddd8531dde9c861273e143a49..580077ab60655408261c27e58920f1c280b2bb7b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #CFLAGS=-ftemplate-depth-20
-CFLAGS=-O -ftemplate-depth-20
-LDFLAGS=
+CFLAGS=-O -Winline -ftemplate-depth-20
+LDFLAGS= -lfltk
 
 #all: seqcomp
 
@@ -19,11 +19,17 @@ seqcomp : seqcomp.cc flp.o flp_seqcomp.o sequence.o
 mussa_nway.o : mussa_nway.cc mussa_nway.hh
        g++ $(CFLAGS) -c mussa_nway.cc
 
+mussa_gui_seq.o : mussa_gui_seq.cc mussa_gui_seq.hh
+       g++ $(CFLAGS) -c mussa_gui_seq.cc
+
+mussa_gui_conn.o : mussa_gui_conn.cc mussa_gui_conn.hh
+       g++ $(CFLAGS) -c mussa_gui_conn.cc
+
 mussa_class.o : mussa_class.cc mussa_class.hh
        g++ $(CFLAGS) -c mussa_class.cc
 
-mussa : mussa.cc mussa_class.o mussa_nway.o flp_seqcomp.o flp.o sequence.o
-       g++ $(CFLAGS) -o mussa mussa.cc mussa_class.o mussa_nway.o flp_seqcomp.o flp.o sequence.o
+mussa : sequence.o flp.o flp_seqcomp.o mussa_nway.o mussa_gui_seq.o mussa_gui_conn.o mussa_class.o mussa.cc  
+       g++ $(CFLAGS) $(LDFLAGS) -o mussa mussa.cc mussa_class.o mussa_gui_conn.o mussa_gui_seq.o mussa_nway.o flp_seqcomp.o flp.o sequence.o
 
 
 #match_list_type.o : modules/match_list_type.c modules/match_list_type.h \
index 44efc2e1b118ab5f8beb3e9ee3719320ed541a44..d61b55421239aa4a27b5581f700ab3bc26d41c40 100644 (file)
@@ -42,7 +42,7 @@ FLPs::seqcomp(string sseq1, string sseq2, bool is_RC)
   if (is_RC)
     i2_offset = window_size - seq2_length;     
   else
-    i2_offset = 1;
+    i2_offset = 0;
 
 
   // loop thru the start positions for sequence 1
@@ -76,7 +76,7 @@ FLPs::seqcomp(string sseq1, string sseq2, bool is_RC)
          (seq1[seq1_i+window_size] != 'N'))       // N's match nothing
         matches = matches + 1;
 
-      add(seq1_i + 1, seq2_i, matches, i2_offset);
+      add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
 
       seq1_i = seq1_i + 1;     // increment seq1_i to next window 
       seq2_i = seq2_i + 1;     // increment seq2_i to next window
@@ -114,7 +114,7 @@ FLPs::seqcomp(string sseq1, string sseq2, bool is_RC)
          (seq1[seq1_i+window_size] != 'N'))       // N's match nothing
         matches = matches + 1;
 
-      add(seq1_i + 1, seq2_i, matches, i2_offset);
+      add(seq1_i + 1, seq2_i + 1, matches, i2_offset);
 
       seq1_i = seq1_i + 1;     // increment seq1_i to next window
       seq2_i = seq2_i + 1;     // increment seq2_i to next window
index 2682772fb14aada77ffee6f8fe944a89e9376b73..af25db2ebb5056887c32d7c29c5e9775481d2726 100644 (file)
--- a/mussa.cc
+++ b/mussa.cc
@@ -4,60 +4,87 @@
 int main(int argc, char **argv) 
 {
   Mussa overlord;
-  char * para_file;
+  char * para_file, * ana_file;
+  string  an_arg;
   time_t t1, t2, begin, end;
   double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
+  string run_mode;
+  int seq_num;
+
 
   begin = time(NULL);
 
   // need more sophisticated arg reading structure
   // support -w and -t override options...other stuff??
-  para_file = * ++argv;
-
-  t1 = time(NULL);
-  overlord.setup(para_file);
-  t2 = time(NULL);
-  setuptime = difftime(t2, t1);
-
-
-      cout << "fee\n";
-  t1 = time(NULL);
-  overlord.get_Seqs();
-  t2 = time(NULL);
-  seqloadtime = difftime(t2, t1);
-
-
-      cout << "fie\n";
-  t1 = time(NULL);
-  overlord.seqcomp();
-  t2 = time(NULL);
-  seqcomptime = difftime(t2, t1);
-
-
-      cout << "foe\n";
-  t1 = time(NULL);
-  overlord.nway();
-  t2 = time(NULL);
-  nwaytime = difftime(t2, t1);
-
-
-      cout << "fum\n";
-  t1 = time(NULL);
-  overlord.save();
-  t2 = time(NULL);
-  savetime = difftime(t2, t1);
-
-  end = time(NULL);
-  totaltime = difftime(end, begin);
-
-  cout << "setup\tseqload\tseqcomp\tnway\tsave\ttotal\n";
-  cout << setuptime << "\t"; 
-  cout << seqloadtime << "\t";
-  cout << seqcomptime << "\t";
-  cout << nwaytime << "\t";
-  cout << savetime << "\t";
-  cout << totaltime << "\n";
-
+  an_arg = * ++argv;
+
+  if (an_arg == "-v")
+  {
+    seq_num = atoi(* ++argv);
+    ana_file = * ++argv;
+    run_mode = "v";
+  }
+  else
+  {
+    para_file = (char*) an_arg.c_str();
+    run_mode = "f";
+  }
+
+  if (run_mode == "v")
+  {
+    cout << "load file = " << ana_file << " seq num = " << seq_num << endl;
+    overlord.load_old(ana_file, seq_num);
+  }
+  else if (run_mode == "f")
+  {
+    t1 = time(NULL);
+    overlord.setup(para_file);
+    t2 = time(NULL);
+    setuptime = difftime(t2, t1);
+
+
+    cout << "fee\n";
+    t1 = time(NULL);
+    overlord.get_Seqs();
+    t2 = time(NULL);
+    seqloadtime = difftime(t2, t1);
+
+
+    cout << "fie\n";
+    t1 = time(NULL);
+    overlord.seqcomp();
+    t2 = time(NULL);
+    seqcomptime = difftime(t2, t1);
+
+
+    cout << "foe\n";
+    t1 = time(NULL);
+    overlord.nway();
+    t2 = time(NULL);
+    nwaytime = difftime(t2, t1);
+
+
+    cout << "fum\n";
+    t1 = time(NULL);
+    overlord.save_old();
+    t2 = time(NULL);
+    savetime = difftime(t2, t1);
+
+    end = time(NULL);
+    totaltime = difftime(end, begin);
+
+    cout << "setup\tseqload\tseqcomp\tnway\tsave\ttotal\n";
+    cout << setuptime << "\t"; 
+    cout << seqloadtime << "\t";
+    cout << seqcomptime << "\t";
+    cout << nwaytime << "\t";
+    cout << savetime << "\t";
+    cout << totaltime << "\n";
+  }
+
+
+  if (run_mode == "v")
+    overlord.FuckingPieceOfShit(1000,500);
 }
 
 
index 442af68ed9b25d8cf2f6a36d880a982609a8612c..d00f76667c0ea91810a6eac1e748abdbee2fe208 100644 (file)
@@ -125,6 +125,12 @@ Mussa::get_Seqs()
   }
 }
 
+/*
+    aSeq.seq();
+    cout << "\n";
+    aSeq.hdr();
+    cout << "\n";
+*/
 
 void
 Mussa::seqcomp()
@@ -152,6 +158,17 @@ Mussa::seqcomp()
       all_comps[i][i2].setup("m", window, threshold, seq_lens[i],seq_lens[i2]);
       all_comps[i][i2].seqcomp(the_Seqs[i].seq(), the_Seqs[i2].seq(), false);
       all_comps[i][i2].seqcomp(the_Seqs[i].seq(),the_Seqs[i2].rev_comp(),true);
+      save_file_string = "ana";
+      if (i == 0)
+        save_file_string += "0";
+      else if (i == 1)
+        save_file_string += "1";
+      if (i2 == 1)
+        save_file_string += "1";
+      else if (i2 == 2)
+        save_file_string += "2";
+
+      all_comps[i][i2].file_save(save_file_string);
     }
 }
 
@@ -165,8 +182,9 @@ Mussa::nway()
 
 
 void
-Mussa::save()
+Mussa::save_old()
 {
+  fstream save_file;
   int i;
 
   save_file.open(ana_name.c_str(), ios::out);
@@ -181,6 +199,78 @@ Mussa::save()
   the_paths.save_old(ana_name);
 }
 
+
+void
+Mussa::load_old(char * load_file_path, int s_num)
+{
+  fstream save_file;
+  string file_data_line; 
+  int i, space_split_i, comma_split_i;
+  vector<int> loaded_path;
+  string node_pair, node;
+  Sequence a_seq;
+
+  seq_num = s_num;
+  the_paths.setup(seq_num);
+  save_file.open(load_file_path, ios::in);
+
+  // currently loads old mussa format
+
+  // get sequences
+  for(i = 0; i < seq_num; i++)
+  {
+    getline(save_file, file_data_line);
+    a_seq.set_seq(file_data_line);
+    the_Seqs.push_back(a_seq);
+  }
+
+  // get window size
+  getline(save_file, file_data_line);
+  window = atoi(file_data_line.c_str());
+  // get paths
+
+  while (!save_file.eof())
+  {
+    loaded_path.clear();
+    getline(save_file, file_data_line);
+    if (file_data_line != "")
+    for(i = 0; i < seq_num; i++)
+    {
+      space_split_i = file_data_line.find(" ");
+      node_pair = file_data_line.substr(0,space_split_i);
+      //cout << "np= " << node_pair;
+      comma_split_i = node_pair.find(",");
+      node = node_pair.substr(comma_split_i+1);
+      //cout << "n= " << node << " ";
+      loaded_path.push_back(atoi (node.c_str()));
+      file_data_line = file_data_line.substr(space_split_i+1);
+    }
+    //cout << endl;
+    the_paths.add_path(loaded_path);
+  }
+  save_file.close();
+
+  //the_paths.save("tmp.save");
+}
+
+
+// In Memorial to Everything that's gone wrong in the last week
+// and Everything that will go wrong in the next 2 weeks 03/02/2004 - Tristan
+void
+Mussa::FuckingPieceOfShit(int x_max, int y_max)
+{
+
+  Fl_Window *conn_window = new Fl_Window(x_max, y_max, "Mussa Connections");
+  ConnView *conn_box = new ConnView(0, 0, x_max, y_max);
+  conn_box->setup(ana_name, seq_num, window, &the_Seqs, &the_paths);
+  conn_box->scale_paths();
+  conn_box->spawnSeq();
+  conn_window->end();
+  conn_window->show();
+
+  Fl::run();
+}
+
 /*
       cout << "fee\n";
       cout << "fie\n";
index a84c159bbe3772c1ba268fad5cd2b98315136253..b80bc3e947b9f577165e892fbe49847dcf0c6e10 100644 (file)
@@ -2,7 +2,7 @@
 //                          ---------- mussa_class.hh -----------
 //                        ----------------------------------------
 
-#include "mussa_nway.hh"
+#include "mussa_gui_conn.hh"
 
 
 class Mussa
@@ -24,8 +24,8 @@ class Mussa
     void get_Seqs();
     void seqcomp();
     void nway();
-    void save();
-
-    fstream save_file;
+    void save_old();
+    void load_old(char * load_file_path, int s_num);
+    void FuckingPieceOfShit(int x_max, int y_max);
 };
 
diff --git a/mussa_gui_conn.cc b/mussa_gui_conn.cc
new file mode 100644 (file)
index 0000000..75a757a
--- /dev/null
@@ -0,0 +1,107 @@
+#include "mussa_gui_conn.hh"
+
+
+
+void
+ConnView::setup(string name, int sq_num, int win_len,
+                vector<Sequence> *some_seqs,
+                Nway_Paths *some_paths)
+{
+  int i;
+  Sequence a_seq;
+
+  ana_name = name;
+  seq_num = sq_num;
+  window = win_len;
+  S = some_seqs;
+  P = some_paths;
+
+  for(i = 0; i < seq_num; ++i)
+  {
+    a_seq = (*S)[i];
+    seq_lens.push_back(a_seq.len());
+  }
+
+  x_scale_factor = (float) seq_lens[0] / x_max;
+  cout << "scale factor is " << x_scale_factor << endl;
+  y_seq_incre = (y_max-20) / (seq_num - 1);
+}
+
+
+void
+ConnView::scale_paths()
+{
+  vector<int> a_path;
+  list<vector<int> >::iterator pathz_i;
+  int i2;
+
+
+  scaled_pathz.clear();
+
+  for(pathz_i = P->pathz.begin(); pathz_i != P->pathz.end(); ++pathz_i)
+  {
+    a_path = *pathz_i;
+    for(i2 = 0; i2 < seq_num; i2++)
+      a_path[i2] = (int) (a_path[i2] / x_scale_factor);
+    scaled_pathz.push_back(a_path);
+  }
+}
+
+
+
+
+void
+ConnView::draw()
+{
+  list<vector<int> >::iterator i;
+  int i2, y_loc, x_loc;
+  vector<int> a_path;
+
+  fl_color(FL_RED);
+  fl_line_style(FL_SOLID, 1, NULL);
+
+  for(i = scaled_pathz.begin(); i != scaled_pathz.end(); ++i)
+  {
+    a_path = *i;
+    y_loc = 10;
+    for(i2 = seq_num - 1; i2 > 0; i2--)
+    {
+      // RC case handling
+      // ugh, and xor...only want blue if one of the nodes is rc
+      if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
+           !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
+        fl_color(FL_BLUE);
+
+      fl_line((int)abs(a_path[i2]),y_loc,(int)abs(a_path[i2-1]),y_loc + y_seq_incre);
+      y_loc += y_seq_incre;
+      fl_color(FL_RED);
+    }
+  }
+
+  fl_color(FL_BLACK);
+  fl_line_style(FL_SOLID, 3, NULL);
+  y_loc = 10;
+  for(i2 = seq_num - 1; i2 >= 0; i2--)
+  {
+    x_loc = (int)(seq_lens[i2] / x_scale_factor);
+    fl_line(0,y_loc,x_loc,y_loc);
+    y_loc += y_seq_incre;
+  }
+}
+
+void
+ConnView::spawnSeq()
+{
+  int seq_box_x;
+
+  Fl_Window *seq_window = new Fl_Window(x_max, y_max, "Mussa Sequence");
+  Fl_Scroll *scroll_seq = new Fl_Scroll(0, 0, x_max, y_max);
+
+  seq_box_x = 32000; 
+    //seq_lens[0]*14;
+  SeqView *seq_box = new SeqView(0, 0, seq_box_x, y_max-20);
+  seq_box->setup(ana_name, seq_num, window, S, P, seq_lens);
+
+  seq_window->end();
+  seq_window->show();
+}
diff --git a/mussa_gui_conn.hh b/mussa_gui_conn.hh
new file mode 100644 (file)
index 0000000..0994dcf
--- /dev/null
@@ -0,0 +1,37 @@
+#include "mussa_gui_seq.hh"
+
+
+
+class ConnView : public Fl_Box
+{
+  private:
+    string ana_name;
+    int seq_num, window, threshold;
+    bool win_append, thres_append;
+
+    //this data is passed as pointers to the instantiated classes
+    vector<Sequence> *S;
+    Nway_Paths *P;
+
+    int x_max, y_max;
+    float x_scale_factor;
+    int y_seq_incre;
+  //list< will be list of these later for zooming history
+    list<vector<int> > scaled_pathz;
+    vector<int> seq_lens;
+
+
+  public:
+    ConnView(int x_top,int y_top,int x_bot,int y_bot) :
+      Fl_Box(x_top,y_top,x_bot,y_bot)
+      {
+        x_max = x_bot;
+        y_max = y_bot;
+      }
+
+    void setup(string name, int sq_num, int win_len,
+               vector<Sequence> *, Nway_Paths *);
+    void scale_paths();
+    void draw();
+    void spawnSeq();
+};
diff --git a/mussa_gui_seq.cc b/mussa_gui_seq.cc
new file mode 100644 (file)
index 0000000..bf1afb3
--- /dev/null
@@ -0,0 +1,136 @@
+#include "mussa_gui_seq.hh"
+
+
+void
+SeqView::setup(string name, int sq_num, int win_len, 
+               vector<Sequence> *some_seqs,
+               Nway_Paths *some_paths, vector<int> some_lens)
+{
+  ana_name = name;
+  seq_num = sq_num;
+  base_window_len = win_len;
+  S = some_seqs;
+  P = some_paths;
+  seq_lens = some_lens;
+
+  y_seq_incre = (y_max-10) / (seq_num - 1);
+
+  fl_font(FL_COURIER, 14);
+  cout << fl_width('A') << endl;
+}
+
+
+void
+SeqView::draw()
+{
+  int seq_i;
+  Sequence a_seq;
+  int i, y_loc;
+  vector<int> a_path;
+  list<vector<int> >::iterator pathz_i;
+  int i2;
+  int x_start, y_start, x_end, y_end;
+  double ch_width;
+  int window_length, win_i;
+  int rc_1 = 0; 
+  int rc_2 = 0;
+
+
+  window_length = base_window_len;
+  fl_font(FL_COURIER, 14);
+  fl_color(FL_BLACK);
+  //blatantly stolen from FR2
+  ch_width = fl_width('A');     // monospaced: all characters are same width
+
+  y_loc = 10;
+  for(seq_i = seq_num-1; seq_i >= 0; --seq_i)
+  {
+    //a_seq = a_seq;
+    fl_draw((*S)[seq_i].c_seq(), 0+x(), y_loc+y()); 
+    y_loc += y_seq_incre;
+  }
+
+  fl_color(FL_RED);
+  fl_line_style(FL_SOLID, 1, NULL);
+  //fl_line(x(),10+y(),20+x(),y_max/2 + y());
+
+      //fl_color(FL_RED);
+
+
+  for(pathz_i = P->pathz.begin(); pathz_i != P->pathz.end(); ++pathz_i)
+  {
+    a_path = *pathz_i;
+    y_loc = 0;
+    for(i2 = seq_num - 1; i2 > 0; i2--)
+    {
+      // RC case handling
+
+      // ugh, and xor...only want black if one of the nodes is rc
+      if ( ((a_path[i2] < 0) || (a_path[i2-1] < 0)) &&
+           !((a_path[i2] < 0) && (a_path[i2-1] < 0)) )
+        fl_color(FL_BLUE);
+
+      // no matter the case, any RC node needs an offset
+      if (a_path[i2] < 0)
+        rc_1 = window_length;        
+      if (a_path[i2-1] < 0)
+        rc_2 = window_length;        
+      // normal case
+      for(win_i = 0; win_i < window_length; win_i++)
+        fl_line(abs((int)((a_path[i2]-rc_1+win_i+x()+0.5)*ch_width)),
+                y_loc + 10+y(),
+                abs((int)((a_path[i2-1]-rc_2+win_i+x()+0.5)*ch_width)),
+                y_loc+y_seq_incre+y());
+      y_loc += y_seq_incre;
+      //if ((a_path[i2] < 0) || (a_path[i2-1] < 0))
+      //{
+        fl_color(FL_RED);
+        rc_1 = 0;
+        rc_2 = 0;
+        //}
+    }
+  }
+}
+/*
+      x_start = (int) ();
+      y_start = ;
+      x_end = (int) ();
+      y_end = ;
+      x_start,y_start,x_end,y_end
+*/
+
+
+/*
+      if ((a_path[i2] >= 0) && (a_path[i2-1] >= 0))
+      {
+      }
+      else if ((a_path[i2] < 0) && (a_path[i2-1] < 0)) 
+      {
+        for(win_i = 0; win_i < window_length; win_i++)
+          fl_line(abs((int)((a_path[i2]+window_length+win_i+x())*ch_width)),
+                  y_loc + 10+y(),
+                  abs((int)((a_path[i2-1]+window_length+win_i+x())*ch_width)),
+                  y_loc+y_seq_incre+y());
+        
+      }
+      else 
+      {
+        fl_color(FL_BLACK);
+        for(win_i = 0; win_i < window_length; win_i++)
+          fl_line(abs((int)((a_path[i2]+window_length+win_i+x())*ch_width)),
+                  y_loc + 10+y(),
+                  abs((int)((a_path[i2-1]+win_i+x())*ch_width)),
+                  y_loc+y_seq_incre+y());
+        fl_color(FL_RED);
+      }
+      else //
+      {
+        fl_color(FL_BLACK);
+        for(win_i = 0; win_i < window_length; win_i++)
+          fl_line(abs((int)((a_path[i2]+win_i+x())*ch_width)),
+                  y_loc + 10+y(),
+                  abs((int)((a_path[i2-1]+window_length+win_i+x())*ch_width)),
+                  y_loc+y_seq_incre+y());
+        fl_color(FL_RED);
+      }
+*/
diff --git a/mussa_gui_seq.hh b/mussa_gui_seq.hh
new file mode 100644 (file)
index 0000000..aed0140
--- /dev/null
@@ -0,0 +1,35 @@
+#include "mussa_nway.hh"
+
+#include <math.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Box.H>
+#include <FL/fl_draw.H>
+#include <FL/Fl_Scroll.H>
+
+class SeqView : public Fl_Box
+{
+  private:
+    string ana_name;
+    int seq_num;
+    int base_window_len;
+
+    //this data is passed as pointers to the instantiated classes
+    vector<Sequence> *S;
+    Nway_Paths *P;
+    vector<int> seq_lens;
+
+    int x_max, y_max;
+    int y_seq_incre;
+
+  public:
+    SeqView(int x_top,int y_top,int x_bot,int y_bot) :
+      Fl_Box(x_top,y_top,x_bot,y_bot)
+    {
+        x_max = x_bot;
+        y_max = y_bot;
+    }
+             
+    void setup(string, int, int, vector<Sequence> *, Nway_Paths *, vector<int>);
+    void draw();
+};
index ecbbb0d3d23e33fdd086d85662bb3f7be34cd279..ae9b69a975a70927ba8ed2aab369e13c502c21ec 100644 (file)
@@ -19,6 +19,7 @@ void
 Nway_Paths::setup(int sp_num)
 {
   species_num = sp_num;
+  pathz.clear();
 }
 
 
@@ -41,13 +42,21 @@ Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path,
     {
       trans_check_good = true;
       trans_check_nodes = all_comparisons[i][depth].matches(path[i]);
-      if (trans_check_nodes.end() == find(trans_check_nodes.begin(),trans_check_nodes.end(), *new_nodes_i) )
+      if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+                                            trans_check_nodes.end(),
+                                            *new_nodes_i) ) &&
+           (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+                                           trans_check_nodes.end(),
+                                           *new_nodes_i * -1) ) )
         trans_check_good = false;
     }
 
     if (trans_check_good)
     {
-      path.push_back(*new_nodes_i);
+      if ( path[depth-1] >= 0)
+        path.push_back(*new_nodes_i);
+      else
+        path.push_back(*new_nodes_i * -1);
       if (depth < species_num - 1)
         path_search(all_comparisons, path, depth + 1);
       else
@@ -97,6 +106,14 @@ Nway_Paths::find_paths_r(vector<vector<FLPs> > all_comparisons)
   }
 }
 
+
+void
+Nway_Paths::add_path(vector<int> loaded_path)
+{
+  pathz.push_back(loaded_path);
+}
+
+
 void
 Nway_Paths::save(string save_file_path)
 {
@@ -229,3 +246,7 @@ void Nway_Paths::print()
   }
 }
 */
+
+
+
+
index 6b4d0a18c296c41210a5d3000f08095855093438..43529247eb2489c3b9e031b6af1f1951e9cbb7cd 100644 (file)
@@ -7,6 +7,8 @@
 
 class Nway_Paths
 {
+  friend class ConnView;
+  friend class SeqView;
   private:
     int species_num;
     int threshold;
@@ -22,7 +24,10 @@ class Nway_Paths
     void save(string save_file_path);
     void save_old(string save_file_path);
     void load(string load_file_path);
+    void add_path(vector<int> loaded_path);
     void find_paths(vector<vector<FLPs> > all_comparisons);
     void refine();
     void print();
+
+    list<vector<int> > scaled_paths(float scale_factor);
 };
diff --git a/mussa_nway_refine.cc b/mussa_nway_refine.cc
new file mode 100644 (file)
index 0000000..ea11273
--- /dev/null
@@ -0,0 +1,134 @@
+PathList
+ExtendPathWindows(PathList raw_list)
+{
+  // to keep track of everything, this function acts like a finite state
+  // automata:  3 bitfields: reset, extending, scanning - ie 8 states
+  int reset = 0, extending = 0, scanning = 0;
+
+  int species_num = raw_list.SpeciesNum();
+  int win_num = raw_list.WinNum();
+
+  int *cur_path, *next_path;
+
+  cur_path = new int[species_num];
+  next_path = new int[species_num];
+
+  raw_list.ResetIndex();
+
+  while (no more windows avaible)
+  {
+    //cur_indices[0] + ref_ext == next_indices[0] + 1:
+
+    // state 000 - start/nominal search
+    // 
+    if !reset && !extending && !scanning
+    {
+      if cur_path[0] == next_path[0]
+      {
+        scanning = 1;                   // go to state 001
+        raw_list.IncreIndex();
+      }
+      else if cur_path[0] + 1 == next_path[0]
+      {
+        extending = 1;                  // go to state 010
+        win_ext = 1;
+        raw_list.SetDirty();
+        raw_list.IncreIndex();
+      }
+      else
+        reset = 1;                      // go to state 100
+    }
+
+    // state 001 - scanning for ext window thru possible interleaving
+    // 
+    else if !reset && !extending && scanning
+    {
+      if cur_path[0] == next_path[0]
+        raw_list.IncreIndex();
+      else if cur_path[0] + 1 == next_path[0]
+      {
+        extending = 1;                  // go to state 011
+        win_ext = 1;
+        raw_list.SetDirty();
+        raw_list.IncreIndex();
+      }
+      else
+        reset = 1;                      // go to state 101
+    }
+
+    // state 010 - extending window with no interleaving
+    // 
+    else if !reset && extending && !scanning
+    {
+      if (cur_path[0] + win_ext) == next_path[0]
+      {
+        extending = 1;                  // go to state 011
+        raw_list.IncreIndex();
+      }
+      else if (cur_path[0] + win_ext + 1) == next_path[0]
+      {
+        win_ext++;
+        raw_list.SetDirty();
+        raw_list.IncreIndex();
+      }
+      else
+        reset = 1;                      // go to state 110
+    }
+
+    // state 011 - extending window with interleaving
+    // 
+    else if !reset && extending && scanning
+    {
+      if (cur_path[0] + win_ext) == next_path[0]
+        raw_list.IncreIndex();
+      else if (cur_path[0] + win_ext + 1) == next_path[0]
+      {
+        win_ext++;
+        raw_list.SetDirty();
+        raw_list.IncreIndex();
+      }
+      else
+        reset = 1;                      // go to state 111
+    }
+
+
+    // reset condition states, return to 000 after taking appropiate action
+
+    // state 100 - no extended window, no scanning happened
+    // save basic window to extended window list
+    if reset && !extending && !scanning
+    {
+      // return to start/nominal search state
+      reset = 0;
+    }
+
+    // state 101 - no extended window, scanned for interleaving
+    // save basic window to extended window list, return to first clean 
+    else if reset && !extending && scanning
+    {
+      // return to start/nominal search state
+      reset = 0;
+      scanning = 0;
+    }
+
+    // state 110 - extended window, no interleaving
+    // calc extended window, save to extended window list
+    else if reset && extending && !scanning
+    {
+      // return to start/nominal search state
+      reset = 0;
+      extending = 0;
+    }
+       
+    // state 111 - extended window, interleaved
+    // calc extended window, save to ext win list, return to first clean
+    else if reset && extending && scanning
+    {        
+      // return to start/nominal search state
+      reset = 0;
+      extending = 0;
+      scanning = 0;
+     }
+
+  return ext_win;
+}
index c2a836d4a2aa5ddb2037921ddd3d874e82164873..199a4abc5fca91dc08f6c84e2f2660d6bfb2b704 100644 (file)
@@ -42,6 +42,7 @@ Sequence::load_fasta(string file_path, int seq_num)
 
   data_file.close();
 
+  // need more sequence filtering for non AGCTN and convert to N
   transform(sequence.begin(), sequence.end(), sequence.begin(), toupper);
 }
 
@@ -49,6 +50,14 @@ Sequence::load_fasta(string file_path, int seq_num)
 void
 Sequence::load_annot(string file_path)
 {
+  fstream data_file;
+  string file_data_line;
+  annot an_annot;
+
+  data_file.open(file_path.c_str(), ios::in);
+
+  data_file.close();
+
 }
 
 
@@ -65,6 +74,12 @@ Sequence::seq()
   return sequence;
 }
 
+const char *
+Sequence::c_seq()
+{
+  return sequence.c_str();
+}
+
 string
 Sequence::rev_comp()
 {
@@ -112,6 +127,14 @@ Sequence::hdr()
   return header;
 }
 
+
+void
+Sequence::set_seq(string a_seq)
+{
+  sequence = a_seq;
+}
+
+
 /*
 string 
 Sequence::species()
index b287c72a321fe833bc51bb60c45a8cbcd9a24091..afbb9da21e65c1454b9d299b19380d119b6e27f5 100644 (file)
@@ -15,6 +15,8 @@
 
 class Sequence
 {
+  friend class ConnView;
+  friend class SeqView;
   private:
     string sequence;
     int length;
@@ -25,7 +27,7 @@ class Sequence
     struct annot
     {
       int start, end;
-      string name, type, color;
+      string name, type;
     };
 
     list<annot> annots;
@@ -38,9 +40,11 @@ class Sequence
     void load_fasta(string file_path, int seq_num);
     void load_annot(string file_path);
     string seq();
+    const char * c_seq();
     string rev_comp();
     int len();
     string hdr();
+    void set_seq(string a_seq);
   //  string species();
     void clear();
 };