| 1 | /* Menus and command line interface for Clustal W */ |
|---|
| 2 | /* DES was here MARCH. 1994 */ |
|---|
| 3 | /* DES was here SEPT. 1994 */ |
|---|
| 4 | #include <stdio.h> |
|---|
| 5 | #include <string.h> |
|---|
| 6 | #include <ctype.h> |
|---|
| 7 | #include <stdlib.h> |
|---|
| 8 | #include <stdarg.h> |
|---|
| 9 | #include <signal.h> |
|---|
| 10 | #include <setjmp.h> |
|---|
| 11 | #include "clustalw.h" |
|---|
| 12 | |
|---|
| 13 | static jmp_buf jmpbuf; |
|---|
| 14 | #ifndef VMS |
|---|
| 15 | #ifndef AIX |
|---|
| 16 | #define BADSIG (void (*)())-1 |
|---|
| 17 | #endif |
|---|
| 18 | #endif |
|---|
| 19 | |
|---|
| 20 | static void jumper(int); |
|---|
| 21 | |
|---|
| 22 | static void jumper(int i) |
|---|
| 23 | { |
|---|
| 24 | longjmp(jmpbuf,1); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | /* |
|---|
| 29 | * Prototypes |
|---|
| 30 | */ |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | static void pair_menu(void); |
|---|
| 34 | static void multi_menu(void); |
|---|
| 35 | static void gap_penalties_menu(void); |
|---|
| 36 | static void multiple_align_menu(void); /* multiple alignments menu */ |
|---|
| 37 | static void profile_align_menu(void); /* profile " " */ |
|---|
| 38 | static void phylogenetic_tree_menu(void); /* NJ trees/distances menu */ |
|---|
| 39 | static void format_options_menu(void); /* format of alignment output */ |
|---|
| 40 | static void tree_format_options_menu(void); /* format of tree output */ |
|---|
| 41 | static void ss_options_menu(void); |
|---|
| 42 | static sint secstroutput_options(void); |
|---|
| 43 | static sint read_matrix(char **mattxt, char *matnam, sint matn, short *mat, short *xref); |
|---|
| 44 | static sint read_dnamatrix(char **mattxt, char *matnam, sint matn, short *mat, short *xref); |
|---|
| 45 | |
|---|
| 46 | /* |
|---|
| 47 | * Global variables |
|---|
| 48 | */ |
|---|
| 49 | |
|---|
| 50 | extern float gap_open, gap_extend; |
|---|
| 51 | extern float dna_gap_open, dna_gap_extend; |
|---|
| 52 | extern float prot_gap_open, prot_gap_extend; |
|---|
| 53 | extern float pw_go_penalty, pw_ge_penalty; |
|---|
| 54 | extern float dna_pw_go_penalty, dna_pw_ge_penalty; |
|---|
| 55 | extern float prot_pw_go_penalty, prot_pw_ge_penalty; |
|---|
| 56 | extern float transition_weight; |
|---|
| 57 | extern char revision_level[]; |
|---|
| 58 | extern sint wind_gap,ktup,window,signif; |
|---|
| 59 | extern sint dna_wind_gap, dna_ktup, dna_window, dna_signif; |
|---|
| 60 | extern sint prot_wind_gap,prot_ktup,prot_window,prot_signif; |
|---|
| 61 | extern sint nseqs; |
|---|
| 62 | extern sint divergence_cutoff; |
|---|
| 63 | extern sint debug; |
|---|
| 64 | extern Boolean neg_matrix; |
|---|
| 65 | extern Boolean quick_pairalign; |
|---|
| 66 | extern Boolean reset_alignments; /* DES */ |
|---|
| 67 | extern sint gap_dist; |
|---|
| 68 | extern Boolean no_hyd_penalties, no_pref_penalties; |
|---|
| 69 | extern sint output_order; |
|---|
| 70 | extern sint profile_no; |
|---|
| 71 | extern short usermat[], pw_usermat[]; |
|---|
| 72 | extern short aa_xref[], pw_aa_xref[]; |
|---|
| 73 | extern short userdnamat[], pw_userdnamat[]; |
|---|
| 74 | extern short dna_xref[], pw_dna_xref[]; |
|---|
| 75 | |
|---|
| 76 | extern Boolean lowercase; /* Flag for GDE output - set on comm. line*/ |
|---|
| 77 | extern Boolean cl_seq_numbers; |
|---|
| 78 | extern Boolean output_clustal, output_nbrf, output_phylip, output_gcg, output_gde; |
|---|
| 79 | extern Boolean output_tree_clustal, output_tree_phylip, output_tree_distances; |
|---|
| 80 | extern sint bootstrap_format; |
|---|
| 81 | extern Boolean tossgaps, kimura; |
|---|
| 82 | extern Boolean percent; |
|---|
| 83 | extern Boolean usemenu; |
|---|
| 84 | extern Boolean showaln, save_parameters; |
|---|
| 85 | extern Boolean dnaflag; |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | extern char hyd_residues[]; |
|---|
| 89 | extern char mtrxname[], pw_mtrxname[]; |
|---|
| 90 | extern char dnamtrxname[], pw_dnamtrxname[]; |
|---|
| 91 | extern char seqname[]; |
|---|
| 92 | |
|---|
| 93 | extern sint output_struct_penalties; |
|---|
| 94 | extern Boolean use_ss1, use_ss2; |
|---|
| 95 | |
|---|
| 96 | extern Boolean empty; |
|---|
| 97 | extern Boolean profile1_empty, profile2_empty; /* whether or not profiles */ |
|---|
| 98 | |
|---|
| 99 | extern char profile1_name[FILENAMELEN+1]; |
|---|
| 100 | extern char profile2_name[FILENAMELEN+1]; |
|---|
| 101 | |
|---|
| 102 | extern Boolean use_endgaps; |
|---|
| 103 | extern sint matnum,pw_matnum; |
|---|
| 104 | extern sint dnamatnum,pw_dnamatnum; |
|---|
| 105 | |
|---|
| 106 | extern sint helix_penalty; |
|---|
| 107 | extern sint strand_penalty; |
|---|
| 108 | extern sint loop_penalty; |
|---|
| 109 | extern sint helix_end_minus; |
|---|
| 110 | extern sint helix_end_plus; |
|---|
| 111 | extern sint strand_end_minus; |
|---|
| 112 | extern sint strand_end_plus; |
|---|
| 113 | extern sint helix_end_penalty; |
|---|
| 114 | extern sint strand_end_penalty; |
|---|
| 115 | |
|---|
| 116 | extern char *matrix_txt[]; |
|---|
| 117 | extern char *pw_matrix_txt[]; |
|---|
| 118 | extern char *dnamatrix_txt[]; |
|---|
| 119 | |
|---|
| 120 | static char phylip_name[FILENAMELEN]=""; |
|---|
| 121 | static char clustal_name[FILENAMELEN]=""; |
|---|
| 122 | static char dist_name[FILENAMELEN]=""; |
|---|
| 123 | static char p1_tree_name[FILENAMELEN]=""; |
|---|
| 124 | static char p2_tree_name[FILENAMELEN]=""; |
|---|
| 125 | |
|---|
| 126 | static char *secstroutput_txt[] = { |
|---|
| 127 | "Secondary Structure", |
|---|
| 128 | "Gap Penalty Mask", |
|---|
| 129 | "Structure and Penalty Mask", |
|---|
| 130 | "None" }; |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | static char *lin1, *lin2, *lin3; |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | void init_amenu(void) |
|---|
| 137 | { |
|---|
| 138 | |
|---|
| 139 | lin1 = (char *)ckalloc( (MAXLINE+1) * sizeof (char) ); |
|---|
| 140 | lin2 = (char *)ckalloc( (MAXLINE+1) * sizeof (char) ); |
|---|
| 141 | lin3 = (char *)ckalloc( (MAXLINE+1) * sizeof (char) ); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | void main_menu(void) |
|---|
| 145 | { |
|---|
| 146 | int catchint; |
|---|
| 147 | |
|---|
| 148 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 149 | if (catchint) { |
|---|
| 150 | if (setjmp(jmpbuf) != 0) |
|---|
| 151 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 152 | #ifdef UNIX |
|---|
| 153 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 154 | fprintf(stdout,"Error: signal\n"); |
|---|
| 155 | #else |
|---|
| 156 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 157 | fprintf(stdout,"Error: signal\n"); |
|---|
| 158 | #endif |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | while(TRUE) { |
|---|
| 162 | fprintf(stdout,"\n\n\n"); |
|---|
| 163 | fprintf(stdout," **************************************************************\n"); |
|---|
| 164 | fprintf(stdout," ******** CLUSTAL %s Multiple Sequence Alignments ********\n",revision_level); |
|---|
| 165 | fprintf(stdout," **************************************************************\n"); |
|---|
| 166 | fprintf(stdout,"\n\n"); |
|---|
| 167 | |
|---|
| 168 | fprintf(stdout," 1. Sequence Input From Disc\n"); |
|---|
| 169 | fprintf(stdout," 2. Multiple Alignments\n"); |
|---|
| 170 | fprintf(stdout," 3. Profile / Structure Alignments\n"); |
|---|
| 171 | fprintf(stdout," 4. Phylogenetic trees\n"); |
|---|
| 172 | fprintf(stdout,"\n"); |
|---|
| 173 | fprintf(stdout," S. Execute a system command\n"); |
|---|
| 174 | fprintf(stdout," H. HELP\n"); |
|---|
| 175 | fprintf(stdout," X. EXIT (leave program)\n\n\n"); |
|---|
| 176 | |
|---|
| 177 | getstr("Your choice",lin1); |
|---|
| 178 | |
|---|
| 179 | switch(toupper(*lin1)) { |
|---|
| 180 | case '1': seq_input(FALSE); |
|---|
| 181 | break; |
|---|
| 182 | case '2': multiple_align_menu(); |
|---|
| 183 | break; |
|---|
| 184 | case '3': profile_align_menu(); |
|---|
| 185 | break; |
|---|
| 186 | case '4': phylogenetic_tree_menu(); |
|---|
| 187 | break; |
|---|
| 188 | case 'S': do_system(); |
|---|
| 189 | break; |
|---|
| 190 | case '?': |
|---|
| 191 | case 'H': get_help('1'); |
|---|
| 192 | break; |
|---|
| 193 | case 'Q': |
|---|
| 194 | case 'X': exit(0); |
|---|
| 195 | break; |
|---|
| 196 | default: fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 197 | break; |
|---|
| 198 | } |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | static void multiple_align_menu(void) |
|---|
| 211 | { |
|---|
| 212 | int catchint; |
|---|
| 213 | |
|---|
| 214 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 215 | if (catchint) { |
|---|
| 216 | if (setjmp(jmpbuf) != 0) |
|---|
| 217 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 218 | #ifdef UNIX |
|---|
| 219 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 220 | fprintf(stdout,"Error: signal\n"); |
|---|
| 221 | #else |
|---|
| 222 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 223 | fprintf(stdout,"Error: signal\n"); |
|---|
| 224 | #endif |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | while(TRUE) |
|---|
| 229 | { |
|---|
| 230 | fprintf(stdout,"\n\n\n"); |
|---|
| 231 | fprintf(stdout,"****** MULTIPLE ALIGNMENT MENU ******\n"); |
|---|
| 232 | fprintf(stdout,"\n\n"); |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | fprintf(stdout," 1. Do complete multiple alignment now (%s)\n", |
|---|
| 236 | (!quick_pairalign) ? "Slow/Accurate" : "Fast/Approximate"); |
|---|
| 237 | fprintf(stdout," 2. Produce guide tree file only\n"); |
|---|
| 238 | fprintf(stdout," 3. Do alignment using old guide tree file\n\n"); |
|---|
| 239 | fprintf(stdout," 4. Toggle Slow/Fast pairwise alignments = %s\n\n", |
|---|
| 240 | (!quick_pairalign) ? "SLOW" : "FAST"); |
|---|
| 241 | fprintf(stdout," 5. Pairwise alignment parameters\n"); |
|---|
| 242 | fprintf(stdout," 6. Multiple alignment parameters\n\n"); |
|---|
| 243 | fprintf(stdout," 7. Reset gaps between alignments?"); |
|---|
| 244 | if(reset_alignments) |
|---|
| 245 | fprintf(stdout," = ON\n"); |
|---|
| 246 | else |
|---|
| 247 | fprintf(stdout," = OFF\n"); |
|---|
| 248 | fprintf(stdout," 8. Toggle screen display = %s\n", |
|---|
| 249 | (!showaln) ? "OFF" : "ON"); |
|---|
| 250 | fprintf(stdout," 9. Output format options\n"); |
|---|
| 251 | fprintf(stdout,"\n"); |
|---|
| 252 | |
|---|
| 253 | fprintf(stdout," S. Execute a system command\n"); |
|---|
| 254 | fprintf(stdout," H. HELP\n"); |
|---|
| 255 | fprintf(stdout," or press [RETURN] to go back to main menu\n\n\n"); |
|---|
| 256 | |
|---|
| 257 | getstr("Your choice",lin1); |
|---|
| 258 | if(*lin1 == EOS) return; |
|---|
| 259 | |
|---|
| 260 | switch(toupper(*lin1)) |
|---|
| 261 | { |
|---|
| 262 | case '1': align(phylip_name); |
|---|
| 263 | break; |
|---|
| 264 | case '2': make_tree(phylip_name); |
|---|
| 265 | break; |
|---|
| 266 | case '3': get_tree(phylip_name); |
|---|
| 267 | break; |
|---|
| 268 | case '4': quick_pairalign ^= TRUE; |
|---|
| 269 | break; |
|---|
| 270 | case '5': pair_menu(); |
|---|
| 271 | break; |
|---|
| 272 | case '6': multi_menu(); |
|---|
| 273 | break; |
|---|
| 274 | case '7': reset_alignments ^= TRUE; |
|---|
| 275 | break; |
|---|
| 276 | case '8': showaln ^= TRUE; |
|---|
| 277 | break; |
|---|
| 278 | case '9': format_options_menu(); |
|---|
| 279 | break; |
|---|
| 280 | case 'S': do_system(); |
|---|
| 281 | break; |
|---|
| 282 | case '?': |
|---|
| 283 | case 'H': get_help('2'); |
|---|
| 284 | break; |
|---|
| 285 | case 'Q': |
|---|
| 286 | case 'X': return; |
|---|
| 287 | |
|---|
| 288 | default: fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 289 | break; |
|---|
| 290 | } |
|---|
| 291 | } |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | static void profile_align_menu(void) |
|---|
| 303 | { |
|---|
| 304 | int catchint; |
|---|
| 305 | |
|---|
| 306 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 307 | if (catchint) { |
|---|
| 308 | if (setjmp(jmpbuf) != 0) |
|---|
| 309 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 310 | #ifdef UNIX |
|---|
| 311 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 312 | fprintf(stdout,"Error: signal\n"); |
|---|
| 313 | #else |
|---|
| 314 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 315 | fprintf(stdout,"Error: signal\n"); |
|---|
| 316 | #endif |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | |
|---|
| 320 | while(TRUE) |
|---|
| 321 | { |
|---|
| 322 | fprintf(stdout,"\n\n\n"); |
|---|
| 323 | fprintf(stdout,"****** PROFILE AND STRUCTURE ALIGNMENT MENU ******\n"); |
|---|
| 324 | fprintf(stdout,"\n\n"); |
|---|
| 325 | |
|---|
| 326 | fprintf(stdout," 1. Input 1st. profile "); |
|---|
| 327 | if (!profile1_empty) fprintf(stdout,"(loaded)"); |
|---|
| 328 | fprintf(stdout,"\n"); |
|---|
| 329 | fprintf(stdout," 2. Input 2nd. profile/sequences "); |
|---|
| 330 | if (!profile2_empty) fprintf(stdout,"(loaded)"); |
|---|
| 331 | fprintf(stdout,"\n\n"); |
|---|
| 332 | fprintf(stdout," 3. Align 2nd. profile to 1st. profile\n"); |
|---|
| 333 | fprintf(stdout," 4. Align sequences to 1st. profile (%s)\n\n", |
|---|
| 334 | (!quick_pairalign) ? "Slow/Accurate" : "Fast/Approximate"); |
|---|
| 335 | fprintf(stdout," 5. Toggle Slow/Fast pairwise alignments = %s\n\n", |
|---|
| 336 | (!quick_pairalign) ? "SLOW" : "FAST"); |
|---|
| 337 | fprintf(stdout," 6. Pairwise alignment parameters\n"); |
|---|
| 338 | fprintf(stdout," 7. Multiple alignment parameters\n\n"); |
|---|
| 339 | fprintf(stdout," 8. Toggle screen display = %s\n", |
|---|
| 340 | (!showaln) ? "OFF" : "ON"); |
|---|
| 341 | fprintf(stdout," 9. Output format options\n"); |
|---|
| 342 | fprintf(stdout," 0. Secondary structure options\n"); |
|---|
| 343 | fprintf(stdout,"\n"); |
|---|
| 344 | fprintf(stdout," S. Execute a system command\n"); |
|---|
| 345 | fprintf(stdout," H. HELP\n"); |
|---|
| 346 | fprintf(stdout," or press [RETURN] to go back to main menu\n\n\n"); |
|---|
| 347 | |
|---|
| 348 | getstr("Your choice",lin1); |
|---|
| 349 | if(*lin1 == EOS) return; |
|---|
| 350 | |
|---|
| 351 | switch(toupper(*lin1)) |
|---|
| 352 | { |
|---|
| 353 | case '1': profile_no = 1; /* 1 => 1st profile */ |
|---|
| 354 | profile_input(); |
|---|
| 355 | strcpy(profile1_name, seqname); |
|---|
| 356 | break; |
|---|
| 357 | case '2': profile_no = 2; /* 2 => 2nd profile */ |
|---|
| 358 | profile_input(); |
|---|
| 359 | strcpy(profile2_name, seqname); |
|---|
| 360 | break; |
|---|
| 361 | case '3': profile_align(p1_tree_name,p2_tree_name); /* align the 2 alignments now */ |
|---|
| 362 | break; |
|---|
| 363 | case '4': new_sequence_align(phylip_name); /* align new sequences to profile 1 */ |
|---|
| 364 | break; |
|---|
| 365 | case '5': quick_pairalign ^= TRUE; |
|---|
| 366 | break; |
|---|
| 367 | case '6': pair_menu(); |
|---|
| 368 | break; |
|---|
| 369 | case '7': multi_menu(); |
|---|
| 370 | break; |
|---|
| 371 | case '8': showaln ^= TRUE; |
|---|
| 372 | break; |
|---|
| 373 | case '9': format_options_menu(); |
|---|
| 374 | break; |
|---|
| 375 | case '0': ss_options_menu(); |
|---|
| 376 | break; |
|---|
| 377 | case 'S': do_system(); |
|---|
| 378 | break; |
|---|
| 379 | case '?': |
|---|
| 380 | case 'H': get_help('6'); |
|---|
| 381 | break; |
|---|
| 382 | case 'Q': |
|---|
| 383 | case 'X': return; |
|---|
| 384 | |
|---|
| 385 | default: fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 386 | break; |
|---|
| 387 | } |
|---|
| 388 | } |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | static void ss_options_menu(void) |
|---|
| 393 | { |
|---|
| 394 | int catchint; |
|---|
| 395 | |
|---|
| 396 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 397 | if (catchint) { |
|---|
| 398 | if (setjmp(jmpbuf) != 0) |
|---|
| 399 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 400 | #ifdef UNIX |
|---|
| 401 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 402 | fprintf(stdout,"Error: signal\n"); |
|---|
| 403 | #else |
|---|
| 404 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 405 | fprintf(stdout,"Error: signal\n"); |
|---|
| 406 | #endif |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | while(TRUE) { |
|---|
| 411 | |
|---|
| 412 | fprintf(stdout,"\n\n\n"); |
|---|
| 413 | fprintf(stdout," ********* SECONDARY STRUCTURE OPTIONS *********\n"); |
|---|
| 414 | fprintf(stdout,"\n\n"); |
|---|
| 415 | |
|---|
| 416 | fprintf(stdout," 1. Use profile 1 secondary structure / penalty mask "); |
|---|
| 417 | if(use_ss1) |
|---|
| 418 | fprintf(stdout,"= YES\n"); |
|---|
| 419 | else |
|---|
| 420 | fprintf(stdout,"= NO\n"); |
|---|
| 421 | fprintf(stdout," 2. Use profile 2 secondary structure / penalty mask "); |
|---|
| 422 | if(use_ss2) |
|---|
| 423 | fprintf(stdout,"= YES\n"); |
|---|
| 424 | else |
|---|
| 425 | fprintf(stdout,"= NO\n"); |
|---|
| 426 | fprintf(stdout,"\n"); |
|---|
| 427 | fprintf(stdout," 3. Output in alignment "); |
|---|
| 428 | fprintf(stdout,"= %s\n",secstroutput_txt[output_struct_penalties]); |
|---|
| 429 | fprintf(stdout,"\n"); |
|---|
| 430 | |
|---|
| 431 | fprintf(stdout," 4. Helix gap penalty :%d\n",(pint)helix_penalty); |
|---|
| 432 | fprintf(stdout," 5. Strand gap penalty :%d\n",(pint)strand_penalty); |
|---|
| 433 | fprintf(stdout," 6. Loop gap penalty :%d\n",(pint)loop_penalty); |
|---|
| 434 | |
|---|
| 435 | fprintf(stdout," 7. Secondary structure terminal penalty :%d\n",(pint)helix_end_penalty); |
|---|
| 436 | fprintf(stdout," 8. Helix terminal positions within :%d outside :%d\n", |
|---|
| 437 | (pint)helix_end_minus,(pint)helix_end_plus); |
|---|
| 438 | fprintf(stdout," 9. Strand terminal positions within :%d outside :%d\n", |
|---|
| 439 | (pint)strand_end_minus,(pint)strand_end_plus); |
|---|
| 440 | |
|---|
| 441 | fprintf(stdout,"\n\n"); |
|---|
| 442 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 443 | |
|---|
| 444 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 445 | if( *lin2 == EOS) { |
|---|
| 446 | return; |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | switch(toupper(*lin2)) { |
|---|
| 450 | case '1': use_ss1 ^= TRUE; |
|---|
| 451 | break; |
|---|
| 452 | case '2': use_ss2 ^= TRUE; |
|---|
| 453 | break; |
|---|
| 454 | case '3': output_struct_penalties = secstroutput_options(); |
|---|
| 455 | break; |
|---|
| 456 | case '4': |
|---|
| 457 | fprintf(stdout,"Helix Penalty Currently: %d\n",(pint)helix_penalty); |
|---|
| 458 | helix_penalty=getint("Enter number",1,9,helix_penalty); |
|---|
| 459 | break; |
|---|
| 460 | case '5': |
|---|
| 461 | fprintf(stdout,"Strand Gap Penalty Currently: %d\n",(pint)strand_penalty); |
|---|
| 462 | strand_penalty=getint("Enter number",1,9,strand_penalty); |
|---|
| 463 | break; |
|---|
| 464 | case '6': |
|---|
| 465 | fprintf(stdout,"Loop Gap Penalty Currently: %d\n",(pint)loop_penalty); |
|---|
| 466 | loop_penalty=getint("Enter number",1,9,loop_penalty); |
|---|
| 467 | break; |
|---|
| 468 | case '7': |
|---|
| 469 | fprintf(stdout,"Secondary Structure Terminal Penalty Currently: %d\n", |
|---|
| 470 | (pint)helix_end_penalty); |
|---|
| 471 | helix_end_penalty=getint("Enter number",1,9,helix_end_penalty); |
|---|
| 472 | strand_end_penalty = helix_end_penalty; |
|---|
| 473 | break; |
|---|
| 474 | case '8': |
|---|
| 475 | fprintf(stdout,"Helix Terminal Positions Currently: \n"); |
|---|
| 476 | fprintf(stdout," within helix: %d outside helix: %d\n", |
|---|
| 477 | (pint)helix_end_minus,(pint)helix_end_plus); |
|---|
| 478 | helix_end_minus=getint("Enter number of residues within helix",0,3,helix_end_minus); |
|---|
| 479 | helix_end_plus=getint("Enter number of residues outside helix",0,3,helix_end_plus); |
|---|
| 480 | break; |
|---|
| 481 | case '9': |
|---|
| 482 | fprintf(stdout,"Strand Terminal Positions Currently: \n"); |
|---|
| 483 | fprintf(stdout," within strand: %d outside strand: %d\n", |
|---|
| 484 | (pint)strand_end_minus,(pint)strand_end_plus); |
|---|
| 485 | strand_end_minus=getint("Enter number of residues within strand",0,3,strand_end_minus); |
|---|
| 486 | strand_end_plus=getint("Enter number of residues outside strand",0,3,strand_end_plus); |
|---|
| 487 | break; |
|---|
| 488 | case '?': |
|---|
| 489 | case 'H': |
|---|
| 490 | get_help('B'); |
|---|
| 491 | break; |
|---|
| 492 | default: |
|---|
| 493 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 494 | break; |
|---|
| 495 | } |
|---|
| 496 | } |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | static sint secstroutput_options(void) |
|---|
| 501 | { |
|---|
| 502 | |
|---|
| 503 | while(TRUE) |
|---|
| 504 | { |
|---|
| 505 | fprintf(stdout,"\n\n\n"); |
|---|
| 506 | fprintf(stdout," ********* Secondary Structure Output Menu *********\n"); |
|---|
| 507 | fprintf(stdout,"\n\n"); |
|---|
| 508 | |
|---|
| 509 | |
|---|
| 510 | fprintf(stdout," 1. %s\n",secstroutput_txt[0]); |
|---|
| 511 | fprintf(stdout," 2. %s\n",secstroutput_txt[1]); |
|---|
| 512 | fprintf(stdout," 3. %s\n",secstroutput_txt[2]); |
|---|
| 513 | fprintf(stdout," 4. %s\n",secstroutput_txt[3]); |
|---|
| 514 | fprintf(stdout," H. HELP\n\n"); |
|---|
| 515 | fprintf(stdout, |
|---|
| 516 | " -- Current output is %s ",secstroutput_txt[output_struct_penalties]); |
|---|
| 517 | fprintf(stdout,"--\n"); |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | getstr("\n\nEnter number (or [RETURN] to exit)",lin2); |
|---|
| 521 | if(*lin2 == EOS) return(output_struct_penalties); |
|---|
| 522 | |
|---|
| 523 | switch(toupper(*lin2)) |
|---|
| 524 | { |
|---|
| 525 | case '1': return(0); |
|---|
| 526 | case '2': return(1); |
|---|
| 527 | case '3': return(2); |
|---|
| 528 | case '4': return(3); |
|---|
| 529 | case '?': |
|---|
| 530 | case 'H': get_help('C'); |
|---|
| 531 | case 'Q': |
|---|
| 532 | case 'X': return(0); |
|---|
| 533 | |
|---|
| 534 | default: fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 535 | break; |
|---|
| 536 | } |
|---|
| 537 | } |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | |
|---|
| 546 | static void phylogenetic_tree_menu(void) |
|---|
| 547 | { |
|---|
| 548 | int catchint; |
|---|
| 549 | |
|---|
| 550 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 551 | if (catchint) { |
|---|
| 552 | if (setjmp(jmpbuf) != 0) |
|---|
| 553 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 554 | #ifdef UNIX |
|---|
| 555 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 556 | fprintf(stdout,"Error: signal\n"); |
|---|
| 557 | #else |
|---|
| 558 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 559 | fprintf(stdout,"Error: signal\n"); |
|---|
| 560 | #endif |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | while(TRUE) |
|---|
| 565 | { |
|---|
| 566 | fprintf(stdout,"\n\n\n"); |
|---|
| 567 | fprintf(stdout,"****** PHYLOGENETIC TREE MENU ******\n"); |
|---|
| 568 | fprintf(stdout,"\n\n"); |
|---|
| 569 | |
|---|
| 570 | fprintf(stdout," 1. Input an alignment\n"); |
|---|
| 571 | fprintf(stdout," 2. Exclude positions with gaps? "); |
|---|
| 572 | if(tossgaps) |
|---|
| 573 | fprintf(stdout,"= ON\n"); |
|---|
| 574 | else |
|---|
| 575 | fprintf(stdout,"= OFF\n"); |
|---|
| 576 | fprintf(stdout," 3. Correct for multiple substitutions? "); |
|---|
| 577 | if(kimura) |
|---|
| 578 | fprintf(stdout,"= ON\n"); |
|---|
| 579 | else |
|---|
| 580 | fprintf(stdout,"= OFF\n"); |
|---|
| 581 | fprintf(stdout," 4. Draw tree now\n"); |
|---|
| 582 | fprintf(stdout," 5. Bootstrap tree\n"); |
|---|
| 583 | fprintf(stdout," 6. Output format options\n"); |
|---|
| 584 | fprintf(stdout,"\n"); |
|---|
| 585 | fprintf(stdout," S. Execute a system command\n"); |
|---|
| 586 | fprintf(stdout," H. HELP\n"); |
|---|
| 587 | fprintf(stdout," or press [RETURN] to go back to main menu\n\n\n"); |
|---|
| 588 | |
|---|
| 589 | getstr("Your choice",lin1); |
|---|
| 590 | if(*lin1 == EOS) return; |
|---|
| 591 | |
|---|
| 592 | switch(toupper(*lin1)) |
|---|
| 593 | { |
|---|
| 594 | case '1': seq_input(FALSE); |
|---|
| 595 | break; |
|---|
| 596 | case '2': tossgaps ^= TRUE; |
|---|
| 597 | break; |
|---|
| 598 | case '3': kimura ^= TRUE;; |
|---|
| 599 | break; |
|---|
| 600 | case '4': phylogenetic_tree(phylip_name,clustal_name,dist_name); |
|---|
| 601 | break; |
|---|
| 602 | case '5': bootstrap_tree(phylip_name,clustal_name); |
|---|
| 603 | break; |
|---|
| 604 | case '6': tree_format_options_menu(); |
|---|
| 605 | break; |
|---|
| 606 | case 'S': do_system(); |
|---|
| 607 | break; |
|---|
| 608 | case '?': |
|---|
| 609 | case 'H': get_help('7'); |
|---|
| 610 | break; |
|---|
| 611 | case 'Q': |
|---|
| 612 | case 'X': return; |
|---|
| 613 | |
|---|
| 614 | default: fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 615 | break; |
|---|
| 616 | } |
|---|
| 617 | } |
|---|
| 618 | } |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | |
|---|
| 622 | |
|---|
| 623 | |
|---|
| 624 | |
|---|
| 625 | static void tree_format_options_menu(void) /* format of tree output */ |
|---|
| 626 | { |
|---|
| 627 | int catchint; |
|---|
| 628 | |
|---|
| 629 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 630 | if (catchint) { |
|---|
| 631 | if (setjmp(jmpbuf) != 0) |
|---|
| 632 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 633 | #ifdef UNIX |
|---|
| 634 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 635 | fprintf(stdout,"Error: signal\n"); |
|---|
| 636 | #else |
|---|
| 637 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 638 | fprintf(stdout,"Error: signal\n"); |
|---|
| 639 | #endif |
|---|
| 640 | } |
|---|
| 641 | |
|---|
| 642 | |
|---|
| 643 | while(TRUE) { |
|---|
| 644 | fprintf(stdout,"\n\n\n"); |
|---|
| 645 | fprintf(stdout," ****** Format of Phylogenetic Tree Output ******\n"); |
|---|
| 646 | fprintf(stdout,"\n\n"); |
|---|
| 647 | fprintf(stdout," 1. Toggle CLUSTAL format tree output = %s\n", |
|---|
| 648 | (!output_tree_clustal) ? "OFF" : "ON"); |
|---|
| 649 | fprintf(stdout," 2. Toggle Phylip format tree output = %s\n", |
|---|
| 650 | (!output_tree_phylip) ? "OFF" : "ON"); |
|---|
| 651 | fprintf(stdout," 3. Toggle Phylip distance matrix output = %s\n\n", |
|---|
| 652 | (!output_tree_distances)? "OFF" : "ON"); |
|---|
| 653 | fprintf(stdout," 4. Toggle Phylip bootstrap positions = %s\n\n", |
|---|
| 654 | (bootstrap_format==BS_NODE_LABELS) ? "NODE LABELS" : "BRANCH LABELS"); |
|---|
| 655 | fprintf(stdout,"\n"); |
|---|
| 656 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 657 | |
|---|
| 658 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 659 | if(*lin2 == EOS) return; |
|---|
| 660 | |
|---|
| 661 | switch(toupper(*lin2)) { |
|---|
| 662 | case '1': |
|---|
| 663 | output_tree_clustal ^= TRUE; |
|---|
| 664 | break; |
|---|
| 665 | case '2': |
|---|
| 666 | output_tree_phylip ^= TRUE; |
|---|
| 667 | break; |
|---|
| 668 | case '3': |
|---|
| 669 | output_tree_distances ^= TRUE; |
|---|
| 670 | break; |
|---|
| 671 | case '4': |
|---|
| 672 | if (bootstrap_format == BS_NODE_LABELS) |
|---|
| 673 | bootstrap_format = BS_BRANCH_LABELS; |
|---|
| 674 | else |
|---|
| 675 | bootstrap_format = BS_NODE_LABELS; |
|---|
| 676 | break; |
|---|
| 677 | case '?': |
|---|
| 678 | case 'H': |
|---|
| 679 | get_help('0'); |
|---|
| 680 | break; |
|---|
| 681 | default: |
|---|
| 682 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 683 | break; |
|---|
| 684 | } |
|---|
| 685 | } |
|---|
| 686 | } |
|---|
| 687 | |
|---|
| 688 | |
|---|
| 689 | static void format_options_menu(void) /* format of alignment output */ |
|---|
| 690 | { |
|---|
| 691 | sint i; |
|---|
| 692 | sint length = 0; |
|---|
| 693 | char path[FILENAMELEN+1]; |
|---|
| 694 | int catchint; |
|---|
| 695 | |
|---|
| 696 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 697 | if (catchint) { |
|---|
| 698 | if (setjmp(jmpbuf) != 0) |
|---|
| 699 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 700 | #ifdef UNIX |
|---|
| 701 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 702 | fprintf(stdout,"Error: signal\n"); |
|---|
| 703 | #else |
|---|
| 704 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 705 | fprintf(stdout,"Error: signal\n"); |
|---|
| 706 | #endif |
|---|
| 707 | } |
|---|
| 708 | |
|---|
| 709 | |
|---|
| 710 | while(TRUE) { |
|---|
| 711 | fprintf(stdout,"\n\n\n"); |
|---|
| 712 | fprintf(stdout," ********* Format of Alignment Output *********\n"); |
|---|
| 713 | fprintf(stdout,"\n\n"); |
|---|
| 714 | fprintf(stdout," 1. Toggle CLUSTAL format output = %s\n", |
|---|
| 715 | (!output_clustal) ? "OFF" : "ON"); |
|---|
| 716 | fprintf(stdout," 2. Toggle NBRF/PIR format output = %s\n", |
|---|
| 717 | (!output_nbrf) ? "OFF" : "ON"); |
|---|
| 718 | fprintf(stdout," 3. Toggle GCG/MSF format output = %s\n", |
|---|
| 719 | (!output_gcg) ? "OFF" : "ON"); |
|---|
| 720 | fprintf(stdout," 4. Toggle PHYLIP format output = %s\n", |
|---|
| 721 | (!output_phylip) ? "OFF" : "ON"); |
|---|
| 722 | fprintf(stdout," 5. Toggle GDE format output = %s\n\n", |
|---|
| 723 | (!output_gde) ? "OFF" : "ON"); |
|---|
| 724 | fprintf(stdout," 6. Toggle GDE output case = %s\n", |
|---|
| 725 | (!lowercase) ? "UPPER" : "LOWER"); |
|---|
| 726 | fprintf(stdout," 7. Toggle CLUSTALW sequence numbers = %s\n", |
|---|
| 727 | (!cl_seq_numbers) ? "OFF" : "ON"); |
|---|
| 728 | fprintf(stdout," 8. Toggle output order = %s\n\n", |
|---|
| 729 | (output_order==0) ? "INPUT FILE" : "ALIGNED"); |
|---|
| 730 | fprintf(stdout," 9. Create alignment output file(s) now?\n\n"); |
|---|
| 731 | fprintf(stdout," 0. Toggle parameter output = %s\n", |
|---|
| 732 | (!save_parameters) ? "OFF" : "ON"); |
|---|
| 733 | fprintf(stdout,"\n"); |
|---|
| 734 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 735 | |
|---|
| 736 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 737 | if(*lin2 == EOS) return; |
|---|
| 738 | |
|---|
| 739 | switch(toupper(*lin2)) { |
|---|
| 740 | case '1': |
|---|
| 741 | output_clustal ^= TRUE; |
|---|
| 742 | break; |
|---|
| 743 | case '2': |
|---|
| 744 | output_nbrf ^= TRUE; |
|---|
| 745 | break; |
|---|
| 746 | case '3': |
|---|
| 747 | output_gcg ^= TRUE; |
|---|
| 748 | break; |
|---|
| 749 | case '4': |
|---|
| 750 | output_phylip ^= TRUE; |
|---|
| 751 | break; |
|---|
| 752 | case '5': |
|---|
| 753 | output_gde ^= TRUE; |
|---|
| 754 | break; |
|---|
| 755 | case '6': |
|---|
| 756 | lowercase ^= TRUE; |
|---|
| 757 | break; |
|---|
| 758 | case '7': |
|---|
| 759 | cl_seq_numbers ^= TRUE; |
|---|
| 760 | break; |
|---|
| 761 | case '8': |
|---|
| 762 | if (output_order == INPUT) output_order = ALIGNED; |
|---|
| 763 | else output_order = INPUT; |
|---|
| 764 | break; |
|---|
| 765 | case '9': /* DES */ |
|---|
| 766 | if(empty) { |
|---|
| 767 | error("No sequences loaded"); |
|---|
| 768 | break; |
|---|
| 769 | } |
|---|
| 770 | get_path(seqname,path); |
|---|
| 771 | if(!open_alignment_output(path)) break; |
|---|
| 772 | create_alignment_output(1,nseqs); |
|---|
| 773 | break; |
|---|
| 774 | case '0': save_parameters ^= TRUE; |
|---|
| 775 | break; |
|---|
| 776 | case '?': |
|---|
| 777 | case 'H': |
|---|
| 778 | get_help('5'); |
|---|
| 779 | break; |
|---|
| 780 | default: |
|---|
| 781 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 782 | break; |
|---|
| 783 | } |
|---|
| 784 | } |
|---|
| 785 | } |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | |
|---|
| 791 | |
|---|
| 792 | |
|---|
| 793 | |
|---|
| 794 | |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | |
|---|
| 798 | static void pair_menu(void) |
|---|
| 799 | { |
|---|
| 800 | int catchint; |
|---|
| 801 | |
|---|
| 802 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 803 | if (catchint) { |
|---|
| 804 | if (setjmp(jmpbuf) != 0) |
|---|
| 805 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 806 | #ifdef UNIX |
|---|
| 807 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 808 | fprintf(stdout,"Error: signal\n"); |
|---|
| 809 | #else |
|---|
| 810 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 811 | fprintf(stdout,"Error: signal\n"); |
|---|
| 812 | #endif |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | |
|---|
| 816 | if(dnaflag) { |
|---|
| 817 | pw_go_penalty = dna_pw_go_penalty; |
|---|
| 818 | pw_ge_penalty = dna_pw_ge_penalty; |
|---|
| 819 | ktup = dna_ktup; |
|---|
| 820 | window = dna_window; |
|---|
| 821 | signif = dna_signif; |
|---|
| 822 | wind_gap = dna_wind_gap; |
|---|
| 823 | |
|---|
| 824 | } |
|---|
| 825 | else { |
|---|
| 826 | pw_go_penalty = prot_pw_go_penalty; |
|---|
| 827 | pw_ge_penalty = prot_pw_ge_penalty; |
|---|
| 828 | ktup = prot_ktup; |
|---|
| 829 | window = prot_window; |
|---|
| 830 | signif = prot_signif; |
|---|
| 831 | wind_gap = prot_wind_gap; |
|---|
| 832 | |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | while(TRUE) { |
|---|
| 836 | |
|---|
| 837 | fprintf(stdout,"\n\n\n"); |
|---|
| 838 | fprintf(stdout," ********* PAIRWISE ALIGNMENT PARAMETERS *********\n"); |
|---|
| 839 | fprintf(stdout,"\n\n"); |
|---|
| 840 | |
|---|
| 841 | fprintf(stdout," Slow/Accurate alignments:\n\n"); |
|---|
| 842 | |
|---|
| 843 | fprintf(stdout," 1. Gap Open Penalty :%4.2f\n",pw_go_penalty); |
|---|
| 844 | fprintf(stdout," 2. Gap Extension Penalty :%4.2f\n",pw_ge_penalty); |
|---|
| 845 | fprintf(stdout," 3. Protein weight matrix :%s\n" , |
|---|
| 846 | pw_matrix_txt[pw_matnum-1]); |
|---|
| 847 | fprintf(stdout," 4. DNA weight matrix :%s\n\n" , |
|---|
| 848 | dnamatrix_txt[pw_dnamatnum-1]); |
|---|
| 849 | |
|---|
| 850 | fprintf(stdout," Fast/Approximate alignments:\n\n"); |
|---|
| 851 | |
|---|
| 852 | fprintf(stdout," 5. Gap penalty :%d\n",(pint)wind_gap); |
|---|
| 853 | fprintf(stdout," 6. K-tuple (word) size :%d\n",(pint)ktup); |
|---|
| 854 | fprintf(stdout," 7. No. of top diagonals :%d\n",(pint)signif); |
|---|
| 855 | fprintf(stdout," 8. Window size :%d\n\n",(pint)window); |
|---|
| 856 | |
|---|
| 857 | fprintf(stdout," 9. Toggle Slow/Fast pairwise alignments "); |
|---|
| 858 | if(quick_pairalign) |
|---|
| 859 | fprintf(stdout,"= FAST\n\n"); |
|---|
| 860 | else |
|---|
| 861 | fprintf(stdout,"= SLOW\n\n"); |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 865 | |
|---|
| 866 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 867 | if( *lin2 == EOS) { |
|---|
| 868 | if(dnaflag) { |
|---|
| 869 | dna_pw_go_penalty = pw_go_penalty; |
|---|
| 870 | dna_pw_ge_penalty = pw_ge_penalty; |
|---|
| 871 | dna_ktup = ktup; |
|---|
| 872 | dna_window = window; |
|---|
| 873 | dna_signif = signif; |
|---|
| 874 | dna_wind_gap = wind_gap; |
|---|
| 875 | |
|---|
| 876 | } |
|---|
| 877 | else { |
|---|
| 878 | prot_pw_go_penalty = pw_go_penalty; |
|---|
| 879 | prot_pw_ge_penalty = pw_ge_penalty; |
|---|
| 880 | prot_ktup = ktup; |
|---|
| 881 | prot_window = window; |
|---|
| 882 | prot_signif = signif; |
|---|
| 883 | prot_wind_gap = wind_gap; |
|---|
| 884 | |
|---|
| 885 | } |
|---|
| 886 | |
|---|
| 887 | return; |
|---|
| 888 | } |
|---|
| 889 | |
|---|
| 890 | switch(toupper(*lin2)) { |
|---|
| 891 | case '1': |
|---|
| 892 | fprintf(stdout,"Gap Open Penalty Currently: %4.2f\n",pw_go_penalty); |
|---|
| 893 | pw_go_penalty=(float)getreal("Enter number",(double)0.0,(double)100.0,(double)pw_go_penalty); |
|---|
| 894 | break; |
|---|
| 895 | case '2': |
|---|
| 896 | fprintf(stdout,"Gap Extension Penalty Currently: %4.2f\n",pw_ge_penalty); |
|---|
| 897 | pw_ge_penalty=(float)getreal("Enter number",(double)0.0,(double)10.0,(double)pw_ge_penalty); |
|---|
| 898 | break; |
|---|
| 899 | case '3': |
|---|
| 900 | pw_matnum = read_matrix(pw_matrix_txt,pw_mtrxname,pw_matnum,pw_usermat,pw_aa_xref); |
|---|
| 901 | break; |
|---|
| 902 | case '4': |
|---|
| 903 | pw_dnamatnum = read_dnamatrix(dnamatrix_txt,pw_dnamtrxname,pw_dnamatnum,pw_userdnamat,pw_dna_xref); |
|---|
| 904 | break; |
|---|
| 905 | case '5': |
|---|
| 906 | fprintf(stdout,"Gap Penalty Currently: %d\n",(pint)wind_gap); |
|---|
| 907 | wind_gap=getint("Enter number",1,500,wind_gap); |
|---|
| 908 | break; |
|---|
| 909 | case '6': |
|---|
| 910 | fprintf(stdout,"K-tuple Currently: %d\n",(pint)ktup); |
|---|
| 911 | if(dnaflag) |
|---|
| 912 | ktup=getint("Enter number",1,4,ktup); |
|---|
| 913 | else |
|---|
| 914 | ktup=getint("Enter number",1,2,ktup); |
|---|
| 915 | break; |
|---|
| 916 | case '7': |
|---|
| 917 | fprintf(stdout,"Top diagonals Currently: %d\n",(pint)signif); |
|---|
| 918 | signif=getint("Enter number",1,50,signif); |
|---|
| 919 | break; |
|---|
| 920 | case '8': |
|---|
| 921 | fprintf(stdout,"Window size Currently: %d\n",(pint)window); |
|---|
| 922 | window=getint("Enter number",1,50,window); |
|---|
| 923 | break; |
|---|
| 924 | case '9': quick_pairalign ^= TRUE; |
|---|
| 925 | break; |
|---|
| 926 | case '?': |
|---|
| 927 | case 'H': |
|---|
| 928 | get_help('3'); |
|---|
| 929 | break; |
|---|
| 930 | default: |
|---|
| 931 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 932 | break; |
|---|
| 933 | } |
|---|
| 934 | } |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | |
|---|
| 941 | static void multi_menu(void) |
|---|
| 942 | { |
|---|
| 943 | int catchint; |
|---|
| 944 | |
|---|
| 945 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 946 | if (catchint) { |
|---|
| 947 | if (setjmp(jmpbuf) != 0) |
|---|
| 948 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 949 | #ifdef UNIX |
|---|
| 950 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 951 | fprintf(stdout,"Error: signal\n"); |
|---|
| 952 | #else |
|---|
| 953 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 954 | fprintf(stdout,"Error: signal\n"); |
|---|
| 955 | #endif |
|---|
| 956 | } |
|---|
| 957 | |
|---|
| 958 | |
|---|
| 959 | if(dnaflag) { |
|---|
| 960 | gap_open = dna_gap_open; |
|---|
| 961 | gap_extend = dna_gap_extend; |
|---|
| 962 | } |
|---|
| 963 | else { |
|---|
| 964 | gap_open = prot_gap_open; |
|---|
| 965 | gap_extend = prot_gap_extend; |
|---|
| 966 | } |
|---|
| 967 | |
|---|
| 968 | while(TRUE) { |
|---|
| 969 | |
|---|
| 970 | fprintf(stdout,"\n\n\n"); |
|---|
| 971 | fprintf(stdout," ********* MULTIPLE ALIGNMENT PARAMETERS *********\n"); |
|---|
| 972 | fprintf(stdout,"\n\n"); |
|---|
| 973 | |
|---|
| 974 | fprintf(stdout," 1. Gap Opening Penalty :%4.2f\n",gap_open); |
|---|
| 975 | fprintf(stdout," 2. Gap Extension Penalty :%4.2f\n",gap_extend); |
|---|
| 976 | |
|---|
| 977 | fprintf(stdout," 3. Delay divergent sequences :%d %%\n\n",(pint)divergence_cutoff); |
|---|
| 978 | |
|---|
| 979 | fprintf(stdout," 4. DNA Transitions Weight :%1.2f\n\n",transition_weight); |
|---|
| 980 | fprintf(stdout," 5. Protein weight matrix :%s\n" |
|---|
| 981 | ,matrix_txt[matnum-1]); |
|---|
| 982 | fprintf(stdout," 6. DNA weight matrix :%s\n" |
|---|
| 983 | ,dnamatrix_txt[dnamatnum-1]); |
|---|
| 984 | fprintf(stdout," 7. Use negative matrix :%s\n\n",(!neg_matrix) ? "OFF" : "ON"); |
|---|
| 985 | fprintf(stdout," 8. Protein Gap Parameters\n\n"); |
|---|
| 986 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 987 | |
|---|
| 988 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 989 | |
|---|
| 990 | if(*lin2 == EOS) { |
|---|
| 991 | if(dnaflag) { |
|---|
| 992 | dna_gap_open = gap_open; |
|---|
| 993 | dna_gap_extend = gap_extend; |
|---|
| 994 | } |
|---|
| 995 | else { |
|---|
| 996 | prot_gap_open = gap_open; |
|---|
| 997 | prot_gap_extend = gap_extend; |
|---|
| 998 | } |
|---|
| 999 | return; |
|---|
| 1000 | } |
|---|
| 1001 | |
|---|
| 1002 | switch(toupper(*lin2)) { |
|---|
| 1003 | case '1': |
|---|
| 1004 | fprintf(stdout,"Gap Opening Penalty Currently: %4.2f\n",gap_open); |
|---|
| 1005 | gap_open=(float)getreal("Enter number",(double)0.0,(double)100.0,(double)gap_open); |
|---|
| 1006 | break; |
|---|
| 1007 | case '2': |
|---|
| 1008 | fprintf(stdout,"Gap Extension Penalty Currently: %4.2f\n",gap_extend); |
|---|
| 1009 | gap_extend=(float)getreal("Enter number",(double)0.0,(double)10.0,(double)gap_extend); |
|---|
| 1010 | break; |
|---|
| 1011 | case '3': |
|---|
| 1012 | fprintf(stdout,"Min Identity Currently: %d\n",(pint)divergence_cutoff); |
|---|
| 1013 | divergence_cutoff=getint("Enter number",0,100,divergence_cutoff); |
|---|
| 1014 | break; |
|---|
| 1015 | case '4': |
|---|
| 1016 | fprintf(stdout,"Transition Weight Currently: %1.2f\n",(pint)transition_weight); |
|---|
| 1017 | transition_weight=(float)getreal("Enter number",(double)0.0,(double)1.0,(double)transition_weight); |
|---|
| 1018 | break; |
|---|
| 1019 | case '5': |
|---|
| 1020 | matnum = read_matrix(matrix_txt,mtrxname,matnum,usermat,aa_xref); |
|---|
| 1021 | break; |
|---|
| 1022 | case '6': |
|---|
| 1023 | dnamatnum = read_dnamatrix(dnamatrix_txt,dnamtrxname,dnamatnum,userdnamat,dna_xref); |
|---|
| 1024 | break; |
|---|
| 1025 | case '7': |
|---|
| 1026 | neg_matrix ^= TRUE; |
|---|
| 1027 | break; |
|---|
| 1028 | case '8': |
|---|
| 1029 | gap_penalties_menu(); |
|---|
| 1030 | break; |
|---|
| 1031 | case '?': |
|---|
| 1032 | case 'H': |
|---|
| 1033 | get_help('4'); |
|---|
| 1034 | break; |
|---|
| 1035 | default: |
|---|
| 1036 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 1037 | break; |
|---|
| 1038 | } |
|---|
| 1039 | } |
|---|
| 1040 | } |
|---|
| 1041 | |
|---|
| 1042 | |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | |
|---|
| 1046 | |
|---|
| 1047 | static void gap_penalties_menu(void) |
|---|
| 1048 | { |
|---|
| 1049 | char c; |
|---|
| 1050 | sint i; |
|---|
| 1051 | int catchint; |
|---|
| 1052 | |
|---|
| 1053 | catchint = signal(SIGINT, SIG_IGN) != SIG_IGN; |
|---|
| 1054 | if (catchint) { |
|---|
| 1055 | if (setjmp(jmpbuf) != 0) |
|---|
| 1056 | fprintf(stdout,"\n.. Interrupt\n"); |
|---|
| 1057 | #ifdef UNIX |
|---|
| 1058 | if (signal(SIGINT,jumper) == BADSIG) |
|---|
| 1059 | fprintf(stdout,"Error: signal\n"); |
|---|
| 1060 | #else |
|---|
| 1061 | if (signal(SIGINT,SIG_DFL) == BADSIG) |
|---|
| 1062 | fprintf(stdout,"Error: signal\n"); |
|---|
| 1063 | #endif |
|---|
| 1064 | } |
|---|
| 1065 | |
|---|
| 1066 | |
|---|
| 1067 | while(TRUE) { |
|---|
| 1068 | |
|---|
| 1069 | fprintf(stdout,"\n\n\n"); |
|---|
| 1070 | fprintf(stdout," ********* PROTEIN GAP PARAMETERS *********\n"); |
|---|
| 1071 | fprintf(stdout,"\n\n\n"); |
|---|
| 1072 | |
|---|
| 1073 | fprintf(stdout," 1. Toggle Residue-Specific Penalties :%s\n\n",(no_pref_penalties) ? "OFF" : "ON"); |
|---|
| 1074 | fprintf(stdout," 2. Toggle Hydrophilic Penalties :%s\n",(no_hyd_penalties) ? "OFF" : "ON"); |
|---|
| 1075 | fprintf(stdout," 3. Hydrophilic Residues :%s\n\n" |
|---|
| 1076 | ,hyd_residues); |
|---|
| 1077 | fprintf(stdout," 4. Gap Separation Distance :%d\n",(pint)gap_dist); |
|---|
| 1078 | fprintf(stdout," 5. Toggle End Gap Separation :%s\n\n",(!use_endgaps) ? "OFF" : "ON"); |
|---|
| 1079 | fprintf(stdout," H. HELP\n\n\n"); |
|---|
| 1080 | |
|---|
| 1081 | getstr("Enter number (or [RETURN] to exit)",lin2); |
|---|
| 1082 | |
|---|
| 1083 | if(*lin2 == EOS) return; |
|---|
| 1084 | |
|---|
| 1085 | switch(toupper(*lin2)) { |
|---|
| 1086 | case '1': |
|---|
| 1087 | no_pref_penalties ^= TRUE; |
|---|
| 1088 | break; |
|---|
| 1089 | case '2': |
|---|
| 1090 | no_hyd_penalties ^= TRUE; |
|---|
| 1091 | break; |
|---|
| 1092 | case '3': |
|---|
| 1093 | fprintf(stdout,"Hydrophilic Residues Currently: %s\n",hyd_residues); |
|---|
| 1094 | |
|---|
| 1095 | getstr("Enter residues (or [RETURN] to quit)",lin1); |
|---|
| 1096 | if (*lin1 != EOS) { |
|---|
| 1097 | for (i=0;i<strlen(hyd_residues) && i<26;i++) { |
|---|
| 1098 | c = lin1[i]; |
|---|
| 1099 | if (isalpha(c)) |
|---|
| 1100 | hyd_residues[i] = (char)toupper(c); |
|---|
| 1101 | else |
|---|
| 1102 | break; |
|---|
| 1103 | } |
|---|
| 1104 | hyd_residues[i] = EOS; |
|---|
| 1105 | } |
|---|
| 1106 | break; |
|---|
| 1107 | case '4': |
|---|
| 1108 | fprintf(stdout,"Gap Separation Distance Currently: %d\n",(pint)gap_dist); |
|---|
| 1109 | gap_dist=getint("Enter number",0,100,gap_dist); |
|---|
| 1110 | break; |
|---|
| 1111 | case '5': |
|---|
| 1112 | use_endgaps ^= TRUE; |
|---|
| 1113 | break; |
|---|
| 1114 | case '?': |
|---|
| 1115 | case 'H': |
|---|
| 1116 | get_help('A'); |
|---|
| 1117 | break; |
|---|
| 1118 | default: |
|---|
| 1119 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 1120 | break; |
|---|
| 1121 | } |
|---|
| 1122 | } |
|---|
| 1123 | } |
|---|
| 1124 | |
|---|
| 1125 | |
|---|
| 1126 | |
|---|
| 1127 | |
|---|
| 1128 | static sint read_matrix(char **mattxt, char *matnam, sint matn, short *mat, short *xref) |
|---|
| 1129 | { static char userfile[FILENAMELEN+1]; |
|---|
| 1130 | |
|---|
| 1131 | while(TRUE) |
|---|
| 1132 | { |
|---|
| 1133 | fprintf(stdout,"\n\n\n"); |
|---|
| 1134 | fprintf(stdout," ********* PROTEIN WEIGHT MATRIX MENU *********\n"); |
|---|
| 1135 | fprintf(stdout,"\n\n"); |
|---|
| 1136 | |
|---|
| 1137 | |
|---|
| 1138 | fprintf(stdout," 1. %s\n",mattxt[0]); |
|---|
| 1139 | fprintf(stdout," 2. %s\n",mattxt[1]); |
|---|
| 1140 | fprintf(stdout," 3. %s\n",mattxt[2]); |
|---|
| 1141 | fprintf(stdout," 4. %s\n",mattxt[3]); |
|---|
| 1142 | fprintf(stdout," 5. %s\n",mattxt[4]); |
|---|
| 1143 | fprintf(stdout," H. HELP\n\n"); |
|---|
| 1144 | fprintf(stdout, |
|---|
| 1145 | " -- Current matrix is the %s ",mattxt[matn-1]); |
|---|
| 1146 | if(matn == 5) fprintf(stdout,"(file = %s)",userfile); |
|---|
| 1147 | fprintf(stdout,"--\n"); |
|---|
| 1148 | |
|---|
| 1149 | |
|---|
| 1150 | getstr("\n\nEnter number (or [RETURN] to exit)",lin2); |
|---|
| 1151 | if(*lin2 == EOS) return(matn); |
|---|
| 1152 | |
|---|
| 1153 | switch(toupper(*lin2)) { |
|---|
| 1154 | case '1': |
|---|
| 1155 | strcpy(matnam,"blosum"); |
|---|
| 1156 | matn=1; |
|---|
| 1157 | break; |
|---|
| 1158 | case '2': |
|---|
| 1159 | strcpy(matnam,"pam"); |
|---|
| 1160 | matn=2; |
|---|
| 1161 | break; |
|---|
| 1162 | case '3': |
|---|
| 1163 | strcpy(matnam,"gonnet"); |
|---|
| 1164 | matn=3; |
|---|
| 1165 | break; |
|---|
| 1166 | case '4': |
|---|
| 1167 | strcpy(matnam,"id"); |
|---|
| 1168 | matn=4; |
|---|
| 1169 | break; |
|---|
| 1170 | case '5': |
|---|
| 1171 | if(user_mat(userfile, mat, xref)) |
|---|
| 1172 | { |
|---|
| 1173 | strcpy(matnam,userfile); |
|---|
| 1174 | matn=5; |
|---|
| 1175 | } |
|---|
| 1176 | break; |
|---|
| 1177 | case '?': |
|---|
| 1178 | case 'H': |
|---|
| 1179 | get_help('8'); |
|---|
| 1180 | break; |
|---|
| 1181 | default: |
|---|
| 1182 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 1183 | break; |
|---|
| 1184 | } |
|---|
| 1185 | } |
|---|
| 1186 | } |
|---|
| 1187 | |
|---|
| 1188 | |
|---|
| 1189 | |
|---|
| 1190 | static sint read_dnamatrix(char **mattxt, char *matnam, sint matn, short *mat, short *xref) |
|---|
| 1191 | { static char userfile[FILENAMELEN+1]; |
|---|
| 1192 | |
|---|
| 1193 | while(TRUE) |
|---|
| 1194 | { |
|---|
| 1195 | fprintf(stdout,"\n\n\n"); |
|---|
| 1196 | fprintf(stdout," ********* DNA WEIGHT MATRIX MENU *********\n"); |
|---|
| 1197 | fprintf(stdout,"\n\n"); |
|---|
| 1198 | |
|---|
| 1199 | |
|---|
| 1200 | fprintf(stdout," 1. %s\n",mattxt[0]); |
|---|
| 1201 | fprintf(stdout," 2. %s\n",mattxt[1]); |
|---|
| 1202 | fprintf(stdout," 3. %s\n",mattxt[2]); |
|---|
| 1203 | fprintf(stdout," H. HELP\n\n"); |
|---|
| 1204 | fprintf(stdout, |
|---|
| 1205 | " -- Current matrix is the %s ",mattxt[matn-1]); |
|---|
| 1206 | if(matn == 5) fprintf(stdout,"(file = %s)",userfile); |
|---|
| 1207 | fprintf(stdout,"--\n"); |
|---|
| 1208 | |
|---|
| 1209 | |
|---|
| 1210 | getstr("\n\nEnter number (or [RETURN] to exit)",lin2); |
|---|
| 1211 | if(*lin2 == EOS) return(matn); |
|---|
| 1212 | |
|---|
| 1213 | switch(toupper(*lin2)) { |
|---|
| 1214 | case '1': |
|---|
| 1215 | strcpy(matnam,"iub"); |
|---|
| 1216 | matn=1; |
|---|
| 1217 | break; |
|---|
| 1218 | case '2': |
|---|
| 1219 | strcpy(matnam,"clustalw"); |
|---|
| 1220 | matn=2; |
|---|
| 1221 | break; |
|---|
| 1222 | case '3': |
|---|
| 1223 | if(user_mat(userfile, mat, xref)) |
|---|
| 1224 | { |
|---|
| 1225 | strcpy(matnam,userfile); |
|---|
| 1226 | matn=3; |
|---|
| 1227 | } |
|---|
| 1228 | break; |
|---|
| 1229 | case '?': |
|---|
| 1230 | case 'H': |
|---|
| 1231 | get_help('8'); |
|---|
| 1232 | break; |
|---|
| 1233 | default: |
|---|
| 1234 | fprintf(stdout,"\n\nUnrecognised Command\n\n"); |
|---|
| 1235 | break; |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | char prompt_for_yes_no(char *title,char *prompt) |
|---|
| 1241 | { |
|---|
| 1242 | char line[80]; |
|---|
| 1243 | char lin2[80]; |
|---|
| 1244 | |
|---|
| 1245 | fprintf(stdout,"\n%s\n",title); |
|---|
| 1246 | strcpy(line,prompt); |
|---|
| 1247 | strcat(line, "(y/n) ? [y]"); |
|---|
| 1248 | getstr(line,lin2); |
|---|
| 1249 | if ((*lin2 != 'n') && (*lin2 != 'N')) |
|---|
| 1250 | return('y'); |
|---|
| 1251 | else |
|---|
| 1252 | return('n'); |
|---|
| 1253 | |
|---|
| 1254 | } |
|---|
| 1255 | |
|---|
| 1256 | |
|---|
| 1257 | /* |
|---|
| 1258 | * fatal() |
|---|
| 1259 | * |
|---|
| 1260 | * Prints error msg to stdout and exits. |
|---|
| 1261 | * Variadic parameter list can be passed. |
|---|
| 1262 | * |
|---|
| 1263 | * Return values: |
|---|
| 1264 | * none |
|---|
| 1265 | */ |
|---|
| 1266 | |
|---|
| 1267 | void fatal( char *msg,...) |
|---|
| 1268 | { |
|---|
| 1269 | va_list ap; |
|---|
| 1270 | |
|---|
| 1271 | va_start(ap,msg); |
|---|
| 1272 | fprintf(stdout,"\n\nFATAL ERROR: "); |
|---|
| 1273 | vfprintf(stdout,msg,ap); |
|---|
| 1274 | fprintf(stdout,"\n\n"); |
|---|
| 1275 | va_end(ap); |
|---|
| 1276 | exit(1); |
|---|
| 1277 | } |
|---|
| 1278 | |
|---|
| 1279 | /* |
|---|
| 1280 | * error() |
|---|
| 1281 | * |
|---|
| 1282 | * Prints error msg to stdout. |
|---|
| 1283 | * Variadic parameter list can be passed. |
|---|
| 1284 | * |
|---|
| 1285 | * Return values: |
|---|
| 1286 | * none |
|---|
| 1287 | */ |
|---|
| 1288 | |
|---|
| 1289 | void error( char *msg,...) |
|---|
| 1290 | { |
|---|
| 1291 | va_list ap; |
|---|
| 1292 | |
|---|
| 1293 | va_start(ap,msg); |
|---|
| 1294 | fprintf(stdout,"\n\nERROR: "); |
|---|
| 1295 | vfprintf(stdout,msg,ap); |
|---|
| 1296 | fprintf(stdout,"\n\n"); |
|---|
| 1297 | va_end(ap); |
|---|
| 1298 | } |
|---|
| 1299 | |
|---|
| 1300 | /* |
|---|
| 1301 | * warning() |
|---|
| 1302 | * |
|---|
| 1303 | * Prints warning msg to stdout. |
|---|
| 1304 | * Variadic parameter list can be passed. |
|---|
| 1305 | * |
|---|
| 1306 | * Return values: |
|---|
| 1307 | * none |
|---|
| 1308 | */ |
|---|
| 1309 | |
|---|
| 1310 | void warning( char *msg,...) |
|---|
| 1311 | { |
|---|
| 1312 | va_list ap; |
|---|
| 1313 | |
|---|
| 1314 | va_start(ap,msg); |
|---|
| 1315 | fprintf(stdout,"\n\nWARNING: "); |
|---|
| 1316 | vfprintf(stdout,msg,ap); |
|---|
| 1317 | fprintf(stdout,"\n\n"); |
|---|
| 1318 | va_end(ap); |
|---|
| 1319 | } |
|---|
| 1320 | |
|---|
| 1321 | /* |
|---|
| 1322 | * info() |
|---|
| 1323 | * |
|---|
| 1324 | * Prints info msg to stdout. |
|---|
| 1325 | * Variadic parameter list can be passed. |
|---|
| 1326 | * |
|---|
| 1327 | * Return values: |
|---|
| 1328 | * none |
|---|
| 1329 | */ |
|---|
| 1330 | |
|---|
| 1331 | void info( char *msg,...) |
|---|
| 1332 | { |
|---|
| 1333 | va_list ap; |
|---|
| 1334 | |
|---|
| 1335 | va_start(ap,msg); |
|---|
| 1336 | fprintf(stdout,"\n"); |
|---|
| 1337 | vfprintf(stdout,msg,ap); |
|---|
| 1338 | va_end(ap); |
|---|
| 1339 | } |
|---|