# may the coders of gcc be infested with the fleas of ten thousand camels...
-CFLAGS=-ftemplate-depth-20
-
-#for development
-#CFLAGS= -Winline -ftemplate-depth-25 -ggdb
+CFLAGS=-ftemplate-depth-25
+#CFLAGS= -ftemplate-depth-25 -ggdb
+#-Winline
OFLAG= -O
# this is sufficient on debian machines
-LDFLAGS= -lfltk
+#LDFLAGS= -lfltk
# this is what's needed on redhat machines
#LDFLAGS= -lfltk -L/usr/X11R6/lib -lX11
#LDFLAGS= -lfltk -L/usr/X11R6/lib -lX11 -lXft
# this is what's needed on gentoo machines
-#LDFLAGS= -L/usr/lib/fltk-1.1/ -lfltk -L/usr/X11R6/lib -lX11 -lXft
-
+LDFLAGS= -L/usr/lib/fltk-1.1/ -lfltk -L/usr/X11R6/lib -lX11 -lXft
+
# needed for apple/OS X
#LDFLAGS= -framework Carbon -framework ApplicationServices -lfltk
-
+
# to check for memory leaks
MEMFLAG= -lefence
mussa_nway.o : mussa_nway.cc mussa_nway.hh
$(CC) $(CFLAGS) $(OFLAG) -c mussa_nway.cc
+mussa_nway_other.o : mussa_nway_other.cc mussa_nway.hh
+ $(CC) $(CFLAGS) $(OFLAG) -c mussa_nway_other.cc
+
mussa_class.o : mussa_class.cc mussa_class.hh
$(CC) $(CFLAGS) -c mussa_class.cc
mussa_gui_conn_window.o : mussa_gui_conn_window.cc mussa_gui_conn_window.hh
$(CC) $(CFLAGS) -c mussa_gui_conn_window.cc
-mussa : sequence.o flp.o flp_seqcomp.o mussa_nway.o mussa_class.o \
+mussa : sequence.o flp.o flp_seqcomp.o \
+ mussa_nway.o mussa_nway_other.o mussa_class.o \
mussa_gui_seq.o mussa_gui_seq_view.o \
mussa_gui_motif_window.o \
- mussa_gui_conn_view.o mussa_gui_conn_window.o \
+ mussa_gui_conn_view.o mussa_gui_conn_window.o \
mussa.cc
$(CC) $(CFLAGS) -o mussa mussa.cc \
mussa_gui_conn_view.o mussa_gui_conn_window.o \
mussa_gui_motif_window.o \
mussa_gui_seq.o mussa_gui_seq_view.o \
- mussa_class.o mussa_nway.o flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
+ mussa_class.o mussa_nway.o mussa_nway_other.o \
+ flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
clean :
--- /dev/null
+#include "mussa_nway.hh"
+
+void
+Nway_Paths::radiate_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, sp_i, sp_depth, window_num;
+ bool some_matches, still_paths, not_advanced;
+ list<int> new_nodes;
+ vector<list<int> > all_matches;
+ vector<list<int>::iterator> sp_nodes, sp_nodes_end;
+ list<int>::iterator debug_i;
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl; // just a sanity check
+
+ sp_nodes.reserve(species_num);
+ sp_nodes_end.reserve(species_num);
+
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // first we see if the first seq has matches to all other seqs at this win
+ some_matches = true;
+ sp_i = 1;
+ all_matches.clear();
+ while ( (sp_i < species_num) && (some_matches) )
+ {
+ new_nodes.clear();
+ new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ if (new_nodes.empty())
+ some_matches = false;
+
+ all_matches.push_back(new_nodes);
+ sp_i++;
+ }
+ //cout << "fee\n";
+ /*
+ if (some_matches)
+ {
+ cout << win_i << " plrf" << endl;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ debug_i = all_matches[sp_i].begin();
+ while (debug_i != all_matches[sp_i].end())
+ {
+ cout << *debug_i << " ";
+ debug_i++;
+ }
+ cout << "plrfff"<< endl;
+ }
+ }
+ */
+ // if 1st seq does match to all others, make all possible paths
+ // out of all these matches
+ if (some_matches)
+ {
+ sp_nodes.clear();
+ sp_nodes_end.clear();
+ // set each species list of matches to beginning
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ sp_nodes.push_back(all_matches[sp_i].begin());
+ sp_nodes_end.push_back(all_matches[sp_i].end());
+ }
+
+ still_paths = true;
+ sp_depth = species_num - 2; // this roves up & down species list
+ //cout << "fie\n";
+ while (still_paths)
+ {
+ // add path that each species iterator is pointing to
+ path.clear();
+ path.push_back(win_i);
+
+ //cout << win_i;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ //cout << ", " << *(sp_nodes[sp_i]);
+ path.push_back(*(sp_nodes[sp_i]));
+ }
+ //cout << endl;
+
+ pathz.push_back(path);
+
+ // now advance the right iterator
+ not_advanced = true;
+ while ( (not_advanced) && (sp_depth != -1) )
+ {
+ //cout << "foe\n";
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+ (sp_nodes[sp_depth])++; // advance iter at current depth
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+
+ // if we reached the end of the list, reset iter & go up one depth
+ if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
+ {
+ //cout << "fum\n";
+ sp_nodes[sp_depth] = all_matches[sp_depth].begin();
+ sp_depth--;
+ //cout << "depth = " << sp_depth << endl;
+ }
+ else
+ not_advanced = false;
+ }
+
+ if (sp_depth == -1) // jumped up to first species, all paths searched
+ still_paths = false;
+ else // otherwise just reset to max depth and continue
+ sp_depth = species_num - 2;
+ }
+ }
+ }
+}
+
+
+
+
+void
+Nway_Paths::trans_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, sp_i, sp_depth, window_num, i, cur_node;
+ bool some_matches, still_paths, not_advanced, trans_good;
+ list<int> new_nodes, trans_check_nodes;
+ vector<list<int> > all_matches;
+ vector<list<int>::iterator> sp_nodes, sp_nodes_end;
+ list<int>::iterator debug_i;
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl; // just a sanity check
+
+ sp_nodes.reserve(species_num);
+ sp_nodes_end.reserve(species_num);
+
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ // first we see if the first seq has matches to all other seqs at this win
+ some_matches = true;
+ sp_i = 1;
+ all_matches.clear();
+ while ( (sp_i < species_num) && (some_matches) )
+ {
+ new_nodes.clear();
+ new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ if (new_nodes.empty())
+ some_matches = false;
+
+ all_matches.push_back(new_nodes);
+ sp_i++;
+ }
+ //cout << "fee\n";
+ /*
+ if (some_matches)
+ {
+ cout << win_i << " plrf" << endl;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ debug_i = all_matches[sp_i].begin();
+ while (debug_i != all_matches[sp_i].end())
+ {
+ cout << *debug_i << " ";
+ debug_i++;
+ }
+ cout << "plrfff"<< endl;
+ }
+ }
+ */
+ // if 1st seq does match to all others, make all possible paths
+ // out of all these matches
+ if (some_matches)
+ {
+ sp_nodes.clear();
+ sp_nodes_end.clear();
+ // set each species list of matches to beginning
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ sp_nodes.push_back(all_matches[sp_i].begin());
+ sp_nodes_end.push_back(all_matches[sp_i].end());
+ }
+
+ still_paths = true;
+ //cout << "fie\n";
+ while (still_paths)
+ {
+ // add path that each species iterator is pointing to
+ path.clear();
+ path.push_back(win_i);
+
+ //cout << win_i;
+ for (sp_i = 0; sp_i < species_num-1; sp_i++)
+ {
+ //cout << ", " << *(sp_nodes[sp_i]);
+ path.push_back(*(sp_nodes[sp_i]));
+ }
+ //cout << endl;
+
+ // check transitivity
+ sp_depth = 1;
+ trans_good = true;
+ while ( (sp_depth != species_num-1) && (trans_good) )
+ {
+ cur_node = path[sp_depth];
+ for(i = sp_depth+1; i < species_num; i++)
+ {
+ trans_check_nodes = all_comparisons[sp_depth][i].matches(cur_node);
+ if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ path[i]) ) &&
+ (trans_check_nodes.end() == find(trans_check_nodes.begin(),
+ trans_check_nodes.end(),
+ path[i] * -1) ) )
+ trans_good = false;
+ }
+
+ sp_depth++;
+ }
+
+ if (trans_good)
+ pathz.push_back(path);
+
+ // now advance the right iterator
+ not_advanced = true;
+ sp_depth = species_num - 2; // this roves up & down species list
+ while ( (not_advanced) && (sp_depth != -1) )
+ {
+ //cout << "foe\n";
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+ (sp_nodes[sp_depth])++; // advance iter at current depth
+ //cout << sp_depth << ".." << *(sp_nodes[sp_depth]) << endl;
+
+ // if we reached the end of the list, reset iter & go up one depth
+ if (sp_nodes[sp_depth] == sp_nodes_end[sp_depth])
+ {
+ //cout << "fum\n";
+ sp_nodes[sp_depth] = all_matches[sp_depth].begin();
+ sp_depth--;
+ //cout << "depth = " << sp_depth << endl;
+ }
+ else
+ not_advanced = false;
+ }
+
+ if (sp_depth == -1) // jumped up to first species, all paths searched
+ still_paths = false;
+ else // otherwise just reset to max depth and continue
+ sp_depth = species_num - 2;
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
+/*
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ path.clear();
+ path.push_back(win_i);
+ cur_nodes = all_comparisons[0][1].matches(path[0]);
+ cur_nodes_i = cur_nodes.begin();
+ cur_nodes_end = cur_nodes.end();
+ path.push_back(0);
+ for (sp_i = 2; sp_i < species_num; sp_i++)
+ {
+ new_nodes = all_comparisons[0][sp_i].matches(path[0]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+
+ while(cur_nodes_i != cur_nodes_end)
+ {
+ intersect_bad = false;
+ if ( (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
+ *cur_nodes_i) ) &&
+ (new_nodes.end() == find(new_nodes.begin(), new_nodes.end(),
+ *cur_nodes_i * -1) ) )
+ intersect_bad = true;
+
+ // if no matches to this sequence, we don't need to check this node
+ // against any of the remaining ones
+ if (intersect_bad)
+ cur_nodes_i = cur_nodes.erase(cur_nodes_i); // this advances the iter
+ else
+ ++cur_nodes_i; // just advance normally
+
+ }
+ }
+
+ }
+*/
+
+
+/*
+ while(new_nodes_i != new_nodes_end)
+
+
+ path[1] = *new_nodes_i;
+ path_search(all_comparisons, path, 2);
+
+*/
+ //if (new_nodes_i != new_nodes_end)
+ //cout << "* species 0 node: " << win_i << endl;
+ // cout << "foookin hell\n";
+
+ //cout << " * species 1 node: " << *new_nodes_i << endl;
+
+ //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
+ // check transitivity with previous nodes in path
+
+/*
+void
+Nway_Paths::path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth)
+{
+ list<int> new_nodes, trans_check_nodes;
+ list<int>::iterator new_nodes_i, new_nodes_end;
+ int i;
+
+ new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+
+ if (trans_check_good)
+ {
+ // this makes sure path nodes are recorded with RC status relative to
+ // the base species
+ 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
+ pathz.push_back(path);
+ path.pop_back();
+ }
+ ++new_nodes_i;
+ }
+}
+*/
+// cout << " ****I have the power...\n";
+
+/* use this if I ever get the friggin seqcomp match lists to sort...
+ if (binary_search(trans_check_nodes.begin(), trans_check_nodes.end(),
+ *new_nodes_i))
+*/