Changeset 6169 for branches/stable_5.0
- Timestamp:
- 02/09/09 11:01:42 (3 years ago)
- Location:
- branches/stable_5.0/EDIT4
- Files:
-
- 4 modified
-
ED4_main.cxx (modified) (1 diff)
-
ED4_root.cxx (modified) (1 diff)
-
graph_aligner_gui.cxx (modified) (15 diffs)
-
graph_aligner_gui.hxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/stable_5.0/EDIT4/ED4_main.cxx
r6143 r6169 378 378 379 379 create_naligner_variables(root, AW_ROOT_DEFAULT); 380 create_ galigner_variables(root, AW_ROOT_DEFAULT);380 create_sina_variables(root, AW_ROOT_DEFAULT); 381 381 382 382 awar_edit_modus = AD_ALIGN; -
branches/stable_5.0/EDIT4/ED4_root.cxx
r6124 r6169 1548 1548 #endif 1549 1549 SEP________________________SEP; 1550 awmm->insert_menu_topic("fast_aligner", INTEGRATED_ALIGNERS_TITLE " [Ctrl-A]", "I", "faligner.hlp", AWM_ALL, AW_POPUP, (AW_CL)ED4_create_faligner_window,(AW_CL)&faligner_client_data);1551 awmm->insert_menu_topic("fast_align_set_ref", "Set aligner reference [Ctrl-R]", "R", "faligner.hlp", AWM_ALL, (AW_CB)AWTC_set_reference_species_name, (AW_CL)aw_root,0);1552 awmm->insert_menu_topic("align_sequence", "Old aligner from ARB_EDIT", "O", "ne_align_seq.hlp", AWM_EXP, AW_POPUP, (AW_CL)create_naligner_window, 0);1553 awmm->insert_menu_topic(" graph_aligner", "SILVA aligner (SINA)", "S", "galign_main.hlp", galign_mask(), show_galigner_window, (AW_CL)&faligner_client_data,0);1554 awmm->insert_menu_topic("del_ali_tmp", "Remove all aligner Entries", "v", 0, AWM_ALL, ED4_remove_faligner_entries, 1, 0);1550 awmm->insert_menu_topic("fast_aligner", INTEGRATED_ALIGNERS_TITLE " [Ctrl-A]", "I", "faligner.hlp", AWM_ALL, AW_POPUP, (AW_CL)ED4_create_faligner_window, (AW_CL)&faligner_client_data); 1551 awmm->insert_menu_topic("fast_align_set_ref", "Set aligner reference [Ctrl-R]", "R", "faligner.hlp", AWM_ALL, (AW_CB)AWTC_set_reference_species_name, (AW_CL)aw_root, 0); 1552 awmm->insert_menu_topic("align_sequence", "Old aligner from ARB_EDIT", "O", "ne_align_seq.hlp", AWM_EXP, AW_POPUP, (AW_CL)create_naligner_window, 0); 1553 awmm->insert_menu_topic("sina", "SINA (SILVA Incremental Aligner)", "S", "sina_main.hlp", sina_mask(aw_root), show_sina_window, (AW_CL)&faligner_client_data, 0); 1554 awmm->insert_menu_topic("del_ali_tmp", "Remove all aligner Entries", "v", 0, AWM_ALL, ED4_remove_faligner_entries, 1, 0); 1555 1555 SEP________________________SEP; 1556 1556 awmm->insert_menu_topic("missing_bases", "Dot potentially missing bases", "D", "missbase.hlp", AWM_EXP, ED4_popup_dot_missing_bases_window, 0, 0); -
branches/stable_5.0/EDIT4/graph_aligner_gui.cxx
r6143 r6169 33 33 using std::endl; 34 34 35 #define GA_AWAR_ROOT "galigner/" 35 #define GA_AWAR_ROOT "sina/" 36 #define GA_AWAR_CMD GA_AWAR_ROOT "command" 36 37 #define GA_AWAR_TGT GA_AWAR_ROOT "target" 37 38 #define GA_AWAR_SAI GA_AWAR_ROOT "sai" … … 55 56 #define GA_AWAR_QSIZE GA_AWAR_ROOT "qsize" 56 57 57 void create_galigner_variables(AW_root *root, AW_default db1) { 58 void create_sina_variables(AW_root *root, AW_default db1) { 59 root->awar_string(GA_AWAR_CMD, "sina", db1); 58 60 root->awar_int(GA_AWAR_TGT, 2, db1); 59 61 root->awar_int(AWAR_PT_SERVER, 0, db1); 60 62 root->awar_string(GA_AWAR_SAI, "none", db1); 61 63 root->awar_int(GA_AWAR_PROTECTION, 0, db1); 62 root->awar_string(GA_AWAR_LOGLEVEL, " normal", db1);64 root->awar_string(GA_AWAR_LOGLEVEL, "3", db1); 63 65 root->awar_int(GA_AWAR_TURN_CHECK, 1, db1); 64 66 root->awar_int(GA_AWAR_REALIGN, 1, db1); … … 78 80 } 79 81 80 int galign_mask() { 81 char *galign = GB_executable("galign"); 82 AW_active sina_mask(AW_root *root) { 83 const char *sinaName = root->awar(GA_AWAR_CMD)->read_char_pntr(); 84 char *sina = GB_executable(sinaName); 82 85 const char *fail_reason = 0; 83 86 84 if (galign) { 85 int galign_vers = system("galign --int-version"); 86 const int expected = 20; 87 88 galign_vers = WEXITSTATUS(galign_vers); 89 free(galign); 90 91 if (galign_vers == expected) { 92 printf("Found galign\n"); 93 return AWM_ALL; 87 if (sina) { 88 int exitstatus = system(GBS_global_string("%s --has-cli-vers 1", sina)); 89 exitstatus = WEXITSTATUS(exitstatus); 90 91 switch (exitstatus) { 92 case EXIT_SUCCESS: 93 break; 94 95 case EXIT_FAILURE: 96 fail_reason = "Incompatible SINA and ARB versions"; 97 break; 98 99 case 127: // libs missing 100 default: // unexpected 101 fail_reason = GBS_global_string("Could execute SINA binary '%s' (exitstatus was %i)", 102 sinaName, exitstatus); 103 break; 94 104 } 95 f ail_reason = GBS_global_string("galign version mismatch (found=%i, expected=%i)", galign_vers, expected);105 free(sina); 96 106 } 97 107 else { 98 fail_reason = "galign not found"; 99 } 100 101 printf("Note: SILVA Aligner disabled (%s)\n", fail_reason); 102 // @@@ print note about download possibility ? 103 104 return AWM_DISABLED; 105 } 106 107 static void galigner_start(AW_window *window, AW_CL cd2) { 108 fail_reason = GBS_global_string("%s not found", sinaName); 109 } 110 111 if (fail_reason) { 112 fprintf(stderr, 113 "Note: SINA (SILVA Aligner) disabled (Reason: %s)\n" 114 " Visit http://www.ribocon.com/sina/ for more information.\n", 115 fail_reason); 116 } 117 118 return fail_reason ? AWM_DISABLED : AWM_ALL; 119 } 120 121 static void sina_start(AW_window *window, AW_CL cd2) { 122 GB_ERROR gb_error; 108 123 AW_root *root = window->get_root(); 109 cerr << "Starting Aligner..." << endl;124 cerr << "Starting SINA..." << endl; 110 125 111 126 // make string from pt server selection 112 127 int pt = root->awar(AWAR_PT_SERVER)->read_int(); 113 std::stringstream tmp; 114 tmp << "ARB_PT_SERVER" << pt; 115 const char *pt_server = GBS_read_arb_tcp(tmp.str().c_str()); 128 const char *pt_server; 129 std::stringstream ptnam; 130 ptnam << "ARB_PT_SERVER" << pt; 131 pt_server = GBS_read_arb_tcp(ptnam.str().c_str()); 132 if (!pt_server) { 133 aw_message("Unable to find definition for chosen PT-server"); 134 return; 135 } 116 136 const char *pt_db = pt_server + strlen(pt_server) +1; 117 137 pt_db += strlen(pt_db)+3; 118 GB_ERROR gb_error;119 138 120 139 // start pt server if necessary 121 gb_error = arb_look_and_start_server(AISC_MAGIC_NUMBER, tmp.str().c_str(),140 gb_error = arb_look_and_start_server(AISC_MAGIC_NUMBER,ptnam.str().c_str(), 122 141 GLOBAL_gb_main); 123 142 if (gb_error) { 124 cerr << "Cannot contact PT server. Aborting" << endl;125 cerr << " ID: \"" << tmp.str().c_str()126 << "\" PORT: \"" << pt_server127 << "\" DB: \"" << pt_db << endl128 << "\" GBERROR: \"" << gb_error << "\"" << endl;129 GB_export_error("Cannot contact PT server");130 143 std::stringstream tmp; 144 tmp << "Cannot contact PT server. Aborting" << endl 145 << " ID: \"" << tmp.str().c_str() 146 << "\" PORT: \"" << pt_server 147 << "\" DB: \"" << pt_db << endl 148 << "\" GBERROR: \"" << gb_error << "\"" << endl; 149 aw_message(tmp.str().c_str()); 131 150 return; 132 151 } 133 152 134 const char *turn_check; 135 if (root->awar(GA_AWAR_TURN_CHECK)->read_int()) 136 turn_check = "all"; 137 else 138 turn_check = "none"; 139 140 int pipe_fds[2]; 141 if (pipe(pipe_fds) == -1) { 142 cerr << "Unable to create pipe! Aborting." << endl; 143 //fixme do errorhandling 153 // create temporary file 154 char* tmpfile_tpl = GB_unique_filename("sina_select","tmp"); 155 char* tmpfile; 156 FILE* tmpfile_F = GB_fopen_tempfile(tmpfile_tpl,"w", &tmpfile); 157 if (!tmpfile_F) { 158 std::stringstream tmp; 159 tmp << "Error: Unable to create temporary file \"" << tmpfile << "\"!"; 160 aw_message(tmp.str().c_str()); 144 161 return; 145 162 } 146 147 pid_t me = fork(); 148 if (!me) { // we are child 149 close(pipe_fds[1]); // close write end of pipe 150 dup2(pipe_fds[0], STDIN_FILENO); // copy read end over stdin 151 152 if (execlp("galign", "galign", 153 "--arb-db", ":", 154 "--pt-port", pt_server, 155 "--pt-db", pt_db, 156 "--no-pt-start", 157 root->awar(GA_AWAR_PTLOAD)->read_int()?"--pt-load":"", 158 root->awar(GA_AWAR_COPYMARKREF)->read_int()?"--copymarkref":"", 159 "--arb-filter", 160 root->awar(GA_AWAR_SAI)->read_string(), 161 "--input-type", "arb", 162 "--turn", turn_check, 163 "--print", 164 root->awar(GA_AWAR_LOGLEVEL)->read_string(), 165 root->awar(GA_AWAR_REALIGN)->read_int()?"--realign":"", 166 "--protection-level", 167 root->awar(GA_AWAR_PROTECTION)->read_as_string(), 168 "--penalties", 169 root->awar(GA_AWAR_GAP_PEN)->read_as_string(), 170 root->awar(GA_AWAR_GAP_EXT)->read_as_string(), 171 "--familyparam", 172 root->awar(GA_AWAR_FS_MIN)->read_as_string(), 173 root->awar(GA_AWAR_FS_MAX)->read_as_string(), 174 root->awar(GA_AWAR_FS_MSC)->read_as_string(), 175 "--overhang-placement", 176 root->awar(GA_AWAR_OVERHANG)->read_string(), 177 "--ncpu", 178 root->awar(GA_AWAR_THREADS)->read_as_string(), 179 "--queue-size", 180 root->awar(GA_AWAR_QSIZE)->read_as_string(), 181 "--min-full", 182 root->awar(GA_AWAR_MIN_FULL)->read_as_string(), 183 "--full-minlen", 184 root->awar(GA_AWAR_FULL_MINLEN)->read_as_string(), 185 #ifdef DEBUG 186 "--arb-debug", 187 #endif 188 (char*) NULL) == -1) { 189 perror("Executing galign failed"); 190 } 191 close (pipe_fds[0]); 192 _exit(0); // kill this process, but don't remove tempfiles, etc. 193 } 194 close(pipe_fds[0]); // close read end of pipe; 163 GB_remove_on_exit(tmpfile); 195 164 196 165 std::vector<std::string> spec_names; … … 199 168 { 200 169 char *spec_name = root->awar(AWAR_SPECIES_NAME)->read_string(); 201 if (spec_name) 202 spec_names.push_back(std::string(spec_name)); 170 if (spec_name) { 171 fwrite(spec_name, strlen(spec_name), 1, tmpfile_F); 172 fwrite("\n", 1, 1, tmpfile_F); 173 } else { 174 aw_message("Unable to get name of currently active species"); 175 return; 176 } 203 177 } 204 178 break; … … 206 180 { 207 181 struct AWTC_faligner_cd *cd = (struct AWTC_faligner_cd *)cd2; 182 GB_begin_transaction(GLOBAL_gb_main); 208 183 int num_selected = 0; 209 GB_begin_transaction(GLOBAL_gb_main);210 184 for (GBDATA *gb_spec = cd->get_first_selected_species(&num_selected); 211 185 gb_spec; gb_spec = cd->get_next_selected_species()) { … … 213 187 if (gbd_name) { 214 188 const char *str = GB_read_char_pntr(gbd_name); 215 spec_names.push_back(std::string(str)); 189 fwrite(str, strlen(str), 1, tmpfile_F); 190 fwrite("\n", 1, 1, tmpfile_F); 216 191 } 217 192 } … … 227 202 if (gbd_name) { 228 203 const char *str = GB_read_char_pntr(gbd_name); 229 spec_names.push_back(std::string(str)); 204 fwrite(str, strlen(str), 1, tmpfile_F); 205 fwrite("\n", 1, 1, tmpfile_F); 230 206 } 231 207 } … … 234 210 break; 235 211 } 236 237 for(std::vector<std::string>::iterator it = spec_names.begin(); 238 it != spec_names.end(); ++it) { 239 write(pipe_fds[1], it->c_str(), it->size()); 240 write(pipe_fds[1], "\n", 1); 241 } 242 243 close(pipe_fds[1]); 244 waitpid(me, NULL, 0); 245 cerr << "ARB: Finished Aligning."; 212 fclose(tmpfile_F); 213 214 // build command line 215 std::stringstream cmdline; 216 cmdline << root->awar(GA_AWAR_CMD)->read_string() 217 << " -i :" 218 << " --queue-size " << root->awar(GA_AWAR_QSIZE)->read_as_string() 219 << " --ncpu " << root->awar(GA_AWAR_THREADS)->read_as_string() 220 << " --verbosity " << root->awar(GA_AWAR_LOGLEVEL)->read_as_string() 221 << " --ptdb " << (root->awar(GA_AWAR_PTLOAD)->read_int()?pt_db:":") 222 << " --ptport " << pt_server 223 << " --turn " << (root->awar(GA_AWAR_TURN_CHECK)->read_int()?"all":"none") 224 << (root->awar(GA_AWAR_REALIGN)->read_int()?" --realign":"") 225 << " --overhang " << root->awar(GA_AWAR_OVERHANG)->read_string() 226 << " --filter " << root->awar(GA_AWAR_SAI)->read_string() 227 << " --fs-min " << root->awar(GA_AWAR_FS_MIN)->read_as_string() 228 << " --fs-msc " << root->awar(GA_AWAR_FS_MSC)->read_as_string() 229 << " --fs-max " << root->awar(GA_AWAR_FS_MAX)->read_as_string() 230 << " --fs-req " << "1" 231 << " --fs-req-full " << root->awar(GA_AWAR_MIN_FULL)->read_as_string() 232 << " --fs-full-len " << root->awar(GA_AWAR_FULL_MINLEN)->read_as_string() 233 << " --pen-gap " << root->awar(GA_AWAR_GAP_PEN)->read_as_string() 234 << " --pen-gapext " << root->awar(GA_AWAR_GAP_EXT)->read_as_string() 235 << (root->awar(GA_AWAR_COPYMARKREF)->read_int()?" --markcopy":"") 236 << " --prot-level " << root->awar(GA_AWAR_PROTECTION)->read_as_string() 237 << " --select-file " << tmpfile; 238 239 gb_error = GB_xcmd(cmdline.str().c_str(), GB_TRUE, GB_FALSE); 240 241 aw_message("SINA finished aligning."); 246 242 } 247 243 … … 285 281 286 282 AW_window_simple* 287 new_ galigner_simple(AW_root *root, AW_CL cd2, bool adv) {283 new_sina_simple(AW_root *root, AW_CL cd2, bool adv) { 288 284 int closex, closey, startx, starty, winx, winy; 289 285 const int hgap = 10; 290 286 AW_window_simple *aws = new AW_window_simple; 291 287 292 aws->init(root, " galigner", "Graph Aligner");288 aws->init(root, "SINA", "SINA (SILVA Incremental Aligner)"); 293 289 294 290 aws->button_length(12); … … 301 297 302 298 aws->at_shift(10,0); 303 aws->callback(show_ galigner_window, cd2, 0);299 aws->callback(show_sina_window, cd2, 0); 304 300 aws->label_length(0); 305 301 aws->label("Show advanced options"); … … 380 376 381 377 aws->at_newline(); 382 aws->label(" Alignerthreads");378 aws->label("Max threads"); 383 379 aws->create_input_field(GA_AWAR_THREADS,3); 384 380 aws->label("Queue size"); 385 381 aws->create_input_field(GA_AWAR_QSIZE,3); 382 383 aws->at_newline(); 384 aws->label("SINA command"); 385 aws->create_input_field(GA_AWAR_CMD,20); 386 386 387 387 aws->at_shift(0,hgap); … … 404 404 aws->at_newline(); 405 405 aws->create_option_menu(GA_AWAR_LOGLEVEL, "Logging level", "L"); 406 aws->insert_option("silent", 0, " silent");407 aws->insert_option("quiet", 0, " quiet");408 aws->insert_default_option("normal", 0, " normal");409 aws->insert_option("verbose", 0, " verbose");410 aws->insert_option("debug", 0, " debug");411 aws->insert_option("debug _graph", 0, "debug_graph");406 aws->insert_option("silent", 0, "1"); 407 aws->insert_option("quiet", 0, "2"); 408 aws->insert_default_option("normal", 0, "3"); 409 aws->insert_option("verbose", 0, "4"); 410 aws->insert_option("debug", 0, "5"); 411 aws->insert_option("debug more", 0, "6"); 412 412 aws->update_option_menu(); 413 413 … … 416 416 417 417 aws->at(winx-closex+5,closey); 418 aws->callback(AW_POPUP_HELP, (AW_CL) " galign_main.hlp");418 aws->callback(AW_POPUP_HELP, (AW_CL) "sina_main.hlp"); 419 419 aws->create_button("HELP", "HELP"); 420 420 421 421 aws->at(winx-closex+5, starty); 422 aws->callback( galigner_start, cd2);422 aws->callback(sina_start, cd2); 423 423 aws->highlight(); 424 424 aws->create_button("Start", "Start", "S"); … … 427 427 } 428 428 429 void show_ galigner_window(AW_window *aw, AW_CL cd2, AW_CL) {429 void show_sina_window(AW_window *aw, AW_CL cd2, AW_CL) { 430 430 static AW_window_simple *ga_aws = 0; 431 431 static AW_window_simple *ga_aws_adv = 0; … … 433 433 AW_root *root = aw->get_root(); 434 434 if (root->awar(GA_AWAR_ADVANCED)->read_int()) { 435 if (!ga_aws_adv) ga_aws_adv = new_ galigner_simple(root, cd2, true);435 if (!ga_aws_adv) ga_aws_adv = new_sina_simple(root, cd2, true); 436 436 ga_aws_adv->show(); 437 437 if (ga_aws) ga_aws->hide(); 438 438 } 439 439 else { 440 if (!ga_aws) ga_aws = new_ galigner_simple(root, cd2, false);440 if (!ga_aws) ga_aws = new_sina_simple(root, cd2, false); 441 441 ga_aws->show(); 442 442 if (ga_aws_adv) ga_aws_adv->hide(); -
branches/stable_5.0/EDIT4/graph_aligner_gui.hxx
r5537 r6169 1 void show_ galigner_window(AW_window*, AW_CL, AW_CL);2 void create_ galigner_variables(AW_root*, AW_default);3 int galign_mask();1 void show_sina_window(AW_window*, AW_CL, AW_CL); 2 void create_sina_variables(AW_root*, AW_default); 3 AW_active sina_mask(AW_root*);
