JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / get_defaults_cuts.c
1       else if(!strncmp(buf,"differ_lib",10)) {/* Read in a variable number  */
2         char *end;                          /*  of distances to be used in  */
3         int val;                            /*  PairCoilDiffer scores.      */
4         int do_each_dist_separately =0;
5
6         if (!strncmp(buf,"differ_lib dim",14))   
7           do_each_dist_separately = 1;
8
9         if (!strncmp(buf,"differ_lib = all",16))
10           {
11                            /* For scscore.c will go through each dist on own*/
12             for (i=0; i<7; i++) 
13               differ_lib[i] = i;
14             *differ_functnum = 1; 
15             *number_differ_lib = 7;
16             printf("differ_lib = all dimensions");
17           }
18      
19         else  {
20           if (do_each_dist_separately)
21             printf("differ_lib dimensions= ");  
22           else printf("differ_lib = ");
23
24           tmp = strchr(buf, '='); 
25           tmp++;                  
26           /* strip leading whitespace */    
27           while(!isdigit(*tmp)&&*tmp) tmp++;
28           while(end = strchrs(tmp, " \t\n\r")) {
29             *end = 0;
30             end++;
31             /* strip leading whitespace */
32             while(*tmp&&!isdigit(*tmp)) tmp++;
33             if(*tmp) {
34               val = atoi(tmp);
35               differ_lib[(*differ_functnum)++] = val;
36               printf("%d ", val);
37             }
38             tmp = end;
39           }
40           printf("\n");
41
42           if (do_each_dist_separately) {
43             *number_differ_lib = *differ_functnum;
44             *differ_functnum=1;
45               /* Each distance is a library to itself. */
46           }
47         }
48       }
49         
50
51
52       else if (!strncmp(buf, "New coil at reg shift",21)) 
53         *start_coil_at_reg_shift = 1;
54
55
56       else if(!strncmp(buf,"differ class scores dimer",25)) { 
57         
58         sscanf(buf,"differ class scores dimer = %s", 
59                differ_class_sc_filenames[0]); 
60         printf("differ class scores dimers = %s\n",  
61                differ_class_sc_filenames[0]); 
62
63       }
64
65       else if(!strncmp(buf,"differ gauss_param",18)) {   
66         sscanf(buf,"differ gauss_param = %s",differ_gaussian_parameters);
67         printf("differ gauss_param = %s\n",differ_gaussian_parameters);
68       }
69
70
71       else if(!strncmp(buf,"prior freq single",17)) {
72         int the_table;
73         if (!strncmp(buf,"prior freq single =",19)) {
74           sscanf(buf,"prior freq single = %lf", &prior_freq_single[0]);  
75           for (the_table =0; the_table < MAX_TABLE_NUMBER; the_table++) {
76             prior_freq_single[the_table] = prior_freq_single[0];
77             printf("prior_freq_single %d = %lf\n", the_table, 
78                    prior_freq_single[the_table]);
79           }
80         }             /* All tables get same scale0. **/
81         else {
82           sscanf(buf,"prior freq single %d", &the_table);
83           sscanf(buf,"prior freq single %d = %lf", &the_table, 
84                  &prior_freq_single[the_table-1]); 
85         printf("prior_freq_single %d = %lf\n",
86                the_table,prior_freq_single[the_table-1]);
87         }
88       }
89       else if(!strncmp(buf,"prior freq pair",15)) {
90         int the_table;
91         if (!strncmp(buf,"prior freq pair =",17)) {
92           sscanf(buf,"prior freq pair = %lf", &prior_freq_pair[0]);  
93           for (the_table =0; the_table < MAX_TABLE_NUMBER; the_table++) {
94             prior_freq_pair[the_table] = prior_freq_pair[0];
95             printf("prior_freq_pair %d = %lf\n", the_table, 
96                    prior_freq_pair[the_table]);
97           }
98         }             /* All tables get same scale0. **/
99         else {
100           sscanf(buf,"prior freq pair %d", &the_table);
101           sscanf(buf,"prior freq pair %d = %lf", &the_table, 
102                  &prior_freq_pair[the_table-1]); 
103         printf("prior_freq_pair %d = %lf\n",
104                the_table,prior_freq_pair[the_table-1]);
105         }
106       }
107
108
109 /***********************************************************/
110       else if(!strncmp(buf,"structurally important pos",26)) {
111         char *end;                        
112         int val;                          
113
114         i =0;
115         printf("structurally important pos = ");         
116         tmp = strchr(buf, '=');         
117         tmp++;                          
118         /* strip leading whitespace */  
119         while(!islower(*tmp)&&*tmp) tmp++;
120         while(end = strchrs(tmp, " \t\n\r")) {
121           *end = 0;
122           end++;
123           /* strip leading whitespace */
124           while(*tmp&&!islower(*tmp)) tmp++;
125           if(*tmp) {
126             val = (*tmp)- 'a';
127             if ((val>=7) || (val<0))
128               printf(" **ILLEGAL position %c ignored** ", 'a' + val);
129             else {
130               printf("%c ", 'a' + val);
131               structural_pos[i]= val;
132               i++;
133             }
134           }
135           tmp = end;
136         }
137         printf("\n");
138         structural_pos[i] = -1;  /*  Flag that at end. */
139       }
140  
141       else if(!strncmp(buf,"good_turing",11)) {
142         *good_turing_fixed_disc = 1;
143         printf("Estimating prob using good_turing method.\n");
144       }
145       else if(!strncmp(buf,"modified_good_turing",20)) {
146         *good_turing_fixed_disc = 3;
147         printf("Estimating prob using modified good_turing method.\n");
148       }
149       else if(!strncmp(buf,"fixed_disc",10)) {
150         *good_turing_fixed_disc = 2;
151         printf("Estimating prob using fixed_discount method with discount determined by SCALE0.\n");
152       }
153 /**********************************************************/
154       else if(!strncmp(buf,"zero freqs from dimers",22)) {
155         *priors =-1;
156         printf("zero freqs for trimers from dimers.\n");
157       }
158
159       else if(!strncmp(buf,"add priors if less than dimer expectation",41)) {
160         *priors =-2;
161         printf("Add priors only if freq is less than dimer expectation.\n");
162       }
163
164       else if(!strncmp(buf,"prior singles from",18)) { 
165                                             /* Reads in what to use as   */
166         tmp = &buf[19]; /* One past space */
167         if (!strncmp(tmp,"dimers",6 )) {     /* prior prob in estimating   */
168           *priors = 1;
169           printf("priors from dimers\n");    /* trimer table probs.  */
170         }
171         else if (!strncmp(tmp,"genbnk",6 )) {     
172           *priors = 2;
173           printf("priors from genbnk\n");
174         }
175         else if (!strncmp(tmp,"average",7 )) {     
176           *priors = 3;
177           printf("priors from average of dimers and genbnk\n");
178         }
179       } 
180
181       else if(!strncmp(buf,"zero freqp from dimers",22)) {
182         *priorp =-1;
183         printf("zero freqp for trimers from dimers.\n");
184       }
185       else if(!strncmp(buf,"add priorp if less than dimer expectation",41)) {
186         *priorp =-2;
187         printf("Add priorp only if freq is less than dimer expectation.\n");
188       }
189
190        else if(!strncmp(buf,"prior pairs from",16)) { 
191                                             /* Reads in what to use as   */
192         tmp = &buf[17]; /* One past space */
193         if (!strncmp(tmp,"dimers",6 )) {     /* prior prob in estimating   */
194           *priorp = 1;
195           printf("priorp from dimers\n");    /* trimer table probs.  */
196         }
197         else if (!strncmp(tmp,"genbnk",6 )) {     
198           *priorp = 2;
199           printf("priorp from genbnk\n");
200         }
201         else if (!strncmp(tmp,"average",7 )) {     
202           *priorp = 3;
203           printf("priorp from average of dimers and genbnk\n");
204         }
205
206         else if (!strncmp(tmp,"product of singles",18 )) {     
207           *priorp = 4;
208           printf("priorp from product of singles\n");
209         }
210       } 
211 /**************************************************************/
212       else if(!strncmp(buf,"differentiator window length",28)) {
213           sscanf(buf,"differentiator window length = %d", 
214                  differ_window_length);
215           printf("differentiator window length = %d\n", 
216                  *differ_window_length);
217         }
218
219
220
221
222 /**************************************************************/
223 /************************Round 2 of cuts **********************/
224 /**************************************************************/
225
226       else if(!strncmp(buf,"coil conflicts",14)) {     
227         if (!strncmp(buf,"coil conflicts dir",19)){ /* automate the name **/ 
228          sscanf(buf,"coil conflicts dir = %s",name);
229          strcat(name,input_name);
230          strcat(name,".coil_conflicts");
231
232           /**** Apend on the library distances.  ***/
233           if (multi_functnum[0] == 1) { /* make sure do dimension scores */
234             lib_numb=0;
235             while (lib_numb < number_multi_lib[0]) {
236               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
237               lib_numb++; }
238             sprintf(&buf[lib_numb],"_");
239             strncat(name,buf,number_multi_lib[0]+1);
240
241
242             lib_numb=0;
243             while (lib_numb < number_multi_lib[1]) {
244               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
245               lib_numb++; }
246             strncat(name,buf,number_multi_lib[1]);
247           }
248
249         }
250         else sscanf(buf,"coil conflicts = %s",name);  
251         *flog_coil_conflicts = sopen(name,"w");
252         printf("coil conflicts = %s\n",name);
253       }
254
255 changed
256       else if(!strncmp(buf,"table",5)) {   /* Get location of postable file */
257         sscanf(buf,"table %d = %s",&i, name);
258         if (strcmp("combination",name)) {  /* If it is combination, just  */
259           fpin[*number_tables] = sopen(name,"r");  /* increment number tables*/
260         }                                    /* Otherwise open file.       */
261         printf("table %d = %s\n",*number_tables,name); 
262         (*number_tables)++;
263         fpin[*number_tables]= NULL;
264       }
265
266 to
267
268       else if(!strncmp(buf,"table",5)) {   /* Get location of postable file */
269         sscanf(buf,"table %d = %s",&i, name);
270         fpin[i-1] = sopen(name,"r");
271         printf("table %d = %s\n",i,name); 
272         (*number_tables)++;
273         fpin[i]= NULL;
274       }
275
276
277 changed
278             if (!strncmp(buf,"multi_lib dim =",15)) {
279               first_table=0; last_table=*number_tables;  
280             }             /* All tables get same lib. **/
281             else {
282               sscanf(buf,"multi_lib dim %d", &last_table);
283               first_table = last_table-1;
284             }
285           }
286           else if (!strncmp(buf,"multi_lib =",11)) {
287             first_table=0; last_table=*number_tables;  
288           }             /* All tables get same lib. **/
289           
290 to
291
292             if (!strncmp(buf,"multi_lib dim =",15)) {
293               first_table=0; last_table=NUMBER_TABLES;  
294             }             /* All tables get same lib. **/
295
296             else {
297               sscanf(buf,"multi_lib dim %d", &last_table);
298               first_table = last_table-1;
299             }
300           }
301           else if (!strncmp(buf,"multi_lib =",11)) {
302             first_table=0; last_table= NUMBER_TABLES;  
303           }             /* All tables get same lib. **/
304
305
306
307
308 cut
309          if (*weighted_avg)
310            strcat(name,"_WtdAvg");
311
312
313       else if (!strncmp(buf,"weighted_avg", 12)) {
314         sscanf(buf, "weighted_avg = %d", weighted_avg);  
315                    /* 0 means just avg. res score over coil.  */
316                    /* 1 means do weighted avg. by likelihoods */
317         if ( (*weighted_avg !=0)  &&(*weighted_avg !=1)) {
318           fprintf(stderr,"\n Illegal weighted_avg method.  Defaults to 0.\n");
319           *weighted_avg = 0;
320         }
321         else fprintf(stderr,"weighted_avg = %d\n", *weighted_avg);
322       }
323     }
324
325
326
327
328 cut
329
330       else if(!strncmp(buf,"tab diff stats",14)) {   
331         sscanf(buf,"tab diff stats = %s",table_diff_stats_filename);
332         printf("tablediff stats = %s\n",table_diff_stats_filename);
333       }
334       else if(!strncmp(buf,"weightfile outname",18)) {   
335         sscanf(buf,"weightfile outname = %s",weightfile_outname);
336         printf("weightfile outname = %s\n",weightfile_outname);
337       }
338
339
340 changed
341
342       else if(!strncmp(buf,"class scores combo",18)) {   
343         sscanf(buf,"class scores combo %d with init prob %lf = %s",&i, 
344                &init_class_prob[*number_classes],
345                class_sc_filenames[0][*number_classes]); 
346         printf("combo class scores %d = %s with init prob %lf\n",
347                *number_classes,class_sc_filenames[0][*number_classes],
348                init_class_prob[*number_classes]);  /* likelihood lines.  */
349         (*number_classes)++;
350         class_sc_filenames[0][*number_classes][0]= ',';
351       }
352
353
354       else if(!strncmp(buf,"class scores max",16)) {   
355         sscanf(buf,"class scores max %d with init prob %lf = %s",&i, 
356                &init_class_prob[number_max_classes],
357                class_sc_filenames[1][number_max_classes]); 
358         printf("max class scores %d = %s with init prob %lf\n",
359                number_max_classes,class_sc_filenames[1][number_max_classes],
360                init_class_prob[number_max_classes]);  /* likelihood lines.  */
361         number_max_classes++;
362         class_sc_filenames[1][number_max_classes][0]= ',';
363       }
364
365 to
366       else if(!strncmp(buf,"class scores combo",18)) {   
367         sscanf(buf,"class scores combo %d with init prob %lf = %s",&i, 
368                &init_class_prob[i-1],
369                class_sc_filenames[0][i-1]); 
370         printf("combo class scores %d = %s with init prob %lf\n",
371                i,class_sc_filenames[0][i-1],
372                init_class_prob[*number_classes]);  /* likelihood lines.  */
373         class_sc_filenames[0][i][0]= ',';
374       }
375
376
377       else if(!strncmp(buf,"class scores max",16)) {   
378         sscanf(buf,"class scores max %d with init prob %lf = %s",&i, 
379                &init_class_prob[i-1],
380                class_sc_filenames[1][i-1]); 
381         printf("max class scores %d = %s with init prob %lf\n",
382                i,class_sc_filenames[1][i-1],
383                init_class_prob[i-1]);  /* likelihood lines.  */
384         class_sc_filenames[1][i][0]= ',';
385
386
387
388 CUT
389       else if(!strncmp(buf,"average differentiator by coil window",37)) {
390         *which_differentiator = 4;
391         printf("The differentiator score is over the entire coiled region\n");
392       }
393  
394
395       else if(!strncmp(buf,"differentiator by coil window",29)) {
396         *which_differentiator = 3;
397         printf("The differentiator score is over the entire coiled region\n");
398       }
399       else if(!strncmp(buf,"differentiator by window score",30)) {
400         *which_differentiator = 1;
401         printf("The differentiator residue score is the score of the window starting at that residue\n");
402       }
403       else if(!strncmp(buf,"differentiator by max-min window score",38)) {
404         *which_differentiator = 2;
405         printf("The differentiator residue score is the scores for the max and min window containing that residue\n");
406       }
407
408
409
410
411 Completely rewrote stuff to read in multi_lib to deal with variables
412 num_dist and combined_dist.
413
414
415 Cut
416
417       else if(!strncmp(buf,"differ class scores trimer",26)) { 
418         
419         sscanf(buf,"differ class scores trimer = %s", 
420                differ_class_sc_filenames[1]); 
421         printf("differ class scores trimers = %s\n",  
422                differ_class_sc_filenames[1]); 
423
424       }
425
426
427 Changed
428
429             lib_numb=0;
430             while (lib_numb < number_multi_lib[0]) {
431               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
432               lib_numb++; }
433             sprintf(&buf[lib_numb],"_");
434             strncat(name,buf,number_multi_lib[0]+1);
435
436             lib_numb=0;
437             while (lib_numb < number_multi_lib[1]) {
438               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
439               lib_numb++; }
440             strncat(name,buf,number_multi_lib[1]);
441
442 to
443
444             while (lib_numb < num_dist[0]) {
445               sprintf(&buf[lib_numb],"%d",multi_lib[0][lib_numb]);
446               lib_numb++; }
447             sprintf(&buf[lib_numb],"_");
448             strncat(name,buf,num_dist[0]+1);
449
450             lib_numb=0;
451             while (lib_numb < num_dist[1]) {
452               sprintf(&buf[lib_numb],"%d",multi_lib[1][lib_numb]);
453               lib_numb++; }
454             strncat(name,buf,num_dist[1]);
455
456
457
458 Changed
459           /**** Apend on the library distances.  ***/
460           if (multi_functnum[0] == 1) { /* make sure do dimension scores */
461             lib_numb=0;
462 to
463           if (combine_dist[0] == 0)
464
465
466
467 Cut
468         class_sc_filenames[0][number_classes][0]= ',';
469 and
470         class_sc_filenames[1][number_max_classes][0]= ',';
471       }
472
473 from when reading in class filenames.
474
475
476
477 Modified stuff that reads in "coil scores = ...."
478 so can also read it in as "seq scores = ...."
479 and seq by_coil_or_seq based on if used "coil" or "seq".
480 Therefore, could eliminate
481       else if (!strncmp(buf,"By coil",7))
482         *by_coil_or_seq = 0;
483       else if (!strncmp(buf,"By seq",6))
484         *by_coil_or_seq =2;
485 but kept
486       else if (!strncmp(buf,"By seq pos regions",18))
487         *by_coil_or_seq =1;
488