JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / sc2seq_interface_cuts.c
diff --git a/sources/multicoil/sc2seq_interface_cuts.c b/sources/multicoil/sc2seq_interface_cuts.c
new file mode 100644 (file)
index 0000000..2a561ea
--- /dev/null
@@ -0,0 +1,263 @@
+changed
+void PairCoilData (FILE *fgin, FILE **fpin, int *number_tables, 
+                  int ProlineFree, int table_to_remove_from,
+                  char *input_filename, int mode, 
+                  double prior_freq_single[MAX_TABLE_NUMBER],
+                  double prior_freq_pair[MAX_TABLE_NUMBER], int which_priors,
+                  int which_priorp, int good_turing, 
+                  int structural_pos[POSNUM+1])
+to
+void PairCoilData (FILE *fgin, FILE **fpin, int *number_tables, 
+                  int ProlineFree, int table_to_remove_from,
+                  char *input_filename, int mode)
+
+changed
+      if (!(mode & WEIGHTED_PROBS)) {
+       
+       set_unimportant_pos_to_genbnk(many_pprobs[i], many_pprobp[i],
+                                     gprobs, gprobp, structural_pos);
+       estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
+                               pfreqp[i], ptotalp[i], many_pprobp,
+                               ProlineFree, which_priors, which_priorp,
+                               prior_freq_single[i],
+                               prior_freq_pair[i], good_turing,
+                               structural_pos);
+to
+      if (!(mode & WEIGHTED_PROBS)) {
+       estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
+                               pfreqp[i], ptotalp[i], many_pprobp,
+                               ProlineFree);
+
+
+changed
+void recalc_prob(Sequence sequence, int input_table, int mode, 
+                int which_priors, int which_priorp,
+                double prior_freq_single[MAX_TABLE_NUMBER],
+                double prior_freq_pair[MAX_TABLE_NUMBER],
+                int good_turing, int structural_pos[POSNUM+1])
+to
+void recalc_prob(Sequence sequence, int input_table, int mode)
+
+and
+    estimate_database_probs(input_table, pfreqs[input_table], 
+                           ptotals[input_table], many_pprobs,
+                           pfreqp[input_table], ptotalp[input_table], 
+                           many_pprobp, ProlineFreeWindow, which_priors,
+                           which_priorp, prior_freq_single[input_table], 
+                           prior_freq_pair[input_table], good_turing,
+                           structural_pos);
+to
+    estimate_database_probs2(input_table, pfreqs[input_table], 
+                           ptotals[input_table], many_pprobs,
+                           pfreqp[input_table], ptotalp[input_table], 
+                           many_pprobp, ProlineFreeWindow);
+
+
+
+
+
+in PairCoilData
+changed
+  for (i=0; i<*number_tables; i++)
+
+
+change
+
+void average_score_over_coils3(Sequence seq, 
+                              double StructureResLike[MAXSEQLEN][POSNUM+1],
+                              double StructureCoilLike[MAXSEQLEN][POSNUM+1],
+                              double CoilLike[MAXSEQLEN][POSNUM+1],
+                              int weighted_avg, int offset_to_use,
+                              char offsets[MAXSEQLEN],
+                              int start_at_reg_shift, double bound,
+                              int avg_max)
+to
+void average_score_over_coils3(Sequence seq, 
+                              double StructureResLike[MAXSEQLEN][POSNUM+1],
+                              double StructureCoilLike[MAXSEQLEN][POSNUM+1],
+                              double CoilLike[MAXSEQLEN][POSNUM+1],
+                              int offset_to_use,
+                              char offsets[MAXSEQLEN],
+                              int start_at_reg_shift, double bound,
+                              int avg_max)
+
+
+replaced
+
+void MultiCoilDimensionScore (int mode, Sequence sequence, char lib[MAXFUNCTNUM], double *maxscore, int table, char offsets[MAXSEQLEN], double scores[MAXSEQLEN][POSNUM+1], int offset_to_use, int pairs)
+by
+void MultiCoilDimensionScore (int mode, Sequence sequence, char lib[MAXFUNCTNUM], double *maxscore, int table, char offsets[MAXSEQLEN], double scores[MAXSEQLEN][POSNUM+1], int offset_to_use)
+
+
+
+in PairCoilData:
+  changed
+    else if (i > 1) {  /* If there are 2 other tables average them.  */
+      average_many_pprob(i);
+      combine_many_weight(i);  
+    }
+    else { 
+      fprintf(stderr, "\nCould not make combination table number %d.",i);
+      fprintf(stderr, "\nAll later tables will be unavailable.\n");
+      *number_tables=i;
+    }
+    
+to
+    else { 
+      fprintf(stderr, "\nCould not make input table number %d.",i);
+      exit(-1);
+    }
+    
+
+and
+    if (*number_tables != i)  {      /*  Just check for above where couldn't */
+      #ifdef AVG_WEIRD_PROBS        /* make table.     */
+        calc_weird_pprob_avg(many_pprobp[i], many_pprobs[i]);   
+      #else
+        calc_weird_pprob_sum(many_pprobp[i], many_pprobs[i]);   
+      #endif
+      }
+to
+#ifdef AVG_WEIRD_PROBS        /* make table.     */
+    calc_weird_pprob_avg(many_pprobp[i], many_pprobs[i]);   
+#else
+    calc_weird_pprob_sum(many_pprobp[i], many_pprobs[i]);   
+#endif
+
+
+
+/*******************************ROUND 2 *****************************/
+CUT
+
+/* #define PAIR_PIR_TXT "/local/bab/pir_pair.txt"  */ 
+
+
+double many_weights[MAX_TABLE_NUMBER][AANUM][POSNUM],
+             many_weightp[MAX_TABLE_NUMBER][AANUM][AANUM][POSNUM][POSNUM];
+
+double dist_weight[POSNUM];
+double prior_probs[NUM_RES_TYPE][POSNUM], 
+        prior_probp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM];
+double (*weights)[POSNUM];
+double (*weightp)[AANUM][POSNUM][POSNUM];
+
+typedef double real;
+
+
+in switch_tables()
+     cut    weights= many_weights[table];
+            weightp= many_weightp[table];
+
+
+Cut
+/*  NOTE THAT THE many_pprob variables are globally defined in interface.h. */
+/** This gives the current_table probabilities the average of tables 1 and 2 */
+void average_many_pprob(int current_table)
+{
+  int reg1, reg2, res1, res2;
+
+  for (res1=0; res1<AANUM; res1++)
+    for (reg1=0; reg1<POSNUM; reg1++) {
+      many_pprobs[current_table][res1][reg1] = 
+          (many_pprobs[0][res1][reg1] + many_pprobs[1][res1][reg1])/2;
+
+      for (res2=0; res2<AANUM; res2++)
+        for (reg2=0; reg2<POSNUM; reg2++)
+          many_pprobp[current_table][res1][res2][reg1][reg2] = 
+            (many_pprobp[0][res1][res2][reg1][reg2] + 
+                many_pprobp[1][res1][res2][reg1][reg2]) /2;
+    }
+}
+
+
+in recalc_prob()
+     cut
+  else {    /* Do weighted paircoil. */
+    calcweight(pfreqs[input_table], pfreqp[input_table],gprobs, gprobp,
+              many_weights[input_table], many_weightp[input_table],
+              ptotals[input_table], ptotalp[input_table],NULL);
+    
+    calc_weighted_pprobs(pfreqs[input_table], ptotals[input_table], 
+                        many_pprobs[input_table], 
+                        ProlineFreeWindow, many_weights[input_table], 
+                        gprobs, NULL);
+    calc_weighted_pprobp(pfreqp[input_table], ptotalp[input_table], 
+                        many_pprobs[input_table], 
+                        many_pprobp[input_table], ProlineFreeWindow, 
+                        many_weightp[input_table],
+                        gprobp, NULL);
+  }
+
+and
+  average_many_pprob(2);
+  combine_many_weight(2);     /*** Recompute the combination table probs. **/ 
+
+
+From PairCoilData, cut:
+  FILE *weight_file=NULL;
+  extern char weightfile_outname[MAXLINE];
+
+  if ((strcmp(weightfile_outname, "/dev/null")) || (mode & WEIGHTED_PROBS))
+    weight_file = sopen(weightfile_outname,"w");
+    if (weight_file) fprintf(weight_file,"\nTable number %d\n",i);
+
+and changed:
+
+      if (!(mode & WEIGHTED_PROBS)) {
+       estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
+                               pfreqp[i], ptotalp[i], many_pprobp,
+                               ProlineFree);
+/******************
+       calcpprobs(pfreqs[i], ptotals[i], many_pprobs[i], ProlineFree);
+       calcpprobp(pfreqp[i], ptotalp[i], many_pprobs[i], many_pprobp[i],
+                ProlineFree);
+********************/
+
+       if (weight_file) printfreq_prob(pfreqs[i],pfreqp[i],
+              weight_file,many_pprobs[i], many_pprobp[i]);
+      }
+      else {    /* Do weighted paircoil. */
+       double bonnies_pprobs[NUM_RES_TYPE][POSNUM];
+       double bonnies_pprobp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM];
+
+       calcweight(pfreqs[i], pfreqp[i],gprobs, gprobp,
+                 many_weights[i], many_weightp[i],
+                 ptotals[i], ptotalp[i],weight_file);
+
+       calcpprobs(pfreqs[i], ptotals[i], bonnies_pprobs, ProlineFree);
+       calcpprobp(pfreqp[i], ptotalp[i], bonnies_pprobs, bonnies_pprobp,
+                ProlineFree);
+
+       calc_weighted_pprobs(pfreqs[i], ptotals[i], many_pprobs[i], 
+                            ProlineFree, many_weights[i], gprobs, NULL);
+       calc_weighted_pprobp(pfreqp[i], ptotalp[i], many_pprobs[i], 
+                            many_pprobp[i], ProlineFree, many_weightp[i],
+                            gprobp, NULL);
+
+       printweight(pfreqs[i],pfreqp[i],gprobs,gprobp,many_weights[i], many_weightp[i], ptotals[i],ptotalp[i],weight_file, many_pprobs[i], many_pprobp[i],bonnies_pprobs,bonnies_pprobp);
+      }
+
+
+
+to
+
+
+      estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
+                               pfreqp[i], ptotalp[i], many_pprobp,
+
+
+cut
+
+  if (mode & WEIGHTED_PROBS) fclose(weight_file);
+  calc_distance_weights(dist,weight);
+
+
+Moved functions:
+  PairCoilDiffer and average_scores_over_coil2 into file
+PairCoilDiffer_cuts.c
+and PairCoilDifferDimension()  and zero_out_non_coils() and
+ zero_out_bad_windows( into PairCoilDiffer.c
+
+
+
+