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_load_window.o : mussa_gui_load_window.cc mussa_gui_load_window.hh
+ $(CC) $(CFLAGS) -c mussa_gui_load_window.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
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_motif_window.o mussa_gui_load_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_motif_window.o mussa_gui_load_window.o \
mussa_gui_seq.o mussa_gui_seq_view.o \
mussa_class.o mussa_nway.o mussa_nway_other.o \
flp_seqcomp.o flp.o sequence.o $(LDFLAGS)
--- /dev/null
+#include "sequence.hh"
+
+int main(int argc, char **argv)
+{
+ Sequence seqA;
+ char * seqA_file, * seqA_annot;
+ cout << "fee fie foe fum" << endl;
+
+
+ seqA_file = * ++argv;
+ seqA_annot = * ++argv;
+
+ seqA.load_fasta(seqA_file, 1);
+ seqA.load_annot(seqA_annot);
+ //seqA_len = seqA.len();
+}
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe ";
+ cout << "fum\n";
+*/
run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold);
if ((run_mode == 'f') || (run_mode == 'n'))
- err_msg = an_analysis.analyze(a_file_path, window, threshold);
+ {
+ err_msg = an_analysis.load_mupa_file(a_file_path);
+ err_msg = an_analysis.analyze(window, threshold);
//an_overlord.do_analysis();
+ }
if (run_mode == 'v')
err_msg = an_analysis.load(a_file_path);
#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)
{
{
}
+// set all parameters to null state
+void
+Mussa::clear()
+{
+ ana_name = "";
+ seq_num = 0;
+ window = 0;
+ threshold = 0;
+ win_append = false;
+ thres_append = false;
+ seq_files.clear();
+ fasta_indices.clear();
+ annot_files.clear();
+ sub_seq_starts.clear();
+ sub_seq_ends.clear();
+}
+
+// these 5 simple methods manually set the parameters for doing an analysis
+// used so that the gui can take input from user and setup the analysis
+// note - still need a set_append(bool, bool) method...
+void
+Mussa::set_name(string a_name)
+{
+ ana_name = a_name;
+}
+
+void
+Mussa::set_seq_num(int a_num)
+{
+ seq_num = a_num;
+}
+
+void
+Mussa::set_window(int a_window)
+{
+ window = a_window;
+}
+
+void
+Mussa::set_threshold(int a_threshold)
+{
+ threshold = a_threshold;
+}
+
+// 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)
+{
+ seq_files.push_back(seq_file);
+ fasta_indices.push_back(fa_i);
+ annot_files.push_back(annot_file);
+ sub_seq_starts.push_back(a_start);
+ sub_seq_ends.push_back(the_end);
+}
string
-Mussa::load_parameters(string para_file_path)
+Mussa::load_mupa_file(string para_file_path)
{
ifstream para_file;
string file_data_line;
// initialize values
- win_append = false;
- thres_append = false;
- seq_files.clear();
- fasta_indices.clear();
- annot_files.clear();
- sub_seq_starts.clear();
- sub_seq_ends.clear();
+ clear();
para_file.open(para_file_path.c_str(), ios::in);
string
-Mussa::analyze(string para_file_path, int w, int t)
+Mussa::analyze(int w, int t)
{
string err_msg;
time_t t1, t2, begin, end;
begin = time(NULL);
- t1 = time(NULL);
- err_msg = load_parameters(para_file_path);
- t2 = time(NULL);
- setuptime = difftime(t2, t1);
+ // now loading parameters from file must be done separately
+ //t1 = time(NULL);
+ //err_msg = load_mupa_file(para_file_path);
+ //t2 = time(NULL);
+ //setuptime = difftime(t2, t1);
if (w > 0)
window = w;
if (t > 0)
threshold = t;
- if (err_msg == "")
- {
+ //if (err_msg == "")
+ //{
cout << "fee\n";
t1 = time(NULL);
err_msg = get_Seqs();
end = time(NULL);
totaltime = difftime(end, begin);
- cout << "setup\tseqload\tseqcomp\tnway\tsave\ttotal\n";
- cout << setuptime << "\t";
+
+ cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
+ //setup\t
+ //cout << setuptime << "\t";
cout << seqloadtime << "\t";
cout << seqcomptime << "\t";
cout << nwaytime << "\t";
}
else
return err_msg;
- }
- else
- return err_msg;
+ //}
+ //else
+ //return err_msg;
}
Sequence aSeq;
string err_msg;
+
seq_files_i = seq_files.begin();
fasta_indices_i = fasta_indices.begin();
annot_files_i = annot_files.begin();
friend class ConnWindow;
private:
- // Private variables
- //string para_file_path;
+ // Private variables
+ // parameters needed for a mussa analysis
string ana_name;
int seq_num, window, threshold;
list<string> seq_files, annot_files;
bool win_override, thres_override;
bool win_append, thres_append;
+ // sequence data
vector<Sequence> the_Seqs;
+ // the seqcomp data
vector<vector<FLPs> > all_comps;
+ // N-way data, ie the mussa results
Nway_Paths the_paths;
- // Private methods
- string load_parameters(string para_file_path);
+ // Private methods
string get_Seqs();
void seqcomp();
void nway();
public:
- Mussa();
- string analyze(string para_file_path, int w, int t);
+ Mussa();
+
+ // 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);
void save();
string load(string ana_file);
- // deprecated - support bridge for python version of mussa
- // these save & load from the old file format
+ // clear parameters and initialize data lists
+ void clear();
+
+ // set parameters from a file - 'mupa' ~ mussa parameters
+ string load_mupa_file(string para_file_path);
+
+ // set parameters individually (eg from user input into gui classes)
+ void set_name(string a_name);
+ void set_seq_num(int a_num);
+ void set_window(int a_window);
+ void set_threshold(int a_threshold);
+ 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
+ // these save & load from the old file format
void save_old();
void load_old(char * load_file_path, int s_num);
};
{
cout << i->seq << " is new\n";
i->locations.clear();
- //i_locs = i->locations
+ //i_locs = i->locations;
for(i2 = 0; i2 < seq_num; i2++)
{
some_motif_locs = (*S)[i2].find_motif(i->seq);
(*i).locations.push_back(some_motif_locs);
- /*
+
i_locs = some_motif_locs.begin();
while (i_locs != some_motif_locs.end())
{
++i_locs;
}
cout << endl;
- */
+
}
i->dirty = false;
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),
picked_file = fl_file_chooser("Analysis Config File", "", "", 1);
a_file_path = picked_file;
-
+
an_analysis = new Mussa();
- err_msg = an_analysis->analyze(a_file_path, 0, 0);
+ err_msg = an_analysis->load_mupa_file(a_file_path);
+
+ if (err_msg == "")
+ {
+ err_msg = an_analysis->analyze(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),
}
}
+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();
+ setup_win = new SetupWindow(650,700,"Analysis Setup", an_analysis);
+
+ while(setup_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();
+}
// all the crap needed for dealing with the scale bars
void
color(FL_WHITE);
resizable(this);
+
// create file menu button
file_menu = new Fl_Menu_Button(padding, 2, button_len, 30, "File");
file_menu->color(FL_WHITE,a_color);
// add menu items
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);
line_input->value("");
line_input->when(FL_WHEN_ENTER_KEY);
line_input->callback((Fl_Callback*)set_line_len_cb, this);
-
+
// create the connections box
conn_box = new ConnView(padding, padding + 30, w-2*padding, h-2*padding-30);
+ //conn_box = new ConnView(padding, padding, w-2*padding, h-2*padding);
end();
show();
#include "mussa_gui_conn_view.hh"
-#include <FL/Fl_File_Chooser.H>
#include <FL/fl_ask.H>
Fl_Button *toggle_lines;
Fl_Input *line_input;
ConnView *conn_box;
+ SetupWindow *setup_win;
int padding, name_pad;
-
+ string window_name;
public:
ConnWindow(int w, int h, const char* title);
void real_load_ana_cb();
void real_do_ana_cb();
+ void real_setup_ana_cb();
void real_toggle_bars_cb();
void real_set_bar_len_cb(Fl_Input* o);
void real_toggle_lines_cb();
--- /dev/null
+#include "mussa_gui_motif_window.hh"
+#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_Scroll.H>
+
+class SetupWindow : public Fl_Window
+{
+ public:
+ SetupWindow(int w, int h, const char* title, Mussa *an_analysis);
+ ~SetupWindow();
+
+ 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 teh selected file
+ vector<Fl_Input*> seq_inputs, annot_inputs;
+
+
+ // callback receiver functions
+
+ void real_do_analysis();
+
+ 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_set_seq_num_cb(Fl_Input* o);
+
+ void real_seq_file_in_cb(Fl_Input* o, int i);
+ void real_choose_seq_file_cb(int i);
+ void real_annot_file_in_cb(Fl_Input* o, int i);
+ void real_choose_annot_file_cb(int i);
+
+ void real_fa_index_in_cb(Fl_Input* o, int i);
+ void real_sub_start_in_cb(Fl_Input* o, int i);
+ void real_sub_end_in_cb(Fl_Input* o, int i);
+
+ private:
+ Mussa *an_analysis;
+ string ana_name;
+ int window, threshold, seq_num;
+ vector<string> seq_files, annot_files;
+ vector<int> fasta_indices, sub_seq_starts, sub_seq_ends;
+ bool win_append, thres_append;
+
+ static void print_cb(Fl_Button*, void*);
+ inline void print_cb_real(Fl_Button*, void*);
+
+ void add_seq_input(int index);
+};
+
+// 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 seq_data_instance
+{
+ SetupWindow * sw_ptr;
+ int index;
+};
void
SeqWinMaster::make_window()
{
+ string window_name;
menu_align_data_bundle * some_menu_data;
vector<int> a_path;
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,
- "Mussa Sequence");
+ (const char*) window_name.c_str());
//seq_window->resizable();
seq_window->color(FL_WHITE);
seq_window->begin();
{
x_start = (int) ((*i_locs +scroll_offset - seq_align_offsets[i2])
* ch_width) + index_pad + x();
- fl_line(x_start,y_loc,x_start+scale_len,y_loc);
+
+ //cout << *i_locs << ":" << x_start << " ";
+ // don't draw highlights outside of box range, they can wraparound past some boundry
+ if ((x_start > 0) && (x_start < w()))
+ fl_line(x_start,y_loc,x_start+scale_len,y_loc);
++i_locs;
}
+ //cout << endl;
y_loc += y_seq_incre;
}
++motif_i;
// for testing purposes: to see everything in the short test sequences
//seq_align_offsets.push_back(0);
}
+ // reset any dragging done, otherwise might be hard to find selected align
+ scroll_offset = 0;
}
}
-#include "mussa_gui_motif_window.hh"
+#include "mussa_gui_load_window.hh"
#include <math.h>
#include <FL/Fl_Box.H>
--- /dev/null
+#include "mussa_class.hh"
+#include "time.h"
+
+int main(int argc, char **argv)
+{
+ Mussa overlord;
+ char * para_file, * ana_file;
+ string an_arg;
+ time_t t1, t2, begin, end;
+ double setuptime, seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
+ string run_mode;
+ int seq_num;
+
+
+ begin = time(NULL);
+
+ // need more sophisticated arg reading structure
+ // support -w and -t override options...other stuff??
+ an_arg = * ++argv;
+
+ if (an_arg == "-v")
+ {
+ ana_file = * ++argv;
+ run_mode = "v";
+ }
+ else
+ {
+ para_file = (char*) an_arg.c_str();
+ run_mode = "f";
+ }
+
+ if (run_mode == "v")
+ {
+ cout << "load file = " << ana_file << endl;
+ overlord.load(ana_file);
+ //overlord.FuckingPieceOfShit(1000,500);
+ }
+ else if (run_mode == "f")
+ {
+ t1 = time(NULL);
+ overlord.setup(para_file);
+ t2 = time(NULL);
+ setuptime = difftime(t2, t1);
+
+
+ cout << "fee\n";
+ t1 = time(NULL);
+ overlord.get_Seqs();
+ t2 = time(NULL);
+ seqloadtime = difftime(t2, t1);
+
+
+ cout << "fie\n";
+ t1 = time(NULL);
+ overlord.seqcomp();
+ t2 = time(NULL);
+ seqcomptime = difftime(t2, t1);
+
+
+ cout << "foe\n";
+ t1 = time(NULL);
+ overlord.nway();
+ t2 = time(NULL);
+ nwaytime = difftime(t2, t1);
+
+
+ cout << "fum\n";
+ t1 = time(NULL);
+ overlord.save_old();
+ t2 = time(NULL);
+ savetime = difftime(t2, t1);
+
+ end = time(NULL);
+ totaltime = difftime(end, begin);
+
+ cout << "setup\tseqload\tseqcomp\tnway\tsave\ttotal\n";
+ cout << setuptime << "\t";
+ cout << seqloadtime << "\t";
+ cout << seqcomptime << "\t";
+ cout << nwaytime << "\t";
+ cout << savetime << "\t";
+ cout << totaltime << "\n";
+ }
+}
+
+
+
+
+/*
+ cout << "fee\n";
+ cout << "fie\n";
+ cout << "foe\n";
+ cout << "fum\n";
+*/
motif_i = 0;
+ cout << "motif: " << a_motif << endl;
+
//cout << "length: " << length << endl;
seq_i = 0;
while (seq_i < length)
{
+ //if ((seq_i > 10885) && (seq_i < 10917))
+ //cout << seq_c[seq_i] << "?" << a_motif[motif_i] << ":" << motif_i << " ";
// this is pretty much a straight translation of Nora's python code
// to match iupac letter codes
if (a_motif[motif_i] =='N')
((seq_c[seq_i]=='C') || (seq_c[seq_i]=='G') ||
(seq_c[seq_i]=='T')))
motif_i++;
+
else
{
seq_i -= motif_i;
// end Nora stuff, now we see if a match is found this pass
if (motif_i == motif_len)
{
- //cout << "MATCH!!!\n";
+ //cout << "!!";
motif_match_starts->push_back(seq_i - motif_len + 1);
motif_i = 0;
}
seq_i++;
}
+ cout << endl;
}
+