JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / get_defaults.c
1
2 /* Code by anonomous and Ethan Wolf 1995. */
3
4 /************************************************************************/
5 /* get_defaults() is called in main() of sc2seq.c to get the default    */
6 /* values for parameters of the program, such as input/output files and */
7 /* options.                                                             */
8 /************************************************************************/
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include "scio.h"
14 #include "switches.h"
15 #include  "interface.h"
16
17
18 /** Returns pointer to first occurance of chrs[0]. If that not present,
19   * returns pointer to first occurance of chrs[1]... If none of 
20   * characters in chrs[] are present then it returns NULL.
21   * This is used to remove whitspace, tabs, returns.
22 **/
23 static char *strchrs(char *str, char *chrs) {
24   char *ret=NULL;
25
26   while(*chrs) {
27     if(ret=strchr(str,*chrs)) return ret;
28     chrs++;
29   }
30   return ret;
31 }
32
33 /************************************************************************/
34 /* Reads in .paircoil file of default values that are normally input to */
35 /* sc2seq in the command line.                                          */
36 /* Any required value not read in here is expected on the command line. */
37 void get_defaults(char *command_line_config,
38                   char *input_location, int *mode, double *bound, 
39                     FILE **fgin, FILE **fpin,
40                     FILE **ftotal_like, FILE **fout, 
41                     FILE **flog,
42                     FILE **fout_coils,  
43                     int *by_coil_or_seq,
44                     char likelihoods[MAX_TABLE_NUMBER][MAXLINE],
45                     char *pir_name, char *lib, 
46                     char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
47                     int *functnum, 
48                     int combine_dist[MAX_TABLE_NUMBER],
49                     char *print, int *main_method, 
50                     int *main_preprocessor_method, int *main_table, 
51                     int *offset_to_use,
52                     int *avg_max,
53                     int *Coil_Score,
54                     int *ps_res_per_line,
55                     char class_sc_filenames[2][MAX_CLASS_NUMBER][MAXLINE],
56                     char gaussian_parameters[2][MAXLINE],
57                     int num_dist[MAX_TABLE_NUMBER],
58                     double init_class_prob[MAX_CLASS_NUMBER],
59                     int *table_to_remove_from,
60                     char *command_line, 
61                     int window_length[MAX_TABLE_NUMBER],
62                     double scale0s[MAX_TABLE_NUMBER],
63                     double scale0p[MAX_TABLE_NUMBER])
64 {
65   char buf[500], *tmp, name[500];
66   FILE *config; FILE *printfile;
67   int i, number_likelihoods=0;
68   char *input_name;
69   int lib_numb=0;
70
71 /******** A hack so I don't have to eliminate all the stuff using these  ****/
72 /******** pointers, since no longer pass them into function.             ****/
73   int num_tab=0, *number_tables, number_classes=0, number_max_classes=0;  
74
75   number_tables= &num_tab;
76 /****************************************************************************/
77
78   strcpy(gaussian_parameters[0], "~/MULTICOIL/CONVERSION_FILES/gauss_param28+");
79
80   if (command_line) { /* Don't use options in config file. */
81     if (!strcmp(command_line,"dimer")) {
82       *table_to_remove_from = 0;
83       printf("Input data is all removed from table 1\n");
84       *mode |= POS_MODE;
85       printf("pos\n");
86     }
87     else if (!strcmp(command_line,"trimer")) {
88       *table_to_remove_from = 1;
89       printf("Input data is all removed from table 2\n");
90       *mode |= POS_MODE;
91       printf("pos\n");
92     }
93     else if (!strcmp(command_line, "dimer-1")) {
94         *mode |= TST_MODE0;                  
95         printf("Input is data from table 1\n");                    
96         *mode |= POS_MODE;
97         printf("pos\n");
98       }
99     else if (!strcmp(command_line, "trimer-1")) {
100       *mode |= TST_MODE1;                  
101       printf("Input is data from table 2\n");                    
102       *mode |= POS_MODE;
103       printf("pos\n");
104     }
105     else if (!strcmp(command_line, "negatives")) {
106       printf("Not doing pos mode");      
107     }
108     else if (!strcmp(command_line, "config_file")) {
109       printf("Doing pos options as in config file\n");
110       command_line =NULL;
111     }
112     else { /*  Bad command line input.  **/
113       usage("paircoil");
114       exit(-1);
115     }
116              
117   }
118
119 /************************** For Automating output file name. ****/
120   /** Strip off directories to get just the program name.  **/
121   i=strlen(input_location);   
122   while ((i>=0) && (input_location[i] != '/') ) 
123     i--;
124   input_name= &input_location[i+1];
125 /***************************/
126
127
128   /*  What directory to look for paircoil defauts in.  Set environment  */
129   /*  variable MULTICOIL_CONFIG to be a path to this file.               */
130
131   if (command_line_config) {  /** Read config location at command line.  **/
132     strcpy(buf, command_line_config);
133     fprintf(stderr,"config = %c",buf);
134   }
135   else
136     if (tmp=getenv("MULTICOIL_CONFIG")) {
137       strcpy(buf,tmp);
138     } 
139     else {
140       strcpy(buf,getenv("HOME"));    
141       strcat(buf,"/MULTICOIL/multicoil_config");
142     }
143
144   if (config=fopen(buf,"r")) {
145     printf("Config file %s\n", buf);
146     while (fgets(buf,500,config)) {
147       
148       if (!command_line)  { /** Read from file since it wasn't **/
149                             /** a command line param. **/
150         if(!strncmp(buf,"pos",3)) {        /* If "pos" is in the .paircoil  */
151           *mode |= POS_MODE;               /* default file, then the test   */
152           printf("pos\n");                 /* file is assumed to be a .pos  */
153         }                                  /* file, where each seq has its  */
154
155         else if(!strncmp(buf,"remove all input from table",27)) {     
156           sscanf(buf,"remove all input from table %d",table_to_remove_from);
157           (*table_to_remove_from)--;
158           printf("Input is data is all removed from table %d\n",
159                  (*table_to_remove_from) +1);                    
160         }                                     
161
162         else if(!strncmp(buf,"input pos1",10)) {     
163           *mode |= TST_MODE0;                  
164           printf("Input is data from table 1\n");                    
165         }                                     
166         else if(!strncmp(buf,"input pos2",10)) {     
167           *mode |= TST_MODE1;                  
168           printf("Input is data from table 2\n");                    
169         }
170       }                                     
171
172
173
174    /**** Now do the rest of the possible non-command line options. *****/
175
176       if(!strncmp(buf,"genbnk",6)) {      /* Get location of genbnk file  */
177         sscanf(buf,"genbnk = %s",name);    /* and open it.                 */
178         *fgin = sopen(name,"r");           
179 /***
180         printf("genbnk = %s\n",name);
181 ***/
182       }
183       else if(!strncmp(buf,"table",5)) {   /* Get location of postable file */
184         sscanf(buf,"table %d = %s",&i, name);
185         fpin[i-1] = sopen(name,"r");
186 /***
187         printf("table %d = %s\n",i,name); 
188 ***/
189         (*number_tables)++;
190       }
191     
192       else if(!strncmp(buf,"pir",3)) {   /* Get location of pir file */
193         sscanf(buf,"pir = %s",pir_name);
194 /****
195         printf("pir = %s\n",pir_name);
196 ***/
197       }
198       else if(!strncmp(buf,"printfile",9)) {   /* File to output printouts to*/
199         sscanf(buf,"printfile = %s",print);
200         printf("printfile = %s\n",print);
201         printfile=sopen(print,"w");  /* We are going to append to this, */ 
202         sclose(printfile);           /*  So first make it empty.   */
203       }
204       else if(!strncmp(buf,"likelihoods",11)) {   
205         sscanf(buf,"likelihoods %d = %s",&i, likelihoods[number_likelihoods]); 
206 /****
207         printf("likelihoods %d = %s\n",number_likelihoods,
208                likelihoods[number_likelihoods]); ***/  /* likelihood lines.  */
209         number_likelihoods++;
210         likelihoods[number_likelihoods][0]= ',';
211       }
212
213
214       else if(!strncmp(buf,"class scores combo",18)) {   
215         sscanf(buf,"class scores combo %d with init prob %lf = %s",&i, 
216                &init_class_prob[number_classes],
217                class_sc_filenames[0][number_classes]); 
218         printf("combo class scores %d = %s with init prob %lf\n",
219                i,class_sc_filenames[0][number_classes],
220                init_class_prob[number_classes]);  /* likelihood lines.  */
221         number_classes++;
222       }
223
224
225       else if(!strncmp(buf,"class scores max",16)) {   
226         sscanf(buf,"class scores max %d with init prob %lf = %s",&i, 
227                &init_class_prob[number_max_classes],
228                class_sc_filenames[1][number_max_classes]); 
229         printf("max class scores %d = %s with init prob %lf\n",
230                i,class_sc_filenames[1][number_max_classes],
231                init_class_prob[number_max_classes]);  /* likelihood lines.  */
232         number_max_classes++;
233       }
234     
235       else if(!strncmp(buf,"gauss_param =",13))  
236         sscanf(buf,"gauss_param = %s",gaussian_parameters[0]);
237
238       else if(!strncmp(buf,"gauss_param combo",17)) {   
239         sscanf(buf,"gauss_param combo = %s",gaussian_parameters[0]);
240 /**** 
241        printf("gauss_param combo = %s\n",gaussian_parameters[0]);
242 ****/
243       }
244
245       else if(!strncmp(buf,"gauss_param max",15)) {   
246         sscanf(buf,"gauss_param max = %s",gaussian_parameters[1]);
247 /***
248         printf("gauss_param max = %s\n",gaussian_parameters[1]);
249 ***/
250       }
251
252       else if(!strncmp(buf,"no GUI",6)) {   
253         *mode |= NO_GUI;
254         printf("NO GUI\n");
255       }
256
257
258       else if(!strncmp(buf,"pair_lib",8)) { /*  Read in a variable number   */
259         char *end;                          /*  of distances to be used in  */
260         int val;                            /*  pair scores.  The number    */
261                                             /*  of variables is stored in   */
262         printf("pair_lib = ");              /*  in the global variable      */
263         tmp = strchr(buf, '=');             /*  functnum.  The distances    */
264         tmp++;                              /*  are stored in               */
265         /* strip leading whitespace */      /*  lib[0],...,lib[functnum-1]. */
266         while(!isdigit(*tmp)&&*tmp) tmp++;
267         while(end = strchrs(tmp, " \t\n\r")) {
268           *end = 0;
269           end++;
270           /* strip leading whitespace */
271           while(*tmp&&!isdigit(*tmp)) tmp++;
272           if(*tmp) {
273             val = atoi(tmp);
274             lib[(*functnum)++] = val-1;  /** scscore.c needs takes residues **/
275                                          /** at dist lib +1 apart.          **/
276             printf("%d ", val);
277           }
278           tmp = end;
279         }
280         printf("\n");
281       }
282
283
284
285       else if(!strncmp(buf,"multi_lib",9)) { /*  Read in a variable number   */
286         if (! (*mode & LIB_AT_COMMAND_LINE)) { /* This flags that **/
287                                         /** got it at command line.         **/
288           int first_table, last_table;
289           int the_table;
290           int combine_distances =1;
291
292           if (!strncmp(buf,"multi_lib dim",13)) {  
293             combine_distances = 0;
294             
295             if (!strncmp(buf,"multi_lib dim =",15)) {
296               first_table=0; last_table=NUMBER_TABLES;  
297             }             /* All tables get same lib. **/
298             else {
299               sscanf(buf,"multi_lib dim %d", &last_table);
300               first_table = last_table-1;
301             }
302           }
303           else if (!strncmp(buf,"multi_lib =",11)) {
304             combine_distances = 0;
305             first_table=0; last_table= NUMBER_TABLES;  
306           }             /* All tables get same lib. **/
307           else {
308             sscanf(buf,"multi_lib %d", &last_table);
309             first_table = last_table-1;
310           }
311           
312           for (the_table=first_table; the_table<last_table; the_table++) {
313             combine_dist[the_table]= combine_distances;
314             num_dist[the_table]=0;
315           }
316           
317           if (!strncmp(buf,"multi_lib = all",15))
318             {
319                            /* For scscore.c will go through each dist on own*/
320               for (the_table=first_table; the_table<last_table; the_table++)
321                 for (i=0; i<7; i++) {
322                   multi_lib[the_table][i] = i;
323                   num_dist[the_table] = 7; 
324                   combine_dist[the_table] = 0;
325                 }
326             }
327         
328           else {
329             char *end;                      /*  of distances to be used in  */
330             int val;                        /*  pair scores.  The number    */
331                                             /*  of variables is stored in   */
332             printf("multi_lib = ");         /*  in the global variable      */
333             tmp = strchr(buf, '=');         /*  functnum.  The distances    */
334             tmp++;                          /*  are stored in               */
335             /* strip leading whitespace */  /*  lib[0],...,lib[functnum-1]. */
336             while(!isdigit(*tmp)&&*tmp) tmp++;
337             while(end = strchrs(tmp, " \t\n\r")) {
338               *end = 0;
339               end++;
340               /* strip leading whitespace */
341               while(*tmp&&!isdigit(*tmp)) tmp++;
342               if(*tmp) {
343                 val = atoi(tmp);
344                 for (the_table=first_table; the_table<last_table; the_table++){
345                   multi_lib[the_table][num_dist[the_table]] = val-1;
346                   /** scscore.c needs takes residues at dist lib +1 apart.  **/
347                   num_dist[the_table]+= 1;
348 /**               combine_dist[the_table] = combine_distances;  **/
349                 }
350                 printf("%d ", val);
351               }
352               tmp = end;
353             }
354             for (the_table=first_table; the_table<last_table; the_table++)
355               if (num_dist[the_table] ==1) combine_dist[the_table] =0;
356
357             printf("\n");
358           }
359         }
360       }
361     
362     
363
364       else if(!strncmp(buf,"Maximize total like",4)) {    
365         sscanf(buf,"Maximize total like = %s",name); /* Compute the sum */     
366         *ftotal_like = sopen(name,"w");              /* over classes of */
367         printf("ftotal_like = %s\n",name);           /* the gauss value */
368                                        /* for the score for various settings */
369                                        /* of the initial class parameters, so*/
370                                        /* we can choose values max total like*/
371       }
372       else if(!strncmp(buf,"out",3)) {     
373         if (!strncmp(buf,"out dir",7)) { /** automate the name **/     
374           sscanf(buf,"out dir = %s",name);
375           strcat(name,input_name);
376           strcat(name,".out");
377         }
378         else sscanf(buf,"out = %s",name);  /* Read in the filename in which */
379                                            /* to output the residue scores  */
380         *fout = sopen(name,"w");            /* and open it.                  */
381         printf("out = %s\n",name);
382       }
383
384       else if(!strncmp(buf,"sparse_out",10)) {     
385         if (!strncmp(buf,"sparse_out dir",14)) { /** automate the name **/     
386           sscanf(buf,"sparse_out dir = %s",name);
387           strcat(name,input_name);
388           strcat(name,".out");
389         }
390         else sscanf(buf,"sparse_out = %s",name); /*Read in filename in which */
391                                            /* to output the residue scores  */
392         *fout = sopen(name,"w");            /* and open it.                  */
393         printf("sparse_out = %s\n",name);
394         *mode ^= WEB_OUT_MODE;        /* Don't want web output mode.  */
395       }
396     
397
398       else if(!strncmp(buf,"raw_out",7)) { 
399         *mode |= RAW_OUT;
400         if (!strncmp(buf,"raw_out dir",11)) { /** automate the name **/     
401           sscanf(buf,"raw_out dir = %s",name);
402           strcat(name,input_name);
403           strcat(name,".raw_out");
404         }
405         else sscanf(buf,"raw_out = %s",name);
406         
407         *fout= sopen(name,"w");        
408         printf("Opened %s for output of raw scores\n",name);
409       }
410
411       else if(!strncmp(buf,"log",3)) {     
412         if (!strncmp(buf,"log dir",7)){ /* automate the name **/ 
413           sscanf(buf,"log dir = %s",name);
414           strcat(name,input_name);
415           strcat(name,".log");
416
417           /**** Apend on the library distances.  ***/
418           if (combine_dist[0] == 0) { /* make sure do dimension scores */
419             lib_numb=0;
420             while (lib_numb < num_dist[0]) {
421               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
422               lib_numb++; }
423             sprintf(&buf[lib_numb],"_");
424             strncat(name,buf,num_dist[0]+1);
425
426             lib_numb=0;
427             while (lib_numb < num_dist[1]) {
428               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
429               lib_numb++; }
430             strncat(name,buf,num_dist[1]);
431           }
432           
433         }                                   /* Read in the filename in which */
434         else sscanf(buf,"log = %s",name);   /* to output the sequences which */
435         *flog = sopen(name,"w");            /* score above the PRN_MODE      */
436         printf("log = %s\n",name);      /* threshhold.  This file will   */
437                                             /* get human readable output.    */
438       }
439     
440       else if (!strncmp(buf,"Log Like Pos",12))
441         *mode |= POS_STYLE_LOG;
442
443
444
445       else if (!strncmp(buf,"By seq pos regions",18))
446         *by_coil_or_seq =1;
447
448 /*************************************************************************/
449 /*******Two Ways of doing same command:  "coil scores" and "seq scores" **/
450 /*** Although slightly diff't since they modify "by_coil_or_seq"  diff'tly**/
451
452       else if(!strncmp(buf,"coil scores",11)) {     
453         *by_coil_or_seq =0;   /** Do coil scores. **/
454         if (!strncmp(buf,"coil scores dir",15)) { /* automate the name **/   
455           sscanf(buf,"coil scores dir = %s",name);
456           strcat(name,input_name);
457           strcat(name,".coil_scores");
458           if (*mode & VER_MODE)
459             strcat(name,"_NoTxt");
460
461           /**** Apend on the library distances.  ***/
462           if (combine_dist[0] == 0) { /* make sure do dimension scores */
463             lib_numb=0;
464             while (lib_numb < num_dist[0]) {
465               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
466               lib_numb++; }
467             sprintf(&buf[lib_numb],"_");
468             strncat(name,buf,num_dist[0]+1);
469
470             lib_numb=0;
471             while (lib_numb < num_dist[1]) {
472               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
473               lib_numb++; }
474             strncat(name,buf,num_dist[1]);
475           }
476         }
477         else sscanf(buf,"coil scores = %s",name);  
478         *fout_coils = sopen(name,"w");         /* For just choosing 1 score */
479         printf("coil scores = %s\n",name);   /* per pos file coil,  or seq   */
480       }
481
482       else if(!strncmp(buf,"seq scores",10)) {     
483         *by_coil_or_seq =2;   /** Do seq scores. **/
484         if (!strncmp(buf,"seq scores dir",14)) { /* automate the name **/     
485           sscanf(buf,"seq scores dir = %s",name);
486           strcat(name,input_name);
487           strcat(name,".seq_scores");
488           if (*mode & VER_MODE)
489             strcat(name,"_NoTxt");
490
491           /**** Apend on the library distances.  ***/
492           if (combine_dist[0] == 0) { /* make sure do dimension scores */
493             lib_numb=0;
494             while (lib_numb < num_dist[0]) {
495               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
496               lib_numb++; }
497             sprintf(&buf[lib_numb],"_");
498             strncat(name,buf,num_dist[0]+1);
499
500             lib_numb=0;
501             while (lib_numb < num_dist[1]) {
502               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
503               lib_numb++; }
504             strncat(name,buf,num_dist[1]);
505           }
506         }
507         else sscanf(buf,"seq scores = %s",name);  
508         *fout_coils = sopen(name,"w");         /* For just choosing 1 score */
509         printf("seq scores = %s\n",name);   /* per pos file coil,  or seq   */
510       }
511    
512 /*************************/   
513
514       else if(!strncmp(buf,"ps res per line",15)) {/* Reads in the length of */
515         sscanf(buf,"ps res per line = %d", ps_res_per_line); /* print line */
516         fprintf(stderr,"res per line = %d\n", *ps_res_per_line); 
517       }
518       else if(!strncmp(buf,"one print line",14)) {
519         *ps_res_per_line = -1;  /* Flag to print on just one line. */
520         fprintf(stderr,"Sequences will be printed on one line in ps file.\n");
521       }
522
523       else if(!strncmp(buf,"max window then combine dist",28)) {   
524         *mode |= MAX_WINDOW_BEFORE_COMBINE_MODE;        /* In scseqadj in */ 
525         printf("max window before combine distances\n"); /* scscore.c, this */                                       /* defines how to compute score. */  
526       }                                    
527
528       else if(!strncmp(buf,"only coiled classes",19)) {
529         *mode |= ONLY_COILED_CLASSES;
530         printf("The paircoil like will be fraction of all positive classes likelihoods (no pdb- class.\n");
531       }
532  
533       else if(!strncmp(buf,"ScoresAboveBound",16)) {  /** Only output scores */
534         *mode |= ABOVE_BOUND_MODE;            /* to score/out/txt files      */
535         printf("Above Bound Mode\n");         /* that are above bound.       */
536       }
537     
538 #ifdef TEST_VERSION       /** Only for testing..... ***/
539       else if(!strncmp(buf,"Prolines",8)) {     
540         *mode ^= PROLINE_FREE_MODE;                  /* Score Prolines   */
541         printf("Score Prolines\n");                    
542       }                                     
543 #endif
544
545       else if(!strncmp(buf,"Show Seq",8)) {   
546         *mode |= DEBUG_MODE;                /* Option to get seq printed in  */
547      /** printf("Show Sequences in log file\n"); **/ /* log file.            */
548         *mode |= PRN_MODE;                  /* Print scores above bound    */
549       }                                     
550       else if(!strncmp(buf,"view",4)) {   
551         *mode |= VIEW_MODE;                 /* Option to get a picture of    */
552         printf("view\n");                   /* STOCKS and PairCoils predicted*/
553       }                                     /* coil regions in the seq.      */
554       else if(!strncmp(buf,"ver",3)) {
555         *mode |= VER_MODE;                  /* Outputs 2 columns of maxseq   */
556         printf("ver\n");                    /* scores, first STOCK, then us  */
557         *main_method = STOCK_PAIR;
558       }                                     /* in log file.                  */
559
560       else if(!strncmp(buf,"Just Scores",11)) {
561         *mode |= VER_MODE;
562         printf ("The coil scores output will contain just scores, no text.");
563       }
564       
565 #ifdef TEST_VERSION       /** Only want release to do pairs.  */
566       else if (!strncmp(buf,"singles",7))   
567         *mode ^= PAIRCOIL_PAIRS;  /* Since default is 1, just XOR it.  */
568 #endif 
569       else if (!strncmp(buf,"pairs",5))
570         *mode |= PAIRCOIL_PAIRS;  
571
572
573       else if(!strncmp(buf,"prn",3)) {
574         *mode |= PRN_MODE;                  /* Print region scores above     */
575         sscanf(buf,"prn = %lf", bound);     /* threshhold prn to logfile.    */
576 /***
577         printf("prn\n");
578 ***/
579       }
580
581       else if(!strncmp(buf,"bound",5)) {
582         *mode |= PRN_MODE;                  /* Print region scores above     */
583         sscanf(buf,"bound = %lf", bound);     /* threshhold prn to logfile.    */
584 /***
585         printf("bound\n");
586 ***/
587       }
588     
589
590       else if(!strncmp(buf,"window length",13)) {
591         int the_table;
592         if (!strncmp(buf,"window length =",15)) {
593           sscanf(buf,"window length = %d", &window_length[0]);  
594           for (the_table =0; the_table < MAX_TABLE_NUMBER; the_table++) {
595             window_length[the_table] =window_length[0];
596             printf("window length %d = %d\n", the_table, 
597                    window_length[the_table]);
598           }
599         }             /* All tables get same windowlength. **/
600         else {
601           sscanf(buf,"window length %d", &the_table);
602           sscanf(buf,"window length %d = %d", &the_table, 
603                  &window_length[the_table-1]); 
604           printf("window length %d = %d\n",the_table,window_length[the_table-1]);
605         }
606       }
607
608       else if(!strncmp(buf,"scale0s",7)) {
609         int the_table;
610         if (!strncmp(buf,"scale0s =",9)) {
611           sscanf(buf,"scale0s = %lf", &scale0s[0]);  
612           for (the_table =0; the_table < MAX_TABLE_NUMBER; the_table++) {
613             scale0s[the_table] =scale0s[0];
614             printf("scale0s %d = %lf\n", the_table, 
615                    scale0s[the_table]);
616           }
617         }             /* All tables get same scale0. **/
618         else {
619           sscanf(buf,"scale0s %d", &the_table);
620           sscanf(buf,"scale0s %d = %lf", &the_table, 
621                  &scale0s[the_table-1]); 
622           printf("scale0s %d = %lf\n",the_table,scale0s[the_table-1]);
623         }
624       }
625       
626
627       else if(!strncmp(buf,"scale0p",7)) {
628         int the_table;
629         if (!strncmp(buf,"scale0p =",9)) {
630           sscanf(buf,"scale0p = %lf", &scale0p[0]);  
631           for (the_table =0; the_table < MAX_TABLE_NUMBER; the_table++) {
632             scale0p[the_table] =scale0s[0];
633             printf("scale0p %d = %lf\n", the_table, 
634                    scale0p[the_table]);
635           }
636         }             /* All tables get same scale0. **/
637         else {
638           sscanf(buf,"scale0p %d", &the_table);
639           sscanf(buf,"scale0p %d = %lf", &the_table, 
640                  &scale0p[the_table-1]); 
641           printf("scale0p %d = %lf\n",the_table,scale0p[the_table-1]);
642         }
643       }
644 /***************************************************************/
645 /***********************************************************/
646     
647  
648
649       else if(!strncmp(buf,"method",6)) {     /* Reads in the method that   */
650         sscanf(buf,"method = %s", name);     /* should output to fout.     */
651 /*****
652         printf("method = %s\n",name);
653 *****/
654         if (!strcmp(name,"PairCoil")) sprintf(name,"Coil");
655         for (i=0; i<NUMBER_METHODS;i++)
656           if (!strcmp(name,methodname[i]))
657             *main_method = i;
658       } 
659       else if(!strncmp(buf,"preprocessor",12)) {/* Reads in the method that  */
660         sscanf(buf,"preprocessor = %s", name); /* should output to fout.   */
661 /*****
662         printf("preprocessor = %s\n",name);
663 ******/
664         if (!strcmp(name,"PairCoil")) sprintf(name,"Coil");
665         for (i=0; i<NUMBER_PREPROCESSORS;i++)
666           if (!strcmp(name,methodname[i]))
667             *main_preprocessor_method = i;
668       } 
669       
670
671       else if(!strncmp(buf,"default table",13)) { 
672         sscanf(buf,"default table = %s", name); 
673         printf ("default table = %s",name);
674         if (!strcmp(name, "dimer"))
675           *main_table =0;   /* Table 0 should be dimer.  */
676         else if (!strcmp(name, "trimer"))
677           *main_table =1;   /* Table 1 should be trimer.  */
678         else if (!strcmp(name, "combination"))
679           *main_table =2;   /* Table 2 should be combination of table 0+1. */
680         else {  /*  Just get a table number.  */
681           sscanf(name,"%d", main_table);  
682           (*main_table)--; /* Human table number starts at 1, computer at 0 */
683         }
684       }
685
686     
687
688 /***************The following options are for dimer-trimer likelihoods******/
689       else if(!strncmp(buf,"avg_max", 7)) {
690         sscanf(buf,"avg_max = %s", name); 
691         if (!strcmp(name,"avg")) *avg_max=0;
692         else if (!strcmp(name,"max")) *avg_max=1;
693         else if (!strcmp(name,"both")) *avg_max=2;
694         
695         fprintf(stderr, "avg_max = %d\n", *avg_max);
696       }
697       else if(!strncmp(buf,"offset", 6)) {  /* -1 means every offset.  */
698         sscanf(buf,"offset = %d", offset_to_use); /* 7 means max like offset */
699         fprintf(stderr, "offset for TableDiff = %d\n", *offset_to_use);
700       }
701       else if (!strncmp(buf,"use like line",  13)) {
702         *mode |= USE_LIKE_LINE;
703         fprintf(stderr,"Using  likelihood line in Pair/SingleCoil computations, not the actual prob. formula.");
704       }
705       else if (!strncmp(buf,"weighted paircoil",  17)) {
706         *mode |= WEIGHTED_PROBS;
707         fprintf(stderr,"Using weights in paircoil computation.");
708       }
709       
710       else if (!strncmp(buf,"do coil avg score", 17)) {
711         *Coil_Score = 1;
712         fprintf(stderr,"\nDoing Coil avg score\n");
713       }
714       
715       else if (!strncmp(buf,"do coil max score", 17)) {
716         *Coil_Score = 2;
717         fprintf(stderr,"\nDoing Coil max score\n");
718       }
719     }
720
721   }
722   else {
723     fprintf(stderr,"\nCouldn't find paircoil_config file.");
724     fprintf(stderr,"\n   Assumed it would be located in %s.",buf);
725     fprintf(stderr,"\n   You should either place it there, or set the environment");
726     fprintf(stderr,"\n   variable PAIRCOIL_CONFIG to its location.\n");
727     exit(-1);
728   }
729 }
730
731
732
733
734
735
736
737
738