JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / interface_cuts.c
1 from interface.h cut #define MAX_TABLE_NUMBER 4
2
3 put /*  #define COMPUTE_GAUSSIAN_VERSION  */ in options.h
4 put  #define NUMBER_TABLES 2  in scconst.h
5 put #define NUMBER_CLASES 3 in scconst.h
6 put #define MAX_TABLE_NUMBER 2   /* Same as NUMBER_TABLES. **/ in scconst.h
7 put #define NUM_DIM_IN_ORIG_MATRIX 14 in scconst.h
8 and in interface.c
9 for both_class_covars[][][][] and both_class_means[][][] made the max size
10 of the matrix be NUM_DIM_IN_ORIG_MATRIX  (Then changed in multivariate_like.c
11 where pass these in).  (get_gauss_param_all_classes2(), compute_submatrices2())
12
13 In scconst.h, put
14 #ifdef COMPUTE_GAUSSIAN_VERSION
15   #define MAX_NUM_SCORE_DIM 14
16 #else
17   #define MAX_NUM_SCORE_DIM 6
18 #endif
19
20
21  double m_single[MAX_TABLE_NUMBER],
22          b_single[MAX_TABLE_NUMBER];  /*  Like line for singlecoil. */
23
24
25  /*************************** PAIRDIFF LIKELIHOOD STUFF. *********************/
26  double differ_determinants[MAX_CLASS_NUMBER];
27  double differ_inverse_covars[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
28  double differ_covars_submatrix[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
29  double differ_means_submatrix[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM];
30
31  int number_differ_score_dim =0;
32  int number_differ_lib=0;
33  int differ_window_length = 28;
34  int which_differentiator=1;   /** Default is just the score for the window **/
35                            /** 2 means to give each residue a pair of scores**/
36                            /** corresponding to the max and min of the      **/
37                            /** windows containing it.                       **/
38  int differ_functnum=0;
39 #endif
40
41
42 #ifdef TEST_VERSION
43   char differ_class_sc_filenames[MAX_CLASS_NUMBER][MAXLINE];
44   double differ_means[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM];
45   double differ_covars[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
46   char differ_gauss_param[MAXLINE];
47   char differ_lib[MAXFUNCTNUM];   /*  Distance values for PairCoilDiff */
48   extern int differ_functnum;     
49 #ifdef TEST_VERSION
50
51 #ifdef TEST_VERSION
52   double prior_freq_single[MAX_TABLE_NUMBER], 
53          prior_freq_pair[MAX_TABLE_NUMBER];
54   int which_priors =0, which_priorp =0;
55   int good_turing_fixed_disc =0;    /** If set to 1 do the good_turing_fixed_disc estimate of probs*/
56   int structural_pos[POSNUM+1];  /** Holds list of which positions are **/
57                                /** structurally important.  All others **/
58                                /** get genbnk probabilities....       **/
59                                /** Value -1 indicates no more entries. **/
60 #endif
61
62  int old_num_dim_differ =0;
63                           /* The gauss param file for multiple distances is */
64                          /* contains the parameters for all distances.     */
65 #ifdef TEST_VERSION
66   compute_multivariate_num_differ_dim(&number_differ_score_dim,
67                                number_differ_lib,
68                                differ_functnum, &old_num_dim_differ,
69                                which_differentiator);
70 #endif
71
72 cut
73 double both_covars_submatrix[2][MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
74
75
76
77 #ifdef TEST_VERSION
78 /*************************************************************************/
79 /******************Now do gauss parameters for PairCoilDiff method.  *****/
80 /*************************************************************************/
81 /**** Note the "2" parameter represents that are 2 classes (dimers, trimers)***/
82 /**** not three, since just differentiating so don't need pdb-.    ************/
83
84   if (differ_gauss_param[0] != ',') {
85     char differ_lib_hack[2][MAXFUNCTNUM];
86                      /** If are computing max and min window scores, **/
87                      /** then need to extract both dimenion i and   **/
88                      /** i + old_num_dim_differ/2. Treat them like they **/
89                      /** were from another table.   ***/
90
91
92     get_gauss_param_all_classes2(differ_class_sc_filenames, 
93                                  old_num_dim_differ,
94                                  differ_means, differ_covars,
95                                  2, differ_gauss_param);
96         
97     if (which_differentiator ==2) {
98       for (i=0; i<number_differ_score_dim/2; i++) {
99         differ_lib_hack[0][i] = differ_lib[i];
100         differ_lib_hack[1][i] = differ_lib[i];
101       }
102       compute_submatrices2(differ_means,differ_means_submatrix,
103                          differ_covars,2, 
104                          differ_inverse_covars,
105                          differ_determinants, differ_lib_hack,
106                          old_num_dim_differ/2, old_num_dim_differ/2,
107                          number_differ_score_dim/2, number_differ_score_dim/2,
108                          1);
109     }
110     else
111       compute_submatrices2(differ_means,differ_means_submatrix,
112                          differ_covars,2, 
113                          differ_inverse_covars,
114                          differ_determinants, differ_lib,
115                          old_num_dim_differ, 0,
116                          number_differ_score_dim, 0,
117                          1);
118
119 /************/
120           for (class=0; class<2; class++) {
121             fprintf(stderr,"\n\nDiffer Mean Submatrix %d:\n",class);
122             print_matrix(differ_means_submatrix[class],1,
123                         number_differ_score_dim,stderr);
124             fprintf(stderr,"\n\nDiffer Inver Covar Submatrix %d:\n", class);
125             print_matrix(differ_inverse_covars[class],
126                          number_differ_score_dim,number_differ_score_dim,
127                          stderr);
128             
129           }
130 /**********/
131
132     fprintf(stderr,"\nDet0 =%lf, det1= %lf\n",
133             differ_determinants[0],differ_determinants[1]);
134         
135     fprintf(stderr,"\nnew_num_dim_differ=%d, old_num_dim_differ=%d,", number_differ_score_dim, old_num_dim_differ);
136
137           
138
139   }
140 #endif
141
142 #ifdef TEST_VERSION
143       case XK_A:         /** Switch between unweighted avg and  **/
144       case XK_a:         /** weighted avg coil score.             **/
145         weighted_avg = !weighted_avg;
146         if (Coil_Score !=0) { /** CoilScore ==0 means not doing coil score. **/
147           ShowSeq(lib,differ_lib,multi_lib,
148                   m,b,m_single,b_single,mode,-1,-1, bound);
149           if (zoomptr) Zoomer();
150         }
151         break;
152
153
154       case XK_b:
155       case XK_B:         /** For CoilScore, change how deal with reg shift. **/
156         start_coil_at_reg_shift = !start_coil_at_reg_shift;
157         if (Coil_Score !=0) { /** CoilScore ==0 means not doing coil score. **/
158           ShowSeq(lib,differ_lib,multi_lib,
159                   m,b,m_single,b_single,mode,-1,-1, bound);
160           if (zoomptr) Zoomer();
161         }
162         break;
163
164
165       case XK_R:
166       case XK_r:
167         offset_to_use = (offset_to_use +1) % 8;   /* Cycle through offsets */
168 /***    switch_gauss_param(offset_to_use);  **/
169         ShowSeq(lib,differ_lib,multi_lib,
170                 m,b,m_single,b_single,mode,1,1, bound);
171         if (zoomptr) Zoomer();
172         break;
173       case XK_s:        /*  Use single probabilities. */
174       case XK_S:
175         if (mode & PAIRCOIL_PAIRS) {
176           mode -= PAIRCOIL_PAIRS; /** Turn it off **/
177           ShowSeq(lib,differ_lib,multi_lib,
178                 m,b,m_single,b_single,mode,1,1, bound);
179           if (zoomptr) Zoomer();
180         }
181         break;
182
183       case XK_l:        /*  Use pair probabilities at lib distances */
184       case XK_L:
185         if (!(mode & PAIRCOIL_PAIRS)) {
186           mode |= PAIRCOIL_PAIRS;  /* Turn it on. */
187           ShowSeq(lib,differ_lib,multi_lib,
188                   m,b,m_single,b_single,mode,1,1, bound);
189           if (zoomptr) Zoomer();
190         }
191         break;
192 #endif
193
194
195
196 changed   
197   initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
198              scale0p,fpin[0],
199              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
200              differ_gauss_param,
201              &mode, prior_freq_single, prior_freq_pair,
202              structural_pos);
203 to
204   initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
205              scale0p,fpin[0],
206              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
207              &mode, prior_freq_single, prior_freq_pair,
208              structural_pos);
209
210
211
212 changed 
213 OpenScreen(int mode, double log_bound, FILE *fin, FILE *flog, 
214                 FILE* flog_coil_conflicts,FILE *fout_coils,
215                 FILE *fout,
216                 double *m, double *b, double *m_single, double *b_single, 
217                 char lib[MAXFUNCTNUM], 
218                 char differ_lib[MAXFUNCTNUM], 
219                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
220                 int main_method, 
221                 int main_preprocessor_method,
222                 int *seqcnt, int which_priors, int which_priorp,
223                 double prior_freq_single[MAX_TABLE_NUMBER],
224                 double prior_freq_pair[MAX_TABLE_NUMBER], 
225                 int good_turing_fixed_disc, int structural_pos[POSNUM+1])
226
227 to
228 OpenScreen(int mode, double log_bound, FILE *fin, FILE *flog, 
229                 FILE* flog_coil_conflicts,FILE *fout_coils,
230                 FILE *fout,
231                 double *m, double *b, double *m_single, double *b_single, 
232                 char lib[MAXFUNCTNUM], 
233                 char differ_lib[MAXFUNCTNUM], 
234                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
235                 int main_method, 
236                 int main_preprocessor_method,
237                 int *seqcnt)
238
239
240 changed
241       finish_log(mode,log_bound,fin,flog,flog_coil_conflicts,fout_coils,
242                  fout, 
243                  m,b, m_single, b_single,
244                      lib,differ_lib,multi_lib, main_method, main_table,
245                      main_preprocessor_method, seqcnt, avg_max, which_priors,
246                      which_priorp, prior_freq_single, prior_freq_pair, 
247                      good_turing_fixed_disc, structural_pos);
248
249 to
250       finish_log(mode,log_bound,fin,flog,flog_coil_conflicts,fout_coils,
251                  fout, 
252                  m,b, m_single, b_single,
253                      lib,differ_lib,multi_lib, main_method, main_table,
254                      main_preprocessor_method, seqcnt, avg_max);
255
256 changed
257   if (mode & TST_MODE0) 
258     recalc_prob(sequence, 0, mode, which_priors, which_priorp,
259                 prior_freq_single, prior_freq_pair, good_turing_fixed_disc,
260                 structural_pos);
261   if (mode & TST_MODE1)
262     recalc_prob(sequence,1, mode, which_priors, which_priorp,
263                 prior_freq_single, prior_freq_pair, good_turing_fixed_disc,
264                 structural_pos);
265 to
266   if (mode & TST_MODE0) 
267     recalc_prob(sequence, 0, mode);
268   if (mode & TST_MODE1)
269     recalc_prob(sequence,1, mode);
270
271
272 /*************************************************************************/
273 /********     ROUND 2 of cuts. *******************************************/
274 /*************************************************************************/
275
276 int number_classes=0;  
277 int weighted_avg = 0;  /*  Determines which method for determining coil */
278                          /*  score will be used in DimerTrimerScore.      */
279 char table_diff_stat_filename[MAXLINE]="/dev/null";
280 char weightfile_outname[MAXLINE]="/dev/null";
281
282   "key 'r':   Cycle through offsets 0-7 for register (7=combo reg)",
283   "key 'b':   For Coil score, toggle whether start new coils at",
284   "             a register shift (break in structure).",
285   "key 'a':   For Coil score, toggle between unweighted and weighted avg",
286   "",
287
288
289 FILE *flog_coil_conflicts=NULL
290   extern int number_classes;  
291
292
293
294   double upper_bound;   /* In DEBUG_MODE (for printing out the predicted    */
295                         /* heptad repeat), scores in  [bound,upper_bound]   */
296                         /* are printed in capital letters.                  */
297
298
299
300 changed
301   initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
302              scale0p,fpin[0],
303              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
304              &mode, prior_freq_single, prior_freq_pair,
305              structural_pos);
306 to 
307   initialize(&number_multi_lib[0], window_length, scale0s,
308              scale0p,fpin[0],
309              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
310              &mode);
311
312 changed
313
314   get_defaults(argv[1], &mode, &log_bound, &fgin, fpin, 
315                &ftotal_like, &fout, 
316                &flog, &flog_coil_conflicts, 
317                &fout_coils, &by_coil_or_seq, likelihoods,
318                pir_name, lib, multi_lib, 
319                &pair_functnum, multi_functnum,
320                print, &main_method, &main_preprocessor_method, 
321                &main_table, &number_tables,  &offset_to_use,  
322                &avg_max, &weighted_avg,   &Coil_Score,
323                table_diff_stat_filename, weightfile_outname,
324                &ps_res_per_line, &number_classes, 
325                class_sc_filenames, 
326                gauss_param,  number_multi_lib,
327                init_class_prob, 
328                &table_to_remove_from,  
329                command_line, window_length, scale0s, scale0p,
330                &which_differentiator);
331 to
332
333
334   get_defaults(argv[1], &mode, &log_bound, &fgin, fpin, 
335                &ftotal_like, &fout, 
336                &flog, 
337                &fout_coils, &by_coil_or_seq, likelihoods,
338                pir_name, lib, multi_lib, 
339                &pair_functnum, multi_functnum,
340                print, &main_method, &main_preprocessor_method, 
341                &main_table, &offset_to_use,  
342                &avg_max,   &Coil_Score,
343                &ps_res_per_line,  
344                class_sc_filenames, 
345                gauss_param,  number_multi_lib,
346                init_class_prob, 
347                &table_to_remove_from,  
348                command_line, window_length, scale0s, scale0p);
349
350
351 cut     int old_num_dim_table[2];
352         int new_num_dim_table[2];
353  
354 and
355 compute_multivariate_num_dim(mode, &number_score_dim,
356                                number_multi_lib,multi_functnum, number_tables,
357                                new_num_dim_table, old_num_dim_table);
358
359
360 changed
361
362   if (number_classes >0)  {        /*** Get gaussian param for the classes. */
363     if (ftotal_like) {      /** Want to output total gauss like over classes*/
364       for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
365         init_class_prob[i]=1;   /** All 1 values is flag to just output     */
366       init_totals(total_gauss_like); /** gauss values, not like values in   */
367       }                              /** convert_raw_scores_to_gauss_like.   */
368   
369 to
370
371   if (ftotal_like) {      /** Want to output total gauss like over classes*/
372     for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
373       init_class_prob[i]=1;   /** All 1 values is flag to just output     */
374     init_totals(total_gauss_like); /** gauss values, not like values in   */
375   }                              /** convert_raw_scores_to_gauss_like.   */
376
377
378 Replace int number_multi_lib[MAX_TABLE_NUMBER]
379 with  int num_dist[MAX_TABLE_NUMBER] almost everywhere
380
381 in conjunction with replacing multi_functnum with a variable indicating
382 if distances are each a dimension, or if should combine into a single
383 library...
384 i.e. change 
385   int multi_functnum[MAX_TABLE_NUMBER]
386     to 
387       int combine_dist[MAX_TABLE_NUMBER];
388
389
390 CHANGED:
391
392     get_gauss_param_all_classes2(class_sc_filenames[i], 
393                                  old_num_dim_table[0]+old_num_dim_table[1],
394                                  both_class_means[i], both_class_covars[i],
395                                  number_classes, gauss_param[i]); 
396 to
397       get_gauss_param_all_classes2(class_sc_filenames[i], 
398                                      6*combine_dist[0] + 1 +
399                                      6*combine_dist[1] + 1,
400                                     both_class_means[i], both_class_covars[i],
401                                     gauss_param[i]);
402
403 changed 
404       compute_submatrices2(both_class_means[i],both_means_submatrix[i],
405                                    both_class_covars[i], 
406                                    both_inverse_covars[i],
407                                    both_determinants[i], multi_lib,
408                                    old_num_dim_table[0], old_num_dim_table[1],
409                                    new_num_dim_table[0], new_num_dim_table[1],
410                                    mode & MULTI_TRIMER_PAIRS);
411 to
412       compute_submatrices2(both_class_means[i],both_means_submatrix[i],
413                                    both_class_covars[i], 
414                                    both_inverse_covars[i],
415                                    both_determinants[i], multi_lib,
416                                    6*combine_dist[0] + 1, 
417                                    6*combine_dist[1] + 1
418                                    (num_dist[0]-1)*combine_dist[0] + 1, 
419                                    (num_dist[1]-1)*combine_dist[1] + 1);
420
421
422
423 added      number_score_dim = (num_dist[0]-1)*combine_dist[0] + 1 +
424                                    (num_dist[1]-1)*combine_dist[1] + 1;
425
426
427
428 changed
429     log_file_header(flog, flog_coil_conflicts,  mode, 
430                     argc, argv, avg_max, log_bound, 
431                     preprocessor_method, preproc_table, log_offset_to_use, 
432                     start_coil_at_reg_shift, weighted_avg, main_method, 
433                     main_table);
434 to
435
436   if ( (mode & PRN_MODE) && flog ){
437     log_file_header(flog,  mode, 
438                     argc, argv, avg_max, log_bound, 
439                     preprocessor_method, preproc_table, log_offset_to_use, 
440                     start_coil_at_reg_shift, main_method, 
441                     main_table);
442
443 from that function, cut stuff for log_coil_conflicts
444 and cut
445       if (weighted_avg == 0) {
446           fprintf(flog, "\n Averaging over coils was done by coil length.");
447       }
448       else  { /* weighted_avg ==1 */
449         fprintf(flog, "\n Averaging over coils was done using coil length weighted at each position by the preprocessor coil likelihood.");
450       }
451
452
453 changed 
454
455
456   PairCoilData(fgin,fpin,&number_tables, mode & PROLINE_FREE_MODE,
457                table_to_remove_from, argv[1], mode);
458                                   /* If fpin[1] != NULL this will call    */
459 to
460   PairCoilData(fgin,fpin, mode & PROLINE_FREE_MODE,
461                table_to_remove_from, argv[1], mode);
462
463
464 changed
465     get_likelihood_line(likelihoods, m, b, m_single, b_single,
466                       lib, pair_functnum,pir_name,mode,number_tables);
467 to
468
469     get_likelihood_line(likelihoods, m, b, m_single, b_single,
470                       lib, pair_functnum,pir_name,mode,NUMBER_TABLES);
471
472
473 changed
474   OpenScreen(mode,log_bound,fin,flog,flog_coil_conflicts, fout_coils,
475              fout,  m,b,m_single, b_single,
476              lib,differ_lib,multi_lib,
477              main_method,main_preprocessor_method, &seqnum);
478 to
479   OpenScreen(mode,log_bound,fin,flog, fout_coils,
480              fout,  m,b,m_single, b_single,
481              lib,multi_lib,
482              main_method,main_preprocessor_method, &seqnum);
483
484
485 changed
486       finish_log(mode,log_bound,fin,flog,fout_coils,
487                  fout, 
488                  m,b, m_single, b_single,
489                      lib,multi_lib, main_method, main_table,
490                      main_preprocessor_method, seqcnt, avg_max);
491 to
492       finish_log(mode,log_bound,fin,flog,fout_coils,
493                  fout, 
494                  m,b, m_single, b_single,
495                      lib,multi_lib, main_method, main_table,
496                      main_preprocessor_method, seqcnt, avg_max);
497
498
499 Changed 
500
501         NextSeq(fin,lib,differ_lib,multi_lib,
502                 m,b,m_single,b_single, 
503                 mode,bound,flog,flog_coil_conflicts,fout_coils,
504                 fout, which_priors, which_priorp, prior_freq_single, 
505                 prior_freq_pair, good_turing_fixed_disc, structural_pos);
506 to
507         NextSeq(fin,lib,multi_lib,m,b,m_single,b_single, 
508                 mode,bound,flog,fout_coils,fout);
509
510
511 changed
512         PrevSeq(fin,lib,differ_lib,multi_lib,
513                 m,b,m_single,b_single,
514                 mode,bound, which_priors,which_priorp, prior_freq_single,
515                 prior_freq_pair, good_turing_fixed_disc, structural_pos);
516 to
517         PrevSeq(fin,lib,multi_lib,m,b,m_single,b_single,mode,bound);
518
519
520 changed ShowSeq(lib,differ_lib,multi_lib,
521                 m,b,m_single,b_single,mode,1,0, bound);
522 to
523         ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,1,0, bound);
524
525
526 cut
527         if (flog_coil_conflicts) sclose(flog_coil_conflicts);
528
529
530 changed
531             type_class_score_convert(sequence,all_scores,bound,
532                                     mode & ONLY_COILED_CLASSES,number_tables,
533                                     number_classes);
534 to
535             type_class_score_convert(sequence,all_scores,bound,
536                                     mode & ONLY_COILED_CLASSES);
537
538 changed
539         if (method == MultiCoil) 
540           table = table % number_classes;
541         else 
542           table = table % number_tables;
543 to
544         if (method == MultiCoil) 
545           table = table % NUMBER_CLASSES;
546         else 
547           table = table % NUMBER_TABLES;
548
549
550 changed
551 NewSeq (int mode, Sequence sequence, int which_priors, int which_priorp,
552         double prior_freq_single[MAX_TABLE_NUMBER],
553         double prior_freq_pair[MAX_TABLE_NUMBER], int good_turing_fixed_disc,
554         int structural_pos[POSNUM+1])
555 to
556 NewSeq (int mode, Sequence sequence)
557
558
559
560
561 In output_seq()
562 changed
563   case MultiCoil:
564 /****/
565     if (fout_coils) 
566       /*** For pos files coils, does a log file version  of coil/seq score. **/
567       output_pos_scores(fout_coils, sequence, all_scores, log_bound, mode, 
568                         by_coil_or_seq, weighted_avg);
569
570 to
571
572   case MultiCoil:
573 /****/
574     if (fout_coils) 
575       /*** For pos files coils, does a log file version  of coil/seq score. **/
576       output_pos_scores(fout_coils, sequence, all_scores, log_bound, mode,
577                         2, 1);
578
579 SO ALWAYS TO SEQUENCE SCORE and Weighted average (weighted by coil prob.).
580
581
582 Cut
583   case MultiCoil
584     if (flog_coil_conflicts) 
585       coil_conflicts(mode,all_scores,all_scores,sequence, seqnum,log_bound, 
586                      log_bound,number_tables, flog_coil_conflicts,avg_max);
587 and
588   case PairCoilDiffAvg:
589     if (flog_coil_conflicts) {
590
591       coil_conflicts(mode,all_scores,all_preprocess_like,sequence, seqnum,
592                      .5, log_bound, number_tables, flog_coil_conflicts,
593                      avg_max);
594
595     }
596     break;
597
598
599 cut
600       else if (main_method == PairCoilDiff)  
601                               /* Output max score for each dimension. */
602                    /** Had to do a hack since tuple_out2 expects number_lib  */
603                   /** to be array of size num_tab, so pass in 1 for num_tab */
604         tuple_output2(sequence, mode, fout, all_scores, 1,
605                       &number_differ_lib,log_bound, number_differ_score_dim);
606     
607
608 in preprocessor_score() changed
609       num_multilib= compute_num_multilib(tablenum, number_multi_lib,
610                                          mode & MULTI_TRIMER_PAIRS);
611 to
612       num_score_dim= combine_dist[tablenum]*num_dist[tablenum] + 
613                        (1-combine_dist[tablenum]); 
614 and
615       functnum = multi_functnum[tablenum];
616 to
617       functnum = combine_dist[tablenum]*num_dist[tablenum] +
618                   (1 - combine_dist[tablenum]);
619
620 changed
621         average_score_over_coils3(sequence, all_preprocess_like[tablenum+3],
622                                   all_preprocess_like[tablenum],
623                              all_preprocess_like[2+3],/** Total Coil Like. **/
624                                 weighted_avg, offset_to_use,
625                                 all_preproc_offsets[tablenum],
626                                 start_coil_at_reg_shift, bound,
627                                 Coil_Score -1);
628 to
629         average_score_over_coils3(sequence, all_preprocess_like[tablenum+3],
630                                   all_preprocess_like[tablenum],
631                              all_preprocess_like[2+3],/** Total Coil Like. **/
632                                 offset_to_use,
633                                 all_preproc_offsets[tablenum],
634                                 start_coil_at_reg_shift, bound,
635                                 Coil_Score -1);
636
637
638 From ScoreSeq()
639 cut
640
641   int use_pairs=1;
642       if (tablenum ==0) use_pairs =1;  /*  Use pairs for cctb */
643       else if (tablenum ==1) use_pairs = (mode & MULTI_TRIMER_PAIRS);  
644                /* Do what config file said to do for trimers. **/
645
646 replaced
647
648         functnum = multi_functnum[tablenum];   /* For use in scscore.c **/
649         num_multilib = compute_num_multilib(tablenum,number_multi_lib, 
650         for (dist=0; dist<num_multilib; dist++) {
651           if (number_multi_lib[tablenum] >1) 
652             local_lib = &multi_lib[tablenum][dist];
653           else local_lib = multi_lib[tablenum];
654 by
655         for (dist=0; dist<num_score_dim; dist++) {
656           if (number_dist[tablenum] >1) 
657             local_lib = &multi_lib[tablenum][dist];
658           else local_lib = multi_lib[tablenum];
659           dimension = compute_dimension2(tablenum, dist,
660                                         num_dist, combine_dist);
661
662
663
664
665 /*************************************************************************/
666 /**********************ADD BACK EVENTUALLY *******************************/
667 From scoreseq cut
668
669
670       case PairCoilDiff:
671         functnum = differ_functnum;   
672         for (dimension=0; dimension<number_differ_lib; dimension++) {
673           if (number_differ_lib >1) { 
674             local_lib = &differ_lib[dimension];
675           }
676           else local_lib = differ_lib;
677         
678
679           PairCoilDifferDimension(mode, sequence, local_lib, &maxsc,
680                                   all_preproc_offsets[preproc_table],
681                                   all_preprocess_like[preproc_table],
682                                   all_scores,
683                                   all_offsets, dimension,
684                                   Offset_to_Use, number_differ_score_dim,
685                                   bound);       
686         
687         }
688         break;
689
690
691 /************************************************************************/
692 changed
693
694     if ( (Method != MultiCoil)  && (Method !=PairCoilDiff)) 
695       get_offsets(all_scores, sequence,all_offsets,number_tables);
696 to
697     if (Method != MultiCoil) 
698       get_offsets(all_scores, sequence,all_offsets,NUMBER_TABLES);
699     else if (!(mode & RAW_OUT)) {
700
701
702 CUT
703
704 /***********Do conversions on PairCoilDiff scores, using preprocessor. **/
705 /*********** Note for differentiator there are only 2 possible classes **/
706 /*********** (dimer and trimer). **********/
707       if (Method == PairCoilDiff) {
708         convert_raw_scores_to_gauss_prob_like2(all_scores,sequence.seqlen,
709                           number_tables, differ_means_submatrix,
710                           differ_inverse_covars,differ_determinants, 2,
711                           init_class_prob, number_differ_score_dim,
712                            0, bound, Offset_to_Use,0);
713         if (Preprocessor_Method == MultiCoil) 
714           preproc_res_like = &all_preprocess_like[preproc_table+3][0][0];
715         else preproc_res_like = &all_preprocess_like[preproc_table][0][0];
716
717
718 /*  Only use window scores that lie completely in coil */
719         if ( (which_differentiator == 3) || (which_differentiator ==4))
720           zero_out_non_coils(all_scores, all_preprocess_like[preproc_table],
721                              sequence.seqlen, bound);
722
723         if (which_differentiator == 1) 
724           zero_out_bad_windows(differ_window_length, 
725                                all_scores,all_preprocess_like[preproc_table],
726                                sequence.seqlen,bound);
727
728         copy_offsets(all_preproc_offsets[preproc_table],sequence, 
729                       all_offsets,2, all_scores, Offset_to_Use);
730         if (Coil_Score) /* Value of 1 means do average, 2 means do max. */
731           for (tablenum=0; tablenum<2; tablenum++) {
732             average_score_over_coils3(sequence, all_scores[tablenum+3],
733                                     all_scores[tablenum],
734                                     preproc_res_like,  
735                                     /** Total Coil Like. **/
736                                 weighted_avg, offset_to_use,
737                                   all_preproc_offsets[preproc_table],
738                                 start_coil_at_reg_shift, bound,
739                                 Coil_Score -1);
740         }
741       }
742
743
744
745 cut
746     if (rescore_seq==-1 && !scored_already && (Method==PairCoilDiff)) {
747       if ( (which_differentiator == 3) || (which_differentiator ==4))
748         zero_out_non_coils(all_scores, all_preprocess_like[preproc_table],
749                              sequence.seqlen, bound);
750       if (which_differentiator == 1) /*  Only use window scores that lie */
751         zero_out_bad_windows(differ_window_length, /* completely in coil */
752                                all_scores, all_preprocess_like[preproc_table],
753                                sequence.seqlen,bound);
754     }
755
756
757 changed
758         get_seq_scores(seq_scores, sequence, all_scores[0+3],
759                                         all_scores[1+3],bound, weighted_avg);
760
761 to
762         get_seq_scores(seq_scores, sequence, all_scores[0+3],
763                                         all_scores[1+3],bound);
764
765
766 cut
767
768
769       else if (Method == PairCoilDiff)  {
770         if (Preprocessor_Method == MultiCoil) 
771           preproc_res_like = &all_preprocess_like[preproc_table+3][0][0];
772         else preproc_res_like = &all_preprocess_like[preproc_table][0][0];
773
774         
775         for (tablenum=0; tablenum<2; tablenum++)
776           average_score_over_coils3(sequence, all_scores[tablenum+3],
777                                     all_scores[tablenum],
778                                     preproc_res_like,  
779                                     /** Total Coil Like. **/
780                                     weighted_avg, offset_to_use,
781                                     all_offsets[tablenum],
782                                     start_coil_at_reg_shift, bound,
783                                     Coil_Score -1);
784       }
785     
786
787
788 changed
789 ShowSeq(char lib[MAXFUNCTNUM], char differ_lib[MAXFUNCTNUM],
790         char  multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
791         double *m, double *b,
792          double *m_single, double *b_single,
793          int mode, int rescore_sequence, int rescore_preproc, double bound)
794 to
795 ShowSeq(char lib[MAXFUNCTNUM], 
796         char  multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
797         double *m, double *b,
798          double *m_single, double *b_single,
799          int mode, int rescore_sequence, int rescore_preproc, double bound)
800
801 changed
802
803
804     all_scores = ScoreSeq(lib, differ_lib, multi_lib, m, b,m_single, b_single,
805                     mode, table, 
806                     method, preprocessor_method,
807                     offset_to_use, &maxscore,  
808                     rescore_sequence, rescore_preproc, bound);
809 to
810     all_scores = ScoreSeq(lib,  multi_lib, m, b,m_single, b_single,
811                     mode, table, 
812                     method, preprocessor_method,
813                     offset_to_use, &maxscore,  
814                     rescore_sequence, rescore_preproc, bound);
815
816 /******************************ROUND 3 OF CHANGES **************************/
817
818 changed
819   initialize(&num_dist[0], window_length, scale0s,
820              scale0p,fpin[0],
821              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
822              &mode);
823 to
824   initialize(&num_dist[0], window_length, scale0s,
825              scale0p,fpin[0],
826              &likelihoods[0][0], &pir_name[0], print, gauss_param, 
827              &mode, init_clas_prob);
828
829
830
831 changed
832 void output_seq(char lib[MAXFUNCTNUM],char differ_lib[MAXFUNCTNUM],
833                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
834                 double *m,double *b,
835                 double *m_single, double *b_single, 
836                 int mode, 
837                 double log_bound,FILE *flog, FILE *flog_coil_conflicts,
838                 FILE *fout_coils,
839                 FILE *fout,  
840                 int avg_max,
841                 int main_method, int main_preprocessor_method,
842                 int main_table)
843 to
844 void output_seq(char lib[MAXFUNCTNUM],char differ_lib[MAXFUNCTNUM],
845                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
846                 double *m,double *b,
847                 double *m_single, double *b_single, 
848                 int mode, 
849                 double log_bound,FILE *flog, 
850                 FILE *fout_coils,
851                 FILE *fout,  
852                 int avg_max,
853                 int main_method, int main_preprocessor_method,
854                 int main_table)
855 cut
856     if (flog_coil_conflicts) sclose(flog_coil_conflicts);
857
858
859
860 changed
861
862
863     convert_raw_scores_to_gauss_prob_like2(all_preprocess_like,sequence.seqlen,
864                                  NUMBER_TABLES,means_submatrix,inverse_covars,
865                                  determinants, NUMBER_CLASSES, init_class_prob,
866                                  number_score_dim,
867                                      mode & ONLY_COILED_CLASSES, 
868                                      bound,Offset_to_Use,  1);
869  to
870     convert_raw_scores_to_gauss_prob_like2(all_preprocess_like,sequence.seqlen,
871                                  NUMBER_TABLES,means_submatrix,inverse_covars,
872                                  determinants, NUMBER_CLASSES, init_class_prob,
873                                  number_score_dim,
874                                      mode & ONLY_COILED_CLASSES, 
875                                      bound,Offset_to_Use);
876  twice.
877
878
879
880
881
882 Changed
883
884   if (ftotal_like) {      /** Want to output total gauss like over classes*/
885     for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
886
887 to 
888
889   if (ftotal_like) {      /** Want to output total gauss like over classes*/
890     for (i=0; i<NUMBER_CLASSES; i++)  /* for various init_prob settings.  */
891  
892
893
894 changed
895       get_gauss_param_all_classes2(class_sc_filenames[i], 
896                                    num_table_dimensions(7,combine_dist[0]) +
897                                    num_table_dimensions(7,combine_dist[1]),
898                                     both_class_means[i], both_class_covars[i],
899                                    number_classes, gauss_param[i]);
900 to
901       get_gauss_param_all_classes2(class_sc_filenames[i], 
902                                    num_table_dimensions(7,combine_dist[0]) +
903                                    num_table_dimensions(7,combine_dist[1]),
904                                     both_class_means[i], both_class_covars[i],
905                                    NUMBER_CLASSES, gauss_param[i]);
906
907
908 Changed
909           preproc_table = (preproc_table +1) % number_classes;
910 to
911   preproc_table = (preproc_table +1) % NUMBER_CLASSES;
912
913
914 Changed 
915             type_class_score_convert(sequence,all_scores,bound,
916                                      mode & ONLY_COILED_CLASSES, number_tables,
917                                      NUMBER_CLASSES);
918 to
919             type_class_score_convert(sequence,all_scores,bound,
920                                      mode & ONLY_COILED_CLASSES);
921
922
923 Changed
924       get_gauss_param_all_classes2(class_sc_filenames[i], 
925                                    num_table_dimensions(7,combine_dist[0]) +
926                                    num_table_dimensions(7,combine_dist[1]),
927                                     both_class_means[i], both_class_covars[i],
928                                    NUMBER_CLASSES, gauss_param[i]);
929 to
930       get_gauss_param_all_classes2(class_sc_filenames[i], 
931                                    num_table_dimensions(7,combine_dist[0]) +
932                                    num_table_dimensions(7,combine_dist[1]),
933                                     both_class_means[i], both_class_covars[i],
934                                    gauss_param[i]);
935 Changed
936       if (Coil_Score ==1)
937         if (weighted_avg)
938           strcat(MethodTitle,"WtdAvg");
939         else strcat(MethodTitle,"Avg");
940 to
941     if (Coil_Score) {
942       if (Coil_Score ==1)
943         strcat(MethodTitle,"WtdAvg");
944
945
946 From function switch_gauss_param() cut
947   else if (Method == PairCoilDiff) {
948     determinants= &differ_determinants[0];
949     inverse_covars= &differ_inverse_covars[0][0][0];
950     means_submatrix= &differ_means_submatrix[0][0];
951   }
952
953
954 /********************************************************************/
955
956 In interface.h
957 changed
958 void output_seq(char lib[MAXFUNCTNUM],char lib_differ[MAXFUNCTNUM],
959                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
960                 double *m,double *b,
961                 double *m_single, double *b_single,
962                 int mode, 
963                 double bound, FILE *flog, FILE *flog_coil_conflicts,
964                 FILE *fout_coils,
965                 FILE *fout, 
966                 int avg_max,
967                 int main_method, int main_preprocessor_method, int main_table);
968
969
970 to
971
972 void output_seq(char lib[MAXFUNCTNUM],
973                 char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
974                 double *m,double *b,
975                 double *m_single, double *b_single, 
976                 int mode, 
977                 double log_bound,FILE *flog, 
978                 FILE *fout_coils,
979                 FILE *fout,  
980                 int avg_max,
981                 int main_method, int main_preprocessor_method,
982                 int main_table);
983
984
985 Changed
986
987       case XK_i:
988         if (preprocessor_method == MultiCoil) 
989           preproc_table = (preproc_table +1) % NUMBER_CLASSES;
990         else
991           preproc_table = (preproc_table +1) % NUMBER_TABLES;
992         ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,2,  bound);
993         if (zoomptr) Zoomer();
994         break;
995       case XK_T:
996       case XK_t:
997         if (method == MultiCoil) 
998           table = (table +1) % NUMBER_CLASSES;
999         else 
1000           table = (table +1) % NUMBER_TABLES;
1001         ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,0, bound);
1002         if (zoomptr) Zoomer();
1003         break;
1004
1005
1006 to
1007
1008       case XK_i:
1009         if (preprocessor_method == MultiCoil) 
1010           preproc_table = (preproc_table +1) % NUMBER_CLASSES;
1011         else if (preprocessor_method == HMMCoil)
1012           preproc_table = (preproc_table +1) % NUMBER_TABLES;
1013         else preproc_table = 0;
1014         ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,2,  bound);
1015         if (zoomptr) Zoomer();
1016         break;
1017       case XK_T:
1018       case XK_t:
1019         if (method == MultiCoil) 
1020           table = (table +1) % NUMBER_CLASSES;
1021         else if (method == HMMCoil)
1022           table = (table +1) % NUMBER_TABLES;
1023         else table =0;
1024         ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,0, bound);
1025         if (zoomptr) Zoomer();
1026         break;
1027
1028 and changed
1029       case XK_M:
1030       case XK_m:
1031         if (method == MultiCoil) 
1032           table = table % NUMBER_CLASSES;
1033         else if 
1034           table = table % NUMBER_TABLES;
1035         
1036 TO
1037
1038       case XK_M:
1039       case XK_m:
1040         if (method == MultiCoil) 
1041           table = table % NUMBER_CLASSES;
1042         else if (method == HMMCoil)
1043           table = table % NUMBER_TABLES;
1044         else table =0;
1045
1046 and similarly for xk_w
1047
1048 Changed
1049     get_likelihood_line(likelihoods, m, b, m_single, b_single,
1050                       lib, pair_functnum,pir_name,mode,NUMBER_TABLES);
1051 to
1052     get_likelihood_line(likelihoods, m, b, m_single, b_single,
1053                       lib, pair_functnum,pir_name,mode,1);
1054 since PairCoil doesn't work well for trimer table.