Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / tcoffee / t_coffee_source / fastal_opt_parsing.c
1
2 #include "string.h"
3 #include "stdio.h"
4 #include "stdlib.h"
5 #include "fastal_lib_header.h"
6
7
8 void
9 tree_parse(struct Fastal_arguments *arguments, char* param)
10 {
11         char delims[] = "";
12         arguments->tree_method = strtok(param,delims);
13         if (arguments->tree_method == "parttree")
14         {
15                 arguments->tree_param1 = 6;
16                 arguments->tree_param2 = 150;
17         }
18         char *tmp = strtok(NULL,delims);
19         if (tmp != NULL)
20         {
21                 arguments->tree_param1 = atoi(tmp);
22                 arguments->tree_param2 = atoi(strtok(NULL,delims));
23         }
24 //      printf("A: %s %i %i", arguments->tree_method, arguments->tree_param1, arguments->tree_param2);
25 }
26
27
28
29 void
30 arg_parse (int argc, char **argv, struct Fastal_arguments *arguments)
31 {
32 //      default values
33
34         arguments->diag_method = "blast";
35         arguments->output_file = "out->aln";
36         arguments->tree_file = NULL;
37         arguments->gep = -1;
38         arguments->gop = -10;
39         arguments->method = "fast";
40         arguments->tree_method = "oligotree";
41         arguments->mat="dna_idmat";
42         arguments->tree_only = 0;
43         arguments->evaluate = 0;
44         arguments->score = 0;
45 //      arguments->retree = 0;
46         arguments->agreement_score = 0;
47         arguments->num_ref_aln = 0;
48         arguments->is_dna = 1;
49         arguments->aln_ref = NULL;
50         arguments->aln2test = NULL;
51         arguments->tree_out = 0;
52         arguments->gap_iterate = 0;
53
54
55         int i = 1;
56         char *param;
57
58         for (i = 0; i < argc; ++i)
59         {
60                 param = argv[i];
61                 if ( ( !strcmp(param, "-d" )) || ( !strcmp(param, "--is_dna")))
62                 {
63                         arguments->is_dna = 1;
64                         arguments->mat = "dna_idmat";
65                 }
66                 else if ( ( !strcmp(param, "-a" )) || ( !strcmp(param, "--is_aa")))
67                 {
68                         arguments->is_dna = 0;
69                         arguments->mat = "blosum62mt";
70
71                 }
72 //              printf("%s\n", arguments->mat);
73         }
74         if (arguments->is_dna)
75         {
76                 arguments->tree_param1 = 2;
77                 arguments->tree_param2 = 5;
78         }
79         else
80         {
81                 arguments->tree_param1 = 1;
82                 arguments->tree_param2 = 10;
83         }
84
85
86         i = 1;
87         while (i < argc)
88         {
89                 param = argv[i];
90                 if ( ( !strcmp(param, "-i" )) || ( !strcmp(param, "--in")))
91                 {
92                         arguments->sequence_file = argv[++i];
93                 }
94                 else if ( ( !strcmp(param, "-t" )) || ( !strcmp(param, "--tree_file")))
95                 {
96                         arguments->tree_file = argv[++i];
97                 }
98                 else if ( !strcmp(param, "--mat"))
99                 {
100                         arguments->mat = argv[++i];
101                 }
102                 else if ( !strcmp(param, "--tree_method"))
103                 {
104                         tree_parse(arguments, argv[++i]);
105 //                      arguments->tree_file = argv[++i];
106                 }
107                 else if ( ( !strcmp(param, "-o" )) || ( !strcmp(param, "--outfile")))
108                 {
109                         arguments->output_file = argv[++i];
110                 }
111                 else if ( ( !strcmp(param, "-m" )) || ( !strcmp(param, "--method")))
112                 {
113                         ++i;
114                         if ( (!strcmp(argv[i], "fast")) || (!strcmp(argv[i], "nw")) || (!strcmp(argv[i], "gotoh")) ||  (!strcmp(argv[i], "udisc")) )
115                                 arguments->method = argv[i];
116                         else
117                         {
118                                 printf("Method %s unknown\n", argv[i]);
119                                 exit(1);
120                         }
121                 }
122                 else if ( ( !strcmp(param, "-b" )) || ( !strcmp(param, "--diag_method")))
123                 {
124                         ++i;
125                         if ( (!strcmp(argv[i], "blast")) || (!strcmp(argv[i], "blastz")) || (!strcmp(argv[i], "blat")) || (!strcmp(argv[i], "ktup")))
126                                 arguments->diag_method = argv[i];
127                         else
128                         {
129                                 printf("DIAG Method %s unknown\n", argv[i]);
130                                 exit(1);
131                         }
132                 }
133                 else if ( ( !strcmp(param, "-d" )) || ( !strcmp(param, "--is_dna")))
134                 {
135                         arguments->is_dna = 1;
136                 }
137                 else if ( ( !strcmp(param, "-a" )) || ( !strcmp(param, "--is_aa")))
138                 {
139                         arguments->is_dna = 0;
140                 }
141                 else if ( ( !strcmp(param, "-g" )) || ( !strcmp(param, "--gop")))
142                 {
143                         arguments->gop = atof(argv[++i]);
144                 }
145 //              else if ( ( !strcmp(param, "-r" )) || ( !strcmp(param, "--retree")))
146 //              {
147 //                      arguments->retree = atoi(argv[++i]);
148 //              }
149                 else if ( ( !strcmp(param, "-e" )) || ( !strcmp(param, "--gep")))
150                 {
151                         arguments->gep = atof(argv[++i]);
152                 }
153                 else if ( ( !strcmp(param, "-k" )) || ( !strcmp(param, "--p1")))
154                 {
155                         arguments->tree_param1 = atoi(argv[++i]);
156                 }
157                 else if ( ( !strcmp(param, "-c" )) || ( !strcmp(param, "--p2")))
158                 {
159                         arguments->tree_param2 = atoi(argv[++i]);
160                 }
161                 else if ( !strcmp(param, "--eval_aln"))
162                 {
163                         arguments->evaluate = 1;
164                 }
165                 else if ( ( !strcmp(param, "-s" )) || ( !strcmp(param, "--score")))
166                 {
167                         arguments->score = 1;
168                 }
169                 else if ( !strcmp(param, "--tree_out"))
170                 {
171                         arguments->tree_out = 1;
172                 }
173                 else if ( !strcmp(param, "--tree_only"))
174                 {
175                         arguments->tree_only = 1;
176                 }
177                 else if ( !strcmp(param, "--agreement_score"))
178                 {
179                         arguments->agreement_score = 1;
180                 }
181                 else if ( !strcmp(param, "--make_ref_aln"))
182                 {
183                         arguments->num_ref_aln = atoi(argv[++i]);
184                         arguments->num_seq_in_ref = atoi(argv[++i]);
185                 }
186                 else if ( !strcmp(param, "--aln_ref"))
187                 {
188                         arguments->aln_ref = argv[++i];
189                 }
190                 else if ( !strcmp(param, "--gap_iterate"))
191                 {
192                         arguments->gap_iterate = atoi(argv[++i]);
193                 }
194                 else if ( !strcmp(param, "--aln2test"))
195                 {
196                         arguments->aln2test = argv[++i];
197                 }
198                 else if ( ( !strcmp(param, "-h" )) || ( !strcmp(param, "--help")) || ( !strcmp(param, "-?" )))
199                 {
200                         printf("Fastal - a fast alignment tool\n");
201                         printf("-i    --in              The sequence_file\n");
202                         printf("-t    --tree_file       The treefile\n");
203                         printf("      --tree_method     The method to produce the tree:\n");
204                         printf("                        oligo - very fast method\n");
205                         printf("                        parttree - method like in mafft\n");
206                         printf("-o    --outfile         The output file\n");
207                         printf("-m    --method          The method to use:\n");
208                         printf("                        fast    - fast approximate algorithm [default]\n");
209                         printf("                        nw      - needleman-wunsch\n");
210                         printf("                        gotoh   - gotoh\n");
211                         printf("-d    --is_dna          Sequence are DNA\n");
212                         printf("-a    --is_aa           Sequences are amino acids\n");
213                         printf("-g    --gop             Gap opening costs\n");
214                         printf("-e    --gep             Gap extension costs\n");
215                         printf("-r    --retree          Number of reconstructions [default=0]\n");
216                         printf("      --tree_only       only tree is produced\n");
217                         printf("      --eval_aln        calculates only the sum-of-pairs-score of a given alignment\n");
218                         printf("-s    --score           calculates the sum of paris score after construction of an alignment. Can take a long time. [default: off]\n");
219 //                      printf("      --make_ref_aln    calculates the sum of paris score after construction of an alignment. Can take a long time. [default: off]\n");
220                         exit(0);
221                 }
222                 else
223                 {
224                         printf("Argument %s unknown\n", param);
225                         exit(1);
226                 }
227                 ++i;
228         }
229 }
230 /******************************COPYRIGHT NOTICE*******************************/
231 /*© Centro de Regulacio Genomica */
232 /*and */
233 /*Cedric Notredame */
234 /*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
235 /*All rights reserved.*/
236 /*This file is part of T-COFFEE.*/
237 /**/
238 /*    T-COFFEE is free software; you can redistribute it and/or modify*/
239 /*    it under the terms of the GNU General Public License as published by*/
240 /*    the Free Software Foundation; either version 2 of the License, or*/
241 /*    (at your option) any later version.*/
242 /**/
243 /*    T-COFFEE is distributed in the hope that it will be useful,*/
244 /*    but WITHOUT ANY WARRANTY; without even the implied warranty of*/
245 /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*/
246 /*    GNU General Public License for more details.*/
247 /**/
248 /*    You should have received a copy of the GNU General Public License*/
249 /*    along with Foobar; if not, write to the Free Software*/
250 /*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
251 /*...............................................                                                                                      |*/
252 /*  If you need some more information*/
253 /*  cedric.notredame@europe.com*/
254 /*...............................................                                                                                                                                     |*/
255 /**/
256 /**/
257 /*      */
258 /******************************COPYRIGHT NOTICE*******************************/