mussa_nway_other.o : mussa_nway_other.cc mussa_nway.hh
$(CC) $(CFLAGS) $(OFLAG) -c mussa_nway_other.cc
+mussa_nway_entropy.o : mussa_nway_entropy.cc mussa_nway.hh
+ $(CC) $(CFLAGS) $(OFLAG) -c mussa_nway_entropy.cc
+
mussa_class.o : mussa_class.cc mussa_class.hh
$(CC) $(CFLAGS) -c mussa_class.cc
mussa_gui_seq.o : mussa_gui_seq.cc mussa_gui_seq.hh
$(CC) $(CFLAGS) -c mussa_gui_seq.cc
+mussa_gui_seq_text.o : mussa_gui_seq_text.cc mussa_gui_seq_text.hh
+ $(CC) $(CFLAGS) -c mussa_gui_seq_text.cc
+
mussa_gui_motif_window.o : mussa_gui_motif_window.cc mussa_gui_motif_window.hh
$(CC) $(CFLAGS) -c mussa_gui_motif_window.cc
+mussa_gui_annot_window.o : mussa_gui_annot_window.cc mussa_gui_annot_window.hh
+ $(CC) $(CFLAGS) -c mussa_gui_annot_window.cc
+
mussa_gui_load_window.o : mussa_gui_load_window.cc mussa_gui_load_window.hh
$(CC) $(CFLAGS) -c mussa_gui_load_window.cc
+mussa_gui_subana.o : mussa_gui_subana.cc mussa_gui_subana.hh
+ $(CC) $(CFLAGS) -c mussa_gui_subana.cc
+
mussa_gui_conn_view.o : mussa_gui_conn_view.cc mussa_gui_conn_view.hh
$(CC) $(CFLAGS) -O -c mussa_gui_conn_view.cc
$(CC) $(CFLAGS) -c mussa_gui_conn_window.cc
mussa : sequence.o flp.o flp_seqcomp.o \
- mussa_nway.o mussa_nway_other.o mussa_class.o \
+ mussa_nway.o mussa_nway_other.o \
+ mussa_nway_entropy.o mussa_class.o \
mussa_gui_seq.o mussa_gui_seq_view.o \
- mussa_gui_motif_window.o mussa_gui_load_window.o \
+ mussa_gui_motif_window.o mussa_gui_annot_window.o \
+ mussa_gui_load_window.o mussa_gui_subana.o \
+ mussa_gui_seq_text.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_load_window.o \
+ mussa_gui_seq_text.o \
+ mussa_gui_subana.o mussa_gui_load_window.o \
+ mussa_gui_motif_window.o mussa_gui_annot_window.o \
mussa_gui_seq.o mussa_gui_seq_view.o \
- mussa_class.o mussa_nway.o mussa_nway_other.o \
+ mussa_class.o mussa_nway.o \
+ mussa_nway_entropy.o mussa_nway_other.o \
flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
clean :
rm *.o
+cleaner :
+ rm *~
+
#mussa_overlord.o : mussa_overlord.cc mussa_overlord.hh
# $(CC) $(CFLAGS) -c mussa_overlord.cc
return these_matches;
}
+list<int>
+FLPs::thres_matches(int index, int thres)
+{
+ list<int> thres_matches;
+ list<match>::iterator list_i, list_end;
+
+ index = abs(index);
+ list_i = all_matches[index].begin();
+ list_end = all_matches[index].end();
+ thres_matches.clear();
+
+ //if (list_i == list_end)
+ //cout << "its fuckin empty!!!!";
+ while (list_i != list_end)
+ {
+ if (list_i->score >= thres)
+ thres_matches.push_back(list_i->index);
+ //cout << list_i->index << " ";
+
+ ++list_i;
+ }
+ //cout << endl;
+
+ return thres_matches;
+}
+
void
FLPs::file_save(string save_file_path)
FLPs::file_load(string file_path)
{
fstream data_file;
- string file_data, file_data_line, index_data, score_data;
- int type, window, hard_thres, index, score;
+ string file_data, file_data_line, pair_data, index_data, score_data;
+ int type, window, hard_thres;
+ match a_match;
+ string::size_type split_index, comma_index;
bool tag_open = false;
+ list<match> a_match_list;
+ int i;
+
+
+
+
data_file.open(file_path.c_str(), ios::in);
while ((!data_file.eof()) && tag_open)
{
+ // intialize list to empty
+ a_match_list.clear();
+
getline(data_file,file_data_line);
- /*
- if ( = "</Seqcomp>")
+
+ if (file_data_line == "</Seqcomp>")
tag_open = false;
// parse line of matches
+ else if (file_data_line == "")
+ {
+ //cout << "empty line\n";
+ all_matches.push_back(a_match_list);
+ }
else
{
- needs stuff...um, code...
- {
- index = atoi(index_data);
- core = atoi(score_data);
- cout << index << "," << score << " ";
- data_file >> index_data;
+ split_index = file_data_line.find(" ");
+
+ while (split_index != string::npos)
{
+ pair_data = file_data_line.substr(0,split_index);
+ file_data_line = file_data_line.substr(split_index+1);
+ //cout << "pair_data = " << pair_data << "...";
+ // parse out the 2 pieces of data, index and score of pair match
+ comma_index = pair_data.find(",");
+ index_data = pair_data.substr(0, comma_index);
+ a_match.index = atoi(index_data.c_str() );
+ score_data = pair_data.substr(comma_index+1);
+ a_match.score = atoi(score_data.c_str() );
+
+ //cout << a_match.index << "," << a_match.score << " ";
+
+ a_match_list.push_back(a_match);
+
+ split_index = file_data_line.find(" ");
+ }
+ //cout << "\n";
+ all_matches.push_back(a_match_list);
}
- cout << "\n";
- */
}
-
+ seq1_win_num = all_matches.size();
+ cout << "windows in flp = " << all_matches.size() << endl;
data_file.close();
}
int score;
};
- vector<list<match> > all_matches;
+
public:
void seqcomp(string seq1, string seq2, bool is_RC);
//bool FLPs::match_less(match *match1, match *match2);
//void FLPs::sort();
- list<int> matches(int index); //later maybe version with int threshold
+ list<int> matches(int index);
+ //version with int threshold
+ list<int> thres_matches(int index, int thres);
int win_num();
void file_save(string save_file_path);
void file_load(string file_path);
+
+ vector<list<match> > all_matches;
};
#include "mussa_gui_conn_window.hh"
+
char
parse_args(int argc, char **argv, string *a_file_path, int *window,
- int *threshold)
-{
- int i;
- string an_arg;
- char run_mode;
-
- *window = 0;
- *threshold = 0;
-
- // minimal arg reading structure, not very robust to errors
-
-
- run_mode = 'g';
- i = 1;
- while (i < argc)
- {
- an_arg = * ++argv;
- i++;
-
- if (an_arg == "-v")
- {
- *a_file_path = * ++argv;
- i++;
- run_mode = 'v';
- }
- else if (an_arg == "-n")
- {
- *a_file_path = * ++argv;
- i++;
- run_mode = 'n';
- }
- else if (an_arg == "-w")
- {
- *window = atoi(* ++argv);
- i++;
- }
- else if (an_arg == "-t")
- {
- *threshold = atoi(* ++argv);
- i++;
- }
- else
- {
- *a_file_path = an_arg;
- run_mode = 'f';
- }
- }
- return run_mode;
-}
+ int *threshold, char *ana_mode, float *ent_thres);
int main(int argc, char **argv)
string a_file_path;
char * picked_file;
int window, threshold;
- char run_mode;
+ float ent_thres;
+ char run_mode, ana_mode;
int x_max=1000;
int y_max=500;
string err_msg;
+
err_msg = "";
// yeah, its horrible to be passing these by reference, but I just don't see
// any other way without making parse_args part of MussaClass, which just
// seems wrong (args are after all, an io type thing, and the gui only mode
// will have it own way as well...
- run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold);
+ run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
+ &ana_mode, &ent_thres);
- if ((run_mode == 'f') || (run_mode == 'n'))
+ cout << "mussa: run mode = " << run_mode;
+ cout << "\tfile_path = "<< a_file_path << endl;
+ cout << "mussa: ent_thres = " << ent_thres << endl;
+
+ // if no error from parse args (run_mode = 'e', ie error), run in proper mode
+ if (run_mode != 'e')
{
- err_msg = an_analysis.load_mupa_file(a_file_path);
- err_msg = an_analysis.analyze(window, threshold);
- //an_overlord.do_analysis();
- }
+ if ((run_mode == 'f') || (run_mode == 'n'))
+ {
+ err_msg = an_analysis.load_mupa_file(a_file_path);
+ err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
+ //an_overlord.do_analysis();
+ }
- if (run_mode == 'v')
- err_msg = an_analysis.load(a_file_path);
+ if (run_mode == 'v')
+ err_msg = an_analysis.load(a_file_path);
//an_overlord.get_analysis();
- // no longer needed, but still semi-useful reality check...
- if (run_mode == 'g')
- {
- cout << "GTV - All Gui, All the Time\n";
- }
+ // no longer needed, but still semi-useful reality check...
+ if (run_mode == 'g')
+ {
+ cout << "GTV - All Gui, All the Time\n";
+ }
- if (err_msg == "")
- {
- if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
+ if (err_msg == "")
{
- //an_overlord.spawnConnView(1000,500);
- ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
+ if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
+ {
+ //an_overlord.spawnConnView(1000,500);
+ ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
- // we have an analysis already if in these 2 modes
- if ((run_mode == 'f') || (run_mode == 'v'))
- a_conn_win->add_ana(&an_analysis);
+ // we have an analysis already if in these 2 modes
+ if ((run_mode == 'f') || (run_mode == 'v'))
+ a_conn_win->add_ana(&an_analysis);
- Fl::run();
+ Fl::run();
+ }
}
+ else
+ cout << err_msg << endl;
+ }
+}
+
+
+// minimal arg reading function, not very robust to errors
+char
+parse_args(int argc, char **argv, string *a_file_path, int *window,
+ int *threshold, char *ana_mode, float *ent_thres)
+{
+ int i, else_i;
+ string an_arg;
+ char run_mode;
+
+ // initialize these to 0 as flag if they are not changed
+ *window = 0;
+ *threshold = 0;
+ *ent_thres = 0.0;
+ run_mode = 'e'; //error default if no run mode set implicitly or explicitly
+ *ana_mode = 't'; // default to transitivie analyses mode
+
+
+
+ // no args means gui only mode
+ if (argc == 1)
+ run_mode = 'g';
+ // 1 arg means its a mupa file and run in full mode
+ /*
+ else if (argc == 2)
+ {
}
+ */
else
- cout << err_msg << endl;
+ {
+ else_i = 0;
+ i = 1;
+ while (i < argc)
+ {
+ an_arg = * ++argv;
+ i++;
+
+ // see what alternate mode the user wants to run in
+ if (an_arg == "-m")
+ {
+ an_arg = * ++argv;
+ i++;
+ if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
+ run_mode = an_arg[0];
+ else
+ {
+ cout << "Error: \'" << an_arg;
+ cout << "\' is not a valid analysis mode for -a argument" << endl;
+ run_mode = 'e';
+ }
+ *a_file_path = * ++argv;
+ i++;
+ }
+ // alternate analyses modes
+ else if (an_arg == "-a")
+ {
+ an_arg = * ++argv;
+ i++;
+ // t = transitive, r = radial, e = entropy
+ if ( (an_arg == "t") || (an_arg == "r") || (an_arg == "e") )
+ *ana_mode = an_arg[0];
+ else
+ {
+ cout << "Error: \'" << an_arg;
+ cout << "\' is not a valid run mode for -m argument" << endl;
+ run_mode = 'e';
+ }
+
+ }
+ else if (an_arg == "-w") // alternate window size arg
+ {
+ *window = atoi(* ++argv);
+ i++;
+ }
+ else if (an_arg == "-t") // alternate threshold arg
+ {
+ *threshold = atoi(* ++argv);
+ i++;
+ }
+ else if (an_arg == "-et") // alternate entropy threshold arg
+ {
+ *ent_thres = atof(* ++argv);
+ i++;
+ }
+ else
+ {
+ if (else_i == 0)
+ {
+ *a_file_path = an_arg;
+ run_mode = 'f';
+ else_i++;
+ }
+ else
+ {
+ //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
+ cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;
+ run_mode == 'e';
+ }
+ }
+ }
+ }
+
+ return run_mode;
}
+
/*
cout << "fee\n";
cout << "fie\n";
// ----------------------------------------
#include "mussa_class.hh"
-
-// doesn't do neg ints...
-// should get rid of and replace int to str needs with string stream stuff...
-string
-int_to_str(int an_int)
-{
- string converted_int;
- int remainder;
-
- converted_int = "";
-
- if (an_int == 0)
- converted_int = "0";
-
- while (an_int != 0)
- {
- remainder = an_int % 10;
-
- if (remainder == 0)
- converted_int = "0" + converted_int;
- else if (remainder == 1)
- converted_int = "1" + converted_int;
- else if (remainder == 2)
- converted_int = "2" + converted_int;
- else if (remainder == 3)
- converted_int = "3" + converted_int;
- else if (remainder == 4)
- converted_int = "4" + converted_int;
- else if (remainder == 5)
- converted_int = "5" + converted_int;
- else if (remainder == 6)
- converted_int = "6" + converted_int;
- else if (remainder == 7)
- converted_int = "7" + converted_int;
- else if (remainder == 8)
- converted_int = "8" + converted_int;
- else if (remainder == 9)
- converted_int = "9" + converted_int;
-
- an_int = an_int / 10;
- }
-
- return converted_int;
-}
-
+#include <sstream>
Mussa::Mussa()
{
seq_num = 0;
window = 0;
threshold = 0;
+ soft_thres = 0;
win_append = false;
thres_append = false;
seq_files.clear();
Mussa::set_threshold(int a_threshold)
{
threshold = a_threshold;
+ //soft_thres = a_threshold;
+}
+
+void
+Mussa::set_soft_thres(int sft_thres)
+{
+ soft_thres = sft_thres;
+}
+
+void
+Mussa::set_ana_mode(char new_ana_mode)
+{
+ ana_mode = new_ana_mode;
+}
+
+// takes a string and sets it as the next seq - no AGCTN checking atm
+void
+Mussa::add_a_seq(string a_seq)
+{
+ Sequence aSeq;
+
+ aSeq.set_seq(a_seq);
+ the_Seqs.push_back(aSeq);
}
+
// sets info for just 1 seq at a time
void
Mussa::set_seq_info(string seq_file, string annot_file, int fa_i, int a_start, int the_end)
Mussa::load_mupa_file(string para_file_path)
{
ifstream para_file;
- string file_data_line;
+ string file_data_line, file_path_base;
string param, value, annot_file;
int split_index, fasta_index;
int sub_seq_start, sub_seq_end;
bool seq_params, did_seq;
string err_msg;
int bogo;
+ bool parsing_path;
+ int new_index, dir_index;
// initialize values
// if file was opened, read the parameter values
if (para_file)
{
+ // need to find the path to the .mupa file
+ parsing_path = true;
+ dir_index = 0;
+ while (parsing_path)
+ {
+ new_index = (para_file_path.substr(dir_index)).find("/");
+ //cout << "mu class: "<< new_index << endl;
+ if (new_index > 0)
+ dir_index += new_index + 1;
+ else
+ parsing_path = false;
+ }
+
+ file_path_base = para_file_path.substr(0,dir_index);
+ cout << "mu class: mupa base path = " << file_path_base << endl;
+
// setup loop by getting file's first line
getline(para_file,file_data_line);
split_index = file_data_line.find(" ");
threshold = atoi(value.c_str());
else if (param == "SEQUENCE")
{
- seq_files.push_back(value);
+ seq_files.push_back(file_path_base + value);
fasta_index = 1;
annot_file = "";
sub_seq_start = 0;
if (param == "FASTA_INDEX")
fasta_index = atoi(value.c_str());
else if (param == "ANNOTATION")
- annot_file = value;
+ annot_file = file_path_base + value;
else if (param == "SEQ_START")
sub_seq_start = atoi(value.c_str());
else if (param == "SEQ_END")
para_file.close();
- cout << "ana_name = " << ana_name << win_append << win_append << "\n";
- cout << "window = " << window << " threshold = " << threshold << "\n";
+ soft_thres = threshold;
+ cout << "nway mupa: ana_name = " << ana_name << " seq_num = " << seq_num;
+ cout << " window = " << window << " threshold = " << threshold << endl;
return "";
}
string
-Mussa::analyze(int w, int t)
+Mussa::analyze(int w, int t, char the_ana_mode, double new_ent_thres)
{
string err_msg;
time_t t1, t2, begin, end;
double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
- int seq_num;
+
+
+ cout << "nway ana: seq_num = " << seq_num << endl;
begin = time(NULL);
//t2 = time(NULL);
//setuptime = difftime(t2, t1);
+ ana_mode = the_ana_mode;
+ ent_thres = new_ent_thres;
if (w > 0)
window = w;
if (t > 0)
+ {
threshold = t;
+ soft_thres = t;
+ }
//if (err_msg == "")
//{
cout << "foe\n";
t1 = time(NULL);
+ cout << "nway ana: seq_num = " << seq_num << endl;
+ the_paths.setup(seq_num, window, threshold);
nway();
t2 = time(NULL);
nwaytime = difftime(t2, t1);
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);
- //all_comps[i][i2].file_save(save_file_string);
}
}
void
Mussa::nway()
{
- the_paths.setup(seq_num, window, threshold);
- //the_paths.find_paths_r(all_comps);
- the_paths.trans_path_search(all_comps);
- //the_paths.radiate_path_search(all_comps);
+ vector<string> some_Seqs;
+ int i;
+
+
+ cout << "nway: ana mode = " << ana_mode << endl;
+ cout << "nway: seq_num = " << seq_num << endl;
+
+ the_paths.set_soft_thres(soft_thres);
+
+ if (ana_mode == 't')
+ the_paths.trans_path_search(all_comps);
+
+ else if (ana_mode == 'r')
+ the_paths.radiate_path_search(all_comps);
+
+ else if (ana_mode == 'e')
+ {
+ //unlike other methods, entropy needs to look at the sequence at this stage
+ some_Seqs.clear();
+ for(i = 0; i < seq_num; i++)
+ some_Seqs.push_back(the_Seqs[i].seq());
+
+ the_paths.setup_ent(ent_thres, some_Seqs); // ent analysis extra setup
+ the_paths.entropy_path_search(all_comps);
+ }
+
+ // old recursive transitive analysis function
+ else if (ana_mode == 'o')
+ the_paths.find_paths_r(all_comps);
+
the_paths.simple_refine();
}
void
Mussa::save()
{
- string save_path_base, save_path;
+ string save_path_base, save_path, create_dir_cmd, flp_filepath;
fstream save_file;
- int i;
+ ostringstream append_info;
+ int i, i2, dir_create_status;
- // gotta do bit with adding win & thres if to be appended - need itos
// not sure why, but gotta close file each time since can't pass file streams
save_path_base = ana_name;
+ // gotta do bit with adding win & thres if to be appended
if (win_append)
- save_path_base += "_w" + int_to_str(window);
+ {
+ append_info.str("");
+ append_info << "_w" << window;
+ save_path_base += append_info.str();
+ }
if (thres_append)
- save_path_base += "_t" + int_to_str(threshold);
+ {
+ append_info.str("");
+ append_info << "_t" << threshold;
+ save_path_base += append_info.str();
+ }
+
+//#include <stdlib.h>
+ create_dir_cmd = "mkdir " + save_path_base;
+ dir_create_status = system( (const char*) create_dir_cmd.c_str());
+ cout << "action: " << dir_create_status << endl;
// save sequence and annots to a special mussa file
- save_path = save_path_base + ".museq";
+ save_path = save_path_base + "/" + save_path_base + ".museq";
save_file.open(save_path.c_str(), ios::out);
save_file << "<Mussa_Sequence>" << endl;
//save_file.close();
save_file.close();
// save nway paths to its mussa save file
- save_path = save_path_base + ".muway";
+ save_path = save_path_base + "/" + save_path_base + ".muway";
+ the_paths.save(save_path);
+
+ for(i = 0; i < seq_num; i++)
+ for(i2 = i+1; i2 < seq_num; i2++)
+ {
+ append_info.str("");
+ append_info << "_sp_" << i << "v" << i2;
+ save_path = save_path_base + "/" + save_path_base + append_info.str() + ".flp";
+ all_comps[i][i2].file_save(save_path);
+ }
+}
+
+void
+Mussa::save_muway(string save_path)
+{
the_paths.save(save_path);
}
string
Mussa::load(string ana_file)
{
- int i;
- string load_file_path;
+ int i, i2, new_index, dir_index;
+ string file_path_base, a_file_path, ana_path;
+ bool parsing_path;
Sequence tmp_seq;
string err_msg;
+ ostringstream append_info;
+ vector<FLPs> empty_FLP_vector;
+ FLPs dummy_comp;
+
+ ana_path = ana_file;
+ parsing_path = true;
+ dir_index = 0;
+ while (parsing_path)
+ {
+ new_index = (ana_path.substr(dir_index)).find("/");
+ //cout << "mu class: "<< new_index << endl;
+ if (new_index > 0)
+ dir_index += new_index + 1;
+ else
+ parsing_path = false;
+ }
- ana_name = ana_file;
- load_file_path = ana_name + ".muway";
- err_msg = the_paths.load(load_file_path);
+ ana_name = ana_path.substr(dir_index);
+ cout << "mu class: ana_name = " << ana_name << endl;
+ file_path_base = ana_path + "/" + ana_path.substr(dir_index);
+ a_file_path = file_path_base + ".muway";
+ err_msg = the_paths.load(a_file_path);
+ cout << "there is no safe distance\n";
if (err_msg == "")
{
cout << "No BAM\n";
- load_file_path = ana_name + ".museq";
+ a_file_path = file_path_base + ".museq";
// this is a bit of a hack due to C++ not acting like it should with files
for (i = 1; i <= seq_num; i++)
{
tmp_seq.clear();
- tmp_seq.load_museq(load_file_path, i);
+ cout << "mussa_class: loading the fucking museq frag...\n";
+ tmp_seq.load_museq(a_file_path, i);
the_Seqs.push_back(tmp_seq);
}
+ empty_FLP_vector.clear();
+ for(i = 0; i < seq_num; i++)
+ {
+ all_comps.push_back(empty_FLP_vector);
+ for(i2 = 0; i2 < seq_num; i2++)
+ all_comps[i].push_back(dummy_comp);
+ }
+
+ for(i = 0; i < seq_num; i++)
+ for(i2 = i+1; i2 < seq_num; i2++)
+ {
+ append_info.str("");
+ append_info << "_sp_" << i << "v" << i2;
+ cout << append_info.str() << endl;
+ a_file_path = file_path_base + append_info.str() + ".flp";
+ all_comps[i][i2].file_load(a_file_path);
+ cout << "real size = " << all_comps[i][i2].all_matches.size() << endl;
+ }
+
+
return "";
}
else
// Private variables
// parameters needed for a mussa analysis
string ana_name;
- int seq_num, window, threshold;
+ int seq_num, window, threshold, soft_thres;
+ char ana_mode;
+ double ent_thres;
list<string> seq_files, annot_files;
list<int> fasta_indices, sub_seq_starts, sub_seq_ends;
bool win_override, thres_override;
// parameters need to be set before calling this
// w & t are for command line override functionality, set to 0 to ignore
- string analyze(int w, int t);
+ string analyze(int w, int t, char ana_mode, double ent_thres);
void save();
+ void save_muway(string save_path);
string load(string ana_file);
// clear parameters and initialize data lists
void set_seq_num(int a_num);
void set_window(int a_window);
void set_threshold(int a_threshold);
+ void set_soft_thres(int sft_thres);
+ void set_ana_mode(char new_ana_mode);
+ // sets an individual sequence to a string (no ATCGN checking atm)
+ void add_a_seq(string a_seq);
+ // sets info to load a seq and annotations from a fasta file
void set_seq_info(string seq_file, string annot_file, int fa_i, int a_start, int the_end);
// deprecated - support bridge for python version of mussa
--- /dev/null
+#include "mussa_gui_annot_window.hh"
+
+
+
+annot_color
+new_blank_annot()
+{
+ annot_color *a_annot;
+
+ a_annot = new annot_color;
+ a_annot->type = "";
+ a_annot->color = (Fl_Color) 5;
+ //cout << "type: " << a_annot->type << endl;
+
+ return *a_annot;
+}
+
+
+void
+cb_annot_color(Fl_Button* o, void* v)
+{
+ annot_instance * blah = (annot_instance *) v;
+ AnnotWindow* T= blah->mw_ptr;
+ T->cb_annot_color_i(o,blah->index);
+}
+
+AnnotWindow::AnnotWindow(int w, int h, const char* title,
+ vector<annot_color> * some_annots):Fl_Window(w,h,title)
+{
+ int i, annot_num;
+
+ the_annots = some_annots;
+ annot_count = 0;
+
+ annot_color_buttons.clear();
+
+ begin();
+ annot_input_pack = new Fl_Pack(0, 0, w, h);
+ annot_input_pack->spacing(4);
+
+ // button to add new annot inputs
+ add_annot = new Fl_Button(0,0,100,24,"Add Annot Slot");
+ add_annot->callback((Fl_Callback*)add_annot_cb, this);
+ annot_input_pack->add(add_annot);
+ // test button to make sure annot data is being stored
+ test = new Fl_Button(0,0,100,24,"show annots");
+ test->callback((Fl_Callback*)print_cb, this);
+ annot_input_pack->add(test);
+
+ // creat an initial set of annot input widgets and attach to annot vector
+ annot_num = some_annots->size();
+ for (i = 0; i < annot_num; i++)
+ {
+ add_annot_input(i);
+ annot_count++;
+ }
+
+ add(annot_input_pack);
+
+ end();
+ resizable(this);
+ show();
+}
+
+ //tmp_input->user_data((void*) i);
+
+AnnotWindow::~AnnotWindow(){}
+
+void
+AnnotWindow::add_annot_input(int index)
+{
+ Fl_Output * new_input;
+ Fl_Button *new_color_button;
+ annot_instance * something;
+ Fl_Pack * annot_hor_pack;
+
+
+ something = new annot_instance;
+ something->mw_ptr = this;
+ something->index = index;
+
+ annot_hor_pack = new Fl_Pack(0, 0, w(), 24);
+ annot_hor_pack->type(Fl_Pack::HORIZONTAL);
+ annot_hor_pack->spacing(4);
+
+ // setup the color display/selection button
+ new_color_button = new Fl_Button(0, 0, 24, 24, "");
+ new_color_button->color((*the_annots)[index].color);
+ new_color_button->box(FL_FLAT_BOX);
+ new_color_button->callback((Fl_Callback*)cb_annot_color, (void*) something);
+ annot_color_buttons.push_back(new_color_button);
+ annot_hor_pack->add(new_color_button);
+
+
+ // setup the annot inputs
+ new_input = new Fl_Output(0, 0, 200, 24, "");
+ new_input->value( ((*the_annots)[index].type).c_str() );
+ //new_input->callback((Fl_Callback*)cb_annot_in, (void*) something);
+ annot_ins.push_back(new_input);
+ annot_hor_pack->add(new_input);
+
+ annot_input_pack->add(annot_hor_pack);
+}
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void
+AnnotWindow::cb_annot_in_i(Fl_Input* o, int i)
+{
+ (*the_annots)[i].type = o->value();
+}
+
+void
+AnnotWindow::cb_annot_color_i(Fl_Button* o, int i)
+{
+ //Fl_Color new_color;
+
+ (*the_annots)[i].color = fl_show_colormap((*the_annots)[i].color);
+ //annot_color_buttons[i]->
+ o->color((*the_annots)[i].color);
+ redraw();
+}
+
+void AnnotWindow::add_annot_cb(Fl_Button* o, void* v)
+{
+ AnnotWindow* T=(AnnotWindow*)v;
+ T->add_annot_cb_real(o,v);
+}
+
+
+void AnnotWindow::add_annot_cb_real(Fl_Button* , void*)
+{
+ annot_color blank_annot;
+
+ //blank_annot.name = "";
+ //blank_annot.seq = "";
+ blank_annot = new_blank_annot();
+ (*the_annots).push_back(blank_annot);
+ add_annot_input(annot_count++);
+ redraw();
+}
+
+
+void AnnotWindow::print_cb(Fl_Button* o, void* v)
+{
+ AnnotWindow* T=(AnnotWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void AnnotWindow::print_cb_real(Fl_Button* , void*)
+{
+ int i;
+
+ for (i = 0; i < annot_count; i++)
+ cout << (*the_annots)[i].type << endl;
+}
+
+/*
+void
+cb_annot_in(Fl_Input* o, void* v)
+{
+ annot_instance * blah = (annot_instance *) v;
+ AnnotWindow* T= blah->mw_ptr;
+ T->cb_annot_in_i(o,blah->index);
+}
+
+
+*/
--- /dev/null
+#include "mussa_gui_motif_window.hh"
+
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Button.H>
+
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Output.H>
+#include <FL/Fl_Pack.H>
+#include <FL/fl_show_colormap.H>
+
+struct annot_color
+{
+ string type;
+ Fl_Color color;
+};
+
+//typedef annot_ptr *annot;
+
+
+class AnnotWindow : public Fl_Window
+{
+ public:
+ AnnotWindow(int w, int h, const char* title,
+ vector<annot_color> * some_annots);
+ ~AnnotWindow();
+ Fl_Pack * annot_input_pack;
+ list<Fl_Output*> annot_ins;
+ vector<Fl_Button*> annot_color_buttons;
+ list<Fl_Input*> name_ins;
+ Fl_Button* test;
+ Fl_Button* add_annot;
+
+ void cb_annot_in_i(Fl_Input*, int i);
+ void cb_annot_color_i(Fl_Button* o, int i);
+
+ private:
+ vector<annot_color> * the_annots;
+ int annot_count;
+
+ void add_annot_input(int index);
+
+ static void add_annot_cb(Fl_Button*, void*);
+ inline void add_annot_cb_real(Fl_Button*, void*);
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+struct annot_instance
+{
+ AnnotWindow * mw_ptr;
+ int index;
+};
+
+annot_color new_blank_annot();
vector<Sequence> *some_seqs,
Nway_Paths *some_paths)
{
- int i, seq_length;
+ int i, i2, seq_length;
Sequence a_seq;
motif blank_motif;
+ annot_color new_annot;
ana_name = name;
S = some_seqs;
P = some_paths;
+ cout << "num of paths = " << some_paths->refined_pathz.size() << endl;
+
cout << "x()=" << x() << " y()=" << y() << " w()=" << w() << " h()=" << h();
cout << endl;
}
name_pad = 80;
- y_pad = 8;
+ y_pad = 20;
x_scale_factor = (float) max_seq_len / (w() - name_pad);
cout << "scale factor is " << x_scale_factor << endl;
blank_motif = new_blank_motif();
some_motifs.push_back(blank_motif);
}
+
+ // find all unique annotation type ids
+ some_annots.clear();
+ vector<annot_color>::iterator annot_type_i;
+ list<annot>::iterator annot_i;
+
+ // loop thru all sequences
+ for(i2 = 0; i2 < seq_num; i2++)
+ {
+ cout << "ConnView: annotation loop\n";
+ // loop thru all annotation entries in this sequence
+ for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
+ {
+ cout << annot_i->start << ", " << annot_i->end << " : ";
+ cout << annot_i->name << " " << annot_i->type << endl;
+ // loop thru annotation types
+ annot_type_i = some_annots.begin();
+ bool type_unfound = true;
+ while ((annot_type_i != some_annots.end()) && type_unfound)
+ {
+ if (annot_i->type == annot_type_i->type)
+ type_unfound = false; // stop search if found
+ ++annot_type_i;
+ }
+ //if unfound, then add to list
+ if (type_unfound)
+ {
+ new_annot = new_blank_annot();
+ new_annot.type = annot_i->type;
+ some_annots.push_back(new_annot);
+ }
+ }
+ }
}
draw_sequence_stuff();
// draw selection box
+ /*
if (selected)
{
fl_color(FL_BLACK);
fl_rect(drag_start,(ref_seq_num*y_seq_incre)+y(),drag_end-drag_start,
16);
}
+ */
}
void
ConnView::draw_sequence_stuff()
{
- int i2, i3, y_loc, y_offset, x_loc, x_start, x_end;
+ int i2, i3, y_loc, y_offset, x_loc, x_start, x_end, mv_offset;
list<annot>::iterator annot_i;
string species_name, seq_length;
stringstream raw_length;
//fl_line(x(),y()+h()-y_pad/2,w()-name_pad,y()+h()-y_pad/2);
// draw annotations
+ vector<annot_color>::iterator annot_type_i;
+
fl_color(FL_GREEN);
fl_line_style(FL_SOLID, 3, NULL);
y_loc = y()+y_pad;
for(i2 = 0; i2 < seq_num; i2++)
{
+ // loop thru all annotation entries
for(annot_i = (*S)[i2].annots.begin(); annot_i != (*S)[i2].annots.end(); ++annot_i)
{
+ fl_line_style(FL_SOLID, 3, NULL);
+ mv_offset = 0;
+
+ // loop thru annotation types to determine color
+ annot_type_i = some_annots.begin();
+ bool type_unfound = true;
+ while ((annot_type_i != some_annots.end()) && type_unfound)
+ {
+ if (annot_i->type == annot_type_i->type)
+ {
+ fl_color(annot_type_i->color);
+ type_unfound = false;
+ }
+ else
+ fl_color(FL_GREEN);
+ ++annot_type_i;
+ }
+
+ // calculate scaled start and end, and draw
x_start = (int)(annot_i->start / x_scale_factor) + x();
x_end = (int)(annot_i->end / x_scale_factor) + x();
- fl_line(x_start,y_loc,x_end,y_loc);
+ fl_line(x_start,y_loc+mv_offset,x_end,y_loc+mv_offset);
}
y_loc += y_seq_incre;
}
int i2, i3, y_loc, x_loc, x_start, x_end;
vector<int> a_path;
list<bool>::iterator highlight_i;
- int seq_y_max;
+ int y_max;
+ string window_name;
if (selected)
++highlight_i;
}
+ // give 50 pixels of height per sequence
+ y_max = seq_num * 50;
+ window_name = "Mussa Sequence: " + ana_name;
- a_seq_win = new SeqWinMaster(1000,ana_name, seq_num, S, selected_paths,
- seq_lens,&some_motifs);
- a_seq_win->make_window();
+ a_seq_win = new SeqWindow(800, y_max, (const char*) window_name.c_str(),
+ seq_num,
+ S, selected_paths, seq_lens, &some_motifs);
}
}
{
motif_find_window = new MotifWindow(300, 300, "Motifs", &some_motifs);
}
+
+void
+ConnView::annot_win()
+{
+ annot_color_window = new AnnotWindow(300, 300, "Annotations", &some_annots);
+}
+
+// @!@! special hacked in color coding for the myf5/6 region annots
+
+/*
+ if (annot_i->type == "mvista")
+ {
+ fl_color(255,230,0);
+ fl_line_style(FL_SOLID, 8, NULL);
+ mv_offset = -4;
+ }
+ else if (annot_i->type == "reg")
+ {
+ fl_line_style(FL_SOLID, 10, NULL);
+ mv_offset = -8;
+
+ if (annot_i->name == "CNS")
+ fl_color(255,150,0);
+ else if (annot_i->name == "ELA")
+ fl_color(0,200,120);
+ else if (annot_i->name == "ES")
+ fl_color(0,200,200);
+ else if (annot_i->name == "NA")
+ fl_color(120,120,120);
+ else if (annot_i->name == "EA")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -13;
+ fl_color(0,200,120);
+ }
+ else if (annot_i->name == "VS")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -6;
+ fl_color(255,255,0);
+ }
+ else if (annot_i->name == "SP")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -13;
+ fl_color(255,230,150);
+ }
+ else if (annot_i->name == "L")
+ {
+ fl_line_style(FL_SOLID, 7, NULL);
+ mv_offset = -6;
+ fl_color(0,0,100);
+ }
+ else if (annot_i->name == "TCM")
+ fl_color(0,130,230);
+ }
+*/
-#include "mussa_gui_seq.hh"
+#include "mussa_gui_subana.hh"
#include <sstream>
void setup(string name, int sq_num, int win_len,
vector<Sequence> *, Nway_Paths *);
void scale_paths();
+
+ void spawnSeq();
+ void find_motifs();
+ void annot_win();
+
void toggle_bars();
void set_bar_interval(int new_bar_len);
void toggle_lines();
void set_line_interval(int new_line_len);
+
private:
string ana_name;
int seq_num, window, threshold;
vector<motif> some_motifs;
MotifWindow *motif_find_window;
- SeqWinMaster *a_seq_win;
+ //keeps track of the colors assigned to each motif type
+ vector<annot_color> some_annots;
+ AnnotWindow *annot_color_window;
+
+ SeqWindow *a_seq_win;
void draw();
void draw_paths();
void resize(int x, int y, int w, int h);
int handle(int e);
void check_new_motifs();
- void spawnSeq();
- void find_motifs();
//for drawing function debugging
void reporter(string var, int value);
string err_msg;
cout << "Load! Load! Load, ye yellow-bellied seadogs!\n";
- picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
- a_file_path = picked_file;
- cout << picked_file << endl;
- cout << a_file_path << endl;
- cout << a_file_path.substr(0,a_file_path.find(".mu")) << endl;
-
- // load the analysis
- an_analysis = new Mussa();
- err_msg = an_analysis->load(a_file_path.substr(0,a_file_path.find(".mu")));
-
- if (err_msg == "")
+ //picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ picked_file = fl_dir_chooser("Find an Analysis", "", 1);
+ if (picked_file != NULL)
{
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
- // show the user the analysis
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
- conn_box->scale_paths();
- }
- else
- {
- fl_alert(err_msg.c_str());
- cout << err_msg << endl;
+ a_file_path = picked_file;
+ cout << "doo wah diddy diddy dum diddy doo\n";
+ cout << a_file_path << endl;
+
+ // load the analysis
+ an_analysis = new Mussa();
+ err_msg = an_analysis->load(a_file_path);
+ //.substr(0,a_file_path.find(".mu")));
+
+ if (err_msg == "")
+ {
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+ // show the user the analysis
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+ conn_box->scale_paths();
+ }
+ else
+ {
+ fl_alert(err_msg.c_str());
+ cout << err_msg << endl;
+ }
}
}
string err_msg;
picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
- a_file_path = picked_file;
+ if (picked_file != NULL)
+ {
+ a_file_path = picked_file;
+
+ an_analysis = new Mussa();
+ err_msg = an_analysis->load_mupa_file(a_file_path);
+
+ if (err_msg == "")
+ {
+ err_msg = an_analysis->analyze(0, 0, 't', 0.0);
+ }
+
+ if (err_msg == "")
+ {
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+ // show the user the analysis
+ conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+ conn_box->scale_paths();
+ }
+ else
+ {
+ fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+ }
+}
+
+void
+setup_ana_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_setup_ana_cb();
+}
+
+void
+ConnWindow::real_setup_ana_cb()
+{
an_analysis = new Mussa();
- err_msg = an_analysis->load_mupa_file(a_file_path);
+ setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
- if (err_msg == "")
- {
- err_msg = an_analysis->analyze(0, 0);
- }
+ while(setup_win->visible())
+ Fl::wait(.1);
+ cout << "Like a warm summer day\n";
- if (err_msg == "")
+ if (setup_win->done())
{
// relabel window with the analysis name
window_name = "Mussa: " + an_analysis->ana_name;
label((const char*)window_name.c_str());
- // show the user the analysis
+ // is it this easy? what if setup window encounters an error...??
conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
+ an_analysis->window, &(an_analysis->the_Seqs),
+ &(an_analysis->the_paths));
+
conn_box->scale_paths();
}
- else
- {
- fl_alert(err_msg.c_str());
- cout << err_msg;
- }
}
+
void
-setup_ana_cb(Fl_Button* o, void* v)
+subana_cb(Fl_Button* o, void* v)
{
ConnWindow* T=(ConnWindow*)v;
- T->real_setup_ana_cb();
+ T->real_subana_cb();
}
void
-ConnWindow::real_setup_ana_cb()
+ConnWindow::real_subana_cb()
{
- an_analysis = new Mussa();
- setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
+ string subana_name;
- while(setup_win->visible())
+ sub_analysis = new Mussa();
+ subana_win = new SubanaWindow(500,400,"Sub Analysis Setup", sub_analysis,
+ an_analysis->the_Seqs);
+
+ while(subana_win->visible())
Fl::wait(.1);
cout << "Like a warm summer day\n";
- // relabel window with the analysis name
- window_name = "Mussa: " + an_analysis->ana_name;
- label((const char*)window_name.c_str());
- // is it this easy? what if setup window encounters an error...??
- conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
- an_analysis->window, &(an_analysis->the_Seqs),
- &(an_analysis->the_paths));
- cout << "Like a warm day in may\n";
- conn_box->scale_paths();
+ if (subana_win->done())
+ {
+ subana_name = "SubMussa: " + sub_analysis->ana_name;
+ sub_conn_win = new ConnWindow(w(), h(), (const char*) subana_name.c_str());
+ cout << "Like a warm day in may\n";
+ sub_conn_win->add_ana(sub_analysis);
+ //Fl::visual(FL_DOUBLE|FL_INDEX);
+ //sub_conn_box->show();
+ }
+}
+
+
+void
+seq_show_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_seq_show_cb();
}
+void
+ConnWindow::real_seq_show_cb()
+{
+ show_seq_win = new SeqTextWin(500,400,"Seq Show", an_analysis->the_Seqs);
+}
+
+void
+seq_win_spawn_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_seq_win_spawn_cb();
+}
+
+void
+ConnWindow::real_seq_win_spawn_cb()
+{
+ conn_box->spawnSeq();
+}
+
+void
+motif_find_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_motif_find_cb();
+}
+
+void
+ConnWindow::real_motif_find_cb()
+{
+ conn_box->find_motifs();
+}
+
+void
+annot_win_cb(Fl_Button* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ T->real_annot_win_cb();
+}
+
+void
+ConnWindow::real_annot_win_cb()
+{
+ conn_box->annot_win();
+}
+
+
// all the crap needed for dealing with the scale bars
void
toggle_scale_bars_cb(Fl_Button* o, void* v)
}
+// setting new soft threshold
+
+void
+set_soft_thres_cb(Fl_Input* o, void* v)
+{
+ ConnWindow* T=(ConnWindow*)v;
+ cout << "WAAAAAAAAA\n";
+ T->real_set_soft_thres_cb(o);
+}
+
+void
+ConnWindow::real_set_soft_thres_cb(Fl_Input* o)
+{
+ int new_soft_thres;
+
+ new_soft_thres = atoi(o->value());
+ cout << "new soft thres = " << new_soft_thres << endl;
+
+ an_analysis->set_soft_thres(new_soft_thres);
+ an_analysis->set_ana_mode('t');
+ an_analysis->nway();
+ conn_box->scale_paths();
+ conn_box->redraw();
+
+ // hacked in stuff to save muway files at different thresholds
+ string save_path;
+ ostringstream append_info;
+
+ save_path = an_analysis->ana_name + "/"
+ + an_analysis->ana_name.substr(0,an_analysis->ana_name.find("_t"));
+ append_info.str("");
+ append_info << "_t" << new_soft_thres << ".muway";
+ //<< "_w" << an_analysis->window
+ save_path += append_info.str();
+ cout << "saving as: " << save_path << endl;
+ an_analysis->save_muway(save_path);
+}
+
+
+
ConnWindow::ConnWindow(int w, int h, const char* title):
Fl_Double_Window(w,h,title)
{
int button_len = 120;
- Fl_Color a_color = fl_rgb_color(150, 200, 255);;
+ Fl_Color a_color = fl_rgb_color(150, 200, 255);
padding = 5;
// create file menu button
- file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "File");
+ file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "Analysis");
file_menu->color(FL_WHITE,a_color);
file_menu->box(FL_BORDER_BOX);
file_menu->clear();
file_menu->add("Do Analysis", 0, (Fl_Callback *) do_ana_cb, this);
file_menu->add("Load Analysis", 0, (Fl_Callback *) load_ana_cb, this);
file_menu->add("Setup Analysis", 0, (Fl_Callback *) setup_ana_cb, this);
-
- toggle_divs = new Fl_Button(padding+button_len, 2, button_len, 30, "Toggle Bars");
- toggle_divs->color(FL_WHITE,a_color);
- toggle_divs->box(FL_BORDER_BOX);
- toggle_divs->callback((Fl_Callback*) toggle_scale_bars_cb, this);
-
- new_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
- new_input->value("");
- new_input->when(FL_WHEN_ENTER_KEY);
- new_input->callback((Fl_Callback*)set_bar_len_cb, this);
-
- toggle_lines = new Fl_Button(padding+4*button_len, 2, button_len, 30, "Toggle Lines");
- toggle_lines->color(FL_WHITE,a_color);
- toggle_lines->box(FL_BORDER_BOX);
- toggle_lines->callback((Fl_Callback*) toggle_scale_lines_cb, this);
-
- line_input = new Fl_Input(padding+6*button_len, 2, button_len, 30, "Line Length (bp)");
+ file_menu->add("Sub Analysis", 0, (Fl_Callback *) subana_cb, this);
+
+
+ view_menu = new Fl_Menu_Button(padding+button_len,2, button_len, 30, "View");
+ view_menu->color(FL_WHITE,a_color);
+ view_menu->box(FL_BORDER_BOX);
+ view_menu->clear();
+ view_menu->add("Sequence Zoom", 0, (Fl_Callback*) seq_win_spawn_cb, this);
+ view_menu->add("Motif Finder", 0, (Fl_Callback*) motif_find_cb, this);
+ view_menu->add("Annotations", 0, (Fl_Callback*) annot_win_cb, this);
+ view_menu->add("Copy Seq", 0, (Fl_Callback*) seq_show_cb, this);
+ view_menu->add("Toggle Bars", 0, (Fl_Callback*) toggle_scale_bars_cb, this,
+ FL_MENU_TOGGLE|FL_MENU_VALUE);
+ view_menu->add("Toggle Lines", 0, (Fl_Callback*) toggle_scale_lines_cb, this,
+ FL_MENU_TOGGLE|FL_MENU_VALUE);
+
+ bar_input = new Fl_Input(padding+3*button_len, 2, button_len, 30, "Bar Length (bp)");
+ bar_input->value("");
+ bar_input->when(FL_WHEN_ENTER_KEY);
+ bar_input->callback((Fl_Callback*)set_bar_len_cb, this);
+
+ line_input = new Fl_Input(padding+5*button_len, 2, button_len, 30, "Line Interval (bp)");
line_input->value("");
line_input->when(FL_WHEN_ENTER_KEY);
line_input->callback((Fl_Callback*)set_line_len_cb, this);
-
+
+
+ thres_input = new Fl_Input(padding+7*button_len, 2, button_len, 30, "Threshold");
+ thres_input->value("");
+ thres_input->when(FL_WHEN_ENTER_KEY);
+ thres_input->callback((Fl_Callback*)set_soft_thres_cb, this);
+
// create the connections box
conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
{
an_analysis = the_ana;
+ // relabel window with the analysis name
+ window_name = "Mussa: " + an_analysis->ana_name;
+ label((const char*)window_name.c_str());
+
conn_box->setup(an_analysis->ana_name, an_analysis->seq_num,
an_analysis->window, &(an_analysis->the_Seqs),
&(an_analysis->the_paths));
class ConnWindow : public Fl_Double_Window
{
private:
- Mussa *an_analysis;
+ Mussa *an_analysis, *sub_analysis;
+ ConnWindow *sub_conn_win;
Fl_Menu_Button *file_menu;
- Fl_Button *toggle_divs;
- Fl_Input *new_input;
- Fl_Button *toggle_lines;
+ Fl_Menu_Button *view_menu;
+ Fl_Input *bar_input;
Fl_Input *line_input;
+ Fl_Input *thres_input;
ConnView *conn_box;
SetupWindow *setup_win;
+ SubanaWindow *subana_win;
+ SeqTextWin *show_seq_win;
int padding, name_pad;
string window_name;
void real_load_ana_cb();
void real_do_ana_cb();
void real_setup_ana_cb();
+ void real_subana_cb();
+ void real_resthres();
+ void real_seq_show_cb();
+
+ void real_seq_win_spawn_cb();
+ void real_motif_find_cb();
+ void real_annot_win_cb();
+
void real_toggle_bars_cb();
void real_set_bar_len_cb(Fl_Input* o);
void real_toggle_lines_cb();
void real_set_line_len_cb(Fl_Input* o);
+ void real_set_soft_thres_cb(Fl_Input* o);
-
-/* I goddamned hate gcc
-*/
+ // I goddamned hate gcc
};
--- /dev/null
+#include "mussa_gui_load_window.hh"
+
+bool
+SetupWindow::done()
+{
+ return all_done;
+}
+
+
+void
+do_analysis_cb(Fl_Button* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_do_analysis();
+}
+
+
+// passes the parameters to the mussa class object and orders it to run
+void
+SetupWindow::real_do_analysis()
+{
+ int i;
+ string err_msg;
+
+ // <-- need a check here to make sure all vars have a valid value
+
+ an_analysis->clear();
+ an_analysis->set_name(ana_name);
+ an_analysis->set_seq_num(seq_num);
+ an_analysis->set_window(window);
+ an_analysis->set_threshold(threshold);
+
+ for(i=0; i < seq_num; i++)
+ an_analysis->set_seq_info(seq_files[i], annot_files[i], fasta_indices[i],
+ sub_seq_starts[i], sub_seq_ends[i]);
+
+ err_msg = an_analysis->analyze(0,0, 't', 0.0);
+ //cout << "Feel the tribal beat\n";
+ if (!(err_msg == ""))
+ {
+ //fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+
+ all_done = true;
+
+ hide();
+}
+
+
+void
+choose_seq_file_cb(Fl_Button* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_choose_seq_file_cb(blah->index);
+}
+
+
+void
+SetupWindow::real_choose_seq_file_cb(int i)
+{
+ char *picked_file;
+ string a_file_path;
+
+ picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ a_file_path = picked_file;
+ seq_files[i] = a_file_path;
+ seq_inputs[i]->value((const char *)picked_file);
+}
+
+
+void
+seq_file_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_seq_file_in_cb(o,blah->index);
+}
+
+
+void
+SetupWindow::real_seq_file_in_cb(Fl_Input* o, int i)
+{
+ seq_files[i] = o->value();
+ // leaving this as a reminder that bools will need to be set to determine
+ // if all needed fields have been filled with some value before an analysis
+ // is attempted
+ //(*the_motifs)[i].dirty = true;
+}
+
+//char *picked_file;
+//picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+
+// *** Annot file selection
+
+void
+choose_annot_file_cb(Fl_Button* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_choose_annot_file_cb(blah->index);
+}
+
+
+void
+SetupWindow::real_choose_annot_file_cb(int i)
+{
+ char *picked_file;
+ string a_file_path;
+
+ picked_file = fl_file_chooser("Find an Analysis", "", "", 1);
+ a_file_path = picked_file;
+ annot_files[i] = a_file_path;
+ annot_inputs[i]->value((const char *)picked_file);
+}
+
+void
+annot_file_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_annot_file_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_annot_file_in_cb(Fl_Input* o, int i)
+{
+ annot_files[i] = o->value();
+}
+
+
+// *** fasta index selection
+
+void
+fa_index_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_fa_index_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_fa_index_in_cb(Fl_Input* o, int i)
+{
+ fasta_indices[i] = atoi(o->value());
+}
+
+// *** subsequence start select
+
+void
+sub_start_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_sub_start_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_sub_start_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_starts[i] = atoi(o->value());
+}
+
+// *** subsequence end select
+
+void
+sub_end_in_cb(Fl_Input* o, void* v)
+{
+ seq_data_instance * blah = (seq_data_instance *) v;
+ SetupWindow* T= blah->sw_ptr;
+ T->real_sub_end_in_cb(o,blah->index);
+}
+
+void
+SetupWindow::real_sub_end_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_ends[i] = atoi(o->value());
+
+}
+
+// *** input analysis name
+
+void
+set_ana_name_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_ana_name_cb(o);
+}
+
+void
+SetupWindow::real_set_ana_name_cb(Fl_Input* o)
+{
+ ana_name = o->value();
+}
+
+// *** input window size
+
+void
+set_win_size_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_win_size_cb(o);
+}
+
+void
+SetupWindow::real_set_win_size_cb(Fl_Input* o)
+{
+ window = atoi(o->value());
+}
+
+// *** input threshold
+
+void
+set_threshold_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_threshold_cb(o);
+}
+
+void
+SetupWindow::real_set_threshold_cb(Fl_Input* o)
+{
+ threshold = atoi(o->value());
+}
+
+void
+set_seq_num_cb(Fl_Input* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->real_set_seq_num_cb(o);
+}
+
+// *** input number of sequences, add appropriate inputs for each sequence
+
+void
+SetupWindow::real_set_seq_num_cb(Fl_Input* o)
+{
+ int i;
+
+ seq_num = atoi(o->value());
+ seq_inputs.clear();
+ annot_inputs.clear();
+
+ seq_scroll = new Fl_Scroll(5,80,w()-10,h()-115);
+ seq_scroll->color(FL_WHITE);
+
+ for (i = 0; i < seq_num; i++)
+ {
+ seq_files.push_back("");
+ annot_files.push_back("");
+ fasta_indices.push_back(1);
+ sub_seq_starts.push_back(0);
+ sub_seq_ends.push_back(0);
+ add_seq_input(i);
+ }
+ seq_scroll->box(FL_DOWN_FRAME);
+ add(seq_scroll);
+ redraw();
+}
+
+
+SetupWindow::SetupWindow(int w, int h, const char* title, Mussa *the_analysis):Fl_Window(w,h,title)
+{
+ color(FL_WHITE);
+
+ an_analysis = the_analysis;
+ all_done = false;
+
+ begin();
+
+ name_input = new Fl_Input(110, 10, w-120, 30, "Analysis Name ");
+ name_input->value("");
+ //name_input->when(FL_WHEN_ENTER_KEY);
+ name_input->box(FL_BORDER_BOX);
+ name_input->callback((Fl_Callback*)set_ana_name_cb, this);
+
+ // add in radio buttons for win_append and thres_append eventually
+ win_append = true;
+ thres_append = true;
+
+ win_input = new Fl_Input(65,45,100,30, "Window ");
+ win_input->value("");
+ win_input->callback((Fl_Callback*)set_win_size_cb, this);
+
+ thres_input = new Fl_Input(250,45,100,30, "Threshold ");
+ thres_input->value("");
+ thres_input->callback((Fl_Callback*)set_threshold_cb, this);
+
+ seq_num_input = new Fl_Input(430,45,100, 30, "Seq Num ");
+ seq_num_input->value("");
+ seq_num_input->callback((Fl_Callback*)set_seq_num_cb, this);
+
+ // button to launch the analysis
+ test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
+ test->callback((Fl_Callback*)do_analysis_cb, this);
+
+ // test button to make sure setup data is being stored
+ test = new Fl_Button(w-200,h-30,100,30,"show setup");
+ test->callback((Fl_Callback*)print_cb, this);
+
+ // generic input, keeping around as template for future additions
+ //_input = new Fl_Input(0, , 30, "");
+ //_input->value("");
+ //_input->when(FL_WHEN_ENTER_KEY);
+ //_input->callback((Fl_Callback*)set__cb, this);
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SetupWindow::~SetupWindow(){}
+
+
+void
+SetupWindow::add_seq_input(int i)
+{
+ Fl_Input *fasta_input, *start_input, *end_input;
+ Fl_Button *seq_browse, *annot_browse;
+
+
+ // this remembers what seq index each input is associated with
+ seq_data_instance * something;
+ something = new seq_data_instance;
+ something->sw_ptr = this;
+ something->index = i;
+
+
+ // setup sequence file input for text input or file browsing
+ seq_inputs.push_back(new Fl_Input(55, 85+(i*105), w()-165, 30, "seq "));
+ seq_inputs[i]->value("");
+ seq_inputs[i]->callback((Fl_Callback*)seq_file_in_cb, (void*) something);
+
+ seq_browse = new Fl_Button(w()-105, 85+(i*105), 80, 30, "Browse");
+ seq_browse->callback((Fl_Callback*)choose_seq_file_cb, (void*) something);
+
+ // setup annotation file input for text input or file browsing
+ annot_inputs.push_back(new Fl_Input(55, 120+(i*105), w()-165, 30, "annot "));
+ annot_inputs[i]->value("");
+ annot_inputs[i]->callback((Fl_Callback*)annot_file_in_cb,(void*)something);
+
+ annot_browse = new Fl_Button(w()-105, 120+(i*105), 80, 30, "Browse");
+ annot_browse->callback((Fl_Callback*)choose_annot_file_cb, (void*)something);
+
+ // index of fasta seq wanted if more than 1 seq in file
+ fasta_input = new Fl_Input(90, 155+(i*105), 50, 30, "fasta index");
+ fasta_input->value("");
+ fasta_input->callback((Fl_Callback*)fa_index_in_cb, (void*) something);
+
+ // subsequence select, index of first bp wanted
+ start_input = new Fl_Input(225, 155+(i*105), 50, 30, "start index");
+ start_input->value("");
+ start_input->callback((Fl_Callback*)sub_start_in_cb, (void*) something);
+
+ // subsequence select, index of last bp wanted
+ end_input = new Fl_Input(355, 155+(i*105), 50, 30, "end index");
+ end_input->value("");
+ end_input->callback((Fl_Callback*)sub_end_in_cb, (void*) something);
+
+ seq_scroll->add(seq_inputs[i]);
+ seq_scroll->add(seq_browse);
+ seq_scroll->add(annot_inputs[i]);
+ seq_scroll->add(annot_browse);
+ seq_scroll->add(fasta_input);
+ seq_scroll->add(start_input);
+ seq_scroll->add(end_input);
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void SetupWindow::print_cb(Fl_Button* o, void* v)
+{
+ SetupWindow* T=(SetupWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void SetupWindow::print_cb_real(Fl_Button* , void*)
+{
+ cout << "ana_name: " << ana_name << endl;
+ cout << "win: " << window << endl;
+ cout << "thres: " << threshold << endl;
+ cout << "seq_num: " << seq_num << endl;
+ //cout << "win_add: " << win_append << end;
+ //cout << "thres_add: " << thres_append << endl;
+
+ int i;
+
+
+
+ for (i = 0; i < seq_num; i++)
+ {
+ cout << seq_files[i] << endl;
+ cout << annot_files[i] << endl;
+ cout << "fasta: " << fasta_indices[i];
+ cout << " start: " << sub_seq_starts[i];
+ cout << " end: " << sub_seq_ends[i] << endl;
+ cout << "blargle!\n";
+ }
+ cout << "end of inputs\n" << endl;
+}
-#include "mussa_gui_motif_window.hh"
+#include "mussa_gui_annot_window.hh"
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Scroll.H>
SetupWindow(int w, int h, const char* title, Mussa *an_analysis);
~SetupWindow();
- Fl_Button* test;
+ bool done();
+ //did I put these in public for a reason?
+ Fl_Button* test;
Fl_Input *name_input;
Fl_Input *win_input;
Fl_Input *thres_input;
vector<int> fasta_indices, sub_seq_starts, sub_seq_ends;
bool win_append, thres_append;
+ bool all_done;
static void print_cb(Fl_Button*, void*);
inline void print_cb_real(Fl_Button*, void*);
#include "mussa_gui_seq.hh"
#include <sstream>
-SeqWinMaster::SeqWinMaster(int x_size, string name, int sq_num,
- vector<Sequence> *some_seqs,
- list<vector<int> > some_paths,
- vector<int> some_lens,
- vector<motif> *some_motifs)
-{
- int seq_i;
-
- x_max = x_size;
- // give 50 pixels of height per sequence
- y_max = sq_num * 50;
-
- // most of this stuff is here just to pass to SeqView object
- ana_name = name;
- seq_num = sq_num;
- S = some_seqs;
- P = some_paths;
- seq_lens = some_lens;
- the_motifs = some_motifs;
-}
-
void
set_align_cb(Fl_Widget* widg, void* the_data)
{
menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
- SeqWinMaster* T= blah->swm_ptr;
+ SeqWindow* T= blah->swm_ptr;
T->real_set_align_cb(blah->which_align);
}
void
-SeqWinMaster::real_set_align_cb(int which_align)
+SeqWindow::real_set_align_cb(int which_align)
{
vector<int> a_path;
int window_length;
show_align_cb(Fl_Widget* widg, void* the_data)
{
menu_align_data_bundle * blah = (menu_align_data_bundle *) the_data;
- SeqWinMaster* T= blah->swm_ptr;
+ SeqWindow* T= blah->swm_ptr;
T->real_show_align_cb(blah->which_align);
}
void
-SeqWinMaster::real_show_align_cb(int which_align)
+SeqWindow::real_show_align_cb(int which_align)
{
vector<int> a_path;
int window_length;
void
toggle_bars_cb(Fl_Button* o, void* v)
{
- SeqWinMaster* T=(SeqWinMaster*)v;
+ SeqWindow* T=(SeqWindow*)v;
T->real_toggle_bars_cb();
}
void
-SeqWinMaster::real_toggle_bars_cb()
+SeqWindow::real_toggle_bars_cb()
{
seq_box->toggle_bars();
}
void
toggle_motifs_cb(Fl_Button* o, void* v)
{
- SeqWinMaster* T=(SeqWinMaster*)v;
+ SeqWindow* T=(SeqWindow*)v;
T->real_toggle_motifs_cb();
}
void
-SeqWinMaster::real_toggle_motifs_cb()
+SeqWindow::real_toggle_motifs_cb()
{
seq_box->toggle_motifs();
}
-void
-SeqWinMaster::make_window()
+// main code, window creation
+
+SeqWindow::SeqWindow(int w, int h, const char* title, int sq_num,
+ vector<Sequence> *some_seqs,
+ list<vector<int> > some_paths,
+ vector<int> some_lens,
+ vector<motif> *some_motifs):
+ Fl_Double_Window(w,h,title)
{
- string window_name;
menu_align_data_bundle * some_menu_data;
-
vector<int> a_path;
int window_length, align_number;
int i;
string align_id_string;
list<vector<int> >::iterator align_iter;
- window_name = "Mussa Sequence: " + ana_name;
- Fl_Double_Window *seq_window = new Fl_Double_Window(x_max, y_max,
- (const char*) window_name.c_str());
- //seq_window->resizable();
- seq_window->color(FL_WHITE);
- seq_window->begin();
+
+
+ // most of this stuff is here just to pass to SeqView object
+ // some is needed to setup the window menus
+ seq_num = sq_num;
+ S = some_seqs;
+ P = some_paths;
+ seq_lens = some_lens;
+ the_motifs = some_motifs;
+
+
+ begin();
+ color(FL_WHITE);
+ resizable(this);
// make the menu that allows alignment selection
- choose_align_menu = new Fl_Menu_Button(3, 2, 180, 30, "Choose Alignment");
+ choose_align_menu = new Fl_Menu_Button(5, 2, 180, 30, "Choose Alignment");
choose_align_menu->color(FL_WHITE,FL_BLUE);
- choose_align_menu->box(FL_PLASTIC_UP_BOX);
+ choose_align_menu->box(FL_BORDER_BOX);
choose_align_menu->clear();
// make the menu that allows alignment selection
- show_align_menu = new Fl_Menu_Button(186, 2, 180, 30, "Show Alignment");
+ show_align_menu = new Fl_Menu_Button(190, 2, 180, 30, "Show Alignment");
show_align_menu->color(FL_WHITE,FL_BLUE);
- show_align_menu->box(FL_PLASTIC_UP_BOX);
+ show_align_menu->box(FL_BORDER_BOX);
show_align_menu->clear();
+
+
+ // adds menu items for each path
align_iter = P.begin();
align_number = 0;
while(align_iter != P.end())
(Fl_Callback *) set_align_cb,
(void*) some_menu_data);
show_align_menu->add((const char*)align_id_string.c_str(), 0,
- (Fl_Callback *) show_align_cb,
- (void*) some_menu_data, FL_MENU_TOGGLE|FL_MENU_VALUE);
+ (Fl_Callback *) show_align_cb,
+ (void*) some_menu_data, FL_MENU_TOGGLE|FL_MENU_VALUE);
align_id_ostr.str("");
++align_number;
show_align_menu->add("f&um");
*/
- Fl_Button *test_but = new Fl_Button(369, 2, 180, 30, "Toggle Motifs");
+ Fl_Button *test_but = new Fl_Button(375, 2, 150, 30, "Toggle Motifs");
test_but->color(FL_WHITE,FL_BLUE);
- test_but->box(FL_PLASTIC_UP_BOX);
+ test_but->box(FL_BORDER_BOX);
test_but->callback((Fl_Callback*) toggle_motifs_cb, this);
- toggle_bars = new Fl_Button(552, 2, 180, 30, "Toggle 10bp bars");
+ toggle_bars = new Fl_Button(530, 2, 150, 30, "Toggle 10bp bars");
toggle_bars->color(FL_WHITE,FL_BLUE);
- toggle_bars->box(FL_PLASTIC_UP_BOX);
+ toggle_bars->box(FL_BORDER_BOX);
toggle_bars->callback((Fl_Callback*) toggle_bars_cb, this);
// make the view of the sequence
- seq_box = new SeqView(0, 34, x_max, y_max-34);
+ seq_box = new SeqView(0, 34, w, h-34);
seq_box->setup(ana_name, seq_num, S, P, seq_lens, the_motifs);
//real_set_align_cb(2);
- seq_window->end();
+ end();
Fl::visual(FL_DOUBLE|FL_INDEX);
- seq_window->show();
+ show();
}
+
+
/*
some_menu_data = new menu_align_data_bundle;
some_menu_data->swm_ptr = this;
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Menu_Button.H>
-#include<FL/Fl_Double_Window.H>
+#include <FL/Fl_Double_Window.H>
-class SeqWinMaster
+class SeqWindow : public Fl_Double_Window
{
private:
string ana_name;
// list of paths in selection box
list<vector<int> > P;
vector<int> seq_lens;
- //pointer to passed motif data
+ //pointer to passed motif data
vector<motif> *the_motifs;
int x_max, y_max;
public:
int seq_num;
- SeqWinMaster(int x_size, string, int, vector<Sequence> *some_seqs,
- list<vector<int> > some_paths, vector<int>,
- vector<motif> *some_motifs);
- virtual ~SeqWinMaster(){ cout << "dying\n"; }
- void make_window();
+
+ SeqWindow(int w, int h, const char* title, int sq_num,
+ vector<Sequence> *some_seqs,
+ list<vector<int> > some_paths, vector<int> some_lens,
+ vector<motif> *some_motifs);
+ virtual ~SeqWindow(){ cout << "dying\n"; }
+
void make_choose_menu();
void make_show_menu();
void real_set_align_cb(int which_align);
struct menu_align_data_bundle
{
- SeqWinMaster * swm_ptr;
+ SeqWindow * swm_ptr;
int which_align;
};
--- /dev/null
+#include "mussa_gui_seq_text.hh"
+
+
+void
+get_seq_cb(Fl_Button* o, void* v)
+{
+ SeqTextWin* T=(SeqTextWin*)v;
+ T->real_get_seq_cb();
+}
+
+void
+SeqTextWin::real_get_seq_cb()
+{
+ string sub_seq_formatted;
+ int seq_len, i, line_len;
+
+
+ cout << "length = " << seq_end-seq_start << endl;
+
+ // make sure inputed values within valid ranges
+ if ((seq_end > seq_start) && (seq_id > -1) && (seq_id < the_Seqs.size()) )
+ {
+ sub_sequence = the_Seqs[seq_id].subseq(seq_start, seq_end-seq_start);
+
+ sub_seq_formatted = "";
+ seq_len = sub_sequence.size();
+ line_len = 40;
+ for (i = 0; i < seq_len; i += line_len)
+ {
+ sub_seq_formatted.append(sub_sequence.substr(i,line_len));
+ sub_seq_formatted.append("\n");
+ }
+
+ seq_display->value((const char *)sub_seq_formatted.c_str());
+ }
+}
+
+
+// *** input seq index id
+
+void
+set_seq_id_cb(Fl_Input* o, void* v)
+{
+ SeqTextWin* T=(SeqTextWin*)v;
+ T->real_set_seq_id_cb(o);
+}
+
+void
+SeqTextWin::real_set_seq_id_cb(Fl_Input* o)
+{
+ seq_id = atoi(o->value()) - 1; // -1 since arrays start at 0
+}
+
+
+// *** input seq start index
+
+void
+set_seq_start_cb(Fl_Input* o, void* v)
+{
+ SeqTextWin* T=(SeqTextWin*)v;
+ T->real_set_seq_start_cb(o);
+}
+
+void
+SeqTextWin::real_set_seq_start_cb(Fl_Input* o)
+{
+ seq_start = atoi(o->value());
+}
+
+// *** input seq end index
+
+void
+set_seq_end_cb(Fl_Input* o, void* v)
+{
+ SeqTextWin* T=(SeqTextWin*)v;
+ T->real_set_seq_end_cb(o);
+}
+
+void
+SeqTextWin::real_set_seq_end_cb(Fl_Input* o)
+{
+ seq_end = atoi(o->value());
+}
+
+
+SeqTextWin::SeqTextWin(int w, int h, const char* title,
+ vector<Sequence> some_Seqs):Fl_Window(w,h,title)
+{
+ string a_name;
+ color(FL_WHITE);
+ the_Seqs = some_Seqs;
+
+
+ seq_id = -1;
+ seq_start = 1000000;
+ seq_end = -1000000;
+
+ begin();
+
+ seq_id_input = new Fl_Input(80,10,30,30, "Seq num: ");
+ seq_id_input->value("");
+ seq_id_input->callback((Fl_Callback*)set_seq_id_cb, this);
+
+ seq_start_input = new Fl_Input(160,10,100,30, " start: ");
+ seq_start_input->value("");
+ seq_start_input->callback((Fl_Callback*)set_seq_start_cb, this);
+
+ seq_end_input = new Fl_Input(310,10,100,30, "end: ");
+ seq_end_input->value("");
+ seq_end_input->callback((Fl_Callback*)set_seq_end_cb, this);
+
+ seq_display = new Fl_Multiline_Output(10, 50, w-20, h-60, "");
+ seq_display->value("");
+
+ //seq_display2 = new Fl_Text_Display(10,100, w-20, h-110,"");
+
+ // button to get the sequence
+ get_seq_but = new Fl_Button(w-80,10,80,30,"Get Seq");
+ get_seq_but->callback((Fl_Callback*)get_seq_cb, this);
+
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SeqTextWin::~SeqTextWin(){}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
--- /dev/null
+#include "mussa_gui_seq.hh"
+#include <FL/Fl_Text_Buffer.H>
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Multiline_Output.H>
+
+class SeqTextWin : public Fl_Window
+{
+ public:
+ SeqTextWin(int w, int h, const char* title, vector<Sequence> some_Seqs);
+ ~SeqTextWin();
+
+ Fl_Button* get_seq_but;
+ Fl_Multiline_Output* seq_display;
+ Fl_Text_Buffer* seq_buffer;
+ Fl_Text_Display* seq_display2;
+ Fl_Input *seq_id_input;
+ Fl_Input *seq_start_input;
+ Fl_Input *seq_end_input;
+
+ // callback receiver functions
+
+ void real_get_seq_cb();
+ void real_set_seq_id_cb(Fl_Input* o);
+ void real_set_seq_start_cb(Fl_Input* o);
+ void real_set_seq_end_cb(Fl_Input* o);
+
+ private:
+ // sequence data
+ vector<Sequence> the_Seqs;
+ string sub_sequence;
+ int seq_id, seq_start, seq_end;
+};
+
#include "mussa_gui_seq.hh"
-
+#include <sstream>
void
SeqView::setup(string name, int sq_num,
cout << x() << " " << y() << " " << w() << " " << h() << endl;
}
+void
+SeqView::resize(int new_x, int new_y, int new_w, int new_h)
+{
+ x(new_x);
+ y(new_y);
+ w(new_w);
+ h(new_h);
+
+ // hmmm, why do I use these values on the the widgets inherent ones?
+ // I think there was a reason...once?
+ x_max = new_w;
+ y_max = new_h;
+ x_min = new_x;
+ y_min = new_y;
+
+ // things that need to be recalculated
+ y_seq_incre = (y_max-10-10) / (seq_num - 1);
+}
+
+
+
void
SeqView::draw()
int seq_i;
Sequence a_seq;
int y_loc;
- string an_index;
+ ostringstream an_index;
int shown_seq_len;
+
// clear out space on sides to draw in index values
// I block out the sides rather than adding offsets to the drawing of seq
y_loc = y_min + 10 + 5;
for(seq_i = 0; seq_i < seq_num; seq_i++)
{
- an_index = int_to_str(seq_align_offsets[seq_i]-scroll_offset);
- fl_draw(an_index.c_str(), 2, y_loc);
+ an_index.str("");
+ an_index << (seq_align_offsets[seq_i]-scroll_offset);
+ fl_draw((an_index.str()).c_str(), 2, y_loc);
shown_seq_len = (w() - 2 * index_pad) / (int) ch_width;
- an_index= int_to_str(seq_align_offsets[seq_i]-scroll_offset+shown_seq_len);
- fl_draw(an_index.c_str(), w()-index_pad+2, y_loc);
+ an_index.str("");
+ an_index << (seq_align_offsets[seq_i]-scroll_offset+shown_seq_len);
+ fl_draw((an_index.str()).c_str(), w()-index_pad+2, y_loc);
y_loc += y_seq_incre;
}
}
bool show_bars, show_motifs;
vector<bool> show_aligns;
+ void resize(int new_x, int new_y, int new_w, int new_h);
void draw();
void draw_motifs(double ch_width);
void draw_sequence(double ch_width);
--- /dev/null
+#include "mussa_gui_subana.hh"
+
+
+void
+do_subana_cb(Fl_Button* o, void* v)
+{
+ SubanaWindow* T=(SubanaWindow*)v;
+ T->real_do_subana();
+}
+
+
+// passes the parameters to the mussa class object and orders it to run
+void
+SubanaWindow::real_do_subana()
+{
+ int i;
+ string a_sequence, err_msg;
+
+ // <-- need a check here to make sure all vars have a valid value
+
+ an_analysis->clear();
+ an_analysis->set_name(ana_name);
+ an_analysis->set_seq_num(seq_num);
+ an_analysis->set_window(window);
+ an_analysis->set_threshold(threshold);
+
+ for(i=0; i < seq_num; i++)
+ {
+ a_sequence = the_Seqs[i].seq();
+ cout << a_sequence.length() << endl;
+ a_sequence = a_sequence.substr(sub_seq_starts[i],
+ sub_seq_ends[i] - sub_seq_starts[i] );
+ cout << a_sequence.length() << endl;
+ an_analysis->add_a_seq(a_sequence);
+ }
+
+ err_msg = an_analysis->analyze(0,0, 't', 0.0);
+
+ cout << "Feel the tribal beat\n";
+ if (!(err_msg == ""))
+ {
+ //fl_alert(err_msg.c_str());
+ cout << err_msg;
+ }
+
+ all_done = true;
+
+ hide();
+}
+
+
+
+// *** subsequence start select
+
+void
+sub_start_in_cb1(Fl_Input* o, void* v)
+{
+ sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
+ SubanaWindow* T= blah->sw_ptr;
+ T->real_sub_start_in_cb(o,blah->index);
+}
+
+void
+SubanaWindow::real_sub_start_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_starts[i] = atoi(o->value());
+}
+
+// *** subsequence end select
+
+void
+sub_end_in_cb1(Fl_Input* o, void* v)
+{
+ sub_seq_data_instance * blah = (sub_seq_data_instance *) v;
+ SubanaWindow* T= blah->sw_ptr;
+ T->real_sub_end_in_cb(o,blah->index);
+}
+
+void
+SubanaWindow::real_sub_end_in_cb(Fl_Input* o, int i)
+{
+ sub_seq_ends[i] = atoi(o->value());
+
+}
+
+// *** input analysis name
+
+void
+set_ana_name_cb1(Fl_Input* o, void* v)
+{
+ SubanaWindow* T=(SubanaWindow*)v;
+ T->real_set_ana_name_cb(o);
+}
+
+void
+SubanaWindow::real_set_ana_name_cb(Fl_Input* o)
+{
+ ana_name = o->value();
+}
+
+// *** input window size
+
+void
+set_win_size_cb1(Fl_Input* o, void* v)
+{
+ SubanaWindow* T=(SubanaWindow*)v;
+ T->real_set_win_size_cb(o);
+}
+
+void
+SubanaWindow::real_set_win_size_cb(Fl_Input* o)
+{
+ window = atoi(o->value());
+}
+
+// *** input threshold
+
+void
+set_threshold_cb1(Fl_Input* o, void* v)
+{
+ SubanaWindow* T=(SubanaWindow*)v;
+ T->real_set_threshold_cb(o);
+}
+
+void
+SubanaWindow::real_set_threshold_cb(Fl_Input* o)
+{
+ threshold = atoi(o->value());
+}
+
+
+bool
+SubanaWindow::done()
+{
+ return all_done;
+}
+
+
+SubanaWindow::SubanaWindow(int w, int h, const char* title,Mussa *the_analysis,
+ vector<Sequence> some_Seqs):Fl_Window(w,h,title)
+{
+ string a_name;
+
+ color(FL_WHITE);
+
+ an_analysis = the_analysis;
+ the_Seqs = some_Seqs;
+ all_done = false;
+
+ begin();
+
+ name_input = new Fl_Input(135, 10, w-140, 30, "SubAnalysis Name ");
+ name_input->value("");
+ //name_input->when(FL_WHEN_ENTER_KEY);
+ name_input->box(FL_BORDER_BOX);
+ name_input->callback((Fl_Callback*)set_ana_name_cb1, this);
+
+ // add in radio buttons for win_append and thres_append eventually
+ win_append = true;
+ thres_append = true;
+
+ win_input = new Fl_Input(135,45,100,30, "Window: ");
+ win_input->value("");
+ win_input->callback((Fl_Callback*)set_win_size_cb1, this);
+
+ thres_input = new Fl_Input(320,45,100,30, "Threshold: ");
+ thres_input->value("");
+ thres_input->callback((Fl_Callback*)set_threshold_cb1, this);
+
+ // button to launch the analysis
+ test = new Fl_Button(w-100,h-30,100,30,"Do Analysis");
+ test->callback((Fl_Callback*)do_subana_cb, this);
+
+ // test button to make sure setup data is being stored
+ test = new Fl_Button(w-200,h-30,100,30,"show setup");
+ test->callback((Fl_Callback*)print_cb, this);
+
+ // add all the inputs for the sub sequence starts & ends
+ int i;
+
+ seq_num = the_Seqs.size();
+
+ seq_scroll = new Fl_Scroll(5,80,w-10,h-115);
+ seq_scroll->color(FL_WHITE);
+
+ for (i = 0; i < seq_num; i++)
+ {
+ sub_seq_starts.push_back(0);
+ sub_seq_ends.push_back(0);
+ a_name = the_Seqs[i].sp_name();
+ cout << a_name << endl;
+ add_seq_input(i, a_name);
+ }
+ seq_scroll->box(FL_DOWN_FRAME);
+ //add(seq_scroll);
+ //redraw();
+
+ end();
+ //resizable(this);
+ show();
+}
+
+
+SubanaWindow::~SubanaWindow(){}
+
+
+void
+SubanaWindow::add_seq_input(int i, string a_name)
+{
+ Fl_Input *start_input, *end_input;
+
+
+ // this remembers what seq index each input is associated with
+ sub_seq_data_instance * something;
+ something = new sub_seq_data_instance;
+ something->sw_ptr = this;
+ something->index = i;
+
+
+ // subsequence select, index of first bp wanted
+ start_input = new Fl_Input(150, 85+(i*35), 70, 30, "start index: ");
+ start_input->value("");
+ start_input->callback((Fl_Callback*)sub_start_in_cb1, (void*) something);
+
+ // subsequence select, index of last bp wanted
+ end_input = new Fl_Input(300, 85+(i*35), 70, 30, "end index: ");
+ end_input->value("");
+ end_input->callback((Fl_Callback*)sub_end_in_cb1, (void*) something);
+
+ seq_scroll->add(start_input);
+ seq_scroll->add(end_input);
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
+
+void SubanaWindow::print_cb(Fl_Button* o, void* v)
+{
+ SubanaWindow* T=(SubanaWindow*)v;
+ T->print_cb_real(o,v);
+}
+
+
+void SubanaWindow::print_cb_real(Fl_Button* , void*)
+{
+ cout << "ana_name: " << ana_name << endl;
+ cout << "win: " << window << endl;
+ cout << "thres: " << threshold << endl;
+ cout << "seq_num: " << seq_num << endl;
+ //cout << "win_add: " << win_append << end;
+ //cout << "thres_add: " << thres_append << endl;
+
+ int i;
+
+
+
+ for (i = 0; i < seq_num; i++)
+ {
+ //cout << seq_files[i] << endl;
+ //cout << annot_files[i] << endl;
+ //cout << "fasta: " << fasta_indices[i];
+ cout << " start: " << sub_seq_starts[i];
+ cout << " end: " << sub_seq_ends[i] << endl;
+ cout << "blargle!\n";
+ }
+ cout << "end of inputs\n" << endl;
+}
--- /dev/null
+#include "mussa_gui_seq_text.hh"
+#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_Scroll.H>
+
+class SubanaWindow : public Fl_Window
+{
+ public:
+ SubanaWindow(int w, int h, const char* title, Mussa *an_analysis,
+ vector<Sequence> some_Seqs);
+ ~SubanaWindow();
+ bool done();
+
+
+ Fl_Button* test;
+
+ Fl_Input *name_input;
+ Fl_Input *win_input;
+ Fl_Input *thres_input;
+ Fl_Input *seq_num_input;
+ Fl_Scroll *seq_scroll;
+ // need to keep track of these so a browsed file search can set the input
+ // fields to the selected file
+ vector<Fl_Input*> seq_inputs, annot_inputs;
+
+
+ // callback receiver functions
+
+ void real_do_subana();
+
+ void real_set_ana_name_cb(Fl_Input* o);
+ void real_set_win_size_cb(Fl_Input* o);
+ void real_set_threshold_cb(Fl_Input* o);
+
+ void real_sub_start_in_cb(Fl_Input* o, int i);
+ void real_sub_end_in_cb(Fl_Input* o, int i);
+
+ private:
+ // sequence data
+ vector<Sequence> the_Seqs;
+ Mussa *an_analysis;
+ string ana_name;
+ int window, threshold, seq_num;
+ vector<int> sub_seq_starts, sub_seq_ends;
+ bool win_append, thres_append;
+ bool all_done;
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+
+ void add_seq_input(int index, string a_name);
+};
+
+// crazy whacked shite Titus taught me to do to get an index value associated
+// with each instance of an input associated with the callback...
+
+
+struct sub_seq_data_instance
+{
+ SubanaWindow * sw_ptr;
+ int index;
+};
+
{
species_num = sp_num;
threshold = t;
+ soft_thres = threshold;
win_size = w;
pathz.clear();
-}
-
-
-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;
- bool trans_check_good;
- new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
- while(new_nodes_i != new_nodes_end)
- {
- //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
- // check transitivity with previous nodes in path
- trans_check_good = true;
- for(i = 0; i < depth - 1; i++)
- {
- 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) ) &&
- (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)
- {
- // 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 << "nway: species_num = " << species_num << ", thres = " << threshold
+ << ", softo = " << soft_thres << endl;
}
-// 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))
-*/
void
-Nway_Paths::find_paths_r(vector<vector<FLPs> > all_comparisons)
+Nway_Paths::set_soft_thres(int sft_thres)
{
- vector<int> path;
- int win_i, window_num;
- list<int> new_nodes;
- list<int>::iterator new_nodes_i, new_nodes_end;
-
- pathz.clear();
- window_num = all_comparisons[0][1].win_num();
- cout << window_num << endl;
- // loop thru all windows in first species
- for (win_i = 0; win_i < window_num; win_i++)
- {
- path.clear();
- path.push_back(win_i);
- new_nodes = all_comparisons[0][1].matches(path[0]);
- new_nodes_i = new_nodes.begin();
- new_nodes_end = new_nodes.end();
- //if (new_nodes_i != new_nodes_end)
- //cout << "* species 0 node: " << win_i << endl;
- // cout << "foookin hell\n";
- path.push_back(0);
- while(new_nodes_i != new_nodes_end)
- {
- //cout << " * species 1 node: " << *new_nodes_i << endl;
- path[1] = *new_nodes_i;
- path_search(all_comparisons, path, 2);
- ++new_nodes_i;
- }
- }
+ soft_thres = sft_thres;
}
+
// dumbly goes thru and combines path windows exactly adjacent (ie + 1 index)
// doesn't deal with interleaved adjacency
void
vector<int> ext_path, cur_path, next_path, new_path;
list<vector<int> >::iterator pathz_i;
int i2, win_ext_len = 0;
- bool extending;
+ bool extending, end = false;
+ int count_loop = 0;
refined_pathz.clear();
cout << "path number is: " << pathz.size() << endl;
pathz_i = pathz.begin();
- ext_path = *pathz_i;
+ ext_path = *pathz_i;
+
while(pathz_i != pathz.end())
{
+ //cout << "path number is: " << pathz.size() << endl;
+ //++count_loop;
+ //cout << "glorpagh!!!!!" << count_loop << endl;
+
// keep track of current path and advance to next path
cur_path = *pathz_i;
++pathz_i;
- next_path = *pathz_i;
+ if (pathz_i == pathz.end())
+ end = true;
+ else
+ next_path = *pathz_i;
+
+ //cout << "S\'Nork!\n";
- // if node for each seq is equal to the next node+1 then for all
- // sequences then we are extending
- extending = true;
- for(i2 = 0; i2 < species_num; i2++)
+ if (not end)
{
- //cout << cur_path[i2] << " vs " << endl;
- //cout << next_path[i2] << endl;
- if (cur_path[i2] + 1 != next_path[i2])
- extending = false;
+ // if node for each seq is equal to the next node+1 then for all
+ // sequences then we are extending
+ extending = true;
+ for(i2 = 0; i2 < species_num; i2++)
+ {
+ //cout << cur_path[i2] << " vs " << endl;
+ //cout << next_path[i2] << endl;
+ if (cur_path[i2] + 1 != next_path[i2])
+ extending = false;
+ }
}
+ else
+ extending = false;
+
if (extending)
{
//cout << "Raaaawwwrrr! I am extending\n";
}
else
{
+ //cout << "Larfnarg?\n";
// add the extend window length as first element and add as refined
new_path = ext_path;
new_path.insert(new_path.begin(),win_size + win_ext_len);
for(i2 = 1; i2 <= species_num; i2++)
{
- if (new_path[i2] < 0)
- {
- //cout << "before: " << new_path[i2];
- new_path[i2] += win_ext_len;
- //cout << " after: " << new_path[i2] << endl;
- }
+ if (new_path[i2] < 0)
+ {
+ //cout << "before: " << new_path[i2];
+ new_path[i2] += win_ext_len;
+ //cout << " after: " << new_path[i2] << endl;
+ }
}
refined_pathz.push_back(new_path);
// reset stuff
+
+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;
+ bool trans_check_good;
+
+ new_nodes = all_comparisons[depth - 1][depth].matches(path[depth-1]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+ while(new_nodes_i != new_nodes_end)
+ {
+ //cout << " * species " << depth << " node: " << *new_nodes_i << endl;
+ // check transitivity with previous nodes in path
+ trans_check_good = true;
+ for(i = 0; i < depth - 1; i++)
+ {
+ 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) ) &&
+ (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)
+ {
+ // 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))
+*/
+
+void
+Nway_Paths::find_paths_r(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ int win_i, window_num;
+ list<int> new_nodes;
+ list<int>::iterator new_nodes_i, new_nodes_end;
+
+ pathz.clear();
+ window_num = all_comparisons[0][1].win_num();
+ cout << window_num << endl;
+ // loop thru all windows in first species
+ for (win_i = 0; win_i < window_num; win_i++)
+ {
+ path.clear();
+ path.push_back(win_i);
+ new_nodes = all_comparisons[0][1].matches(path[0]);
+ new_nodes_i = new_nodes.begin();
+ new_nodes_end = new_nodes.end();
+ //if (new_nodes_i != new_nodes_end)
+ //cout << "* species 0 node: " << win_i << endl;
+ // cout << "foookin hell\n";
+ path.push_back(0);
+ while(new_nodes_i != new_nodes_end)
+ {
+ //cout << " * species 1 node: " << *new_nodes_i << endl;
+ path[1] = *new_nodes_i;
+ path_search(all_comparisons, path, 2);
+ ++new_nodes_i;
+ }
+ }
+}
+
+
void
Nway_Paths::save_old(string save_file_path)
{
int species_num;
int threshold;
int win_size;
+ int soft_thres;
+
+ double ent_thres;
+ vector<char *> c_sequences;
+
list<vector<int> > pathz;
list<vector<int> > refined_pathz;
+
public:
Nway_Paths();
void setup(int sp_num, int w, int t);
- void find_paths_r(vector<vector<FLPs> > all_comparisons);
- void path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth);
+ void setup_ent(double new_entropy_thres, vector<string> some_Seqs);
+ void set_soft_thres(int soft_thres);
+
void radiate_path_search(vector<vector<FLPs> > all_comparisons);
void trans_path_search(vector<vector<FLPs> > all_comparisons);
+ void entropy_path_search(vector<vector<FLPs> > all_comparisons);
+ double path_entropy(vector<int> path);
+ // old recursive transitive nway ... has issues checking all links?
+ void find_paths_r(vector<vector<FLPs> > all_comparisons);
+ void path_search(vector<vector<FLPs> > all_comparisons, vector<int> path, int depth);
void simple_refine();
void save(string save_file_path);
--- /dev/null
+/*
+#include <list>
+#include <vector>
+#include <string>
+#include <stdlib.h>
+#include <algorithm>
+
+#include <iostream>
+
+using namespace std;
+*/
+#include "mussa_nway.hh"
+#include <math.h>
+
+// vars that will be availble to entropy function when in its nway class
+//vector<char *> c_sequences;
+//int window = 5, seq_num;
+
+
+void
+Nway_Paths::setup_ent(double new_entropy_thres, vector<string> some_Seqs)
+{
+ int i;
+
+ ent_thres = new_entropy_thres;
+
+ c_sequences.clear();
+ for (i = 0; i < species_num; i++)
+ c_sequences.push_back((char *)some_Seqs[i].c_str());
+}
+
+
+double
+Nway_Paths::path_entropy(vector<int> path)
+{
+ int bp_occurences[5];
+ double bp_prob, frac_ent, avg_entropy;
+ vector<double> entropies;
+ int i, seq_i, i2;
+ int window = win_size;
+ int seq_num = species_num;
+
+
+ for(i = 0; i < window; i++) // loop thru all bp positions
+ {
+ for(i2 = 0; i2 < 5; i2++) // clear old occurences
+ bp_occurences[i2] = 0;
+
+ for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
+ if (path[seq_i] > -1)
+ switch (c_sequences[seq_i][i+path[seq_i]])
+ {
+ case 'A':
+ ++bp_occurences[0];
+ break;
+ case 'T':
+ ++bp_occurences[1];
+ break;
+ case 'G':
+ ++bp_occurences[2];
+ break;
+ case 'C':
+ ++bp_occurences[3];
+ break;
+ case 'N':
+ ++bp_occurences[4];
+ break;
+ default:
+ cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
+ cout << i+path[seq_i] << endl;
+ }
+ else
+ switch (c_sequences[seq_i][-1 * (i + path[seq_i] - window + 1) ])
+ {
+ case 'A':
+ ++bp_occurences[1];
+ break;
+ case 'T':
+ ++bp_occurences[0];
+ break;
+ case 'G':
+ ++bp_occurences[3];
+ break;
+ case 'C':
+ ++bp_occurences[2];
+ break;
+ case 'N':
+ ++bp_occurences[4];
+ break;
+ default:
+ cout << "error, nonAGCTN on seq: " << seq_i << " at index: ";
+ cout << (i + path[seq_i] - window + 1) << endl;
+ }
+
+
+ entropies.push_back(0.000);
+ for(i2 = 0; i2 < 5; i2++) //calculate entropies
+ {
+ bp_prob = (double) bp_occurences[i2] / (double) seq_num;
+ //cout << bp_prob << "::";
+ if (bp_prob == 0.0000)
+ frac_ent = 0.0000;
+ else
+ frac_ent = bp_prob * ( log10(bp_prob) / log10(2.0) );
+ //cout << frac_ent << " ";
+ entropies[i] += frac_ent;
+ }
+ //cout << endl;
+ }
+
+ avg_entropy = 0;
+ for(i = 0; i < window; i++)
+ {
+ avg_entropy += entropies[i];
+ //cout << entropies[i] << endl;
+ }
+
+ avg_entropy = -1.00 * (avg_entropy / (double) window);
+ //cout << "average entropy: " << avg_entropy << endl;
+ return avg_entropy;
+}
+
+
+
+
+
+void
+Nway_Paths::entropy_path_search(vector<vector<FLPs> > all_comparisons)
+{
+ vector<int> path;
+ double avg_entropy;
+ 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 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 entropy <---------------------------------------------------
+ avg_entropy = path_entropy(path);
+ if (avg_entropy <= ent_thres)
+ 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;
+ }
+ }
+ }
+}
+
+
+//initial coding testing
+/*
+int main(int argc, char **argv)
+{
+ vector<string> sequences;
+ vector<int> i_starts;
+ double avg_entropy;
+ int seq_i;
+
+ sequences.clear();
+ sequences.push_back("AAAAA");
+ sequences.push_back("AAAAT");
+ sequences.push_back("AATTG");
+ sequences.push_back("ATTGC");
+
+ seq_num = 4;
+
+ c_sequences.clear();
+ i_starts.clear();
+ for(seq_i = 0; seq_i < seq_num; seq_i++) //loop thru all sequences at pos i
+ {
+ c_sequences.push_back((char *)sequences[seq_i].c_str());
+ i_starts.push_back(0);
+ }
+
+ avg_entropy = Window_Entropy(i_starts);
+
+ cout << "average entropy: " << avg_entropy << endl;
+}
+*/
vector<list<int>::iterator> sp_nodes, sp_nodes_end;
list<int>::iterator debug_i;
+ cout << "trans: softhres = " << soft_thres;
+ cout << ", window = " << win_size << ", ";
+
pathz.clear();
window_num = all_comparisons[0][1].win_num();
- cout << window_num << endl; // just a sanity check
-
+ cout << "window number = " << window_num << endl; // just a sanity check
+ cout << "trans: species_num = " << species_num << endl;
sp_nodes.reserve(species_num);
+ cout << "trans: fie\n";
sp_nodes_end.reserve(species_num);
-
+ cout << "trans: foe\n";
// loop thru all windows in first species
for (win_i = 0; win_i < window_num; win_i++)
{
while ( (sp_i < species_num) && (some_matches) )
{
new_nodes.clear();
- new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ // --thres
+ //new_nodes = all_comparisons[0][sp_i].matches(win_i);
+ new_nodes = all_comparisons[0][sp_i].thres_matches(win_i, soft_thres);
if (new_nodes.empty())
some_matches = false;
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);
+ // --thres
+ //trans_check_nodes = all_comparisons[sp_depth][i].matches(cur_node);
+ trans_check_nodes =
+ all_comparisons[sp_depth][i].thres_matches(cur_node, soft_thres);
+
if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
trans_check_nodes.end(),
path[i]) ) &&
-
-
-
/*
// loop thru all windows in first species
for (win_i = 0; win_i < window_num; win_i++)
list<annot>::iterator list_i;
string err_msg;
+
annots.clear();
data_file.open(file_path.c_str(), ios::in);
annot_value = file_data_line.substr(0,space_split_i);
an_annot.end = atoi (annot_value.c_str());
file_data_line = file_data_line.substr(space_split_i+1);
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.name = annot_value;
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot start index
+
+ cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
+ << endl;
+
+ // get annot name
space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
- /*
- cout << "ANA_START: " << an_annot.start <<
- " ANA_END: " << an_annot.end << endl;
- */
+ if (space_split_i == string::npos) // no entries for name & type
+ {
+ cout << "seq, annots - no name or type\n";
+ an_annot.name = "";
+ an_annot.type = "";
+ }
+ else
+ {
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.name = annot_value;
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot type
+ space_split_i = file_data_line.find(" ");
+ if (space_split_i == string::npos) // no entry for type
+ an_annot.type = "";
+ else
+ {
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ }
+ }
+
+
// add annot to list if it falls within the range of sequence specified
if ((start_index <= an_annot.start) && (end_index >= an_annot.end))
{
return sequence;
}
+
+string
+Sequence::subseq(int start, int end)
+{
+ return sequence.substr(start, end);
+}
+
+
const char *
Sequence::c_seq()
{
space_split_i = file_data_line.find(" ");
annot_value = file_data_line.substr(0,space_split_i);
an_annot.end = atoi (annot_value.c_str());
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.name = annot_value;
- file_data_line = file_data_line.substr(space_split_i+1);
- // get annot start index
- space_split_i = file_data_line.find(" ");
- annot_value = file_data_line.substr(0,space_split_i);
- an_annot.type = annot_value;
- annots.push_back(an_annot);
+
+ if (space_split_i == string::npos) // no entry for type or name
+ {
+ cout << "seq, annots - no type or name\n";
+ an_annot.type = "";
+ an_annot.name = "";
+ }
+ else // else get annot type
+ {
+ file_data_line = file_data_line.substr(space_split_i+1);
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ if (space_split_i == string::npos) // no entry for name
+ {
+ cout << "seq, annots - no name\n";
+ an_annot.name = "";
+ }
+ else // get annot name
+ {
+ file_data_line = file_data_line.substr(space_split_i+1);
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+ }
+ }
+ annots.push_back(an_annot); // don't forget to actually add the annot
}
+ cout << "seq, annots: " << an_annot.start << ", " << an_annot.end
+ << "-->" << an_annot.type << "::" << an_annot.name << endl;
}
}
load_file.close();
cout << endl;
}
+/*
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.name = annot_value;
+ file_data_line = file_data_line.substr(space_split_i+1);
+ // get annot start index
+ space_split_i = file_data_line.find(" ");
+ annot_value = file_data_line.substr(0,space_split_i);
+ an_annot.type = annot_value;
+*/
int start_index, int end_index);
string load_annot(string file_path, int start_index, int end_index);
string seq();
+ string subseq(int start, int end);
const char * c_seq();
string rev_comp();
int len();