src/common/energy_functions.cc

00001 #include <math.h>
00002 #include <stdio.h>
00003 #include <assert.h>
00004 
00005 #define energy_global_define 1
00006 #include "open_prospect.h"
00007 #include "sm_matrix.h"
00008 
00009 extern "C" {
00010 #include "filter_net.h"
00011 }
00012 
00013 #define ABS(a)         ( (a) < 0 ? (-(a)) : (a) )
00014 
00015 
00016 pValType calc_raw_score( WeightArray weights, EnergyArray energies ) {
00017         pValType total = 0.0;
00018         for (int i = 0; i < e_count; i++ ) {
00019                 total += weights[i] * energies[i];
00020         }
00021         return total;
00022 }
00023 
00024 pValType calc_single_energy(ProspectParam *param,
00025                                                         WeightArray weights,
00026                                                         TemplateStruct *template_data,
00027                                                         TargetStruct *target_data,
00028                                                         int template_res_num,
00029                                                         int target_res_num) {
00030         pValType score = 0;
00031         
00032         if ( target_res_num >= 0 && target_res_num < target_data->len) {
00033         
00034                 if (weights[e_mutation] != 0) 
00035                         score += weights[e_mutation] * calc_mutation(param, template_data, target_data, template_res_num, target_res_num);
00036                 
00037                 //      if (weights[e_mutationfull] != 0) 
00038                 //              score += weights[e_mutationfull] * calc_mutationfull(param, template_data, target_data, template_res_num, target_res_num);
00039                 
00040                 if (weights[e_mutationlog] != 0) 
00041                         score += weights[e_mutationlog] * calc_mutationlog(param, template_data, target_data, template_res_num, target_res_num);
00042                 
00043                 if (weights[e_singleton] != 0) 
00044                         score += weights[e_singleton] * calc_singleton(param, template_data, target_data, template_res_num, target_res_num);
00045                 
00046                 if (weights[e_mutscore] != 0) 
00047                         score += weights[e_mutscore] * calc_mutscore(param, template_data, target_data, template_res_num, target_res_num);
00048                 
00049                 if (weights[e_sec_struct] != 0) 
00050                         score += weights[e_sec_struct] * calc_sec_struct(param, template_data, target_data, template_res_num, target_res_num);
00051                 
00052                 if (weights[e_contact] != 0) 
00053                         score += weights[e_contact] * calc_contact_frozen(param, template_data, target_data, template_res_num, target_res_num);
00054 
00055                 
00056                 //      if (weights[e_twobody_frozen] != 0) 
00057                 //              score += weights[e_twobody_frozen] * calc_twobody_frozen(param, template_data, target_data, template_res_num, target_res_num);
00058         }
00059                 
00060         return score;
00061 }
00062 
00063 
00064 
00065 pValType calc_pair_energy(ProspectParam *param,
00066                                                   WeightArray weights,
00067                                                   TemplateStruct *template_data,
00068                                                   TargetStruct *target_data,
00069                                                   int template_res_num_1, int template_res_num_2,
00070                                                   int target_res_num_1, int target_res_num_2) {
00071         pValType score = 0;
00072         
00073         if (weights[e_twobody] != 0.0)
00074                 score += weights[e_twobody] * calc_twobody(param, template_data, target_data, 
00075                                                                                                    template_res_num_1, template_res_num_2, 
00076                                                                                                    target_res_num_1, target_res_num_2);
00077 
00078         if (weights[e_dfire] != 0.0)
00079                 score += weights[e_dfire] * calc_dfire(param, template_data, target_data, 
00080                                                                                                    template_res_num_1, template_res_num_2, 
00081                                                                                                    target_res_num_1, target_res_num_2);
00082 
00083         
00084         if (weights[e_distconst] != 0.0)
00085                 score += weights[e_distconst] * calc_distconst(param, template_data, target_data, 
00086                                                                                                    template_res_num_1, template_res_num_2, 
00087                                                                                                    target_res_num_1, target_res_num_2);
00088         
00089         return score;
00090 }
00091 
00092 /*
00093 void calc_core_single_energies(ProspectParam *param,
00094                                TemplateStruct *template_data,
00095                                TargetStruct *target_data,                              
00096                                long core, long core_pos, pValType *energies) {
00097   long i;
00098   
00099   for (i = 0; i < e_count; i++) {
00100     energies[i] = 0;
00101   }
00102   for (i = 0; i < template_data->cores[ core ].len; i++) {
00103           if (core_pos+i >= 0 && core_pos+i < target_data->len) {
00104                   energies[e_mutation] += calc_mutation(param, template_data, target_data,
00105                                                                                                 template_data->cores[ core ].head + i, core_pos + i);
00106 //                energies[e_mutationfull] += calc_mutationfull(param, template_data, target_data,
00107 //                                                                                                              template_data->cores[ core ].head + i, core_pos + i);
00108                   energies[e_mutationlog] += calc_mutationlog(param, template_data, target_data,
00109                                                                                                           template_data->cores[ core ].head + i, core_pos + i);
00110 //                energies[e_gonnet] += calc_gonnet(param, template_data, target_data,
00111 //                                                                                      template_data->cores[ core ].head + i, core_pos + i);
00112                   energies[e_singleton] += calc_singleton(param, template_data, target_data,
00113                                                                                                   template_data->cores[ core ].head + i, core_pos + i);
00114                   energies[e_sec_struct] += calc_sec_struct(param, template_data, target_data,
00115                                                                                                         template_data->cores[ core ].head + i, core_pos + i);
00116 //                energies[e_twobody_frozen] += calc_twobody_frozen(param, template_data, target_data,
00117 //                                                                                                                      template_data->cores[ core ].head + i, core_pos + i);
00118           }
00119   }
00120 }
00121 */
00122 
00123 
00124 
00125 //--------------------ENERGY FUNCTIONS-----------------
00126 pValType calc_mutation(ProspectParam *param,
00127                      TemplateStruct *template_data,
00128                      TargetStruct *target_data,
00129                      int template_res_num,
00130                      int target_res_num) {
00131   int k;
00132   pValType mutation=0.0;
00133 
00134 #ifdef ALTIVEC
00135   vector float partialProduct = (vector float) (0.0f, 0.0f, 0.0f, 0.0f), 
00136     temp, sum;
00137   vector unsigned int minusZero;
00138   float vDotProduct;                            /* X dot Y              */
00139   vector float  x,y;
00140   float *a,*b;
00141 #if 0
00142   minusZero = vec_splat_u32 ( -1 );             /* create the -0.0 vector */
00143   minusZero = vec_sl ( minusZero, minusZero );  /* in vector integer      */
00144   partialProduct = ( vector float ) minusZero;   /* initialize to -0.0    */
00145 #endif
00146   
00147 
00148   a = template_data->residue[template_res_num].PROFILE;
00149   b =  target_data->residue[target_res_num].FREQ;
00150 
00151   x = vec_ld(0, a);
00152   y = vec_ld(0, b);
00153   a+=4;
00154   b+=4;
00155   for (i = 1; i < 5; i++) {
00156     partialProduct = vec_madd ( x, y, partialProduct ); 
00157     x = vec_ld(0, a );
00158     y = vec_ld(0, b );
00159     a+=4;
00160     b+=4;
00161   }
00162 
00163   temp = vec_sld ( partialProduct, partialProduct, 4 );
00164   sum  = vec_add ( partialProduct, temp );
00165   temp = vec_sld ( sum, sum, 8 );
00166   sum  = vec_add ( sum, temp);
00167   
00168   vec_ste ( sum, 0, &vDotProduct );
00169   return -vDotProduct;  
00170 #else
00171    if (template_res_num < template_data->len && template_res_num >= 0 &&
00172           target_res_num < target_data->len && target_res_num >= 0) {
00173 
00174  
00175      for (k=0;k<20;k++) {
00176                  mutation=mutation+template_data->residue[template_res_num].FREQ[k]*
00177          target_data->residue[target_res_num].FREQ[k];
00178      }
00179   }
00180   return (-mutation);
00181 #endif
00182   
00183 }
00184 
00185 
00186 pValType calc_mutationfull(ProspectParam *param,
00187                                            TemplateStruct *template_data,
00188                                            TargetStruct *target_data,
00189                                            int template_res_num,
00190                                            int target_res_num) {
00191         int i,j;
00192         pValType mutation=0.0;
00193 
00194 
00195     if (template_res_num < template_data->len && template_res_num >= 0 &&
00196           target_res_num < target_data->len && target_res_num >= 0) {
00197         
00198         for (i = 0; i < 20; i++) {
00199                 for (j = 0; j < 20; j++) {
00200                         mutation = mutation +
00201                         (template_data->residue[template_res_num].FREQ[i]*
00202                          target_data->residue[target_res_num].FREQ[j] * 
00203                          param->GONNET_MATRIX[ i ][ j ] );
00204                 }
00205         }
00206       }
00207 
00208         return (-mutation);     
00209 }
00210 
00211 
00212 typedef struct AA_LetterProb {
00213   char a;
00214   pValType prob;
00215 } AA_LetterProb;
00216 
00217 static AA_LetterProb Robinson_prob[] = {
00218   { 'A', 0.07805 },
00219   { 'R', 0.05129 },
00220   { 'N', 0.04487 },
00221   { 'D', 0.05364 },
00222   { 'C', 0.01925 },
00223   { 'Q', 0.04264 },
00224   { 'E', 0.06295 },
00225   { 'G', 0.07377 },
00226   { 'H', 0.02199 },
00227   { 'I', 0.05142 },
00228   { 'L', 0.09019 },
00229   { 'K', 0.05744 },
00230   { 'M', 0.02243 },
00231   { 'F', 0.03856 },
00232   { 'P', 0.05203 },
00233   { 'S', 0.07120 },
00234   { 'T', 0.05841 },
00235   { 'W', 0.01330 },
00236   { 'Y', 0.03216 },
00237   { 'V', 0.06441 }
00238 };
00239 
00240 
00241 
00242 pValType calc_mutationlog(ProspectParam *param,
00243                      TemplateStruct *template_data,
00244                      TargetStruct *target_data,
00245                      int template_res_num,
00246                      int target_res_num) {
00247   long i;
00248   pValType sum = 0;
00249 /*
00250   for (i = 0; i < 20; i++) {
00251     if ( template_data->residue[template_res_num].PROFILE[i] > 0.000001)
00252       sum += log( template_data->residue[template_res_num].PROFILE[i] / Robinson_prob[i].prob ) * 
00253         target_data->residue[target_res_num].FREQ[i] ;
00254     else 
00255       sum += -32768 * target_data->residue[target_res_num].FREQ[i];
00256   }
00257   if ( sum < -32768)
00258     sum = -32768;
00259 
00260   assert(!isnan(sum));
00261  */
00262   
00263   for (i = 0; i < 20; i++) {
00264           sum += target_data->residue[target_res_num].FREQ[i] * template_data->t_residue_info[template_res_num].Score[i];
00265   }
00266   assert( !isnan(sum) );
00267   return -sum;
00268 }
00269 
00270 pValType calc_mutscore(ProspectParam *param,
00271                      TemplateStruct *template_data,
00272                      TargetStruct *target_data,
00273                      int template_res_num,
00274                      int target_res_num) {
00275     return template_data->t_residue_info[ template_res_num ].Score[ AA1toAANum( target_data->residue[target_res_num].RS ) ];
00276 }
00277 
00278 pValType calc_sec_struct(ProspectParam *param,
00279                                                  TemplateStruct *template_data,
00280                                                  TargetStruct *target_data,
00281                                                  int template_res_num,
00282                                                  int target_res_num) {
00283         pValType ss_fit=0.0;    
00284         if (template_data->residue[template_res_num].SS=='H') {
00285                 //ss_fit = 3.0 - rint(target_data->residue[target_res_num].SS_PROB[HELIX]*10.0);
00286                 ss_fit = 0.3 - (target_data->residue[target_res_num].SS_PROB[HELIX]);
00287         } else if (template_data->residue[template_res_num].SS=='E') {
00288                 //ss_fit = 3.0 - rint(target_data->residue[target_res_num].SS_PROB[SHEET]*10.0);
00289                 ss_fit = 0.3 - (target_data->residue[target_res_num].SS_PROB[SHEET]);
00290         } else {
00291                 //ss_fit = 3.0 - rint(target_data->residue[target_res_num].SS_PROB[LOOP]*10.0);
00292                 ss_fit = 0.3 - (target_data->residue[target_res_num].SS_PROB[LOOP]);
00293         }
00294         return (ss_fit);
00295 }
00296 
00297 
00298 pValType calc_singleton(ProspectParam *param,
00299                       TemplateStruct *template_data,
00300                       TargetStruct *target_data,
00301                       int template_res_num,
00302                       int target_res_num) {
00303 
00304   int k,index;
00305 
00306   index = solvent_sec_struct(template_data,template_res_num);
00307 
00308   if (index==-1)
00309     return (0.0);
00310   
00311   pValType singleton=0.0;
00312   for (k=0;k<20;k++) {
00313     singleton = singleton + param->SINGLETON[k][index]*target_data->residue[target_res_num].FREQ[k];
00314   }
00315 
00316   return (singleton);
00317 
00318 }
00319 
00320 
00321 int solvent_sec_struct(TemplateStruct *template_data,
00322                        int template_res_num)
00323 {
00324 
00325   int i,max;
00326 
00327   switch (template_data->residue[template_res_num].SS)
00328   {
00329     case 'H': i=0; break;
00330     case 'G': i=0; break;
00331     case 'I': i=0; break;
00332     case 'E': i=3; break;
00333     case 'B': i=3; break;
00334     default : i=6; break;
00335   }
00336 
00337   switch (template_data->residue[template_res_num].RS)
00338   {
00339     case 'A': max = 101; break;
00340     case 'C': max = 127; break;
00341     case 'D': max = 161; break;
00342     case 'E': max = 195; break;
00343     case 'F': max = 214; break;
00344     case 'G': max = 73;  break;
00345     case 'H': max = 193; break;
00346     case 'I': max = 174; break;
00347     case 'K': max = 200; break;
00348     case 'L': max = 182; break;
00349     case 'M': max = 192; break;
00350     case 'N': max = 171; break;
00351     case 'P': max = 127; break;
00352     case 'Q': max = 190; break;
00353     case 'R': max = 242; break;
00354     case 'S': max = 122; break;
00355     case 'T': max = 144; break;
00356     case 'V': max = 148; break;
00357     case 'W': max = 259; break;
00358     case 'Y': max = 235; break;
00359     default : max = -1;  break;
00360   }
00361 
00362   if (max==-1)
00363     return (-1);
00364 
00365   pValType check;
00366   check = (pValType)template_data->t_residue_info[template_res_num].ACC/(pValType)max;
00367 
00368   if (check <= 0.069) {
00369     return (i+0);
00370   } else if (check <= 0.368) {
00371     return (i+1);
00372   } else {
00373     return (i+2);
00374   }
00375 
00376 }
00377 
00378 
00379 pValType calc_contact_frozen(ProspectParam *param,
00380                                                          TemplateStruct *template_data,
00381                                                          TargetStruct *target_data,
00382                                                          int template_res_num,
00383                                                          int target_res_num) {
00384         int count = 0;
00385         if ( !template_data->structure )
00386                 return 0;
00387         
00388         for (int i = 0; i < template_data->len; i++) {
00389                 if ( i != template_res_num ) {
00390                         if ( smDistance( template_data->structure[i].atom[ template_data->structure[i].bb_num[ anCb ] ], 
00391                                                          template_data->structure[template_res_num].atom[ template_data->structure[template_res_num].bb_num[ anCb ] ] )
00392                                  < PairDistCutoffSqrt ) {
00393                                 count++;
00394                         }
00395                 }
00396         }
00397         if (count < MaxContactCount ) {
00398                 pValType score = 0.0;
00399                 for (int i = 0; i < 20; i++) 
00400                         score += target_data->residue[ target_res_num ].FREQ[i] * param->CONTACT_MATRIX[ i ][ count ];
00401                 return score;
00402         }
00403         return 3200;
00404 }
00405 
00406 
00407 pValType calc_twobody_frozen(ProspectParam *param,
00408                                  TemplateStruct *template_data,
00409                                  TargetStruct *target_data,
00410                                  int template_res_num,
00411                                  int target_res_num) {
00412         pValType score = 0;
00413         long i,j,k;
00414         if ( !template_data->twobody_interactions) 
00415                 return 0;
00416         
00417         for (i = 0; i < template_data->twobody_count; i++) {
00418         if (template_data->twobody_interactions[i].core_number[0] != -1 &&
00419                         template_data->twobody_interactions[i].core_number[1] != -1 &&
00420                         template_data->twobody_interactions[i].core_number[0] != template_data->twobody_interactions[i].core_number[1]) {
00421                         if (template_res_num == template_data->twobody_interactions[i].residue_number[0]) {
00422 /*
00423                                 for (j=0; j<20; j++) {
00424                                         for (k=0; k<20; k++) {
00425                                                         score += target_data->residue[target_res_num].FREQ[j] * 
00426                                                                  template_data->residue[template_data->twobody_interactions[i].residue_number[1]].PROFILE[k] *
00427                                                                  param->PAIR_POT[j][k];
00428       
00429                                                 }
00430                                         } 
00431  */
00432                                         score += param->PAIR_POT[ AA1toAANum(target_data->residue[target_res_num].RS) ]
00433                                         [ AA1toAANum(template_data->residue[template_data->twobody_interactions[i].residue_number[1]].RS) ];
00434                                         
00435                         }
00436                         if (template_res_num == template_data->twobody_interactions[i].residue_number[1]) {
00437 /*
00438                                 for (j=0; j<20; j++) {
00439                                         for (k=0; k<20; k++) {
00440                                                         score += target_data->residue[target_res_num].FREQ[j] * 
00441                                                                  template_data->residue[template_data->twobody_interactions[i].residue_number[0]].PROFILE[k] *
00442                                                                  param->PAIR_POT[j][k];
00443       
00444                                                 }
00445                                         } 
00446  */
00447                                         score += param->PAIR_POT[ AA1toAANum(target_data->residue[target_res_num].RS) ]
00448                                         [ AA1toAANum(template_data->residue[template_data->twobody_interactions[i].residue_number[0]].RS) ];
00449                                         
00450                         }
00451         }
00452     }   
00453         return score;      
00454 }
00455 
00456 
00457 pValType calc_twobody(ProspectParam *param,
00458                     TemplateStruct *template_data,
00459                     TargetStruct *target_data,
00460                     int template_res_num_1, int template_res_num_2,
00461                     int target_res_num_1, int target_res_num_2) {
00462         if ( ABS( (template_res_num_1 - template_res_num_2) ) > MinDistTwoBody &&
00463                  template_data->cb_dist[ template_res_num_1 ][template_res_num_2 ] <= PairDistCutoffSqrt ) {
00464                 assert( target_res_num_1 >= 0 && target_res_num_1 < target_data->len && target_res_num_2 >= 0 && target_res_num_2 < target_data->len);
00465                 assert( target_data->residue[ target_res_num_1 ].orig_num >= 0 && target_data->residue[ target_res_num_1 ].orig_num < target_data->len &&
00466                                 target_data->residue[ target_res_num_2 ].orig_num >= 0 && target_data->residue[ target_res_num_2 ].orig_num < target_data->len );
00467                 return target_data->twobody[ target_data->residue[ target_res_num_1 ].orig_num ][ target_data->residue[ target_res_num_2 ].orig_num ];
00468         } else 
00469                 return 0;
00470 }
00471 
00472 
00473 pValType calc_twobody_val(ProspectParam *param,
00474                     TargetStruct *target_data,
00475                     int target_res_num_1, int target_res_num_2) {
00476         int i,j;
00477         pValType twobody = 0.0;
00478         twobody = 0;
00479         if ( param->simple_twobody ) {
00480                 return param->PAIR_POT[ AA1toAANum( target_data->residue[target_res_num_1].RS ) ]
00481                 [ AA1toAANum( target_data->residue[target_res_num_2].RS ) ];
00482         } else {
00483                 for (i=0;i<20;i++) {
00484                         for (j=0;j<20;j++) {                    
00485                                 twobody += target_data->residue[target_res_num_1].FREQ[i] * 
00486                                 target_data->residue[target_res_num_2].FREQ[j] *
00487                                 param->PAIR_POT[i][j];
00488                         }
00489                 }       
00490         }
00491         return (twobody);
00492 }
00493 
00494 
00495 pValType calc_dfire(ProspectParam *param,
00496                       TemplateStruct *template_data,
00497                       TargetStruct *target_data,
00498                       int template_res_num_1, int template_res_num_2,
00499                       int target_res_num_1, int target_res_num_2) {
00500         long i;
00501         if (target_res_num_1 >= 0 && target_res_num_1 < target_data->len &&
00502                 target_res_num_2 >= 0 && target_res_num_2 < target_data->len &&
00503                 template_res_num_1 >= 0 && template_res_num_1 < template_data->len &&
00504                 template_res_num_2 >= 0 && template_res_num_2 < template_data->len ) {
00505                 pValType dist = template_data->cb_dist[ template_res_num_1 ][ template_res_num_2 ];
00506                 
00507 #if 0
00508                 for (i = 0; i < param->dfire.bin_count; i++) {
00509                         if ( param->dfire.bin_min[i] <= dist && param->dfire.bin_max[i] > dist) {
00510                                 return param->dfire.bin[i][ AA1toAANum(target_data->residue[target_res_num_1].RS) ]
00511                                 [ AA1toAANum(target_data->residue[target_res_num_2].RS) ];
00512                         }
00513                 }
00514 #else
00515                 i = (long)(dist * 10.0);
00516                 if (i < param->dfire.dist_hash_size && param->dfire.dist_hash[i] != -1) {
00517                         return param->dfire.bin[ param->dfire.dist_hash[i] ][ AA1toAANum(target_data->residue[target_res_num_1].RS) ]
00518                         [ AA1toAANum(target_data->residue[target_res_num_2].RS) ];
00519                 }
00520 #endif
00521         }
00522         return 0;
00523 }
00524 
00525 
00526 pValType calc_dfire( ProspectParam *param, char res_a, char res_b, float dist ) {
00527         long i = (long)(dist * 10.0);
00528         if (i < param->dfire.dist_hash_size && param->dfire.dist_hash[i] != -1) {
00529                 return param->dfire.bin[ param->dfire.dist_hash[i] ]
00530                 [ AA1toAANum(res_a) ]
00531                 [ AA1toAANum(res_b) ];
00532         }
00533         return 0;       
00534 }
00535                                          
00536 
00537 pValType calc_distconst(ProspectParam *param,
00538                                                 TemplateStruct *template_data,
00539                                                 TargetStruct *target_data,
00540                                                 int template_res_num_1, int template_res_num_2,
00541                                                 int target_res_num_1, int target_res_num_2) {
00542         pValType score = 0;
00543         long i;
00544         
00545         if (target_data->distconst) {
00546                 for (i = 0; i < target_data->distconst_count; i++) {
00547                         if ( (target_data->distconst[i].aa[0] == target_res_num_1 &&
00548                                   target_data->distconst[i].aa[1] == target_res_num_2) ||
00549                                  (target_data->distconst[i].aa[1] == target_res_num_1 &&
00550                                   target_data->distconst[i].aa[0] == target_res_num_2) ) {
00551                                 if ( fabs( template_data->cb_dist[ template_res_num_1 ][ template_res_num_2 ] - 
00552                                                   target_data->distconst[i].dist) < target_data->distconst[i].var ) {
00553                                         score--;
00554                                 } else {
00555                                 //      printf("distconst: %f %f\n", template_data->cb_dist[ template_res_num_1 ][ template_res_num_2 ],
00556                                 //                 target_data->distconst[i].dist);
00557                                 }
00558                         }
00559                 }               
00560         }
00561         
00562         return score;
00563 }
00564 
00565 
00566 
00567 float residue_max_sasa[21] = {
00568         //measured by DSSP
00569         240.0 , // A max:
00570         295.0 , // R max: 
00571         221.0 , // N max: 
00572         247.0 , // D max: 
00573         174.0 , // C max: 
00574         245.0 , // Q max: 
00575         254.0 , // E max: 
00576         262.0 , // G max: 
00577         254.0 , // H max: 
00578         235.0 , // I max: 
00579         234.0 , // L max: 
00580         318.0 , // K max: 
00581         242.0 , // M max: 
00582         246.0 , // F max: 
00583         230.0 , // P max: 
00584         238.0 , // S max: 
00585         217.0 , // T max: 
00586         262.0 , // W max: 
00587         290.0 , // Y max: 
00588         227.0 , // V max: 
00589         1
00590 };
00591 
00592 float residue_ave_sasa[21] = {
00593 /*
00594     //These averages are from the PopsR methods
00595         46.9261382097 , // A
00596         57.3720124498 , // R
00597         63.7989959076 , // N
00598         68.5261292949 , // D
00599         34.9587602287 , // C
00600         59.4041861357 , // Q
00601         65.0916408168 , // E
00602         63.612917346 , // G
00603         58.1849100782 , // H
00604         40.8545366915 , // I
00605         43.1632268618 , // L
00606         63.2779060589 , // K
00607         52.5770223822 , // M
00608         43.48384953 , // F
00609         66.5627212905 , // P
00610         61.2538013547 , // S
00611         54.7516852259 , // T
00612         44.1986291123 , // W
00613         44.6581405873 , // Y
00614         41.2469820032 , // V
00615 */
00616         //These averages are from DSSP
00617         35.7522151899 , // A max: 240.0
00618         102.584053794 , // R max: 295.0
00619         74.2146892655 , // N max: 221.0
00620         76.1526104418 , // D max: 247.0
00621         26.4561101549 , // C max: 174.0
00622         83.9657701711 , // Q max: 245.0
00623         88.9936708861 , // E max: 254.0
00624         38.6197583511 , // G max: 262.0
00625         69.592469546 , // H max: 254.0
00626         37.14604811 , // I max: 235.0
00627         41.0129971406 , // L max: 234.0
00628         99.2901748543 , // K max: 318.0
00629         55.1653439153 , // M max: 242.0
00630         48.2477650064 , // F max: 246.0
00631         61.3702882483 , // P max: 230.0
00632         52.223880597 , // S max: 238.0
00633         55.0547826087 , // T max: 217.0
00634         61.4861878453 , // W max: 262.0
00635         63.7211838006 , // Y max: 290.0
00636         35.5517128874 , // V max: 227.0
00637         
00638         1.0
00639 };
00640 
00641 
00642 pValType calc_del_val(ProspectParam *param,
00643                                           WeightArray weights,
00644                                           TemplateStruct *template_data,
00645                                           TargetStruct *target_data, 
00646                                           int template_res_num, int target_res_num ) {
00647         pValType total = 0.0;
00648         if ( weights[ e_tsingledel ] != 0.0 ) {
00649                 total += weights[ e_tsingledel ]  * calc_singledel( param, template_data, template_res_num );
00650         }
00651         if ( weights[ e_coredel ] != 0.0 ) {
00652                 total += weights[ e_coredel ] * calc_coredel( param, template_data, template_res_num );
00653         }
00654         if ( weights[ e_contactdel ] != 0.0 ) {
00655                 total += weights[ e_contactdel ] * calc_contactdel( param, template_data, template_res_num );
00656         }
00657         if ( weights[ e_qsingleins ] != 0.0 ) {
00658                 total += weights[ e_qsingleins ] * target_data->residue[ target_res_num ].single_ins;
00659         }
00660         
00661         return total;
00662 }
00663         
00664 
00665 pValType calc_ins_val( ProspectParam *param,
00666                                            WeightArray weights,
00667                                            TemplateStruct *template_data,
00668                                            TargetStruct *target_data, 
00669                                            int template_res_num, int target_res_num ) {
00670         pValType total = 0.0;
00671         if ( weights[ e_tsingleins ] != 0.0 ) {
00672                 total += weights[ e_tsingleins ] * calc_singleins(param, template_data, template_res_num);
00673         }
00674         if ( weights[ e_qsingledel ] != 0.0 ) {
00675                 total += weights[ e_qsingledel ] * target_data->residue[ target_res_num ].single_del;
00676         }
00677         return total;
00678 }
00679 
00680         
00681 pValType calc_singledel(ProspectParam *param,
00682                                          TemplateStruct *template_data,
00683                                          int template_res_num) {
00684         return (template_data->residue[template_res_num].single_del);
00685         //int res = AA1toAANum( template_data->residue[template_res_num].RS );
00686         //return (residue_max_sasa[ res ] - template_data->residue[template_res_num].ACC) / residue_ave_sasa[res]; 
00687         //return 1.0 - (template_data->residue[template_res_num].ACC / residue_ave_sasa[res]) ;
00688         //return residue_ave_sasa[res] - template_data->residue[template_res_num].ACC;
00689 }
00690 
00691 
00692 pValType calc_coredel(ProspectParam *param,
00693                                           TemplateStruct *template_data,
00694                                           int template_res_num) {
00695         if ( template_data->t_residue_info == NULL || 
00696                  template_data->cores == NULL || 
00697                  template_data->t_residue_info[ template_res_num ].core_num == -1 )
00698                 return 0;
00699         
00700         return 1.0 / (float) ( template_data->cores[ template_data->t_residue_info[ template_res_num ].core_num ].len );
00701         
00702 }
00703 
00704 pValType calc_contactdel(ProspectParam *param,
00705                                                   TemplateStruct *template_data,
00706                                                   int template_res_num) {
00707         float total_contact = 0;
00708         ResidueAtoms *res_1 = &template_data->structure[ template_res_num ];
00709         for ( int i = 0; i < template_data->len; i++ ) {
00710                 if ( i != template_res_num ) {
00711                         ResidueAtoms *res_2 = &template_data->structure[i];
00712                         float dist = smDistance( res_1->atom[ res_1->bb_num[ anCa ] ], 
00713                                                                          res_2->atom[ res_2->bb_num[ anCa ] ] );
00714                         if ( dist < 7.6 ) {
00715                                 total_contact++;
00716                         }
00717                 }
00718         }
00719         return total_contact;
00720 }
00721 
00722 
00723 pValType calc_singleins(ProspectParam *param,
00724                                                 TemplateStruct *template_data,
00725                                                 int template_res_num) {
00726         return (template_data->residue[template_res_num].single_ins);
00727 }
00728 
00729 
00730 #define kCoreMinSize   6
00731 #define filter_cut     0.01
00732 
00733 //FIXME:  This should be defined closer to the neural network
00734 //mutation,singleton,sec_struct
00735 char energy_mask[ e_count ] = {1,0,0,0,1,1,0,0,0,0,0};
00736 
00737 
00738 int ss_filter(ProspectParam *param,
00739                 TemplateStruct *template_data,
00740                 TargetStruct *target_data,
00741                 int core_num, int core_position) {
00742         //BUG:: This is all outdated code
00743         
00744         /*
00745   pValType score = 0;           
00746   long i, j;
00747   pValType energy_out[ e_count ];
00748   float energy_nn[ e_count ], filter_out;
00749 
00750  // calc_core_single_energies(param, template_data, target_data, core_num, core_position, energy_out );
00751   j = 0;
00752   for (i = 0; i < e_count; i++) {
00753     if (energy_mask[i]) {
00754       energy_nn[j] = energy_out[i];
00755       j++;
00756     }
00757   }
00758   filter_net( energy_nn, &filter_out, 1);
00759   if (filter_out > filter_cut) 
00760     return 1;
00761   */
00762         
00763   return 0;
00764 }
00765 

Generated on Wed Apr 11 16:50:49 2007 for open_prospect by  doxygen 1.4.6