1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
|
Description: Fix_link_name_clashes
--- a/commline.c
+++ b/commline.c
@@ -35,16 +35,16 @@
/* reported to the user, arguments not preceded by a dash are assumed to */
/* be filenames. The input, output and bulk output files to be precise */
/**************************************************************************/
-int proc_comm_line( int *pargc , char ***pargv)
+int proc_comm_line( int *pargc , char ***pargv)
{
char *p;
char c;
int n;
char prog_name[64];
char root[MAX_FILENAME_LEN];
-
+
/* decide how to process argc[0] which will be the name of the programme */
-#if defined (_WINDOWS) || defined (_DOS) || defined ( WIN32 )
+#if defined (_WINDOWS) || defined (_DOS) || defined ( WIN32 )
if ( (p = strrchr(**pargv, '\\')) != NULL )
strncpy(prog_name, p+1 , 63);
else
@@ -53,26 +53,26 @@
if ( (p = strrchr(**pargv, '/')) != NULL )
strncpy(prog_name, p+1, 63);
else
- strncpy(prog_name, **pargv, 10);
+ strncpy(prog_name, **pargv, 10);
#elif defined(VMS) || defined (OPENVMS) /* maybe VMS or OPENVMS */
if ( (p = strrchr(**pargv, ']')) != NULL )
strncpy(prog_name, p+1, 63);
else
- strncpy(prog_name, **pargv, 10);
+ strncpy(prog_name, **pargv, 10);
#else
printf("UNRECOGNISED SYSTEM type won't be able to impersonate other programmes\n");
strcpy(prog_name, "codon"); /* OK I give up */
#endif
- if ( (p = strrchr(prog_name, '.')) != NULL ) /* remove file extension */
+ if ( (p = strrchr(prog_name, '.')) != NULL ) /* remove file extension */
*p = '\0'; /* tidy.exe -> tidy */
/* first call to garg initialises the function with the command line*/
/* parameters and the number of arguments, subsequent calls strip */
/* these off one by one */
-
+
/* has the user asked for help ???????????? */
- if ((p = garg(*pargc, *pargv, "-h", GARG_EXACT)) ||
+ if ((p = garg(*pargc, *pargv, "-h", GARG_EXACT)) ||
(p = garg(0, NULL, "-help", GARG_EXACT))){
printf(
"codonW [inputfile] [outputfile] [bulkoutfile] [options]\n"
@@ -80,7 +80,7 @@
" -h(elp)\tThis help message\n"
" -nomenu\tPrevent the menu interface being displayed\n"
" -nowarn\tPrevent warnings about sequences being displayed\n"
- " -silent\tOverwrite files silently\n"
+ " -silent\tOverwrite files silently\n"
" -totals\tConcatenate all genes in inputfile\n"
" -machine\tMachine readable output\n"
" -human\t\tHuman readable output\n"
@@ -100,6 +100,7 @@
"positions\n"
);
+ pause;
printf(
" -L_sym\t\tNumber of synonymous codons\n"
" -L_aa\t\tTotal number of synonymous and non-synonymous codons\n"
@@ -123,6 +124,7 @@
" -raau\t\tRelative Amino Acid Usage (RAAU)\n"
" -cu\t\tCodon Usage (CU) (default)\n"
);
+ pause;
printf(
" -cutab\t\tTabulation of codon usage\n"
" -cutot\t\tTabulation of dataset's codon usage\n"
@@ -137,37 +139,38 @@
"\nWhere {file} represents an input filename, and N an integer"
" value"
);
+ pause;
my_exit(99,""); /* after writing out help quit */
}
-
-/* These parameters are normally set in menu3 ie. the defaults menu */
+
+/* These parameters are normally set in menu3 ie. the defaults menu */
/* for a explanation of the various GARG_FLAGS see gargs */
/* -silent stops warnings about file about to be overwritten */
- if (garg(0, NULL, "-silent", GARG_THERE))
+ if (garg(0, NULL, "-silent", GARG_THERE))
pm->verbose = FALSE;
-
+
/* -total causes sequences to be concatenated and treated as one sequence */
if ( garg(0, NULL, "-total" , GARG_THERE))
- pm->totals = TRUE;
+ pm->totals = TRUE;
/* -machine or -human determines for whom the output should be formatted */
- if (p = garg(0, NULL, "-human", GARG_THERE))
+ if (p = garg(0, NULL, "-human", GARG_THERE))
pm->seq_format = 'H';
if (p = garg(0, NULL, "-mach", GARG_THERE))
pm->seq_format = 'M';
-/* -code determines the genetic code */
+/* -code determines the genetic code */
if (p = garg(0, NULL, "-code", GARG_NEXT | GARG_EXACT)) {
strcpy(pm->junk, p);
n=0;
- while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
+ while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
n++;
if ( n != (int)strlen(pm->junk)
- || atoi(pm->junk) < 0 || atoi(pm->junk) > NumGeneticCodes ) {
- printf( "FATAL: The value for genetic code %s is invalid\n",
+ || atoi(pm->junk) < 0 || atoi(pm->junk) > NumGeneticCodes ) {
+ printf( "FATAL: The value for genetic code %s is invalid\n",
pm->junk);
my_exit(99,"Fatal error in genetic code value");
} else {
@@ -184,14 +187,14 @@
if (p = garg(0, NULL, "-f_type", GARG_NEXT | GARG_EXACT)) {
strcpy(pm->junk, p);
n = 0;
- while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
+ while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
n++;
- if ( n != (int)strlen(pm->junk) || atoi(pm->junk) < 0 ||
+ if ( n != (int)strlen(pm->junk) || atoi(pm->junk) < 0 ||
atoi(pm->junk) >= NumFopSpecies ) {
- printf("FATAL: The value for fop_type %s is not valid\n",
+ printf("FATAL: The value for fop_type %s is not valid\n",
pm->junk);
my_exit(99,"Fatal error in Fop value");
- } else {
+ } else {
pm->f_type = (char) atoi(p); /* define organism type for Fop */
initilize_point(pm->code, pm->f_type, pm->c_type);
}
@@ -203,11 +206,11 @@
if (p = garg(0, NULL, "-c_type", GARG_NEXT | GARG_EXACT)) {
strcpy(pm->junk,p);
n = 0;
- while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
+ while ( isdigit( (int) pm->junk[n]) && pm->junk[n] != '\0')
n++;
- if ( n != (int)strlen(pm->junk) || atoi(pm->junk) < 0 ||
+ if ( n != (int)strlen(pm->junk) || atoi(pm->junk) < 0 ||
atoi(pm->junk) >= NumCaiSpecies) {
- printf("FATAL: The value for cai_type %s is not valid\n",
+ printf("FATAL: The value for cai_type %s is not valid\n",
pm->junk);
my_exit(99,"Fatal error in CAI type value");
@@ -244,7 +247,7 @@
if (p = garg(0, NULL, "-hyd" , GARG_EXACT))
pm->hyd = TRUE;
if (p = garg(0, NULL, "-aro" , GARG_EXACT))
- pm->aro = TRUE;
+ pm->aro = TRUE;
/* Turns on all the above indices */
if (p = garg(0, NULL, "-all_indices" , GARG_EXACT)){
pm->cai = TRUE;
@@ -257,23 +260,23 @@
pm->L_sym = TRUE;
pm->L_aa = TRUE;
pm->hyd = TRUE;
- pm->aro = TRUE;
+ pm->aro = TRUE;
}
/* This section in used to input the filenames for personal choices of Fop */
/* CBI or CAI values. The name is tested to make sure the file is readable */
/* the pointer to the file is then assign to the relevant pointer in the */
/* struct Z_menu and then processed properly in codon_us.c */
-
-/* Fop */
+
+/* Fop */
if (p = garg(0, NULL, "-fop_file", GARG_NEXT | GARG_EXACT)) {
if ( (pm->fopfile = open_file( "", p, "r", FALSE)) == NULL ) {
printf("Could not open Fop file - %s\n", p);
my_exit(1,"commline open fop file");
} else
- strncpy(pm->fop_filen, pm->junk, MAX_FILENAME_LEN - 1);
+ strncpy(pm->fop_filen, pm->junk, MAX_FILENAME_LEN - 1);
/* idiot catch, if you load personal fop values you want to calculate fop */
- pm->fop=TRUE;
+ pm->fop=TRUE;
}
/* CAI */
@@ -307,15 +310,15 @@
pm->coa = 'a';
if (p = garg(0, NULL, "-coa_expert", GARG_EXACT)) /* detailed inertia */
(coa.level='e'); /* analysis */
-
-
+
+
/* These are options selectable under the advanced COA menu */
-/* This first option -coa_axes changes the number of axis recorded to file */
+/* This first option -coa_axes changes the number of axis recorded to file */
if (p = garg(0, NULL, "-coa_axes", GARG_NEXT | GARG_EXACT)){
- if ( isdigit( (int) *p) ){
- n = (char)atoi(p);
- /* just check that correspondence analysis has been selected */
- if ( pm->coa == 'a' && (n > 20 || n<0) || ( n<0 || n>59 )) {
+ if ( isdigit( (int) *p) ){
+ n = (char)atoi(p);
+ /* just check that correspondence analysis has been selected */
+ if ( pm->coa == 'a' && (n > 20 || n<0) || ( n<0 || n>59 )) {
fprintf(pm->my_err,"Value %d is out of range for Number COA Axis "
"adjusting to max value\n",n);
if ( pm->coa == 'a' ) pcoa->axis = 20; else pcoa->axis = 59;
@@ -324,7 +327,7 @@
}
}
}
-
+
/* Select the size of dataset to use to identify optimal codons */
if (p = garg(0, NULL, "-coa_num", GARG_NEXT|GARG_EXACT)) {
strcpy (pm->junk,p) ;
@@ -333,8 +336,8 @@
pcoa->fop_gene=atoi(pm->junk)*-1;
}else {
pcoa->fop_gene=atoi(pm->junk);
- }
- }
+ }
+ }
/* These option are mutually exclusive and are normally selected using the */
@@ -349,7 +352,7 @@
if ( p = garg(0, NULL, "-cutot", GARG_THERE)){
pm->bulk = 'C';
pm->totals =TRUE;
- }
+ }
if ( p = garg(0, NULL, "-reader", GARG_EXACT))
pm->bulk = 'R';
if ( p = garg(0, NULL, "-rscu", GARG_EXACT))
@@ -362,16 +365,16 @@
pm->bulk = 'A';
if ( p = garg(0, NULL, "-transl", GARG_THERE))
pm->bulk = 'N';
- if ( p = garg(0, NULL, "-base", GARG_THERE))
+ if ( p = garg(0, NULL, "-base", GARG_THERE))
pm->bulk = 'B';
if (p = garg(0, NULL, "-dinuc", GARG_THERE))
pm->bulk = 'D';
if (p = garg(0, NULL, "-noblk", GARG_EXACT))
pm->bulk = 'X';
-
+
/* -t is used to change the column separator used in the output files */
/* at present it must be a space, tab or comma */
-/* Must occur after -transl or it misreads transl as a seperator */
+/* Must occur after -transl or it misreads transl as a seperator */
if (p = garg(0, NULL, "-t" , GARG_NEXT | GARG_SUBSQ)) {
strcpy(pm->junk, p);
n = 0;
@@ -382,11 +385,11 @@
printf( "WARNING: The chosen separator %s is unsuitable use"
"comma, tab or space\n", pm->junk);
} else {
- pm->seperator = c;
+ pm->seperator = c;
}
}
-
-
+
+
/* These options are commandline specific, ie. they do not have an */
/* menu option */
@@ -417,67 +420,67 @@
/* programmes. In essence CodonW will impersonate other commonly used */
/* codon usage analysis programmes if called using a special name */
- if ( !strcmp(prog_name, "raau" ) )
+ if ( !strcmp(prog_name, "raau") || !strcmp(prog_name+7, "raau"))
pm->bulk = 'L';
- else if ( !strcmp(prog_name, "cu" ) )
+ else if ( !strcmp(prog_name, "cu") || !strcmp(prog_name+7, "cu"))
pm->bulk = 'C';
- else if ( !strcmp(prog_name, "cutab" ) )
+ else if ( !strcmp(prog_name, "cutab") || !strcmp(prog_name+7, "cutab"))
pm->bulk = 'O';
- else if ( !strcmp(prog_name, "reader") )
+ else if ( !strcmp(prog_name, "reader") || !strcmp(prog_name+7, "reader"))
pm->bulk = 'R';
- else if ( !strcmp(prog_name, "rscu" ) )
+ else if ( !strcmp(prog_name, "rscu") || !strcmp(prog_name+7, "rscu"))
pm->bulk = 'S';
- else if ( !strcmp(prog_name, "tidy" ) )
+ else if ( !strcmp(prog_name, "tidy") || !strcmp(prog_name+7, "tidy"))
pm->bulk = 'T';
- else if ( !strcmp(prog_name, "aau" ) )
+ else if ( !strcmp(prog_name, "aau") || !strcmp(prog_name+7, "aau"))
pm->bulk = 'A';
- else if ( !strcmp(prog_name, "dinuc" ) )
+ else if ( !strcmp(prog_name, "dinuc") || !strcmp(prog_name+7, "dinuc"))
pm->bulk = 'D';
- else if ( !strcmp(prog_name, "transl") )
+ else if ( !strcmp(prog_name, "transl") || !strcmp(prog_name+7, "transl"))
pm->bulk = 'N';
- else if ( !strcmp(prog_name, "bases" ) )
- pm->bulk = 'B';
- else if ( !strcmp(prog_name, "base3s") ) {
+ else if ( !strcmp(prog_name, "bases") || !strcmp(prog_name+7, "bases"))
+ pm->bulk = 'B';
+ else if ( !strcmp(prog_name, "base3s") || !strcmp(prog_name+7, "base3s")) {
pm->prog = 's' ;
pm->menu = FALSE;
pm->sil_base = TRUE;
- } else if ( !strcmp(prog_name, "cai" ) ) {
+ } else if ( !strcmp(prog_name, "cai") || !strcmp(prog_name+7, "cai")) {
pm->prog = 'c';
pm->menu = FALSE;
pm->cai = TRUE;
- } else if ( !strcmp(prog_name, "fop" ) ) {
+ } else if ( !strcmp(prog_name, "fop") || !strcmp(prog_name+7, "fop")) {
pm->prog = 'f';
pm->menu = FALSE;
pm->fop = TRUE;
- } else if ( !strcmp(prog_name, "gc3s" ) ) {
+ } else if ( !strcmp(prog_name, "gc3s") || !strcmp(prog_name+7, "gc3s")) {
pm->prog = '3';
pm->menu = FALSE;
pm->gc3s = TRUE;
- } else if ( !strcmp(prog_name, "gc" ) ) {
+ } else if ( !strcmp(prog_name, "gc") || !strcmp(prog_name+7, "gc")) {
pm->prog = 'g';
pm->menu = FALSE;
pm->gc = TRUE;
- } else if ( !strcmp(prog_name, "enc" ) ) {
+ } else if ( !strcmp(prog_name, "enc") || !strcmp(prog_name+7, "enc")) {
pm->prog = 'e';
pm->menu = FALSE;
pm->enc = TRUE;
- } else if ( !strcmp(prog_name, "cbi" ) ) {
+ } else if ( !strcmp(prog_name, "cbi") || !strcmp(prog_name+7, "cbi")) {
pm->prog = 'i';
pm->menu = FALSE;
pm->cbi = TRUE;
- } else if ( !strcmp(prog_name, "cutot" ) ) {
+ } else if ( !strcmp(prog_name, "cutot") || !strcmp(prog_name+7, "cutot")) {
pm->bulk = 'C';
pm->menu = FALSE;
pm->totals =TRUE;
} else {
pm->codonW=TRUE; /* if argc[0] is not recognised assume codons*/
/* if blk output is still X then assume cu */
- if (pm->bulk=='X') pm->bulk='C';
+ if (pm->bulk=='X') pm->bulk='C';
}
if (!pm->codonW ) { /* we appear to be impersonating another prog*/
- /* now we switch to the correct greeting */
+ /* now we switch to the correct greeting */
if (pm->bulk && pm->bulk!='X'){
pm->seperator='\000'; /* stop chars being converted by tidy*/
switch (pm->bulk) {
@@ -564,7 +567,7 @@
/* so now we test for any remaining, these are unrecognised */
while (p = garg(0, NULL, "-", GARG_THERE))
- if ( pm->menu )
+ if ( pm->menu )
printf("Unrecognised argument %s\n", p);
else {
/* if we are running without a menu then abort this run */
@@ -584,24 +587,24 @@
}
/* The second should be the output filename */
if ( p = garg(0, NULL, "", GARG_THERE)) {
- if ( (pm->outputfile = open_file( "", p, "w",
+ if ( (pm->outputfile = open_file( "", p, "w",
(int) pm->verbose)) == NULL ) {
printf("Could not open output file - %s\n", p );
my_exit(1,"commline out file");
} else
strncpy(pm->curr_outfilename, pm->junk, MAX_FILENAME_LEN - 1);
- }
+ }
/* The third which only occurs if the programme is running as CodonW */
if ( pm->codonW && (p = garg(0, NULL, "", GARG_THERE)) ) {
- if ( (pm->tidyoutfile = open_file( "", p, "w",
+ if ( (pm->tidyoutfile = open_file( "", p, "w",
(int) pm->verbose)) == NULL ) {
printf("Could not open blkoutput file - %s\n", p );
my_exit(1,"commline blk outfile");
} else
strncpy(pm->curr_tidyoutname, pm->junk, MAX_FILENAME_LEN - 1);
- }
+ }
/* Now check the command line is empty ... it should be at this point */
while (p = garg(0, NULL, "", GARG_THERE))
@@ -612,25 +615,25 @@
/* we need to load an input file name */
if ( (!pm->codonW || !pm->menu) && !pm->inputfile ){
- if ( (pm->inputfile = open_file( "input filename", "input.dat",
+ if ( (pm->inputfile = open_file( "input filename", "input.dat",
"r", FALSE)) == NULL ) {
printf("Could not open input file - %s\n", p );
my_exit(1,"commline inputfile");
- }
+ }
strncpy(pm->curr_infilename, pm->junk, MAX_FILENAME_LEN - 1);
}
-
+
/* If we have an input filename but no output then we must prompt for the */
/* output filename */
- if ( pm->inputfile && !pm->outputfile ) {
+ if ( pm->inputfile && !pm->outputfile ) {
/* If we are trying to impersonate another programme use this method*/
/* but make sure that we know what this other programme is called */
if ( !pm->codonW && strlen (prog_name) ){
strcpy(pm->curr_outfilename, prog_name);
strcat(pm->curr_outfilename, ".def");
} else {
-
+
/* Use the input filename as a root filename */
strncpy(root, pm->curr_infilename, MAX_FILENAME_LEN - 5);
for (n = (int) strlen(root); n && root[n]!='.' ; --n);
@@ -638,23 +641,23 @@
strcpy(pm->curr_outfilename, root);
strcat(pm->curr_outfilename, ".out");
- } /* matchs else */
+ } /* matchs else */
- /* now we know the suggested name for the output file lets open it */
+ /* now we know the suggested name for the output file lets open it */
if ( pm->verbose ) {
if ( (pm->outputfile = open_file( "indices output filename",
- pm->curr_outfilename, "w",(int) pm->verbose)) == NULL )
+ pm->curr_outfilename, "w",(int) pm->verbose)) == NULL )
my_exit(1,"commline");
strncpy(pm->curr_outfilename, pm->junk, MAX_FILENAME_LEN - 1);
}else{
if ( (pm->outputfile = open_file( "",
- pm->curr_outfilename, "w",(int) pm->verbose)) == NULL )
+ pm->curr_outfilename, "w",(int) pm->verbose)) == NULL )
my_exit(1,"commline");
strncpy(pm->curr_outfilename, pm->junk, MAX_FILENAME_LEN - 1);
}
} /* match if ( pm->inputfile */
-
+
/* we had a commandline inputfile name and output filename but none */
@@ -670,22 +673,22 @@
strcpy(pm->curr_tidyoutname, root);
strcat(pm->curr_tidyoutname, ".blk");
- /* now we know the suggested name for the output file lets open it */
+ /* now we know the suggested name for the output file lets open it */
if( pm->verbose) {
if ( (pm->tidyoutfile = open_file( "bulk output filename",
- pm->curr_tidyoutname, "w",(int) pm->verbose)) == NULL )
+ pm->curr_tidyoutname, "w",(int) pm->verbose)) == NULL )
my_exit(1,"commline");
strncpy(pm->curr_tidyoutname, pm->junk, MAX_FILENAME_LEN - 1);
}else{
if ( (pm->tidyoutfile = open_file( "",
- pm->curr_tidyoutname, "w",(int) pm->verbose)) == NULL )
+ pm->curr_tidyoutname, "w",(int) pm->verbose)) == NULL )
my_exit(1,"commline");
strncpy(pm->curr_tidyoutname, pm->junk, MAX_FILENAME_LEN - 1);
}
- }else{
+ }else{
/* only use one output file when impersonating other programmes */
- /* just in case we make blkout and output the same file */
- pm->tidyoutfile = pm->outputfile;
+ /* just in case we make blkout and output the same file */
+ pm->tidyoutfile = pm->outputfile;
}
}
return 1;
@@ -699,8 +702,8 @@
/* This subroutine was developed as a collaboration with Colin McFarlane */
/* GARG_EXACT The argument must match targ exactly */
/* GARG_THERE The targ may be sub-string of the argument */
-/* GARG_SUBSQ The string immediate after targ is returned */
-/* GARG_NEXT The next argument after targ is returned */
+/* GARG_SUBSQ The string immediate after targ is returned */
+/* GARG_NEXT The next argument after targ is returned */
/* else return NULL */
/***************************************************************************/
char *garg(int argc, char *argv[], const char *targ, int mode)
|