source: branches/profile/GDE/PHYML/options.c

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