1 // ----------------------------------------
2 // ---------- mussa_class.cc -----------
3 // ----------------------------------------
5 #include "mussa_class.hh"
13 Mussa::setup(char * para_file_path)
16 string file_data_line;
17 string param, value, annot_file;
18 int split_index, fasta_index;
19 bool seq_params, did_seq;
26 para_file.open(para_file_path, ios::in);
28 getline(para_file,file_data_line);
29 split_index = file_data_line.find(" ");
30 param = file_data_line.substr(0,split_index);
31 value = file_data_line.substr(split_index+1);
34 while (!para_file.eof())
37 if (param == "ANA_NAME")
39 else if (param == "APPEND_WIN")
41 else if (param == "APPEND_THRES")
43 else if (param == "SEQUENCE_NUM")
44 seq_num = atoi(value.c_str());
45 else if (param == "WINDOW")
46 window = atoi(value.c_str());
47 else if (param == "THRESHOLD")
48 threshold = atoi(value.c_str());
49 else if (param == "SEQUENCE")
51 seq_files.push_back(value);
56 while ((!para_file.eof()) && seq_params)
58 getline(para_file,file_data_line);
59 split_index = file_data_line.find(" ");
60 param = file_data_line.substr(0,split_index);
61 value = file_data_line.substr(split_index+1);
63 if (param == "FASTA_INDEX")
64 fasta_index = atoi(value.c_str());
65 else if (param == "ANNOTATION")
67 //ignore empty lines or that start with '#'
68 else if ((param == "") || (param == "#")) {}
69 else seq_params = false;
73 fasta_indices.push_back(fasta_index);
74 annot_files.push_back(annot_file);
78 //ignore empty lines or that start with '#'
79 else if ((param == "") || (param == "#")) {}
82 cout << "Illegal/misplaced mussa parameter in file\n";
83 cout << param << "\n";
88 getline(para_file,file_data_line);
89 split_index = file_data_line.find(" ");
90 param = file_data_line.substr(0,split_index);
91 value = file_data_line.substr(split_index+1);
98 cout << "ana_name = " << ana_name << win_append << win_append << "\n";
99 cout << "window = " << window << " threshold = " << threshold << "\n";
106 list<string>::iterator seq_files_i, annot_files_i;
107 list<int>::iterator fasta_indices_i;
110 seq_files_i = seq_files.begin();
111 fasta_indices_i = fasta_indices.begin();
112 annot_files_i = annot_files.begin();
114 while ( (seq_files_i != seq_files.end()) &&
115 (fasta_indices_i != fasta_indices.end()) &&
116 (annot_files_i != annot_files.end()) )
118 aSeq.load_fasta(*seq_files_i, *fasta_indices_i);
119 the_Seqs.push_back(aSeq);
120 cout << aSeq.hdr() << endl;
138 int i, i2; // loop vars over sequences to analyze
139 vector<int> seq_lens;
140 vector<FLPs> empty_FLP_vector;
142 string save_file_string;
144 empty_FLP_vector.clear();
145 for(i = 0; i < seq_num; i++)
147 all_comps.push_back(empty_FLP_vector);
148 for(i2 = 0; i2 < seq_num; i2++)
149 all_comps[i].push_back(dummy_comp);
152 for(i = 0; i < seq_num; i++)
153 seq_lens.push_back(the_Seqs[i].len());
155 for(i = 0; i < seq_num; i++)
156 for(i2 = i+1; i2 < seq_num; i2++)
158 all_comps[i][i2].setup("m", window, threshold, seq_lens[i],seq_lens[i2]);
159 all_comps[i][i2].seqcomp(the_Seqs[i].seq(), the_Seqs[i2].seq(), false);
160 all_comps[i][i2].seqcomp(the_Seqs[i].seq(),the_Seqs[i2].rev_comp(),true);
161 save_file_string = "ana";
163 save_file_string += "0";
165 save_file_string += "1";
167 save_file_string += "1";
169 save_file_string += "2";
171 all_comps[i][i2].file_save(save_file_string);
179 the_paths.setup(seq_num);
180 the_paths.find_paths_r(all_comps);
190 save_file.open(ana_name.c_str(), ios::out);
192 for(i = 0; i < seq_num; i++)
193 save_file << the_Seqs[i].seq() << endl;
195 save_file << window << endl;
197 //note more complex eventually since ana_name may need to have
198 //window size, threshold and other stuff to modify it...
199 the_paths.save_old(ana_name);
204 Mussa::load_old(char * load_file_path, int s_num)
207 string file_data_line;
208 int i, space_split_i, comma_split_i;
209 vector<int> loaded_path;
210 string node_pair, node;
214 the_paths.setup(seq_num);
215 save_file.open(load_file_path, ios::in);
217 // currently loads old mussa format
220 for(i = 0; i < seq_num; i++)
222 getline(save_file, file_data_line);
223 a_seq.set_seq(file_data_line);
224 the_Seqs.push_back(a_seq);
228 getline(save_file, file_data_line);
229 window = atoi(file_data_line.c_str());
232 while (!save_file.eof())
235 getline(save_file, file_data_line);
236 if (file_data_line != "")
237 for(i = 0; i < seq_num; i++)
239 space_split_i = file_data_line.find(" ");
240 node_pair = file_data_line.substr(0,space_split_i);
241 //cout << "np= " << node_pair;
242 comma_split_i = node_pair.find(",");
243 node = node_pair.substr(comma_split_i+1);
244 //cout << "n= " << node << " ";
245 loaded_path.push_back(atoi (node.c_str()));
246 file_data_line = file_data_line.substr(space_split_i+1);
249 the_paths.add_path(loaded_path);
253 //the_paths.save("tmp.save");
257 // In Memorial to Everything that's gone wrong in the last week
258 // and Everything that will go wrong in the next 2 weeks 03/02/2004 - Tristan
260 Mussa::FuckingPieceOfShit(int x_max, int y_max)
263 Fl_Window *conn_window = new Fl_Window(x_max, y_max, "Mussa Connections");
264 ConnView *conn_box = new ConnView(0, 0, x_max, y_max);
265 conn_box->setup(ana_name, seq_num, window, &the_Seqs, &the_paths);
266 conn_box->scale_paths();
267 conn_box->spawnSeq();