JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / interface_cuts.c
diff --git a/sources/multicoil/interface_cuts.c b/sources/multicoil/interface_cuts.c
new file mode 100644 (file)
index 0000000..1c0872f
--- /dev/null
@@ -0,0 +1,1054 @@
+from interface.h cut #define MAX_TABLE_NUMBER 4
+
+put /*  #define COMPUTE_GAUSSIAN_VERSION  */ in options.h
+put  #define NUMBER_TABLES 2  in scconst.h
+put #define NUMBER_CLASES 3 in scconst.h
+put #define MAX_TABLE_NUMBER 2   /* Same as NUMBER_TABLES. **/ in scconst.h
+put #define NUM_DIM_IN_ORIG_MATRIX 14 in scconst.h
+and in interface.c
+for both_class_covars[][][][] and both_class_means[][][] made the max size
+of the matrix be NUM_DIM_IN_ORIG_MATRIX  (Then changed in multivariate_like.c
+where pass these in).  (get_gauss_param_all_classes2(), compute_submatrices2())
+
+In scconst.h, put
+#ifdef COMPUTE_GAUSSIAN_VERSION
+  #define MAX_NUM_SCORE_DIM 14
+#else
+  #define MAX_NUM_SCORE_DIM 6
+#endif
+
+
+ double m_single[MAX_TABLE_NUMBER],
+         b_single[MAX_TABLE_NUMBER];  /*  Like line for singlecoil. */
+
+
+ /*************************** PAIRDIFF LIKELIHOOD STUFF. *********************/
+ double differ_determinants[MAX_CLASS_NUMBER];
+ double differ_inverse_covars[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
+ double differ_covars_submatrix[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
+ double differ_means_submatrix[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM];
+
+ int number_differ_score_dim =0;
+ int number_differ_lib=0;
+ int differ_window_length = 28;
+ int which_differentiator=1;   /** Default is just the score for the window **/
+                           /** 2 means to give each residue a pair of scores**/
+                           /** corresponding to the max and min of the      **/
+                           /** windows containing it.                       **/
+ int differ_functnum=0;
+#endif
+
+
+#ifdef TEST_VERSION
+  char differ_class_sc_filenames[MAX_CLASS_NUMBER][MAXLINE];
+  double differ_means[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM];
+  double differ_covars[MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
+  char differ_gauss_param[MAXLINE];
+  char differ_lib[MAXFUNCTNUM];   /*  Distance values for PairCoilDiff */
+  extern int differ_functnum;     
+#ifdef TEST_VERSION
+
+#ifdef TEST_VERSION
+  double prior_freq_single[MAX_TABLE_NUMBER], 
+         prior_freq_pair[MAX_TABLE_NUMBER];
+  int which_priors =0, which_priorp =0;
+  int good_turing_fixed_disc =0;    /** If set to 1 do the good_turing_fixed_disc estimate of probs*/
+  int structural_pos[POSNUM+1];  /** Holds list of which positions are **/
+                               /** structurally important.  All others **/
+                               /** get genbnk probabilities....       **/
+                               /** Value -1 indicates no more entries. **/
+#endif
+
+ int old_num_dim_differ =0;
+                          /* The gauss param file for multiple distances is */
+                         /* contains the parameters for all distances.     */
+#ifdef TEST_VERSION
+  compute_multivariate_num_differ_dim(&number_differ_score_dim,
+                              number_differ_lib,
+                              differ_functnum, &old_num_dim_differ,
+                              which_differentiator);
+#endif
+
+cut
+double both_covars_submatrix[2][MAX_CLASS_NUMBER][MAX_NUM_SCORE_DIM][MAX_NUM_SCORE_DIM];
+
+
+
+#ifdef TEST_VERSION
+/*************************************************************************/
+/******************Now do gauss parameters for PairCoilDiff method.  *****/
+/*************************************************************************/
+/**** Note the "2" parameter represents that are 2 classes (dimers, trimers)***/
+/**** not three, since just differentiating so don't need pdb-.    ************/
+
+  if (differ_gauss_param[0] != ',') {
+    char differ_lib_hack[2][MAXFUNCTNUM];
+                     /** If are computing max and min window scores, **/
+                     /** then need to extract both dimenion i and   **/
+                     /** i + old_num_dim_differ/2. Treat them like they **/
+                     /** were from another table.   ***/
+
+
+    get_gauss_param_all_classes2(differ_class_sc_filenames, 
+                                old_num_dim_differ,
+                                differ_means, differ_covars,
+                                2, differ_gauss_param);
+       
+    if (which_differentiator ==2) {
+      for (i=0; i<number_differ_score_dim/2; i++) {
+       differ_lib_hack[0][i] = differ_lib[i];
+       differ_lib_hack[1][i] = differ_lib[i];
+      }
+      compute_submatrices2(differ_means,differ_means_submatrix,
+                        differ_covars,2, 
+                        differ_inverse_covars,
+                        differ_determinants, differ_lib_hack,
+                        old_num_dim_differ/2, old_num_dim_differ/2,
+                        number_differ_score_dim/2, number_differ_score_dim/2,
+                        1);
+    }
+    else
+      compute_submatrices2(differ_means,differ_means_submatrix,
+                        differ_covars,2, 
+                        differ_inverse_covars,
+                        differ_determinants, differ_lib,
+                        old_num_dim_differ, 0,
+                        number_differ_score_dim, 0,
+                        1);
+
+/************/
+         for (class=0; class<2; class++) {
+           fprintf(stderr,"\n\nDiffer Mean Submatrix %d:\n",class);
+           print_matrix(differ_means_submatrix[class],1,
+                       number_differ_score_dim,stderr);
+           fprintf(stderr,"\n\nDiffer Inver Covar Submatrix %d:\n", class);
+           print_matrix(differ_inverse_covars[class],
+                        number_differ_score_dim,number_differ_score_dim,
+                        stderr);
+           
+         }
+/**********/
+
+    fprintf(stderr,"\nDet0 =%lf, det1= %lf\n",
+           differ_determinants[0],differ_determinants[1]);
+       
+    fprintf(stderr,"\nnew_num_dim_differ=%d, old_num_dim_differ=%d,", number_differ_score_dim, old_num_dim_differ);
+
+         
+
+  }
+#endif
+
+#ifdef TEST_VERSION
+      case XK_A:         /** Switch between unweighted avg and  **/
+      case XK_a:         /** weighted avg coil score.             **/
+       weighted_avg = !weighted_avg;
+       if (Coil_Score !=0) { /** CoilScore ==0 means not doing coil score. **/
+         ShowSeq(lib,differ_lib,multi_lib,
+                 m,b,m_single,b_single,mode,-1,-1, bound);
+         if (zoomptr) Zoomer();
+       }
+       break;
+
+
+      case XK_b:
+      case XK_B:         /** For CoilScore, change how deal with reg shift. **/
+       start_coil_at_reg_shift = !start_coil_at_reg_shift;
+       if (Coil_Score !=0) { /** CoilScore ==0 means not doing coil score. **/
+         ShowSeq(lib,differ_lib,multi_lib,
+                 m,b,m_single,b_single,mode,-1,-1, bound);
+         if (zoomptr) Zoomer();
+       }
+       break;
+
+
+      case XK_R:
+      case XK_r:
+       offset_to_use = (offset_to_use +1) % 8;   /* Cycle through offsets */
+/***   switch_gauss_param(offset_to_use);  **/
+       ShowSeq(lib,differ_lib,multi_lib,
+               m,b,m_single,b_single,mode,1,1, bound);
+       if (zoomptr) Zoomer();
+        break;
+      case XK_s:        /*  Use single probabilities. */
+      case XK_S:
+       if (mode & PAIRCOIL_PAIRS) {
+         mode -= PAIRCOIL_PAIRS; /** Turn it off **/
+         ShowSeq(lib,differ_lib,multi_lib,
+               m,b,m_single,b_single,mode,1,1, bound);
+         if (zoomptr) Zoomer();
+       }
+       break;
+
+      case XK_l:        /*  Use pair probabilities at lib distances */
+      case XK_L:
+       if (!(mode & PAIRCOIL_PAIRS)) {
+         mode |= PAIRCOIL_PAIRS;  /* Turn it on. */
+         ShowSeq(lib,differ_lib,multi_lib,
+                 m,b,m_single,b_single,mode,1,1, bound);
+         if (zoomptr) Zoomer();
+       }
+       break;
+#endif
+
+
+
+changed   
+  initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            differ_gauss_param,
+            &mode, prior_freq_single, prior_freq_pair,
+            structural_pos);
+to
+  initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            &mode, prior_freq_single, prior_freq_pair,
+            structural_pos);
+
+
+
+changed 
+OpenScreen(int mode, double log_bound, FILE *fin, FILE *flog, 
+               FILE* flog_coil_conflicts,FILE *fout_coils,
+               FILE *fout,
+               double *m, double *b, double *m_single, double *b_single, 
+               char lib[MAXFUNCTNUM], 
+               char differ_lib[MAXFUNCTNUM], 
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               int main_method, 
+               int main_preprocessor_method,
+               int *seqcnt, int which_priors, int which_priorp,
+               double prior_freq_single[MAX_TABLE_NUMBER],
+               double prior_freq_pair[MAX_TABLE_NUMBER], 
+               int good_turing_fixed_disc, int structural_pos[POSNUM+1])
+
+to
+OpenScreen(int mode, double log_bound, FILE *fin, FILE *flog, 
+               FILE* flog_coil_conflicts,FILE *fout_coils,
+               FILE *fout,
+               double *m, double *b, double *m_single, double *b_single, 
+               char lib[MAXFUNCTNUM], 
+               char differ_lib[MAXFUNCTNUM], 
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               int main_method, 
+               int main_preprocessor_method,
+               int *seqcnt)
+
+
+changed
+      finish_log(mode,log_bound,fin,flog,flog_coil_conflicts,fout_coils,
+                fout, 
+                m,b, m_single, b_single,
+                    lib,differ_lib,multi_lib, main_method, main_table,
+                    main_preprocessor_method, seqcnt, avg_max, which_priors,
+                    which_priorp, prior_freq_single, prior_freq_pair, 
+                    good_turing_fixed_disc, structural_pos);
+
+to
+      finish_log(mode,log_bound,fin,flog,flog_coil_conflicts,fout_coils,
+                fout, 
+                m,b, m_single, b_single,
+                    lib,differ_lib,multi_lib, main_method, main_table,
+                    main_preprocessor_method, seqcnt, avg_max);
+
+changed
+  if (mode & TST_MODE0) 
+    recalc_prob(sequence, 0, mode, which_priors, which_priorp,
+               prior_freq_single, prior_freq_pair, good_turing_fixed_disc,
+               structural_pos);
+  if (mode & TST_MODE1)
+    recalc_prob(sequence,1, mode, which_priors, which_priorp,
+               prior_freq_single, prior_freq_pair, good_turing_fixed_disc,
+               structural_pos);
+to
+  if (mode & TST_MODE0) 
+    recalc_prob(sequence, 0, mode);
+  if (mode & TST_MODE1)
+    recalc_prob(sequence,1, mode);
+
+
+/*************************************************************************/
+/********     ROUND 2 of cuts. *******************************************/
+/*************************************************************************/
+
+int number_classes=0;  
+int weighted_avg = 0;  /*  Determines which method for determining coil */
+                         /*  score will be used in DimerTrimerScore.      */
+char table_diff_stat_filename[MAXLINE]="/dev/null";
+char weightfile_outname[MAXLINE]="/dev/null";
+
+  "key 'r':   Cycle through offsets 0-7 for register (7=combo reg)",
+  "key 'b':   For Coil score, toggle whether start new coils at",
+  "             a register shift (break in structure).",
+  "key 'a':   For Coil score, toggle between unweighted and weighted avg",
+  "",
+
+
+FILE *flog_coil_conflicts=NULL
+  extern int number_classes;  
+
+
+
+  double upper_bound;   /* In DEBUG_MODE (for printing out the predicted    */
+                        /* heptad repeat), scores in  [bound,upper_bound]   */
+                        /* are printed in capital letters.                  */
+
+
+
+changed
+  initialize(&number_classes, &number_multi_lib[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            &mode, prior_freq_single, prior_freq_pair,
+            structural_pos);
+to 
+  initialize(&number_multi_lib[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            &mode);
+
+changed
+
+  get_defaults(argv[1], &mode, &log_bound, &fgin, fpin, 
+              &ftotal_like, &fout, 
+              &flog, &flog_coil_conflicts, 
+              &fout_coils, &by_coil_or_seq, likelihoods,
+              pir_name, lib, multi_lib, 
+              &pair_functnum, multi_functnum,
+              print, &main_method, &main_preprocessor_method, 
+              &main_table, &number_tables,  &offset_to_use,  
+              &avg_max, &weighted_avg,   &Coil_Score,
+              table_diff_stat_filename, weightfile_outname,
+              &ps_res_per_line, &number_classes, 
+              class_sc_filenames, 
+              gauss_param,  number_multi_lib,
+              init_class_prob, 
+              &table_to_remove_from,  
+              command_line, window_length, scale0s, scale0p,
+              &which_differentiator);
+to
+
+
+  get_defaults(argv[1], &mode, &log_bound, &fgin, fpin, 
+              &ftotal_like, &fout, 
+              &flog, 
+              &fout_coils, &by_coil_or_seq, likelihoods,
+              pir_name, lib, multi_lib, 
+              &pair_functnum, multi_functnum,
+              print, &main_method, &main_preprocessor_method, 
+              &main_table, &offset_to_use,  
+              &avg_max,   &Coil_Score,
+              &ps_res_per_line,  
+              class_sc_filenames, 
+              gauss_param,  number_multi_lib,
+              init_class_prob, 
+              &table_to_remove_from,  
+              command_line, window_length, scale0s, scale0p);
+
+
+cut     int old_num_dim_table[2];
+        int new_num_dim_table[2];
+and
+compute_multivariate_num_dim(mode, &number_score_dim,
+                              number_multi_lib,multi_functnum, number_tables,
+                              new_num_dim_table, old_num_dim_table);
+
+
+changed
+
+  if (number_classes >0)  {        /*** Get gaussian param for the classes. */
+    if (ftotal_like) {      /** Want to output total gauss like over classes*/
+      for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
+       init_class_prob[i]=1;   /** All 1 values is flag to just output     */
+      init_totals(total_gauss_like); /** gauss values, not like values in   */
+      }                              /** convert_raw_scores_to_gauss_like.   */
+  
+to
+
+  if (ftotal_like) {      /** Want to output total gauss like over classes*/
+    for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
+      init_class_prob[i]=1;   /** All 1 values is flag to just output     */
+    init_totals(total_gauss_like); /** gauss values, not like values in   */
+  }                              /** convert_raw_scores_to_gauss_like.   */
+
+
+Replace int number_multi_lib[MAX_TABLE_NUMBER]
+with  int num_dist[MAX_TABLE_NUMBER] almost everywhere
+
+in conjunction with replacing multi_functnum with a variable indicating
+if distances are each a dimension, or if should combine into a single
+library...
+i.e. change 
+  int multi_functnum[MAX_TABLE_NUMBER]
+    to 
+      int combine_dist[MAX_TABLE_NUMBER];
+
+
+CHANGED:
+
+    get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                old_num_dim_table[0]+old_num_dim_table[1],
+                                both_class_means[i], both_class_covars[i],
+                                number_classes, gauss_param[i]); 
+to
+      get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                    6*combine_dist[0] + 1 +
+                                    6*combine_dist[1] + 1,
+                                   both_class_means[i], both_class_covars[i],
+                                   gauss_param[i]);
+
+changed 
+      compute_submatrices2(both_class_means[i],both_means_submatrix[i],
+                                  both_class_covars[i], 
+                                  both_inverse_covars[i],
+                                  both_determinants[i], multi_lib,
+                                  old_num_dim_table[0], old_num_dim_table[1],
+                                  new_num_dim_table[0], new_num_dim_table[1],
+                                  mode & MULTI_TRIMER_PAIRS);
+to
+      compute_submatrices2(both_class_means[i],both_means_submatrix[i],
+                                  both_class_covars[i], 
+                                  both_inverse_covars[i],
+                                  both_determinants[i], multi_lib,
+                                  6*combine_dist[0] + 1, 
+                                  6*combine_dist[1] + 1
+                                  (num_dist[0]-1)*combine_dist[0] + 1, 
+                                  (num_dist[1]-1)*combine_dist[1] + 1);
+
+
+
+added      number_score_dim = (num_dist[0]-1)*combine_dist[0] + 1 +
+                                  (num_dist[1]-1)*combine_dist[1] + 1;
+
+
+
+changed
+    log_file_header(flog, flog_coil_conflicts,  mode, 
+                   argc, argv, avg_max, log_bound, 
+                   preprocessor_method, preproc_table, log_offset_to_use, 
+                   start_coil_at_reg_shift, weighted_avg, main_method, 
+                   main_table);
+to
+
+  if ( (mode & PRN_MODE) && flog ){
+    log_file_header(flog,  mode, 
+                   argc, argv, avg_max, log_bound, 
+                   preprocessor_method, preproc_table, log_offset_to_use, 
+                   start_coil_at_reg_shift, main_method, 
+                   main_table);
+
+from that function, cut stuff for log_coil_conflicts
+and cut
+      if (weighted_avg == 0) {
+         fprintf(flog, "\n Averaging over coils was done by coil length.");
+      }
+      else  { /* weighted_avg ==1 */
+       fprintf(flog, "\n Averaging over coils was done using coil length weighted at each position by the preprocessor coil likelihood.");
+      }
+
+
+changed 
+
+
+  PairCoilData(fgin,fpin,&number_tables, mode & PROLINE_FREE_MODE,
+              table_to_remove_from, argv[1], mode);
+                                  /* If fpin[1] != NULL this will call    */
+to
+  PairCoilData(fgin,fpin, mode & PROLINE_FREE_MODE,
+              table_to_remove_from, argv[1], mode);
+
+
+changed
+    get_likelihood_line(likelihoods, m, b, m_single, b_single,
+                     lib, pair_functnum,pir_name,mode,number_tables);
+to
+
+    get_likelihood_line(likelihoods, m, b, m_single, b_single,
+                     lib, pair_functnum,pir_name,mode,NUMBER_TABLES);
+
+
+changed
+  OpenScreen(mode,log_bound,fin,flog,flog_coil_conflicts, fout_coils,
+            fout,  m,b,m_single, b_single,
+            lib,differ_lib,multi_lib,
+            main_method,main_preprocessor_method, &seqnum);
+to
+  OpenScreen(mode,log_bound,fin,flog, fout_coils,
+            fout,  m,b,m_single, b_single,
+            lib,multi_lib,
+            main_method,main_preprocessor_method, &seqnum);
+
+
+changed
+      finish_log(mode,log_bound,fin,flog,fout_coils,
+                fout, 
+                m,b, m_single, b_single,
+                    lib,multi_lib, main_method, main_table,
+                    main_preprocessor_method, seqcnt, avg_max);
+to
+      finish_log(mode,log_bound,fin,flog,fout_coils,
+                fout, 
+                m,b, m_single, b_single,
+                    lib,multi_lib, main_method, main_table,
+                    main_preprocessor_method, seqcnt, avg_max);
+
+
+Changed 
+
+       NextSeq(fin,lib,differ_lib,multi_lib,
+               m,b,m_single,b_single, 
+               mode,bound,flog,flog_coil_conflicts,fout_coils,
+               fout, which_priors, which_priorp, prior_freq_single, 
+               prior_freq_pair, good_turing_fixed_disc, structural_pos);
+to
+       NextSeq(fin,lib,multi_lib,m,b,m_single,b_single, 
+               mode,bound,flog,fout_coils,fout);
+
+
+changed
+       PrevSeq(fin,lib,differ_lib,multi_lib,
+               m,b,m_single,b_single,
+               mode,bound, which_priors,which_priorp, prior_freq_single,
+               prior_freq_pair, good_turing_fixed_disc, structural_pos);
+to
+       PrevSeq(fin,lib,multi_lib,m,b,m_single,b_single,mode,bound);
+
+
+changed ShowSeq(lib,differ_lib,multi_lib,
+               m,b,m_single,b_single,mode,1,0, bound);
+to
+        ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,1,0, bound);
+
+
+cut
+       if (flog_coil_conflicts) sclose(flog_coil_conflicts);
+
+
+changed
+           type_class_score_convert(sequence,all_scores,bound,
+                                   mode & ONLY_COILED_CLASSES,number_tables,
+                                   number_classes);
+to
+           type_class_score_convert(sequence,all_scores,bound,
+                                   mode & ONLY_COILED_CLASSES);
+
+changed
+       if (method == MultiCoil) 
+         table = table % number_classes;
+       else 
+         table = table % number_tables;
+to
+       if (method == MultiCoil) 
+         table = table % NUMBER_CLASSES;
+       else 
+         table = table % NUMBER_TABLES;
+
+
+changed
+NewSeq (int mode, Sequence sequence, int which_priors, int which_priorp,
+       double prior_freq_single[MAX_TABLE_NUMBER],
+       double prior_freq_pair[MAX_TABLE_NUMBER], int good_turing_fixed_disc,
+       int structural_pos[POSNUM+1])
+to
+NewSeq (int mode, Sequence sequence)
+
+
+
+
+In output_seq()
+changed
+  case MultiCoil:
+/****/
+    if (fout_coils) 
+      /*** For pos files coils, does a log file version  of coil/seq score. **/
+      output_pos_scores(fout_coils, sequence, all_scores, log_bound, mode, 
+                       by_coil_or_seq, weighted_avg);
+
+to
+
+  case MultiCoil:
+/****/
+    if (fout_coils) 
+      /*** For pos files coils, does a log file version  of coil/seq score. **/
+      output_pos_scores(fout_coils, sequence, all_scores, log_bound, mode,
+                       2, 1);
+
+SO ALWAYS TO SEQUENCE SCORE and Weighted average (weighted by coil prob.).
+
+
+Cut
+  case MultiCoil
+    if (flog_coil_conflicts) 
+      coil_conflicts(mode,all_scores,all_scores,sequence, seqnum,log_bound, 
+                    log_bound,number_tables, flog_coil_conflicts,avg_max);
+and
+  case PairCoilDiffAvg:
+    if (flog_coil_conflicts) {
+
+      coil_conflicts(mode,all_scores,all_preprocess_like,sequence, seqnum,
+                    .5, log_bound, number_tables, flog_coil_conflicts,
+                    avg_max);
+
+    }
+    break;
+
+
+cut
+      else if (main_method == PairCoilDiff)  
+                             /* Output max score for each dimension. */
+                  /** Had to do a hack since tuple_out2 expects number_lib  */
+                 /** to be array of size num_tab, so pass in 1 for num_tab */
+       tuple_output2(sequence, mode, fout, all_scores, 1,
+                     &number_differ_lib,log_bound, number_differ_score_dim);
+    
+
+in preprocessor_score() changed
+      num_multilib= compute_num_multilib(tablenum, number_multi_lib,
+                                        mode & MULTI_TRIMER_PAIRS);
+to
+      num_score_dim= combine_dist[tablenum]*num_dist[tablenum] + 
+                      (1-combine_dist[tablenum]); 
+and
+      functnum = multi_functnum[tablenum];
+to
+      functnum = combine_dist[tablenum]*num_dist[tablenum] +
+                 (1 - combine_dist[tablenum]);
+
+changed
+       average_score_over_coils3(sequence, all_preprocess_like[tablenum+3],
+                                 all_preprocess_like[tablenum],
+                            all_preprocess_like[2+3],/** Total Coil Like. **/
+                               weighted_avg, offset_to_use,
+                               all_preproc_offsets[tablenum],
+                               start_coil_at_reg_shift, bound,
+                               Coil_Score -1);
+to
+       average_score_over_coils3(sequence, all_preprocess_like[tablenum+3],
+                                 all_preprocess_like[tablenum],
+                            all_preprocess_like[2+3],/** Total Coil Like. **/
+                               offset_to_use,
+                               all_preproc_offsets[tablenum],
+                               start_coil_at_reg_shift, bound,
+                               Coil_Score -1);
+
+
+From ScoreSeq()
+cut
+
+  int use_pairs=1;
+      if (tablenum ==0) use_pairs =1;  /*  Use pairs for cctb */
+      else if (tablenum ==1) use_pairs = (mode & MULTI_TRIMER_PAIRS);  
+               /* Do what config file said to do for trimers. **/
+
+replaced
+
+       functnum = multi_functnum[tablenum];   /* For use in scscore.c **/
+       num_multilib = compute_num_multilib(tablenum,number_multi_lib, 
+       for (dist=0; dist<num_multilib; dist++) {
+         if (number_multi_lib[tablenum] >1) 
+           local_lib = &multi_lib[tablenum][dist];
+         else local_lib = multi_lib[tablenum];
+by
+       for (dist=0; dist<num_score_dim; dist++) {
+         if (number_dist[tablenum] >1) 
+           local_lib = &multi_lib[tablenum][dist];
+         else local_lib = multi_lib[tablenum];
+         dimension = compute_dimension2(tablenum, dist,
+                                       num_dist, combine_dist);
+
+
+
+
+/*************************************************************************/
+/**********************ADD BACK EVENTUALLY *******************************/
+From scoreseq cut
+
+
+      case PairCoilDiff:
+       functnum = differ_functnum;   
+       for (dimension=0; dimension<number_differ_lib; dimension++) {
+         if (number_differ_lib >1) { 
+           local_lib = &differ_lib[dimension];
+         }
+         else local_lib = differ_lib;
+       
+
+         PairCoilDifferDimension(mode, sequence, local_lib, &maxsc,
+                                 all_preproc_offsets[preproc_table],
+                                 all_preprocess_like[preproc_table],
+                                 all_scores,
+                                 all_offsets, dimension,
+                                 Offset_to_Use, number_differ_score_dim,
+                                 bound);       
+       
+       }
+       break;
+
+
+/************************************************************************/
+changed
+
+    if ( (Method != MultiCoil)  && (Method !=PairCoilDiff)) 
+      get_offsets(all_scores, sequence,all_offsets,number_tables);
+to
+    if (Method != MultiCoil) 
+      get_offsets(all_scores, sequence,all_offsets,NUMBER_TABLES);
+    else if (!(mode & RAW_OUT)) {
+
+
+CUT
+
+/***********Do conversions on PairCoilDiff scores, using preprocessor. **/
+/*********** Note for differentiator there are only 2 possible classes **/
+/*********** (dimer and trimer). **********/
+      if (Method == PairCoilDiff) {
+       convert_raw_scores_to_gauss_prob_like2(all_scores,sequence.seqlen,
+                         number_tables, differ_means_submatrix,
+                         differ_inverse_covars,differ_determinants, 2,
+                         init_class_prob, number_differ_score_dim,
+                          0, bound, Offset_to_Use,0);
+       if (Preprocessor_Method == MultiCoil) 
+         preproc_res_like = &all_preprocess_like[preproc_table+3][0][0];
+       else preproc_res_like = &all_preprocess_like[preproc_table][0][0];
+
+
+/*  Only use window scores that lie completely in coil */
+       if ( (which_differentiator == 3) || (which_differentiator ==4))
+         zero_out_non_coils(all_scores, all_preprocess_like[preproc_table],
+                            sequence.seqlen, bound);
+
+       if (which_differentiator == 1) 
+         zero_out_bad_windows(differ_window_length, 
+                              all_scores,all_preprocess_like[preproc_table],
+                              sequence.seqlen,bound);
+
+       copy_offsets(all_preproc_offsets[preproc_table],sequence, 
+                     all_offsets,2, all_scores, Offset_to_Use);
+       if (Coil_Score) /* Value of 1 means do average, 2 means do max. */
+         for (tablenum=0; tablenum<2; tablenum++) {
+           average_score_over_coils3(sequence, all_scores[tablenum+3],
+                                   all_scores[tablenum],
+                                   preproc_res_like,  
+                                   /** Total Coil Like. **/
+                               weighted_avg, offset_to_use,
+                                 all_preproc_offsets[preproc_table],
+                               start_coil_at_reg_shift, bound,
+                               Coil_Score -1);
+       }
+      }
+
+
+
+cut
+    if (rescore_seq==-1 && !scored_already && (Method==PairCoilDiff)) {
+      if ( (which_differentiator == 3) || (which_differentiator ==4))
+       zero_out_non_coils(all_scores, all_preprocess_like[preproc_table],
+                            sequence.seqlen, bound);
+      if (which_differentiator == 1) /*  Only use window scores that lie */
+       zero_out_bad_windows(differ_window_length, /* completely in coil */
+                              all_scores, all_preprocess_like[preproc_table],
+                              sequence.seqlen,bound);
+    }
+
+
+changed
+       get_seq_scores(seq_scores, sequence, all_scores[0+3],
+                                       all_scores[1+3],bound, weighted_avg);
+
+to
+       get_seq_scores(seq_scores, sequence, all_scores[0+3],
+                                       all_scores[1+3],bound);
+
+
+cut
+
+
+      else if (Method == PairCoilDiff)  {
+       if (Preprocessor_Method == MultiCoil) 
+         preproc_res_like = &all_preprocess_like[preproc_table+3][0][0];
+       else preproc_res_like = &all_preprocess_like[preproc_table][0][0];
+
+       
+       for (tablenum=0; tablenum<2; tablenum++)
+         average_score_over_coils3(sequence, all_scores[tablenum+3],
+                                   all_scores[tablenum],
+                                   preproc_res_like,  
+                                   /** Total Coil Like. **/
+                                   weighted_avg, offset_to_use,
+                                   all_offsets[tablenum],
+                                   start_coil_at_reg_shift, bound,
+                                   Coil_Score -1);
+      }
+    
+
+
+changed
+ShowSeq(char lib[MAXFUNCTNUM], char differ_lib[MAXFUNCTNUM],
+       char  multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+       double *m, double *b,
+        double *m_single, double *b_single,
+        int mode, int rescore_sequence, int rescore_preproc, double bound)
+to
+ShowSeq(char lib[MAXFUNCTNUM], 
+       char  multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+       double *m, double *b,
+        double *m_single, double *b_single,
+        int mode, int rescore_sequence, int rescore_preproc, double bound)
+
+changed
+
+
+    all_scores = ScoreSeq(lib, differ_lib, multi_lib, m, b,m_single, b_single,
+                   mode, table, 
+                   method, preprocessor_method,
+                   offset_to_use, &maxscore,  
+                   rescore_sequence, rescore_preproc, bound);
+to
+    all_scores = ScoreSeq(lib,  multi_lib, m, b,m_single, b_single,
+                   mode, table, 
+                   method, preprocessor_method,
+                   offset_to_use, &maxscore,  
+                   rescore_sequence, rescore_preproc, bound);
+
+/******************************ROUND 3 OF CHANGES **************************/
+
+changed
+  initialize(&num_dist[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            &mode);
+to
+  initialize(&num_dist[0], window_length, scale0s,
+            scale0p,fpin[0],
+            &likelihoods[0][0], &pir_name[0], print, gauss_param, 
+            &mode, init_clas_prob);
+
+
+
+changed
+void output_seq(char lib[MAXFUNCTNUM],char differ_lib[MAXFUNCTNUM],
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               double *m,double *b,
+               double *m_single, double *b_single, 
+               int mode, 
+               double log_bound,FILE *flog, FILE *flog_coil_conflicts,
+               FILE *fout_coils,
+               FILE *fout,  
+               int avg_max,
+               int main_method, int main_preprocessor_method,
+               int main_table)
+to
+void output_seq(char lib[MAXFUNCTNUM],char differ_lib[MAXFUNCTNUM],
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               double *m,double *b,
+               double *m_single, double *b_single, 
+               int mode, 
+               double log_bound,FILE *flog, 
+               FILE *fout_coils,
+               FILE *fout,  
+               int avg_max,
+               int main_method, int main_preprocessor_method,
+               int main_table)
+cut
+    if (flog_coil_conflicts) sclose(flog_coil_conflicts);
+
+
+
+changed
+
+
+    convert_raw_scores_to_gauss_prob_like2(all_preprocess_like,sequence.seqlen,
+                                NUMBER_TABLES,means_submatrix,inverse_covars,
+                                determinants, NUMBER_CLASSES, init_class_prob,
+                                number_score_dim,
+                                    mode & ONLY_COILED_CLASSES, 
+                                    bound,Offset_to_Use,  1);
+ to
+    convert_raw_scores_to_gauss_prob_like2(all_preprocess_like,sequence.seqlen,
+                                NUMBER_TABLES,means_submatrix,inverse_covars,
+                                determinants, NUMBER_CLASSES, init_class_prob,
+                                number_score_dim,
+                                    mode & ONLY_COILED_CLASSES, 
+                                    bound,Offset_to_Use);
+ twice.
+
+
+
+
+
+Changed
+
+  if (ftotal_like) {      /** Want to output total gauss like over classes*/
+    for (i=0; i<number_classes; i++)  /* for various init_prob settings.  */
+
+to 
+
+  if (ftotal_like) {      /** Want to output total gauss like over classes*/
+    for (i=0; i<NUMBER_CLASSES; i++)  /* for various init_prob settings.  */
+
+
+changed
+      get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                  num_table_dimensions(7,combine_dist[0]) +
+                                  num_table_dimensions(7,combine_dist[1]),
+                                   both_class_means[i], both_class_covars[i],
+                                  number_classes, gauss_param[i]);
+to
+      get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                  num_table_dimensions(7,combine_dist[0]) +
+                                  num_table_dimensions(7,combine_dist[1]),
+                                   both_class_means[i], both_class_covars[i],
+                                  NUMBER_CLASSES, gauss_param[i]);
+
+
+Changed
+         preproc_table = (preproc_table +1) % number_classes;
+to
+  preproc_table = (preproc_table +1) % NUMBER_CLASSES;
+
+
+Changed 
+           type_class_score_convert(sequence,all_scores,bound,
+                                    mode & ONLY_COILED_CLASSES, number_tables,
+                                    NUMBER_CLASSES);
+to
+           type_class_score_convert(sequence,all_scores,bound,
+                                    mode & ONLY_COILED_CLASSES);
+
+
+Changed
+      get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                  num_table_dimensions(7,combine_dist[0]) +
+                                  num_table_dimensions(7,combine_dist[1]),
+                                   both_class_means[i], both_class_covars[i],
+                                  NUMBER_CLASSES, gauss_param[i]);
+to
+      get_gauss_param_all_classes2(class_sc_filenames[i], 
+                                  num_table_dimensions(7,combine_dist[0]) +
+                                  num_table_dimensions(7,combine_dist[1]),
+                                   both_class_means[i], both_class_covars[i],
+                                  gauss_param[i]);
+Changed
+      if (Coil_Score ==1)
+       if (weighted_avg)
+         strcat(MethodTitle,"WtdAvg");
+       else strcat(MethodTitle,"Avg");
+to
+    if (Coil_Score) {
+      if (Coil_Score ==1)
+       strcat(MethodTitle,"WtdAvg");
+
+
+From function switch_gauss_param() cut
+  else if (Method == PairCoilDiff) {
+    determinants= &differ_determinants[0];
+    inverse_covars= &differ_inverse_covars[0][0][0];
+    means_submatrix= &differ_means_submatrix[0][0];
+  }
+
+
+/********************************************************************/
+
+In interface.h
+changed
+void output_seq(char lib[MAXFUNCTNUM],char lib_differ[MAXFUNCTNUM],
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               double *m,double *b,
+               double *m_single, double *b_single,
+               int mode, 
+               double bound, FILE *flog, FILE *flog_coil_conflicts,
+               FILE *fout_coils,
+               FILE *fout, 
+               int avg_max,
+               int main_method, int main_preprocessor_method, int main_table);
+
+
+to
+
+void output_seq(char lib[MAXFUNCTNUM],
+               char multi_lib[MAX_TABLE_NUMBER][MAXFUNCTNUM],
+               double *m,double *b,
+               double *m_single, double *b_single, 
+               int mode, 
+               double log_bound,FILE *flog, 
+               FILE *fout_coils,
+               FILE *fout,  
+               int avg_max,
+               int main_method, int main_preprocessor_method,
+               int main_table);
+
+
+Changed
+
+      case XK_i:
+       if (preprocessor_method == MultiCoil) 
+         preproc_table = (preproc_table +1) % NUMBER_CLASSES;
+       else
+         preproc_table = (preproc_table +1) % NUMBER_TABLES;
+       ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,2,  bound);
+       if (zoomptr) Zoomer();
+       break;
+      case XK_T:
+      case XK_t:
+       if (method == MultiCoil) 
+         table = (table +1) % NUMBER_CLASSES;
+       else 
+         table = (table +1) % NUMBER_TABLES;
+       ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,0, bound);
+       if (zoomptr) Zoomer();
+       break;
+
+
+to
+
+      case XK_i:
+       if (preprocessor_method == MultiCoil) 
+         preproc_table = (preproc_table +1) % NUMBER_CLASSES;
+       else if (preprocessor_method == HMMCoil)
+         preproc_table = (preproc_table +1) % NUMBER_TABLES;
+       else preproc_table = 0;
+       ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,2,  bound);
+       if (zoomptr) Zoomer();
+       break;
+      case XK_T:
+      case XK_t:
+       if (method == MultiCoil) 
+         table = (table +1) % NUMBER_CLASSES;
+       else if (method == HMMCoil)
+         table = (table +1) % NUMBER_TABLES;
+       else table =0;
+       ShowSeq(lib,multi_lib,m,b,m_single,b_single,mode,0,0, bound);
+       if (zoomptr) Zoomer();
+       break;
+
+and changed
+      case XK_M:
+      case XK_m:
+       if (method == MultiCoil) 
+         table = table % NUMBER_CLASSES;
+       else if 
+         table = table % NUMBER_TABLES;
+       
+TO
+
+      case XK_M:
+      case XK_m:
+       if (method == MultiCoil) 
+         table = table % NUMBER_CLASSES;
+       else if (method == HMMCoil)
+         table = table % NUMBER_TABLES;
+       else table =0;
+
+and similarly for xk_w
+
+Changed
+    get_likelihood_line(likelihoods, m, b, m_single, b_single,
+                     lib, pair_functnum,pir_name,mode,NUMBER_TABLES);
+to
+    get_likelihood_line(likelihoods, m, b, m_single, b_single,
+                     lib, pair_functnum,pir_name,mode,1);
+since PairCoil doesn't work well for trimer table.