| 1 | /* |
|---|
| 2 | |
|---|
| 3 | PHYML : a program that computes maximum likelihood phylogenies from |
|---|
| 4 | DNA or AA homologous sequences |
|---|
| 5 | |
|---|
| 6 | Copyright (C) Stephane Guindon. Oct 2003 onward |
|---|
| 7 | |
|---|
| 8 | All parts of the source except where indicated are distributed under |
|---|
| 9 | the GNU public licence. See http://www.opensource.org for details. |
|---|
| 10 | |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #include "utilities.h" |
|---|
| 14 | #include "options.h" |
|---|
| 15 | #include "models.h" |
|---|
| 16 | #include "free.h" |
|---|
| 17 | |
|---|
| 18 | /* int T_MAX_FILE; */ |
|---|
| 19 | /* double MDBL_MIN; */ |
|---|
| 20 | /* double UNLIKELY; */ |
|---|
| 21 | |
|---|
| 22 | #define BOLD "\033[00;01m" |
|---|
| 23 | #define FLAT "\033[00;00m" |
|---|
| 24 | #define LINE "\033[00;04m" |
|---|
| 25 | |
|---|
| 26 | /*********************************************************/ |
|---|
| 27 | |
|---|
| 28 | void Usage() |
|---|
| 29 | { |
|---|
| 30 | printf(BOLD"NAME\n" |
|---|
| 31 | FLAT"\tphyml\n" |
|---|
| 32 | FLAT"\tA simple, fast, and accurate algorithm to estimate\n" |
|---|
| 33 | FLAT"\tlarge phylogenies by maximum likelihood.\n\n" |
|---|
| 34 | FLAT"\tStephane Guindon and Olivier Gascuel,\n" |
|---|
| 35 | FLAT"\tSystematic Biology 52(5):696-704, 2003.\n" |
|---|
| 36 | FLAT"\tPlease cite this paper if you use this software in your publications.\n"); |
|---|
| 37 | |
|---|
| 38 | printf(BOLD"\nCOMMAND-LINE USE\n" |
|---|
| 39 | BOLD"\tphyml "FLAT"[ " |
|---|
| 40 | LINE"sequences"FLAT" " |
|---|
| 41 | LINE"data_type"FLAT" " |
|---|
| 42 | LINE"format"FLAT" " |
|---|
| 43 | LINE"data_sets"FLAT" " |
|---|
| 44 | LINE"bootstrap_sets"FLAT" " |
|---|
| 45 | LINE"model"FLAT" " |
|---|
| 46 | LINE"\n\t\t[kappa]"FLAT" " |
|---|
| 47 | LINE"invar"FLAT" " |
|---|
| 48 | LINE"nb_categ"FLAT" " |
|---|
| 49 | LINE"alpha"FLAT" " |
|---|
| 50 | LINE"tree"FLAT" " |
|---|
| 51 | LINE"opt_topology"FLAT" " |
|---|
| 52 | LINE"opt_lengths"FLAT" " |
|---|
| 53 | "]\n"); |
|---|
| 54 | |
|---|
| 55 | printf(FLAT"\n\tYou can use phyml with no arguments, in this case change the value of\n" |
|---|
| 56 | FLAT"\ta parameter by typing its corresponding character as shown on screen.\n\n" |
|---|
| 57 | FLAT"\tYou can alternatively use phyml with the following arguments :\n"); |
|---|
| 58 | |
|---|
| 59 | printf(LINE"\n\tsequence_file" |
|---|
| 60 | FLAT"\tDNA or Amino-Acids sequence filename (PHYLIP format)\n" |
|---|
| 61 | |
|---|
| 62 | LINE"\n\tdata type" |
|---|
| 63 | FLAT"\t"BOLD"0"FLAT" = DNA | "BOLD"1"FLAT" = Amino-Acids\n" |
|---|
| 64 | |
|---|
| 65 | LINE"\n\tformat" |
|---|
| 66 | FLAT"\t\t"BOLD"i"FLAT" = interleaved sequence format | " |
|---|
| 67 | BOLD"s"FLAT" = sequential\n" |
|---|
| 68 | |
|---|
| 69 | LINE"\n\tdata_sets" |
|---|
| 70 | FLAT"\tnumber of data sets to analyse (ex:3)\n" |
|---|
| 71 | |
|---|
| 72 | LINE"\n\tbootstrap_sets" |
|---|
| 73 | FLAT"\tnumber of bootstrap data sets to generate (ex:2)\n" |
|---|
| 74 | FLAT"\t\t\tonly works with one data set to analyse\n" |
|---|
| 75 | |
|---|
| 76 | LINE"\n\tmodel" |
|---|
| 77 | FLAT"\t\tsubstitution model name\n" |
|---|
| 78 | BOLD"\t\t\tJC69 | K2P | F81 | HKY | F84 | TN93 | GTR "FLAT"(DNA)\n" |
|---|
| 79 | BOLD"\t\t\tJTT | MtREV | Dayhoff | WAG "FLAT"(Amino-Acids)\n" |
|---|
| 80 | |
|---|
| 81 | LINE"\n\tkappa" |
|---|
| 82 | FLAT"\t\ttransition/transversion ratio, only for DNA sequences,\n" |
|---|
| 83 | FLAT"\t\t\ta fixed value (ex:4.0) | "BOLD"e"FLAT" to get the maximum likelihood estimate\n" |
|---|
| 84 | |
|---|
| 85 | LINE"\n\tinvar" |
|---|
| 86 | FLAT"\t\tproportion of invariable sites,\n" |
|---|
| 87 | FLAT"\t\t\ta fixed value (ex:0.0) | "BOLD"e"FLAT" to get the maximum likelihood estimate\n" |
|---|
| 88 | |
|---|
| 89 | LINE"\n\tnb_categ" |
|---|
| 90 | FLAT"\tnumber of relative substitution rate categories (ex:4)\n" |
|---|
| 91 | |
|---|
| 92 | LINE"\n\talpha" |
|---|
| 93 | FLAT"\t\tgamma distribution parameter,\n" |
|---|
| 94 | FLAT"\t\t\ta fixed value (ex:1.0) | "BOLD"e"FLAT" to get the maximum likelihood estimate\n" |
|---|
| 95 | |
|---|
| 96 | LINE"\n\ttree" |
|---|
| 97 | FLAT"\t\tstarting tree filename (Newick format),\n" |
|---|
| 98 | FLAT"\t\t\tyour tree filename | "BOLD"BIONJ"FLAT" for a distance-based tree\n" |
|---|
| 99 | |
|---|
| 100 | LINE"\n\topt_topology" |
|---|
| 101 | FLAT"\toptimise tree topology ? "BOLD"y | n\n" |
|---|
| 102 | |
|---|
| 103 | LINE"\n\topt_lengths" |
|---|
| 104 | FLAT"\toptimise branch lengths and rate parameters ? "BOLD"y | n\n"); |
|---|
| 105 | |
|---|
| 106 | printf( FLAT"\n\tExamples\n" |
|---|
| 107 | FLAT"\tDNA sequences : "BOLD" ./phyml seqs1 0 i 2 0 HKY 4.0 e 1 1.0 BIONJ y n \n" |
|---|
| 108 | FLAT"\n\tAA sequences : "BOLD" ./phyml seqs2 1 i 1 5 JTT 0.0 4 1.0 BIONJ n n \n"FLAT); |
|---|
| 109 | Exit(""); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | /*********************************************************/ |
|---|
| 113 | |
|---|
| 114 | #define N_SEQUENCEFILE 1 |
|---|
| 115 | #define N_DATATYPE 2 |
|---|
| 116 | #define N_FORMAT 3 |
|---|
| 117 | #define N_DATASETS 4 |
|---|
| 118 | #define N_BOOTSTRAPSETS 5 |
|---|
| 119 | #define N_MODELNAME 6 |
|---|
| 120 | #define N_KAPPA 7 |
|---|
| 121 | #define N_PROPORTIONINVAR 7 /*same as kappa*/ |
|---|
| 122 | #define N_NBCATG 8 |
|---|
| 123 | #define N_ALPHA 9 |
|---|
| 124 | #define N_STARTINGTREE 10 |
|---|
| 125 | #define N_OPT_TOPO 11 |
|---|
| 126 | #define N_OPT_LENGTHSRATES 12 |
|---|
| 127 | |
|---|
| 128 | #define N_NB_PARAMS_DNA 13 |
|---|
| 129 | #define N_NB_PARAMS_AA 12 |
|---|
| 130 | |
|---|
| 131 | option *Get_Input(int argc, char **argv) |
|---|
| 132 | { |
|---|
| 133 | |
|---|
| 134 | option* input = (option *)mCalloc(1,sizeof(option)); |
|---|
| 135 | putchar('\n'); |
|---|
| 136 | |
|---|
| 137 | input->fp_seq = NULL; |
|---|
| 138 | input->fp_input_tree = NULL; |
|---|
| 139 | input->mod = Make_Model_Basic(); |
|---|
| 140 | input->seqfile = (char *)mCalloc(T_MAX_FILE,sizeof(char)); |
|---|
| 141 | input->modelname = (char *)mCalloc(50,sizeof(char)); |
|---|
| 142 | input->nt_or_cd = (char *)mCalloc(50,sizeof(char)); |
|---|
| 143 | input->inputtreefile = (char *)mCalloc(T_MAX_FILE,sizeof(char)); |
|---|
| 144 | input->phyml_tree_file = (char *)mCalloc(T_MAX_FILE,sizeof(char)); |
|---|
| 145 | input->phyml_stat_file = (char *)mCalloc(T_MAX_FILE,sizeof(char)); |
|---|
| 146 | input->phyml_lk_file = (char *)mCalloc(T_MAX_FILE,sizeof(char)); |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | Set_Defaults_Input(input); |
|---|
| 150 | Set_Defaults_Model(input->mod); |
|---|
| 151 | Set_Defaults_Optimiz(input->mod->s_opt); |
|---|
| 152 | |
|---|
| 153 | Translate_Custom_Mod_String(input->mod); |
|---|
| 154 | Init_Optimiz(input->mod->s_opt); |
|---|
| 155 | |
|---|
| 156 | switch (argc) |
|---|
| 157 | { |
|---|
| 158 | case 1: |
|---|
| 159 | Get_Input_Interactive(input); |
|---|
| 160 | break; |
|---|
| 161 | case 2: |
|---|
| 162 | Usage(); |
|---|
| 163 | break; |
|---|
| 164 | default: |
|---|
| 165 | if (isdigit((int)argv[N_DATATYPE][0])) |
|---|
| 166 | { |
|---|
| 167 | if (atoi(argv[N_DATATYPE])==0 && argc-1==N_NB_PARAMS_DNA) |
|---|
| 168 | Get_Input_CommandLine_DNA(input, argc, argv); |
|---|
| 169 | else if (atoi(argv[N_DATATYPE])==1 && argc-1==N_NB_PARAMS_AA) |
|---|
| 170 | Get_Input_CommandLine_AA(input, argc, argv); |
|---|
| 171 | else |
|---|
| 172 | Usage(); |
|---|
| 173 | } |
|---|
| 174 | else |
|---|
| 175 | Usage(); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /*print the parameter values*/ |
|---|
| 179 | printf("\n\n\n"); |
|---|
| 180 | |
|---|
| 181 | printf("Sequence filename : \t\t\t\t %s\n", input->seqfile); |
|---|
| 182 | |
|---|
| 183 | printf("Data type : \t\t\t %s\n", (input->mod->datatype ? "aa" : "dna")); |
|---|
| 184 | |
|---|
| 185 | printf("Sequence format : \t\t\t\t %s\n", input->interleaved ? "interleaved" : "sequential"); |
|---|
| 186 | |
|---|
| 187 | printf("Number of data sets : \t\t\t\t %d\n", input->n_data_sets); |
|---|
| 188 | |
|---|
| 189 | printf("Nb of bootstrapped data sets : \t\t\t %d\n", input->mod->bootstrap); |
|---|
| 190 | |
|---|
| 191 | printf("Model name : \t\t\t\t\t %s\n", input->modelname); |
|---|
| 192 | |
|---|
| 193 | if (input->mod->datatype == NT) { |
|---|
| 194 | if (input->mod->s_opt->opt_kappa) |
|---|
| 195 | printf("ts/tv ratio : \t\t\t\t\t estimated\n"); |
|---|
| 196 | else |
|---|
| 197 | { |
|---|
| 198 | if ((input->mod->whichmodel == 2)|| |
|---|
| 199 | (input->mod->whichmodel == 4)|| |
|---|
| 200 | (input->mod->whichmodel == 5)|| |
|---|
| 201 | (input->mod->whichmodel == 6)) |
|---|
| 202 | printf("ts/tv ratio : \t\t\t\t\t %f\n", input->mod->kappa); |
|---|
| 203 | } |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | if (input->mod->s_opt->opt_pinvar) |
|---|
| 207 | printf("Proportion of invariable sites :\t\t estimated\n"); |
|---|
| 208 | else |
|---|
| 209 | printf("Proportion of invariable sites :\t\t %f\n", input->mod->pinvar); |
|---|
| 210 | |
|---|
| 211 | printf("Number of subst. rate categs : \t\t\t %d\n", input->mod->n_catg); |
|---|
| 212 | |
|---|
| 213 | if (input->mod->s_opt->opt_alpha) |
|---|
| 214 | printf("Gamma distribution parameter : \t\t\t estimated\n"); |
|---|
| 215 | else |
|---|
| 216 | printf("Gamma distribution parameter : \t\t\t %f\n", input->mod->alpha); |
|---|
| 217 | |
|---|
| 218 | printf("Starting tree : \t\t\t\t %s\n", (!input->inputtree) ? "BIONJ" : input->inputtreefile); |
|---|
| 219 | |
|---|
| 220 | printf("Optimise tree topology : \t\t\t %s\n", (input->mod->s_opt->opt_topo) ? "yes" : "no"); |
|---|
| 221 | |
|---|
| 222 | printf("Optimise branch lengths and rate parameters : \t %s\n", (input->mod->s_opt->opt_free_param) ? "yes" : "no"); |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | return input; |
|---|
| 226 | } |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | void Get_Input_CommandLine_Common(option *input, int argc, char **argv) |
|---|
| 231 | { |
|---|
| 232 | (void)argc; // suppress warning |
|---|
| 233 | char* p; |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | p = argv[N_SEQUENCEFILE]; |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | #ifdef PHYML |
|---|
| 241 | |
|---|
| 242 | strcpy(input->seqfile, p); |
|---|
| 243 | input->fp_seq = Openfile(input->seqfile,0); |
|---|
| 244 | |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | input->phyml_stat_file_open_mode = 1; /* stands for the "R" (Replacement) interactive option */ |
|---|
| 249 | |
|---|
| 250 | input->phyml_tree_file_open_mode = 1; /* stands for the "R" (Replacement) interactive option */ |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | #ifdef PHYML |
|---|
| 254 | strcpy(input->phyml_stat_file,input->seqfile); |
|---|
| 255 | strcat(input->phyml_stat_file,"_phyml_stat.txt"); |
|---|
| 256 | |
|---|
| 257 | strcpy(input->phyml_tree_file,input->seqfile); |
|---|
| 258 | strcat(input->phyml_tree_file,"_phyml_tree.txt"); |
|---|
| 259 | |
|---|
| 260 | strcpy(input->phyml_lk_file,input->seqfile); |
|---|
| 261 | strcat(input->phyml_lk_file,"_phyml_lk.txt"); |
|---|
| 262 | #endif |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | p = argv[N_FORMAT]; |
|---|
| 267 | input->interleaved = (!strcmp(p,"i")) ? 1 : 0; |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | p = argv[N_DATASETS]; |
|---|
| 271 | if (!atoi(p) || (input->n_data_sets = atoi(p)) < 0) |
|---|
| 272 | Exit("\nThe number of data sets should be a positive integer\n"); |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | p = argv[N_BOOTSTRAPSETS]; |
|---|
| 276 | if ((input->mod->bootstrap = atoi(p)) < 0) |
|---|
| 277 | Exit("\nThe number of bootstrapped data sets should be a positive or null integer\n"); |
|---|
| 278 | |
|---|
| 279 | if(!input->mod->bootstrap) |
|---|
| 280 | { |
|---|
| 281 | input->print_boot_trees = 0; |
|---|
| 282 | input->fp_boot_tree = NULL; |
|---|
| 283 | input->fp_boot_stats = NULL; |
|---|
| 284 | |
|---|
| 285 | } |
|---|
| 286 | else |
|---|
| 287 | { |
|---|
| 288 | char *r; |
|---|
| 289 | r = (char *)mCalloc(T_MAX_LINE, sizeof(char)); |
|---|
| 290 | strcpy(r,input->seqfile); |
|---|
| 291 | input->print_boot_trees = 1; |
|---|
| 292 | input->fp_boot_tree = Openfile(strcat(r,"_phyml_boot_trees.txt"),1); |
|---|
| 293 | strcpy(r,input->seqfile); |
|---|
| 294 | input->fp_boot_stats = Openfile(strcat(r,"_phyml_boot_stats.txt"),1); |
|---|
| 295 | Free(r); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | p = argv[N_PROPORTIONINVAR]; |
|---|
| 300 | if (!strcmp(p,"e")) |
|---|
| 301 | { |
|---|
| 302 | input->mod->s_opt->opt_pinvar = 1; |
|---|
| 303 | input->mod->pinvar = 0.2; |
|---|
| 304 | input->mod->invar = 1; |
|---|
| 305 | } |
|---|
| 306 | else |
|---|
| 307 | { |
|---|
| 308 | if((atof(p) < 0.0) || (atof(p) > 1.0)) |
|---|
| 309 | { |
|---|
| 310 | Exit("\nErr : the proportion of invariable sites must be a positive number between 0.0 and 1.0\n"); |
|---|
| 311 | } |
|---|
| 312 | else |
|---|
| 313 | { |
|---|
| 314 | input->mod->s_opt->opt_pinvar = 0; |
|---|
| 315 | input->mod->pinvar = (double)atof(p); |
|---|
| 316 | input->mod->invar = (input->mod->pinvar > 0.0+MDBL_MIN) ? 1 : 0; |
|---|
| 317 | } |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | p = argv[N_NBCATG]; |
|---|
| 322 | if (!atoi(p) || (input->mod->n_catg = atoi(p)) < 0) |
|---|
| 323 | Exit("\nThe number of categories should be a positive integer\n"); |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | p = argv[N_ALPHA]; |
|---|
| 327 | if (!strcmp(p,"e")) |
|---|
| 328 | { |
|---|
| 329 | input->mod->s_opt->opt_alpha = 1; |
|---|
| 330 | } |
|---|
| 331 | else |
|---|
| 332 | { |
|---|
| 333 | input->mod->s_opt->opt_alpha = 0; |
|---|
| 334 | input->mod->alpha = 1.0; |
|---|
| 335 | |
|---|
| 336 | if(!atof(p) || (input->mod->alpha = (double)atof(p)) < .0) |
|---|
| 337 | Exit("\nAlpha must be a positive number\n"); |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | p = argv[N_STARTINGTREE]; |
|---|
| 342 | if (!strcmp(p,"BIONJ")) |
|---|
| 343 | { |
|---|
| 344 | input->inputtree = 0; |
|---|
| 345 | } |
|---|
| 346 | else |
|---|
| 347 | { |
|---|
| 348 | input->inputtree = 1; |
|---|
| 349 | strcpy(input->inputtreefile, p); |
|---|
| 350 | input->fp_input_tree = Openfile(input->inputtreefile,0); |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | p = argv[N_OPT_TOPO]; |
|---|
| 355 | input->mod->s_opt->opt_topo = (!strcmp(p,"y")) ? 1 : 0; |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | p = argv[N_OPT_LENGTHSRATES]; |
|---|
| 359 | input->mod->s_opt->opt_free_param = (!strcmp(p,"y")) ? 1 : 0; |
|---|
| 360 | |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | /*Attention phyml compilé avec les symboles de compilation EVOLVE et OPTIMIZ n'est utilisable qu'en mode interactif */ |
|---|
| 364 | void Get_Input_CommandLine_DNA(option *input, int argc, char **argv) |
|---|
| 365 | { |
|---|
| 366 | char* p; |
|---|
| 367 | |
|---|
| 368 | /*convert into AA syntax to have a common code with the AA case*/ |
|---|
| 369 | char** argvbis; |
|---|
| 370 | int i; |
|---|
| 371 | char kappa[30]; |
|---|
| 372 | model *mod; |
|---|
| 373 | |
|---|
| 374 | |
|---|
| 375 | mod = input->mod; |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | argvbis = (char**)calloc(argc-1, sizeof(char*)); |
|---|
| 379 | for (i=0; i<N_KAPPA; i++) |
|---|
| 380 | { |
|---|
| 381 | argvbis[i] = (char*)malloc(T_MAX_FILE); |
|---|
| 382 | strcpy(argvbis[i], argv[i]); |
|---|
| 383 | } |
|---|
| 384 | strcpy(kappa, argv[N_KAPPA]); |
|---|
| 385 | for (i=N_KAPPA; i<argc-1; i++) |
|---|
| 386 | { |
|---|
| 387 | argvbis[i] = (char*)malloc(T_MAX_FILE); |
|---|
| 388 | strcpy(argvbis[i], argv[i+1]); |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | Get_Input_CommandLine_Common(input, argc-1, argvbis); /*argv must not change*/ |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | input->mod->datatype = 0; |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | p = argvbis[N_MODELNAME]; |
|---|
| 398 | strcpy(input->modelname, p); |
|---|
| 399 | if (!strcmp(p,"JC69")) mod->whichmodel = 1; |
|---|
| 400 | else if (!strcmp(p,"K2P")) mod->whichmodel = 2; |
|---|
| 401 | else if (!strcmp(p,"F81")) mod->whichmodel = 3; |
|---|
| 402 | else if (!strcmp(p,"HKY")) mod->whichmodel = 4; |
|---|
| 403 | else if (!strcmp(p,"F84")) mod->whichmodel = 5; |
|---|
| 404 | else if (!strcmp(p,"TN93")) mod->whichmodel = 6; |
|---|
| 405 | else if (!strcmp(p,"GTR")) mod->whichmodel = 7; |
|---|
| 406 | |
|---|
| 407 | else Exit("\nUnknown model \n"); |
|---|
| 408 | |
|---|
| 409 | mod->ns = 4; |
|---|
| 410 | |
|---|
| 411 | p = kappa; |
|---|
| 412 | if (!strcmp(p,"e")) |
|---|
| 413 | { |
|---|
| 414 | mod->s_opt->opt_kappa = 1; |
|---|
| 415 | mod->kappa = 4.0; |
|---|
| 416 | |
|---|
| 417 | if(mod->whichmodel == 6) |
|---|
| 418 | mod->s_opt->opt_lambda = 1; |
|---|
| 419 | if((mod->whichmodel == 1) || |
|---|
| 420 | (mod->whichmodel == 3) || |
|---|
| 421 | (mod->whichmodel == 7) || |
|---|
| 422 | (mod->whichmodel == 8)) |
|---|
| 423 | mod->s_opt->opt_kappa = 0; |
|---|
| 424 | } |
|---|
| 425 | else |
|---|
| 426 | { |
|---|
| 427 | mod->s_opt->opt_kappa = 0; |
|---|
| 428 | mod->s_opt->opt_lambda = 0; |
|---|
| 429 | |
|---|
| 430 | if(!atof(p) || (mod->kappa = (double)atof(p)) < .0) |
|---|
| 431 | Exit("\nThe ts/tv ratio should be a positive number\n"); |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | if( |
|---|
| 436 | (mod->whichmodel == 1) || |
|---|
| 437 | (mod->whichmodel == 3) || |
|---|
| 438 | (mod->whichmodel == 7) || |
|---|
| 439 | (mod->whichmodel == 8)) |
|---|
| 440 | { |
|---|
| 441 | mod->s_opt->opt_kappa = 0; |
|---|
| 442 | mod->s_opt->opt_lambda = 0; |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | if(mod->whichmodel != 6) mod->s_opt->opt_lambda = 0; |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | for (i=0; i<argc-1; i++) |
|---|
| 449 | free(argvbis[i]); |
|---|
| 450 | free(argvbis); |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | |
|---|
| 454 | /*Attention phyml compilé avec les symboles de compilation EVOLVE et OPTIMIZ n'est utilisable qu'en mode interactif */ |
|---|
| 455 | void Get_Input_CommandLine_AA(option *input, int argc, char **argv) |
|---|
| 456 | { |
|---|
| 457 | char* p; |
|---|
| 458 | |
|---|
| 459 | Get_Input_CommandLine_Common(input, argc, argv); |
|---|
| 460 | |
|---|
| 461 | input->mod->datatype = 1; |
|---|
| 462 | |
|---|
| 463 | |
|---|
| 464 | p = argv[N_MODELNAME]; |
|---|
| 465 | strcpy(input->modelname, p); |
|---|
| 466 | if (!strcmp(p,"Dayhoff")) input->mod->whichmodel = 11; |
|---|
| 467 | else if (!strcmp(p,"JTT")) input->mod->whichmodel = 12; |
|---|
| 468 | else if (!strcmp(p,"MtREV")) input->mod->whichmodel = 13; |
|---|
| 469 | else if (!strcmp(p,"WAG")) input->mod->whichmodel = 14; |
|---|
| 470 | else if (!strcmp(p,"DCMut")) input->mod->whichmodel = 15; |
|---|
| 471 | else if (!strcmp(p,"RtREV")) input->mod->whichmodel = 16; |
|---|
| 472 | else if (!strcmp(p,"CpREV")) input->mod->whichmodel = 17; |
|---|
| 473 | else if (!strcmp(p,"VT")) input->mod->whichmodel = 18; |
|---|
| 474 | else if (!strcmp(p,"Blosum62"))input->mod->whichmodel = 19; |
|---|
| 475 | else if (!strcmp(p,"MtMam")) input->mod->whichmodel = 20; |
|---|
| 476 | else Exit("\nUnknown model name\n"); |
|---|
| 477 | |
|---|
| 478 | input->mod->ns = 20; |
|---|
| 479 | |
|---|
| 480 | if(input->mod->whichmodel != 6) input->mod->s_opt->opt_lambda = 0; |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | void Get_Input_Interactive(option *input) |
|---|
| 484 | { |
|---|
| 485 | char choix; |
|---|
| 486 | char *s = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 487 | char *buff = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 488 | int n_trial; |
|---|
| 489 | |
|---|
| 490 | #ifdef EVOLVE |
|---|
| 491 | |
|---|
| 492 | char *n_data_sets; |
|---|
| 493 | |
|---|
| 494 | printf("Enter the tree file name > "); fflush(NULL); |
|---|
| 495 | Getstring_Stdin(input->inputtreefile); |
|---|
| 496 | input->fp_input_tree = Openfile(input->inputtreefile,0); |
|---|
| 497 | printf("\n"); |
|---|
| 498 | |
|---|
| 499 | printf("Enter the reference sequence file name > "); fflush(NULL); |
|---|
| 500 | Getstring_Stdin(input->seqfile); |
|---|
| 501 | input->fp_seq = Openfile(input->seqfile,0); |
|---|
| 502 | printf("\n"); |
|---|
| 503 | |
|---|
| 504 | printf("Number of data sets > "); |
|---|
| 505 | n_data_sets = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 506 | Getstring_Stdin(n_data_sets); |
|---|
| 507 | n_trial = 0; |
|---|
| 508 | while((!atoi(n_data_sets)) || (atoi(n_data_sets) < 0)) |
|---|
| 509 | { |
|---|
| 510 | if(++n_trial > 10) Exit("\nErr : the number of sets must be a positive integer\n"); |
|---|
| 511 | printf("\nThe number of sets must be a positive integer\n"); |
|---|
| 512 | printf("Enter a new value > "); |
|---|
| 513 | Getstring_Stdin(n_data_sets); |
|---|
| 514 | } |
|---|
| 515 | input->n_data_set_asked = atoi(n_data_sets); |
|---|
| 516 | Free(n_data_sets); |
|---|
| 517 | |
|---|
| 518 | #elif OPTIMIZ |
|---|
| 519 | |
|---|
| 520 | printf("Enter the tree file name > "); fflush(NULL); |
|---|
| 521 | Getstring_Stdin(input->inputtreefile); |
|---|
| 522 | input->fp_input_tree = Openfile(input->inputtreefile,0); |
|---|
| 523 | printf("\n"); |
|---|
| 524 | |
|---|
| 525 | printf("Enter the reference sequence file name > "); fflush(NULL); |
|---|
| 526 | Getstring_Stdin(input->seqfile); |
|---|
| 527 | input->fp_seq = Openfile(input->seqfile,0); |
|---|
| 528 | printf("\n"); |
|---|
| 529 | |
|---|
| 530 | #elif PHYML |
|---|
| 531 | |
|---|
| 532 | printf("Enter the sequence file name > "); fflush(NULL); |
|---|
| 533 | Getstring_Stdin(input->seqfile); |
|---|
| 534 | input->fp_seq = Openfile(input->seqfile,0); |
|---|
| 535 | |
|---|
| 536 | #endif |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | #ifdef PHYML |
|---|
| 540 | strcpy(input->phyml_stat_file,input->seqfile); |
|---|
| 541 | strcat(input->phyml_stat_file,"_phyml_stat.txt"); |
|---|
| 542 | |
|---|
| 543 | strcpy(input->phyml_tree_file,input->seqfile); |
|---|
| 544 | strcat(input->phyml_tree_file,"_phyml_tree.txt"); |
|---|
| 545 | |
|---|
| 546 | strcpy(input->phyml_lk_file,input->seqfile); |
|---|
| 547 | strcat(input->phyml_lk_file,"_phyml_lk.txt"); |
|---|
| 548 | #endif |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | #ifdef WIN32 |
|---|
| 552 | #ifdef EVOLVE |
|---|
| 553 | if(Filexists("evolve_out.txt")); |
|---|
| 554 | #elif OPTIMIZ |
|---|
| 555 | if(Filexists("optimiz_out.txt")) |
|---|
| 556 | #elif PHYML |
|---|
| 557 | if(Filexists(input->phyml_stat_file)) |
|---|
| 558 | #endif |
|---|
| 559 | #elif UNIX |
|---|
| 560 | #ifdef EVOLVE |
|---|
| 561 | if(Filexists("evolve_out")); |
|---|
| 562 | #elif OPTIMIZ |
|---|
| 563 | if(Filexists("optimiz_out")) |
|---|
| 564 | #elif PHYML |
|---|
| 565 | if(Filexists(input->phyml_stat_file)) |
|---|
| 566 | #endif |
|---|
| 567 | #endif |
|---|
| 568 | { |
|---|
| 569 | printf("\n"); |
|---|
| 570 | #ifdef EVOLVE |
|---|
| 571 | printf("A file 'evolve_out' already exists\n"); |
|---|
| 572 | #elif OPTIMIZ |
|---|
| 573 | printf("A file 'optimiz_out' already exists\n"); |
|---|
| 574 | #elif PHYML |
|---|
| 575 | printf("A file '%s' already exists\n",input->phyml_stat_file); |
|---|
| 576 | #endif |
|---|
| 577 | printf("Do you want to Replace it or Append to it ?\n"); |
|---|
| 578 | n_trial = 0; |
|---|
| 579 | do |
|---|
| 580 | { |
|---|
| 581 | printf("Please type R or A > "); |
|---|
| 582 | scanf("%c",&choix); |
|---|
| 583 | if(choix == '\n') choix = 'r'; |
|---|
| 584 | else getchar(); |
|---|
| 585 | if(++n_trial>10) Exit("\n"); |
|---|
| 586 | Uppercase(&choix); |
|---|
| 587 | } |
|---|
| 588 | while((choix != 'R') && (choix != 'A')); |
|---|
| 589 | if(choix == 'R') input->phyml_stat_file_open_mode = 1; |
|---|
| 590 | else input->phyml_stat_file_open_mode = 2; |
|---|
| 591 | } |
|---|
| 592 | |
|---|
| 593 | #ifdef WIN32 |
|---|
| 594 | #ifdef EVOLVE |
|---|
| 595 | if(Filexists("evolve_seq.txt")) |
|---|
| 596 | #elif OPTIMIZ |
|---|
| 597 | if(Filexists("optimiz_tree.txt")) |
|---|
| 598 | #elif PHYML |
|---|
| 599 | if(Filexists(input->phyml_tree_file)) |
|---|
| 600 | #endif |
|---|
| 601 | #elif UNIX |
|---|
| 602 | #ifdef EVOLVE |
|---|
| 603 | if(Filexists("evolve_seq")) |
|---|
| 604 | #elif OPTIMIZ |
|---|
| 605 | if(Filexists("optimiz_tree")) |
|---|
| 606 | #elif PHYML |
|---|
| 607 | if(Filexists(input->phyml_tree_file)) |
|---|
| 608 | #endif |
|---|
| 609 | #endif |
|---|
| 610 | { |
|---|
| 611 | printf("\n"); |
|---|
| 612 | #ifdef EVOLVE |
|---|
| 613 | printf("A file 'evolve_seq' already exists\n"); |
|---|
| 614 | #elif OPTIMIZ |
|---|
| 615 | printf("A file 'optimiz_tree' already exists\n"); |
|---|
| 616 | #elif PHYML |
|---|
| 617 | printf("A file '%s' already exists\n",input->phyml_tree_file); |
|---|
| 618 | #endif |
|---|
| 619 | printf("Do you want to Replace it or Append to it ?\n"); |
|---|
| 620 | n_trial = 0; |
|---|
| 621 | do |
|---|
| 622 | { |
|---|
| 623 | printf("Please type R or A > "); |
|---|
| 624 | scanf("%c",&choix); |
|---|
| 625 | if(choix == '\n') choix = 'X'; |
|---|
| 626 | else getchar(); |
|---|
| 627 | Uppercase(&choix); |
|---|
| 628 | if(++n_trial>10) Exit("\n"); |
|---|
| 629 | } |
|---|
| 630 | while((choix != 'R') && (choix != 'A')); |
|---|
| 631 | if(choix == 'R') input->phyml_tree_file_open_mode = 1; |
|---|
| 632 | else input->phyml_tree_file_open_mode = 2; |
|---|
| 633 | } |
|---|
| 634 | |
|---|
| 635 | choix = 0; |
|---|
| 636 | |
|---|
| 637 | |
|---|
| 638 | do |
|---|
| 639 | { |
|---|
| 640 | #ifdef WIN32 |
|---|
| 641 | system("cls"); |
|---|
| 642 | #elif UNIX |
|---|
| 643 | printf("\033[2J\033[H"); |
|---|
| 644 | #endif |
|---|
| 645 | |
|---|
| 646 | |
|---|
| 647 | #ifdef EVOLVE |
|---|
| 648 | printf("\n - EVOLVE - \n\n\n"); |
|---|
| 649 | #elif OPTIMIZ |
|---|
| 650 | printf("\n - OPTIMIZ - \n\n\n"); |
|---|
| 651 | #elif PHYML |
|---|
| 652 | printf("\n - PHYML %s - \n\n\n",VERSION); |
|---|
| 653 | #endif |
|---|
| 654 | |
|---|
| 655 | printf("Settings for this run:\n\n"); |
|---|
| 656 | |
|---|
| 657 | |
|---|
| 658 | printf(" D " |
|---|
| 659 | " Data type (DNA/AA) " |
|---|
| 660 | " %-15s \n", |
|---|
| 661 | (input->mod->datatype)?("AA"):("DNA")); |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | printf(" I " |
|---|
| 665 | " Input sequences interleaved (or sequential) " |
|---|
| 666 | " %-15s \n", |
|---|
| 667 | (input->interleaved)?("interleaved"):("sequential")); |
|---|
| 668 | |
|---|
| 669 | |
|---|
| 670 | strcpy(s,""); |
|---|
| 671 | sprintf(s," (%d sets)",input->n_data_sets); |
|---|
| 672 | strcpy(buff,(input->n_data_sets > 1)?("yes"):("no")); |
|---|
| 673 | buff=strcat(buff,(input->n_data_sets > 1)?(s):("\0")); |
|---|
| 674 | printf(" S " |
|---|
| 675 | " Analyze multiple data sets " |
|---|
| 676 | " %-15s \n",buff); |
|---|
| 677 | |
|---|
| 678 | strcpy(buff,(input->mod->bootstrap > 0)?("yes"):("no")); |
|---|
| 679 | if(input->mod->bootstrap > 0) sprintf(buff+strlen(buff)," (%d replicate%s)", |
|---|
| 680 | input->mod->bootstrap, |
|---|
| 681 | (input->mod->bootstrap>1)?("s"):("")); |
|---|
| 682 | |
|---|
| 683 | printf(" B " |
|---|
| 684 | " Non parametric bootstrap analysis " |
|---|
| 685 | " %-15s \n",buff); |
|---|
| 686 | |
|---|
| 687 | if (input->mod->datatype == NT) |
|---|
| 688 | { |
|---|
| 689 | if(!strcmp(input->nt_or_cd,"nucleotides")) |
|---|
| 690 | { |
|---|
| 691 | printf(" M " |
|---|
| 692 | " Model of nucleotide substitution " |
|---|
| 693 | " %-15s \n", input->modelname); |
|---|
| 694 | |
|---|
| 695 | if((input->mod->whichmodel < 8) && (input->mod->whichmodel > 2)) |
|---|
| 696 | printf(" E " |
|---|
| 697 | " Base frequency estimates (empirical/ML) " |
|---|
| 698 | " %-15s \n", |
|---|
| 699 | (input->mod->s_opt->opt_bfreq)?("ML"):("empirical")); |
|---|
| 700 | |
|---|
| 701 | else if(input->mod->whichmodel == 8) |
|---|
| 702 | { |
|---|
| 703 | |
|---|
| 704 | printf(" E " |
|---|
| 705 | " Optimise equilibrium frequencies " |
|---|
| 706 | " %-15s \n", |
|---|
| 707 | (input->mod->s_opt->opt_bfreq)?("yes"):("no")); |
|---|
| 708 | |
|---|
| 709 | } |
|---|
| 710 | |
|---|
| 711 | |
|---|
| 712 | if(input->mod->whichmodel == 8) |
|---|
| 713 | { |
|---|
| 714 | printf(" F " |
|---|
| 715 | " Equilibrium frequencies " |
|---|
| 716 | " %-15s \n", |
|---|
| 717 | (input->mod->user_b_freq[0]<.0)?("empirical"):("user defined")); |
|---|
| 718 | |
|---|
| 719 | printf(" K " |
|---|
| 720 | " Current custom model " |
|---|
| 721 | " %-15s \n", input->mod->custom_mod_string); |
|---|
| 722 | |
|---|
| 723 | printf(" W " |
|---|
| 724 | " Optimise relative rate parameters " |
|---|
| 725 | " %-15s \n",(input->mod->s_opt->opt_rr_param)?("yes"):("no")); |
|---|
| 726 | |
|---|
| 727 | } |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | } |
|---|
| 731 | else |
|---|
| 732 | printf(" M " |
|---|
| 733 | " Model of codon substitution " |
|---|
| 734 | " %-15s \n", input->modelname); |
|---|
| 735 | } |
|---|
| 736 | else |
|---|
| 737 | { |
|---|
| 738 | printf(" M " |
|---|
| 739 | " Model of amino-acids substitution " |
|---|
| 740 | " %-15s \n", input->modelname); |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | |
|---|
| 744 | if ((input->mod->datatype == NT) && |
|---|
| 745 | ((input->mod->whichmodel == 2)|| |
|---|
| 746 | (input->mod->whichmodel == 4)|| |
|---|
| 747 | (input->mod->whichmodel == 5)|| |
|---|
| 748 | (input->mod->whichmodel == 6))) |
|---|
| 749 | { |
|---|
| 750 | if (input->mod->s_opt->opt_kappa) { |
|---|
| 751 | strcpy(s,"estimated"); |
|---|
| 752 | } |
|---|
| 753 | else { |
|---|
| 754 | sprintf(s,"fixed (ts/tv = %3.2f)",input->mod->kappa); |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | printf(" T " |
|---|
| 758 | " Ts/tv ratio (fixed/estimated) " |
|---|
| 759 | " %-15s \n",s); |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | if (input->mod->s_opt->opt_pinvar) { |
|---|
| 763 | strcpy(s,"estimated"); |
|---|
| 764 | } |
|---|
| 765 | else { |
|---|
| 766 | sprintf(s,"fixed (p-invar = ""%3.2f)",input->mod->pinvar); |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | printf(" V " |
|---|
| 770 | " Proportion of invariable sites (fixed/estimated)" |
|---|
| 771 | " %-15s \n",s); |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | printf(" R " |
|---|
| 775 | " One category of substitution rate (yes/no) " |
|---|
| 776 | " %-15s \n", |
|---|
| 777 | (input->mod->n_catg > 1)?("no"):("yes")); |
|---|
| 778 | |
|---|
| 779 | if(input->mod->n_catg > 1) |
|---|
| 780 | { |
|---|
| 781 | printf(" C " |
|---|
| 782 | " Number of substitution rate categories " |
|---|
| 783 | " %-15d \n", |
|---|
| 784 | input->mod->n_catg); |
|---|
| 785 | } |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | if(input->mod->n_catg > 1) |
|---|
| 789 | { |
|---|
| 790 | if (input->mod->s_opt->opt_alpha) { |
|---|
| 791 | strcpy(s,"estimated"); |
|---|
| 792 | } |
|---|
| 793 | else { |
|---|
| 794 | sprintf(s,"fixed (alpha = %3.2f)",input->mod->alpha); |
|---|
| 795 | } |
|---|
| 796 | |
|---|
| 797 | printf(" A " |
|---|
| 798 | " Gamma distribution parameter (fixed/estimated) " |
|---|
| 799 | " %-15s \n",s); |
|---|
| 800 | } |
|---|
| 801 | |
|---|
| 802 | |
|---|
| 803 | #ifdef PHYML |
|---|
| 804 | printf(" U " |
|---|
| 805 | " Input tree (BIONJ/user tree) " |
|---|
| 806 | " %-15s \n", |
|---|
| 807 | (!input->inputtree)?("BIONJ"):("user tree")); |
|---|
| 808 | |
|---|
| 809 | printf(" O " |
|---|
| 810 | " Optimise tree topology " |
|---|
| 811 | " %-15s \n", |
|---|
| 812 | (input->mod->s_opt->opt_topo)?("yes"):("no")); |
|---|
| 813 | |
|---|
| 814 | |
|---|
| 815 | #endif |
|---|
| 816 | |
|---|
| 817 | #ifdef EVOLVE |
|---|
| 818 | strcpy(s,""); |
|---|
| 819 | (input->seq_len==-1)?((int)strcpy(s,"Reference data set length")):((int)sprintf(s,"l = %d",input->seq_len)); |
|---|
| 820 | |
|---|
| 821 | printf(" L " |
|---|
| 822 | " Sequence length " |
|---|
| 823 | " %-15s \n",s); |
|---|
| 824 | #elif PHYML |
|---|
| 825 | if(!input->mod->s_opt->opt_topo) |
|---|
| 826 | { |
|---|
| 827 | printf(" L " |
|---|
| 828 | " Optimise branch lengths & rate parameters " |
|---|
| 829 | " %-15s \n", |
|---|
| 830 | (input->mod->s_opt->opt_free_param)?("yes"):("no")); |
|---|
| 831 | } |
|---|
| 832 | else |
|---|
| 833 | { |
|---|
| 834 | printf(" L " |
|---|
| 835 | " Last optimisation step on numerical parameters " |
|---|
| 836 | " %-15s \n", |
|---|
| 837 | (input->mod->s_opt->last_opt)?("yes"):("no")); |
|---|
| 838 | } |
|---|
| 839 | |
|---|
| 840 | #endif |
|---|
| 841 | |
|---|
| 842 | |
|---|
| 843 | |
|---|
| 844 | printf("\n"); |
|---|
| 845 | |
|---|
| 846 | printf("\nAre these settings correct? " |
|---|
| 847 | "(type Y or letter for one to change) "); |
|---|
| 848 | |
|---|
| 849 | scanf("%c",&choix); |
|---|
| 850 | if(choix == '\n') choix = 'X'; |
|---|
| 851 | else getchar(); /* \n */ |
|---|
| 852 | |
|---|
| 853 | Uppercase(&choix); |
|---|
| 854 | |
|---|
| 855 | if ((choix == 'Y') || (choix == 'y')) |
|---|
| 856 | break; |
|---|
| 857 | |
|---|
| 858 | switch(choix) |
|---|
| 859 | { |
|---|
| 860 | |
|---|
| 861 | #ifdef PHYML |
|---|
| 862 | case 'B' : |
|---|
| 863 | { |
|---|
| 864 | if(input->mod->bootstrap > 0) input->mod->bootstrap = 0; |
|---|
| 865 | else |
|---|
| 866 | { |
|---|
| 867 | char *r; |
|---|
| 868 | char answer; |
|---|
| 869 | |
|---|
| 870 | |
|---|
| 871 | if(input->n_data_sets > 1) |
|---|
| 872 | Exit("\n. Bootstrap option is not allowed with multiple data sets\n"); |
|---|
| 873 | |
|---|
| 874 | printf("Number of replicates > "); |
|---|
| 875 | r = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 876 | Getstring_Stdin(r); |
|---|
| 877 | n_trial = 0; |
|---|
| 878 | while((!atoi(r)) || (atoi(r) < 0)) |
|---|
| 879 | { |
|---|
| 880 | if(++n_trial > 10) Exit("\nErr : the number of replicates must be a positive integer\n"); |
|---|
| 881 | printf("\nThe number of replicates must be a positive integer\n"); |
|---|
| 882 | printf("Enter a new value > "); |
|---|
| 883 | Getstring_Stdin(r); |
|---|
| 884 | } |
|---|
| 885 | input->mod->bootstrap = atoi(r); |
|---|
| 886 | |
|---|
| 887 | printf("Print bootstrap trees (and statistics) ? (%s) > ", |
|---|
| 888 | (input->print_boot_trees)?("Y/n"):("y/N")); |
|---|
| 889 | |
|---|
| 890 | scanf("%c",&answer); |
|---|
| 891 | if(answer == '\n') answer = (input->print_boot_trees)?('Y'):('N'); |
|---|
| 892 | else getchar(); |
|---|
| 893 | |
|---|
| 894 | switch(answer) |
|---|
| 895 | { |
|---|
| 896 | case 'Y' : case 'y' : |
|---|
| 897 | { |
|---|
| 898 | input->print_boot_trees = 1; |
|---|
| 899 | strcpy(r,input->seqfile); |
|---|
| 900 | input->fp_boot_tree = Openfile(strcat(r,"_phyml_boot_trees.txt"),1); |
|---|
| 901 | strcpy(r,input->seqfile); |
|---|
| 902 | input->fp_boot_stats = Openfile(strcat(r,"_phyml_boot_stats.txt"),1); |
|---|
| 903 | break; |
|---|
| 904 | } |
|---|
| 905 | case 'N' : case 'n' : |
|---|
| 906 | { |
|---|
| 907 | input->print_boot_trees = 0; |
|---|
| 908 | input->fp_boot_tree = NULL; |
|---|
| 909 | input->fp_boot_stats = NULL; |
|---|
| 910 | break; |
|---|
| 911 | } |
|---|
| 912 | } |
|---|
| 913 | Free(r); |
|---|
| 914 | } |
|---|
| 915 | break; |
|---|
| 916 | } |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | case 'U' : |
|---|
| 920 | { |
|---|
| 921 | if(!input->inputtree) |
|---|
| 922 | { |
|---|
| 923 | input->inputtree = 1; |
|---|
| 924 | printf("Enter the name of the tree file > "); |
|---|
| 925 | Getstring_Stdin(input->inputtreefile); |
|---|
| 926 | input->fp_input_tree = Openfile(input->inputtreefile,0); |
|---|
| 927 | } |
|---|
| 928 | else input->inputtree = 0; |
|---|
| 929 | break; |
|---|
| 930 | } |
|---|
| 931 | #endif |
|---|
| 932 | case 'O' : |
|---|
| 933 | { |
|---|
| 934 | input->mod->s_opt->opt_topo = |
|---|
| 935 | (input->mod->s_opt->opt_topo)?(0):(1); |
|---|
| 936 | break; // unintentional fallthrough fixed --ralf |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | case 'W' : |
|---|
| 940 | { |
|---|
| 941 | input->mod->s_opt->opt_rr_param = |
|---|
| 942 | (input->mod->s_opt->opt_rr_param)?(0):(1); |
|---|
| 943 | break; |
|---|
| 944 | } |
|---|
| 945 | |
|---|
| 946 | case 'K' : |
|---|
| 947 | { |
|---|
| 948 | int i,j; |
|---|
| 949 | char **rr_param,*rr; |
|---|
| 950 | model *mod; |
|---|
| 951 | int curr_param; |
|---|
| 952 | |
|---|
| 953 | if(input->mod->whichmodel == 8) |
|---|
| 954 | { |
|---|
| 955 | rr_param = (char **)mCalloc(5,sizeof(char *)); |
|---|
| 956 | For(i,5) rr_param[i] = (char *)mCalloc(10,sizeof(char)); |
|---|
| 957 | rr = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 958 | |
|---|
| 959 | mod = input->mod; |
|---|
| 960 | |
|---|
| 961 | n_trial = 0; |
|---|
| 962 | do |
|---|
| 963 | { |
|---|
| 964 | printf("Enter a new custom model > "); |
|---|
| 965 | Getstring_Stdin(input->mod->custom_mod_string); |
|---|
| 966 | if(strlen(input->mod->custom_mod_string) == 6) |
|---|
| 967 | { |
|---|
| 968 | For(i,6) |
|---|
| 969 | { |
|---|
| 970 | while(!isdigit((int)input->mod->custom_mod_string[i])) |
|---|
| 971 | { |
|---|
| 972 | if(++n_trial > 10) Exit("\nErr : this string is not valid !\n"); |
|---|
| 973 | printf("\nThis string is not valid\n"); |
|---|
| 974 | printf("Enter a new model > "); |
|---|
| 975 | Getstring_Stdin(input->mod->custom_mod_string); |
|---|
| 976 | } |
|---|
| 977 | } |
|---|
| 978 | if(i == 6) break; |
|---|
| 979 | } |
|---|
| 980 | else |
|---|
| 981 | { |
|---|
| 982 | printf("\nThe string should be of length 6\n"); |
|---|
| 983 | n_trial++; |
|---|
| 984 | } |
|---|
| 985 | }while(n_trial < 10); |
|---|
| 986 | if(n_trial == 10) Exit(""); |
|---|
| 987 | |
|---|
| 988 | Translate_Custom_Mod_String(input->mod); |
|---|
| 989 | |
|---|
| 990 | strcpy(rr_param[0],"A<->C"); |
|---|
| 991 | strcpy(rr_param[1],"A<->G"); |
|---|
| 992 | strcpy(rr_param[2],"A<->T"); |
|---|
| 993 | strcpy(rr_param[3],"C<->G"); |
|---|
| 994 | strcpy(rr_param[4],"C<->T"); |
|---|
| 995 | |
|---|
| 996 | printf("\nSet the relative rate values (G<->T is fixed to 1.0) \n"); |
|---|
| 997 | curr_param = 0; |
|---|
| 998 | For(i,mod->n_diff_rr_param) |
|---|
| 999 | { |
|---|
| 1000 | For(j,mod->n_rr_param_per_cat[i]) |
|---|
| 1001 | if(mod->rr_param_num[i][j] == 5) break; |
|---|
| 1002 | |
|---|
| 1003 | if(j == mod->n_rr_param_per_cat[i]) |
|---|
| 1004 | { |
|---|
| 1005 | printf("["); |
|---|
| 1006 | For(j,mod->n_rr_param_per_cat[i]) |
|---|
| 1007 | { |
|---|
| 1008 | printf("%s",rr_param[mod->rr_param_num[i][j]]); |
|---|
| 1009 | if(j<mod->n_rr_param_per_cat[i]-1) printf(" = "); |
|---|
| 1010 | } |
|---|
| 1011 | printf("]"); |
|---|
| 1012 | |
|---|
| 1013 | printf(" (current=%.2f) > ",mod->rr_param_values[i]); |
|---|
| 1014 | |
|---|
| 1015 | Getstring_Stdin(rr); |
|---|
| 1016 | |
|---|
| 1017 | if(rr[0] != '\0') |
|---|
| 1018 | { |
|---|
| 1019 | n_trial = 0; |
|---|
| 1020 | while((atof(rr) < .0)) |
|---|
| 1021 | { |
|---|
| 1022 | if(++n_trial > 10) |
|---|
| 1023 | Exit("\nErr : the value of this parameter must be a positive number\n"); |
|---|
| 1024 | printf("The value of this parameter must be a positive number\n"); |
|---|
| 1025 | printf("Enter a new value > "); |
|---|
| 1026 | Getstring_Stdin(rr); |
|---|
| 1027 | } |
|---|
| 1028 | input->mod->rr_param_values[curr_param] = (double)atof(rr); |
|---|
| 1029 | } |
|---|
| 1030 | For(j,mod->n_rr_param_per_cat[i]) |
|---|
| 1031 | mod->rr_param[mod->rr_param_num[i][j]] = |
|---|
| 1032 | mod->rr_param_values+curr_param; |
|---|
| 1033 | curr_param++; |
|---|
| 1034 | } |
|---|
| 1035 | else |
|---|
| 1036 | { |
|---|
| 1037 | For(j,mod->n_rr_param_per_cat[i]) |
|---|
| 1038 | mod->rr_param_values[mod->rr_param_num[i][j]] = 1.0; |
|---|
| 1039 | For(j,mod->n_rr_param_per_cat[i]) |
|---|
| 1040 | mod->rr_param[mod->rr_param_num[i][j]] = |
|---|
| 1041 | mod->rr_param_values+5; |
|---|
| 1042 | } |
|---|
| 1043 | } |
|---|
| 1044 | |
|---|
| 1045 | For(i,5) Free(rr_param[i]); |
|---|
| 1046 | Free(rr_param); |
|---|
| 1047 | Free(rr); |
|---|
| 1048 | } |
|---|
| 1049 | break; |
|---|
| 1050 | } |
|---|
| 1051 | |
|---|
| 1052 | case 'F' : |
|---|
| 1053 | { |
|---|
| 1054 | int i; |
|---|
| 1055 | |
|---|
| 1056 | if(input->mod->whichmodel == 8) |
|---|
| 1057 | { |
|---|
| 1058 | if(input->mod->user_b_freq[0] >= .0) |
|---|
| 1059 | For(i,4) input->mod->user_b_freq[i] = -1.; |
|---|
| 1060 | else |
|---|
| 1061 | { |
|---|
| 1062 | char **bases; |
|---|
| 1063 | char *bs; |
|---|
| 1064 | double sum; |
|---|
| 1065 | |
|---|
| 1066 | bases = (char **)mCalloc(4,sizeof(char *)); |
|---|
| 1067 | For(i,4) bases[i] = (char *)mCalloc(50,sizeof(char)); |
|---|
| 1068 | bs = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1069 | |
|---|
| 1070 | strcpy(bases[0],"f(A) > "); |
|---|
| 1071 | strcpy(bases[1],"f(C) > "); |
|---|
| 1072 | strcpy(bases[2],"f(G) > "); |
|---|
| 1073 | strcpy(bases[3],"f(T) > "); |
|---|
| 1074 | |
|---|
| 1075 | printf("Set nucleotide frequencies \n"); |
|---|
| 1076 | sum = .0; |
|---|
| 1077 | For(i,4) |
|---|
| 1078 | { |
|---|
| 1079 | printf("%s",bases[i]); |
|---|
| 1080 | |
|---|
| 1081 | Getstring_Stdin(bs); |
|---|
| 1082 | |
|---|
| 1083 | n_trial = 0; |
|---|
| 1084 | |
|---|
| 1085 | while((atof(bs) < .0001) || |
|---|
| 1086 | (bs[0] == '\0')) |
|---|
| 1087 | { |
|---|
| 1088 | if(++n_trial > 10) |
|---|
| 1089 | Exit("\nErr : the value of this parameter must be a positive number\n"); |
|---|
| 1090 | printf("The value of this parameter must be a positive number\n"); |
|---|
| 1091 | printf("Enter a new value > "); |
|---|
| 1092 | Getstring_Stdin(bs); |
|---|
| 1093 | } |
|---|
| 1094 | input->mod->user_b_freq[i] = (double)atof(bs); |
|---|
| 1095 | sum += input->mod->user_b_freq[i]; |
|---|
| 1096 | } |
|---|
| 1097 | |
|---|
| 1098 | For(i,4) |
|---|
| 1099 | { |
|---|
| 1100 | input->mod->user_b_freq[i] /= sum; |
|---|
| 1101 | } |
|---|
| 1102 | |
|---|
| 1103 | For(i,4) Free(bases[i]); |
|---|
| 1104 | Free(bases); |
|---|
| 1105 | Free(bs); |
|---|
| 1106 | } |
|---|
| 1107 | } |
|---|
| 1108 | break; |
|---|
| 1109 | } |
|---|
| 1110 | |
|---|
| 1111 | case 'E' : |
|---|
| 1112 | { |
|---|
| 1113 | if((input->mod->whichmodel > 10) || |
|---|
| 1114 | (input->mod->whichmodel < 3)) Exit("\n. Invalid choice...\n"); |
|---|
| 1115 | input->mod->s_opt->opt_bfreq = (input->mod->s_opt->opt_bfreq)?(0):(1); |
|---|
| 1116 | break; |
|---|
| 1117 | } |
|---|
| 1118 | |
|---|
| 1119 | case 'D' : |
|---|
| 1120 | { |
|---|
| 1121 | if(input->mod->datatype == NT) |
|---|
| 1122 | { |
|---|
| 1123 | input->mod->datatype = 1; |
|---|
| 1124 | input->mod->stepsize = 1; |
|---|
| 1125 | input->mod->ns = 20; |
|---|
| 1126 | input->mod->whichmodel = 12; |
|---|
| 1127 | strcpy(input->modelname,"JTT"); |
|---|
| 1128 | } |
|---|
| 1129 | else |
|---|
| 1130 | { |
|---|
| 1131 | input->mod->ns = 4; |
|---|
| 1132 | input->mod->datatype = 0; |
|---|
| 1133 | input->mod->stepsize = 1; |
|---|
| 1134 | input->mod->whichmodel = 4; |
|---|
| 1135 | strcpy(input->modelname,"HKY"); |
|---|
| 1136 | strcpy(input->nt_or_cd,"nucleotides"); |
|---|
| 1137 | } |
|---|
| 1138 | break; |
|---|
| 1139 | } |
|---|
| 1140 | |
|---|
| 1141 | case 'M' : |
|---|
| 1142 | { |
|---|
| 1143 | if(input->mod->datatype == NT) |
|---|
| 1144 | { |
|---|
| 1145 | if(!strcmp(input->nt_or_cd,"nucleotides")) |
|---|
| 1146 | { |
|---|
| 1147 | if(input->mod->whichmodel == 1) |
|---|
| 1148 | { |
|---|
| 1149 | input->mod->whichmodel = 2; |
|---|
| 1150 | strcpy(input->modelname,"K2P"); |
|---|
| 1151 | } |
|---|
| 1152 | else if(input->mod->whichmodel == 2) |
|---|
| 1153 | { |
|---|
| 1154 | input->mod->whichmodel = 3; |
|---|
| 1155 | strcpy(input->modelname,"F81"); |
|---|
| 1156 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1157 | } |
|---|
| 1158 | else if(input->mod->whichmodel == 3) |
|---|
| 1159 | { |
|---|
| 1160 | input->mod->whichmodel = 4; |
|---|
| 1161 | strcpy(input->modelname,"HKY"); |
|---|
| 1162 | } |
|---|
| 1163 | else if(input->mod->whichmodel == 4) |
|---|
| 1164 | { |
|---|
| 1165 | input->mod->whichmodel = 5; |
|---|
| 1166 | strcpy(input->modelname,"F84"); |
|---|
| 1167 | } |
|---|
| 1168 | else if(input->mod->whichmodel == 5) |
|---|
| 1169 | { |
|---|
| 1170 | input->mod->whichmodel = 6; |
|---|
| 1171 | strcpy(input->modelname,"TN93"); |
|---|
| 1172 | if(input->mod->s_opt->opt_kappa) input->mod->s_opt->opt_lambda = 1; |
|---|
| 1173 | } |
|---|
| 1174 | else if(input->mod->whichmodel == 6) |
|---|
| 1175 | { |
|---|
| 1176 | input->mod->whichmodel = 7; |
|---|
| 1177 | strcpy(input->modelname,"GTR"); |
|---|
| 1178 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1179 | } |
|---|
| 1180 | else if(input->mod->whichmodel == 7) |
|---|
| 1181 | { |
|---|
| 1182 | input->mod->whichmodel = 8; |
|---|
| 1183 | strcpy(input->modelname,"custom"); |
|---|
| 1184 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1185 | } |
|---|
| 1186 | |
|---|
| 1187 | else if(input->mod->whichmodel == 8) |
|---|
| 1188 | { |
|---|
| 1189 | input->mod->whichmodel = 1; |
|---|
| 1190 | strcpy(input->modelname,"JC69"); |
|---|
| 1191 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1192 | } |
|---|
| 1193 | } |
|---|
| 1194 | } |
|---|
| 1195 | else |
|---|
| 1196 | { |
|---|
| 1197 | if(input->mod->whichmodel == 11) |
|---|
| 1198 | { |
|---|
| 1199 | input->mod->whichmodel = 12; |
|---|
| 1200 | strcpy(input->modelname,"JTT"); |
|---|
| 1201 | } |
|---|
| 1202 | else if(input->mod->whichmodel == 12) |
|---|
| 1203 | { |
|---|
| 1204 | input->mod->whichmodel = 13; |
|---|
| 1205 | strcpy(input->modelname,"MtREV"); |
|---|
| 1206 | } |
|---|
| 1207 | else if(input->mod->whichmodel == 13) |
|---|
| 1208 | { |
|---|
| 1209 | input->mod->whichmodel = 14; |
|---|
| 1210 | strcpy(input->modelname,"WAG"); |
|---|
| 1211 | } |
|---|
| 1212 | else if(input->mod->whichmodel == 14) |
|---|
| 1213 | { |
|---|
| 1214 | input->mod->whichmodel = 15; |
|---|
| 1215 | strcpy(input->modelname,"DCMut"); |
|---|
| 1216 | } |
|---|
| 1217 | else if(input->mod->whichmodel == 15) |
|---|
| 1218 | { |
|---|
| 1219 | input->mod->whichmodel = 16; |
|---|
| 1220 | strcpy(input->modelname,"RtREV"); |
|---|
| 1221 | } |
|---|
| 1222 | else if(input->mod->whichmodel == 16) |
|---|
| 1223 | { |
|---|
| 1224 | input->mod->whichmodel = 17; |
|---|
| 1225 | strcpy(input->modelname,"CpREV"); |
|---|
| 1226 | } |
|---|
| 1227 | else if(input->mod->whichmodel == 17) |
|---|
| 1228 | { |
|---|
| 1229 | input->mod->whichmodel = 18; |
|---|
| 1230 | strcpy(input->modelname,"VT"); |
|---|
| 1231 | } |
|---|
| 1232 | else if(input->mod->whichmodel == 18) |
|---|
| 1233 | { |
|---|
| 1234 | input->mod->whichmodel = 19; |
|---|
| 1235 | strcpy(input->modelname,"Blosum62"); |
|---|
| 1236 | } |
|---|
| 1237 | else if(input->mod->whichmodel == 19) |
|---|
| 1238 | { |
|---|
| 1239 | input->mod->whichmodel = 20; |
|---|
| 1240 | strcpy(input->modelname,"MtMam"); |
|---|
| 1241 | } |
|---|
| 1242 | else if(input->mod->whichmodel == 20) |
|---|
| 1243 | { |
|---|
| 1244 | input->mod->whichmodel = 11; |
|---|
| 1245 | strcpy(input->modelname,"Dayhoff"); |
|---|
| 1246 | } |
|---|
| 1247 | } |
|---|
| 1248 | break; |
|---|
| 1249 | } |
|---|
| 1250 | |
|---|
| 1251 | case 'R' : |
|---|
| 1252 | { |
|---|
| 1253 | (input->mod->n_catg == 1)?(input->mod->n_catg = 4):(input->mod->n_catg = 1); |
|---|
| 1254 | break; |
|---|
| 1255 | } |
|---|
| 1256 | |
|---|
| 1257 | case 'C' : |
|---|
| 1258 | { |
|---|
| 1259 | char *c; |
|---|
| 1260 | printf("Enter your number of categories > "); |
|---|
| 1261 | c = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1262 | Getstring_Stdin(c); |
|---|
| 1263 | n_trial = 0; |
|---|
| 1264 | while((!atoi(c)) || (atoi(c) < 0)) |
|---|
| 1265 | { |
|---|
| 1266 | if(++n_trial > 10) Exit("\nErr : the number of categories must be a positive integer\n"); |
|---|
| 1267 | printf("\nThe number of categories must be a positive integer\n"); |
|---|
| 1268 | printf("Enter a new value > "); |
|---|
| 1269 | Getstring_Stdin(c); |
|---|
| 1270 | } |
|---|
| 1271 | input->mod->n_catg = atoi(c); |
|---|
| 1272 | Free(c); |
|---|
| 1273 | break; |
|---|
| 1274 | } |
|---|
| 1275 | |
|---|
| 1276 | |
|---|
| 1277 | case 'A' : |
|---|
| 1278 | { |
|---|
| 1279 | char answer; |
|---|
| 1280 | |
|---|
| 1281 | switch(input->mod->s_opt->opt_alpha) |
|---|
| 1282 | { |
|---|
| 1283 | case 0 : |
|---|
| 1284 | { |
|---|
| 1285 | printf("Optimise alpha ? [Y/n] "); |
|---|
| 1286 | scanf("%c",&answer); |
|---|
| 1287 | if(answer == '\n') answer = 'Y'; |
|---|
| 1288 | else getchar(); |
|---|
| 1289 | break; |
|---|
| 1290 | } |
|---|
| 1291 | case 1 : |
|---|
| 1292 | { |
|---|
| 1293 | printf("Optimise alpha ? [N/y] "); |
|---|
| 1294 | scanf("%c",&answer); |
|---|
| 1295 | if(answer == '\n') answer = 'N'; |
|---|
| 1296 | else getchar(); |
|---|
| 1297 | break; |
|---|
| 1298 | } |
|---|
| 1299 | default : Exit("\n"); |
|---|
| 1300 | } |
|---|
| 1301 | |
|---|
| 1302 | n_trial = 0; |
|---|
| 1303 | while((answer != 'Y') && (answer != 'y') && |
|---|
| 1304 | (answer != 'N') && (answer != 'n')) |
|---|
| 1305 | { |
|---|
| 1306 | if(++n_trial > 10) Exit("\nErr : wrong answers !"); |
|---|
| 1307 | printf("Optimise alpha ? [N/y] "); |
|---|
| 1308 | scanf("%c",&answer); |
|---|
| 1309 | if(answer == '\n') answer = 'N'; |
|---|
| 1310 | else getchar(); |
|---|
| 1311 | } |
|---|
| 1312 | |
|---|
| 1313 | switch(answer) |
|---|
| 1314 | { |
|---|
| 1315 | case 'Y' : case 'y' : |
|---|
| 1316 | { |
|---|
| 1317 | input->mod->s_opt->opt_alpha = 1; |
|---|
| 1318 | input->mod->s_opt->opt_free_param = 1; |
|---|
| 1319 | break; |
|---|
| 1320 | } |
|---|
| 1321 | case 'N' : case 'n' : |
|---|
| 1322 | { |
|---|
| 1323 | char *a; |
|---|
| 1324 | a = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1325 | input->mod->alpha = 10.0; |
|---|
| 1326 | input->mod->s_opt->opt_alpha = 0; |
|---|
| 1327 | printf("Enter your value of alpha > "); |
|---|
| 1328 | Getstring_Stdin(a); |
|---|
| 1329 | n_trial = 0; |
|---|
| 1330 | while((!atof(a)) || (atof(a) < .0)) |
|---|
| 1331 | { |
|---|
| 1332 | if(++n_trial > 10) Exit("\nErr : alpha must be a positive number\n"); |
|---|
| 1333 | printf("Alpha must be a positive number\n"); |
|---|
| 1334 | printf("Enter a new value > "); |
|---|
| 1335 | Getstring_Stdin(a); |
|---|
| 1336 | } |
|---|
| 1337 | input->mod->alpha = (double)atof(a); |
|---|
| 1338 | Free(a); |
|---|
| 1339 | input->mod->s_opt->opt_alpha = 0; |
|---|
| 1340 | break; |
|---|
| 1341 | } |
|---|
| 1342 | } |
|---|
| 1343 | break; |
|---|
| 1344 | } |
|---|
| 1345 | |
|---|
| 1346 | case 'T' : |
|---|
| 1347 | { |
|---|
| 1348 | char answer; |
|---|
| 1349 | |
|---|
| 1350 | if((input->mod->datatype) || |
|---|
| 1351 | (input->mod->whichmodel == 1) || |
|---|
| 1352 | (input->mod->whichmodel == 3) || |
|---|
| 1353 | (input->mod->whichmodel == 7)) |
|---|
| 1354 | Exit("\n 'T' is not a valid choice for this model\n"); |
|---|
| 1355 | |
|---|
| 1356 | switch(input->mod->s_opt->opt_kappa) |
|---|
| 1357 | { |
|---|
| 1358 | case 0 : |
|---|
| 1359 | { |
|---|
| 1360 | printf("Optimise ts/tv ratio ? [Y/n] "); |
|---|
| 1361 | scanf("%c", &answer); |
|---|
| 1362 | if(answer == '\n') answer = 'Y'; |
|---|
| 1363 | else getchar(); |
|---|
| 1364 | break; |
|---|
| 1365 | } |
|---|
| 1366 | case 1 : |
|---|
| 1367 | { |
|---|
| 1368 | printf("Optimise ts/tv ratio ? [N/y] "); |
|---|
| 1369 | scanf("%c", &answer); |
|---|
| 1370 | if(answer == '\n') answer = 'N'; |
|---|
| 1371 | else getchar(); |
|---|
| 1372 | break; |
|---|
| 1373 | } |
|---|
| 1374 | default : Exit("\n"); |
|---|
| 1375 | } |
|---|
| 1376 | |
|---|
| 1377 | n_trial = 0; |
|---|
| 1378 | while((answer != 'Y') && (answer != 'y') && |
|---|
| 1379 | (answer != 'N') && (answer != 'n')) |
|---|
| 1380 | { |
|---|
| 1381 | if(++n_trial > 10) Exit("\nErr : wrong answers !"); |
|---|
| 1382 | printf("Optimise ts/tv ratio ? [N/y] "); |
|---|
| 1383 | scanf("%c", &answer); |
|---|
| 1384 | if(answer == '\n') answer = 'N'; |
|---|
| 1385 | else getchar(); |
|---|
| 1386 | } |
|---|
| 1387 | |
|---|
| 1388 | switch(answer) |
|---|
| 1389 | { |
|---|
| 1390 | case 'Y' : case 'y' : |
|---|
| 1391 | { |
|---|
| 1392 | input->mod->kappa = 4.0; |
|---|
| 1393 | input->mod->s_opt->opt_free_param = 1; |
|---|
| 1394 | input->mod->s_opt->opt_kappa = 1; |
|---|
| 1395 | input->mod->s_opt->opt_kappa = 1; |
|---|
| 1396 | if(input->mod->whichmodel == 6) |
|---|
| 1397 | input->mod->s_opt->opt_lambda = 1; |
|---|
| 1398 | break; |
|---|
| 1399 | } |
|---|
| 1400 | case 'N' : case 'n' : |
|---|
| 1401 | { |
|---|
| 1402 | char *t; |
|---|
| 1403 | t = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1404 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1405 | printf("Enter your value of the ts/tv ratio > "); |
|---|
| 1406 | Getstring_Stdin(t); |
|---|
| 1407 | n_trial = 0; |
|---|
| 1408 | while((!atof(t)) || (atof(t) < .0)) |
|---|
| 1409 | { |
|---|
| 1410 | if(++n_trial > 10) Exit("\nErr : the ts/tv ratio must be a positive number\n"); |
|---|
| 1411 | printf("The ratio must be a positive number\n"); |
|---|
| 1412 | printf("Enter a new value > "); |
|---|
| 1413 | Getstring_Stdin(t); |
|---|
| 1414 | } |
|---|
| 1415 | input->mod->kappa = (double)atof(t); |
|---|
| 1416 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1417 | input->mod->s_opt->opt_lambda = 0; |
|---|
| 1418 | Free(t); |
|---|
| 1419 | break; |
|---|
| 1420 | } |
|---|
| 1421 | } |
|---|
| 1422 | break; |
|---|
| 1423 | } |
|---|
| 1424 | |
|---|
| 1425 | case 'I' : |
|---|
| 1426 | { |
|---|
| 1427 | if(input->interleaved) |
|---|
| 1428 | input->interleaved = 0; |
|---|
| 1429 | else input->interleaved = 1; |
|---|
| 1430 | break; |
|---|
| 1431 | } |
|---|
| 1432 | |
|---|
| 1433 | case 'S' : |
|---|
| 1434 | { |
|---|
| 1435 | char *c; |
|---|
| 1436 | |
|---|
| 1437 | printf("How many data sets > "); |
|---|
| 1438 | c = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1439 | Getstring_Stdin(c); |
|---|
| 1440 | n_trial = 0; |
|---|
| 1441 | while((!atoi(c)) || (atoi(c) < 0)) |
|---|
| 1442 | { |
|---|
| 1443 | if(++n_trial > 10) Exit("\nErr : The number of data sets must be a positive integer\n"); |
|---|
| 1444 | printf("\nThe number of data sets must be a positive integer\n"); |
|---|
| 1445 | printf("Enter a new value > "); |
|---|
| 1446 | Getstring_Stdin(c); |
|---|
| 1447 | } |
|---|
| 1448 | input->n_data_sets = atoi(c); |
|---|
| 1449 | |
|---|
| 1450 | if((input->mod->bootstrap > 1) && (input->n_data_sets > 1)) |
|---|
| 1451 | Exit("\n. Bootstrap option is not allowed with multiple data sets\n"); |
|---|
| 1452 | |
|---|
| 1453 | Free(c); |
|---|
| 1454 | break; |
|---|
| 1455 | } |
|---|
| 1456 | |
|---|
| 1457 | case 'V' : |
|---|
| 1458 | { |
|---|
| 1459 | char answer; |
|---|
| 1460 | |
|---|
| 1461 | switch(input->mod->s_opt->opt_pinvar) |
|---|
| 1462 | { |
|---|
| 1463 | case 0 : |
|---|
| 1464 | { |
|---|
| 1465 | printf("Optimise p-invar ? [Y/n] "); |
|---|
| 1466 | scanf("%c", &answer); |
|---|
| 1467 | if(answer == '\n') answer = 'Y'; |
|---|
| 1468 | else getchar(); |
|---|
| 1469 | break; |
|---|
| 1470 | } |
|---|
| 1471 | case 1 : |
|---|
| 1472 | { |
|---|
| 1473 | printf("Optimise p-invar ? [N/y] "); |
|---|
| 1474 | scanf("%c", &answer); |
|---|
| 1475 | if(answer == '\n') answer = 'N'; |
|---|
| 1476 | else getchar(); |
|---|
| 1477 | break; |
|---|
| 1478 | } |
|---|
| 1479 | default : Exit("\n"); |
|---|
| 1480 | } |
|---|
| 1481 | |
|---|
| 1482 | n_trial = 0; |
|---|
| 1483 | while((answer != 'Y') && (answer != 'y') && |
|---|
| 1484 | (answer != 'N') && (answer != 'n')) |
|---|
| 1485 | { |
|---|
| 1486 | if(++n_trial > 10) Exit("\nErr : wrong answers !"); |
|---|
| 1487 | printf("Optimise p-invar ? [N/y] "); |
|---|
| 1488 | scanf("%c", &answer); |
|---|
| 1489 | if(answer == '\n') answer = 'N'; |
|---|
| 1490 | else getchar(); |
|---|
| 1491 | } |
|---|
| 1492 | |
|---|
| 1493 | switch(answer) |
|---|
| 1494 | { |
|---|
| 1495 | case 'Y' : case 'y' : |
|---|
| 1496 | { |
|---|
| 1497 | input->mod->s_opt->opt_free_param = 1; |
|---|
| 1498 | input->mod->s_opt->opt_pinvar = 1; |
|---|
| 1499 | input->mod->pinvar = 0.2; |
|---|
| 1500 | input->mod->invar = 1; |
|---|
| 1501 | break; |
|---|
| 1502 | } |
|---|
| 1503 | case 'N' : case 'n' : |
|---|
| 1504 | { |
|---|
| 1505 | char *p; |
|---|
| 1506 | p = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1507 | printf("Enter your value of p-invar > "); |
|---|
| 1508 | Getstring_Stdin(p); |
|---|
| 1509 | n_trial = 0; |
|---|
| 1510 | while((atof(p) < 0.0) || (atof(p) > 1.0)) |
|---|
| 1511 | { |
|---|
| 1512 | if(++n_trial > 10) |
|---|
| 1513 | Exit("\nErr : the proportion of invariable sites must be a positive number between 0.0 and 1.0\n"); |
|---|
| 1514 | printf("The proportion must be a positive number between 0.0 and 1.0\n"); |
|---|
| 1515 | printf("Enter a new value > "); |
|---|
| 1516 | Getstring_Stdin(p); |
|---|
| 1517 | } |
|---|
| 1518 | input->mod->pinvar = (double)atof(p); |
|---|
| 1519 | |
|---|
| 1520 | if(input->mod->pinvar > 0.0+MDBL_MIN) input->mod->invar = 1; |
|---|
| 1521 | else input->mod->invar = 0; |
|---|
| 1522 | |
|---|
| 1523 | Free(p); |
|---|
| 1524 | |
|---|
| 1525 | input->mod->s_opt->opt_pinvar = 0; |
|---|
| 1526 | break; |
|---|
| 1527 | } |
|---|
| 1528 | } |
|---|
| 1529 | break; |
|---|
| 1530 | } |
|---|
| 1531 | |
|---|
| 1532 | #ifdef EVOLVE |
|---|
| 1533 | case 'L' : |
|---|
| 1534 | { |
|---|
| 1535 | char *len; |
|---|
| 1536 | len = (char *)mCalloc(T_MAX_LINE,sizeof(char)); |
|---|
| 1537 | printf("Enter the sequence length > "); |
|---|
| 1538 | Getstring_Stdin(len); |
|---|
| 1539 | n_trial = 0; |
|---|
| 1540 | while((!atof(len)) || (atof(len) < 0.0-MDBL_MIN)) |
|---|
| 1541 | { |
|---|
| 1542 | if(++n_trial > 10) |
|---|
| 1543 | Exit("\nErr : sequence length must be a positive integer \n"); |
|---|
| 1544 | printf("Sequence length must be a positive integer \n"); |
|---|
| 1545 | printf("Enter a new value > "); |
|---|
| 1546 | Getstring_Stdin(len); |
|---|
| 1547 | } |
|---|
| 1548 | input->seq_len = (double)atoi(len); |
|---|
| 1549 | Free(len); |
|---|
| 1550 | break; |
|---|
| 1551 | } |
|---|
| 1552 | #elif PHYML |
|---|
| 1553 | case 'L' : |
|---|
| 1554 | { |
|---|
| 1555 | if(!input->mod->s_opt->opt_topo) |
|---|
| 1556 | { |
|---|
| 1557 | input->mod->s_opt->opt_free_param = |
|---|
| 1558 | (input->mod->s_opt->opt_free_param)?(0):(1); |
|---|
| 1559 | |
|---|
| 1560 | if(!input->mod->s_opt->opt_free_param) |
|---|
| 1561 | { |
|---|
| 1562 | input->mod->s_opt->opt_alpha = 0; |
|---|
| 1563 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1564 | input->mod->s_opt->opt_lambda = 0; |
|---|
| 1565 | input->mod->s_opt->opt_bl = 0; |
|---|
| 1566 | input->mod->s_opt->opt_pinvar = 0; |
|---|
| 1567 | input->mod->s_opt->opt_rr_param = 0; |
|---|
| 1568 | input->mod->s_opt->opt_topo = 0; |
|---|
| 1569 | } |
|---|
| 1570 | } |
|---|
| 1571 | else |
|---|
| 1572 | { |
|---|
| 1573 | input->mod->s_opt->last_opt = |
|---|
| 1574 | (input->mod->s_opt->last_opt)?(0):(1); |
|---|
| 1575 | } |
|---|
| 1576 | break; |
|---|
| 1577 | } |
|---|
| 1578 | |
|---|
| 1579 | #endif |
|---|
| 1580 | |
|---|
| 1581 | default : |
|---|
| 1582 | { |
|---|
| 1583 | printf("Not a valid choice\n"); |
|---|
| 1584 | break; |
|---|
| 1585 | } |
|---|
| 1586 | } |
|---|
| 1587 | }while(1); |
|---|
| 1588 | |
|---|
| 1589 | if((input->mod->whichmodel == 1) || (input->mod->whichmodel == 3)) |
|---|
| 1590 | { |
|---|
| 1591 | input->mod->s_opt->opt_kappa = 0; |
|---|
| 1592 | input->mod->s_opt->opt_lambda = 0; |
|---|
| 1593 | } |
|---|
| 1594 | |
|---|
| 1595 | if(input->mod->whichmodel != 6) input->mod->s_opt->opt_lambda = 0; |
|---|
| 1596 | |
|---|
| 1597 | |
|---|
| 1598 | Free(s); |
|---|
| 1599 | Free(buff); |
|---|
| 1600 | |
|---|
| 1601 | } |
|---|
| 1602 | |
|---|
| 1603 | /*********************************************************/ |
|---|