JPRED-2 Add sources of all binaries (except alscript) to Git
[jpred.git] / sources / multicoil / sc2seq_interface_cuts.c
1 changed
2 void PairCoilData (FILE *fgin, FILE **fpin, int *number_tables, 
3                    int ProlineFree, int table_to_remove_from,
4                    char *input_filename, int mode, 
5                    double prior_freq_single[MAX_TABLE_NUMBER],
6                    double prior_freq_pair[MAX_TABLE_NUMBER], int which_priors,
7                    int which_priorp, int good_turing, 
8                    int structural_pos[POSNUM+1])
9 to
10 void PairCoilData (FILE *fgin, FILE **fpin, int *number_tables, 
11                    int ProlineFree, int table_to_remove_from,
12                    char *input_filename, int mode)
13
14 changed
15       if (!(mode & WEIGHTED_PROBS)) {
16         
17         set_unimportant_pos_to_genbnk(many_pprobs[i], many_pprobp[i],
18                                       gprobs, gprobp, structural_pos);
19         estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
20                                 pfreqp[i], ptotalp[i], many_pprobp,
21                                 ProlineFree, which_priors, which_priorp,
22                                 prior_freq_single[i],
23                                 prior_freq_pair[i], good_turing,
24                                 structural_pos);
25 to
26       if (!(mode & WEIGHTED_PROBS)) {
27         estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
28                                 pfreqp[i], ptotalp[i], many_pprobp,
29                                 ProlineFree);
30
31
32 changed
33 void recalc_prob(Sequence sequence, int input_table, int mode, 
34                  int which_priors, int which_priorp,
35                  double prior_freq_single[MAX_TABLE_NUMBER],
36                  double prior_freq_pair[MAX_TABLE_NUMBER],
37                  int good_turing, int structural_pos[POSNUM+1])
38 to
39 void recalc_prob(Sequence sequence, int input_table, int mode)
40
41 and
42     estimate_database_probs(input_table, pfreqs[input_table], 
43                             ptotals[input_table], many_pprobs,
44                             pfreqp[input_table], ptotalp[input_table], 
45                             many_pprobp, ProlineFreeWindow, which_priors,
46                             which_priorp, prior_freq_single[input_table], 
47                             prior_freq_pair[input_table], good_turing,
48                             structural_pos);
49 to
50     estimate_database_probs2(input_table, pfreqs[input_table], 
51                             ptotals[input_table], many_pprobs,
52                             pfreqp[input_table], ptotalp[input_table], 
53                             many_pprobp, ProlineFreeWindow);
54
55
56
57
58
59 in PairCoilData
60 changed
61   for (i=0; i<*number_tables; i++)
62
63
64 change
65
66 void average_score_over_coils3(Sequence seq, 
67                                double StructureResLike[MAXSEQLEN][POSNUM+1],
68                                double StructureCoilLike[MAXSEQLEN][POSNUM+1],
69                                double CoilLike[MAXSEQLEN][POSNUM+1],
70                                int weighted_avg, int offset_to_use,
71                                char offsets[MAXSEQLEN],
72                                int start_at_reg_shift, double bound,
73                                int avg_max)
74 to
75 void average_score_over_coils3(Sequence seq, 
76                                double StructureResLike[MAXSEQLEN][POSNUM+1],
77                                double StructureCoilLike[MAXSEQLEN][POSNUM+1],
78                                double CoilLike[MAXSEQLEN][POSNUM+1],
79                                int offset_to_use,
80                                char offsets[MAXSEQLEN],
81                                int start_at_reg_shift, double bound,
82                                int avg_max)
83
84
85 replaced
86
87 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)
88 by
89 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)
90
91
92
93 in PairCoilData:
94   changed
95     else if (i > 1) {  /* If there are 2 other tables average them.  */
96       average_many_pprob(i);
97       combine_many_weight(i);  
98     }
99     else { 
100       fprintf(stderr, "\nCould not make combination table number %d.",i);
101       fprintf(stderr, "\nAll later tables will be unavailable.\n");
102       *number_tables=i;
103     }
104     
105 to
106     else { 
107       fprintf(stderr, "\nCould not make input table number %d.",i);
108       exit(-1);
109     }
110     
111
112 and
113     if (*number_tables != i)  {      /*  Just check for above where couldn't */
114       #ifdef AVG_WEIRD_PROBS        /* make table.     */
115         calc_weird_pprob_avg(many_pprobp[i], many_pprobs[i]);   
116       #else
117         calc_weird_pprob_sum(many_pprobp[i], many_pprobs[i]);   
118       #endif
119       }
120 to
121 #ifdef AVG_WEIRD_PROBS        /* make table.     */
122     calc_weird_pprob_avg(many_pprobp[i], many_pprobs[i]);   
123 #else
124     calc_weird_pprob_sum(many_pprobp[i], many_pprobs[i]);   
125 #endif
126
127
128
129 /*******************************ROUND 2 *****************************/
130 CUT
131
132 /* #define PAIR_PIR_TXT "/local/bab/pir_pair.txt"  */ 
133
134
135 double many_weights[MAX_TABLE_NUMBER][AANUM][POSNUM],
136              many_weightp[MAX_TABLE_NUMBER][AANUM][AANUM][POSNUM][POSNUM];
137
138 double dist_weight[POSNUM];
139 double prior_probs[NUM_RES_TYPE][POSNUM], 
140         prior_probp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM];
141 double (*weights)[POSNUM];
142 double (*weightp)[AANUM][POSNUM][POSNUM];
143
144 typedef double real;
145
146
147 in switch_tables()
148      cut    weights= many_weights[table];
149             weightp= many_weightp[table];
150
151
152 Cut
153 /*  NOTE THAT THE many_pprob variables are globally defined in interface.h. */
154 /** This gives the current_table probabilities the average of tables 1 and 2 */
155 void average_many_pprob(int current_table)
156 {
157   int reg1, reg2, res1, res2;
158
159   for (res1=0; res1<AANUM; res1++)
160     for (reg1=0; reg1<POSNUM; reg1++) {
161       many_pprobs[current_table][res1][reg1] = 
162           (many_pprobs[0][res1][reg1] + many_pprobs[1][res1][reg1])/2;
163
164       for (res2=0; res2<AANUM; res2++)
165         for (reg2=0; reg2<POSNUM; reg2++)
166           many_pprobp[current_table][res1][res2][reg1][reg2] = 
167             (many_pprobp[0][res1][res2][reg1][reg2] + 
168                 many_pprobp[1][res1][res2][reg1][reg2]) /2;
169     }
170 }
171
172
173 in recalc_prob()
174      cut
175   else {    /* Do weighted paircoil. */
176     calcweight(pfreqs[input_table], pfreqp[input_table],gprobs, gprobp,
177                many_weights[input_table], many_weightp[input_table],
178                ptotals[input_table], ptotalp[input_table],NULL);
179     
180     calc_weighted_pprobs(pfreqs[input_table], ptotals[input_table], 
181                          many_pprobs[input_table], 
182                          ProlineFreeWindow, many_weights[input_table], 
183                          gprobs, NULL);
184     calc_weighted_pprobp(pfreqp[input_table], ptotalp[input_table], 
185                          many_pprobs[input_table], 
186                          many_pprobp[input_table], ProlineFreeWindow, 
187                          many_weightp[input_table],
188                          gprobp, NULL);
189   }
190
191 and
192   average_many_pprob(2);
193   combine_many_weight(2);     /*** Recompute the combination table probs. **/ 
194
195
196 From PairCoilData, cut:
197   FILE *weight_file=NULL;
198   extern char weightfile_outname[MAXLINE];
199
200   if ((strcmp(weightfile_outname, "/dev/null")) || (mode & WEIGHTED_PROBS))
201     weight_file = sopen(weightfile_outname,"w");
202     if (weight_file) fprintf(weight_file,"\nTable number %d\n",i);
203
204 and changed:
205
206       if (!(mode & WEIGHTED_PROBS)) {
207         estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
208                                 pfreqp[i], ptotalp[i], many_pprobp,
209                                 ProlineFree);
210 /******************
211         calcpprobs(pfreqs[i], ptotals[i], many_pprobs[i], ProlineFree);
212         calcpprobp(pfreqp[i], ptotalp[i], many_pprobs[i], many_pprobp[i],
213                  ProlineFree);
214 ********************/
215
216         if (weight_file) printfreq_prob(pfreqs[i],pfreqp[i],
217                weight_file,many_pprobs[i], many_pprobp[i]);
218       }
219       else {    /* Do weighted paircoil. */
220         double bonnies_pprobs[NUM_RES_TYPE][POSNUM];
221         double bonnies_pprobp[NUM_RES_TYPE][NUM_RES_TYPE][POSNUM][POSNUM];
222
223         calcweight(pfreqs[i], pfreqp[i],gprobs, gprobp,
224                   many_weights[i], many_weightp[i],
225                   ptotals[i], ptotalp[i],weight_file);
226
227         calcpprobs(pfreqs[i], ptotals[i], bonnies_pprobs, ProlineFree);
228         calcpprobp(pfreqp[i], ptotalp[i], bonnies_pprobs, bonnies_pprobp,
229                  ProlineFree);
230
231         calc_weighted_pprobs(pfreqs[i], ptotals[i], many_pprobs[i], 
232                              ProlineFree, many_weights[i], gprobs, NULL);
233         calc_weighted_pprobp(pfreqp[i], ptotalp[i], many_pprobs[i], 
234                              many_pprobp[i], ProlineFree, many_weightp[i],
235                              gprobp, NULL);
236
237         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);
238       }
239
240
241
242 to
243
244
245       estimate_database_probs(i, pfreqs[i], ptotals[i], many_pprobs,
246                                 pfreqp[i], ptotalp[i], many_pprobp,
247
248
249 cut
250
251   if (mode & WEIGHTED_PROBS) fclose(weight_file);
252   calc_distance_weights(dist,weight);
253
254
255 Moved functions:
256   PairCoilDiffer and average_scores_over_coil2 into file
257 PairCoilDiffer_cuts.c
258 and PairCoilDifferDimension()  and zero_out_non_coils() and
259  zero_out_bad_windows( into PairCoilDiffer.c
260
261
262
263