00001 #include "../headers/descriptors.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 s_desc* allocate_s_desc(void)
00087 {
00088 s_desc *desc = (s_desc*)my_malloc(sizeof(s_desc)) ;
00089
00090 reset_desc(desc) ;
00091
00092 return desc ;
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 void reset_desc(s_desc *desc)
00109 {
00110 desc->hydrophobicity_score = 0.0 ;
00111 desc->volume_score = 0.0 ;
00112 desc->volume = 0.0 ;
00113 desc->prop_polar_atm = 0.0 ;
00114 desc->mean_asph_ray = 0.0 ;
00115 desc->masph_sacc = 0.0 ;
00116 desc->apolar_asphere_prop = 0.0 ;
00117 desc->mean_loc_hyd_dens = 0.0 ;
00118 desc->as_density = 0.0 ;
00119 desc->as_max_dst = 0.0 ;
00120
00121 desc->flex = 0.0 ;
00122 desc->nas_norm = 0.0 ;
00123 desc->prop_asapol_norm = 0.0 ;
00124 desc->mean_loc_hyd_dens_norm = 0.0 ;
00125 desc->as_density_norm = 0.0 ;
00126 desc->polarity_score_norm = 0.0 ;
00127 desc->as_max_dst_norm = 0.0 ;
00128
00129 desc->nb_asph = 0 ;
00130 desc->polarity_score = 0 ;
00131 desc->charge_score = 0 ;
00132
00133 desc->surf_apol_vdw=0.0;
00134 desc->surf_apol_vdw14=0.0;
00135 desc->surf_apol_vdw22=0.0;
00136
00137 desc->surf_pol_vdw=0.0;
00138 desc->surf_pol_vdw14=0.0;
00139 desc->surf_pol_vdw22=0.0;
00140
00141 desc->surf_vdw=0.0;
00142 desc->surf_vdw14=0.0;
00143 desc->surf_vdw22=0.0;
00144
00145 desc->drug_score=0.0;
00146 desc->numResChain1=0;
00147 desc->numResChain2=0;
00148 desc->characterChain1=0;
00149 desc->characterChain2=0;
00150
00151 int i ;
00152 for(i = 0 ; i < 20 ; i++) desc->aa_compo[i] = 0 ;
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 void set_descriptors(s_atm **atoms, int natoms, s_vvertice **tvert, int nvert,
00183 s_desc *desc,int niter,s_pdb *pdb, int flag_do_expensive_calculations)
00184 {
00185
00186 set_atom_based_descriptors(atoms, natoms, desc, pdb->latoms, pdb->natoms) ;
00187
00188
00189 if(! tvert) return ;
00190
00191 float d = 0.0, vx, vy, vz, vrad,
00192 masph_sacc = 0.0,
00193 mean_ashape_radius = 0.0,
00194 as_density = 0.0, as_max_dst = -1.0,
00195 dtmp = 0.0 ;
00196
00197 int i, j,
00198 napol_neigh = 0,
00199 nAlphaApol = 0 ;
00200
00201 float as_max_r = -1.0 ;
00202
00203 s_vvertice *vcur = NULL,
00204 *vc = NULL ;
00205
00206 desc->mean_loc_hyd_dens = 0.0 ;
00207
00208
00209
00210 for(i = 0 ; i < nvert ; i++) {
00211 vcur = tvert[i] ;
00212
00213
00214
00215 if(vcur->ray > as_max_r) as_max_r = vcur->ray ;
00216
00217 vx = vcur->x ; vy = vcur->y ; vz = vcur->z ; vrad = vcur->ray ;
00218
00219
00220 j = 0 ;
00221 if(vcur->type == M_APOLAR_AS) {
00222 napol_neigh = 0 ;
00223 for(j = 0 ; j < nvert ; j++) {
00224 vc = tvert[j] ;
00225
00226
00227 if(vc != vcur && vc->type == M_APOLAR_AS &&
00228 dist(vx, vy, vz, vc->x, vc->y, vc->z)-(vc->ray + vrad) <= 0.) {
00229 napol_neigh += 1 ;
00230 }
00231
00232
00233 if(j > i) {
00234 dtmp = dist(vcur->x, vcur->y, vcur->z,
00235 vc->x, vc->y, vc->z);
00236
00237 if(dtmp > as_max_dst) as_max_dst = dtmp ;
00238 as_density += dtmp ;
00239 }
00240 }
00241 desc->mean_loc_hyd_dens += (float) napol_neigh ;
00242 nAlphaApol += 1 ;
00243 }
00244 else {
00245
00246 for(j = i+1 ; j < nvert ; j++) {
00247 dtmp = dist(vcur->x, vcur->y, vcur->z,
00248 tvert[j]->x, tvert[j]->y, tvert[j]->z) ;
00249
00250 if(dtmp > as_max_dst) as_max_dst = dtmp ;
00251 as_density += dtmp ;
00252 }
00253 }
00254
00255 mean_ashape_radius += vcur->ray ;
00256
00257 d = dist(vcur->x, vcur->y, vcur->z,
00258 vcur->bary[0], vcur->bary[1], vcur->bary[2]) ;
00259 masph_sacc += d/vcur->ray ;
00260 }
00261
00262 if(nAlphaApol>0) desc->mean_loc_hyd_dens /= (float)nAlphaApol ;
00263 else desc->mean_loc_hyd_dens= 0.0;
00264
00265 if(flag_do_expensive_calculations) {
00266 set_ASA(desc, pdb, tvert, nvert);
00267 desc->volume = get_verts_volume_ptr(tvert, nvert, niter,-1.6) ;
00268 }
00269
00270
00271 desc->as_max_dst = as_max_dst ;
00272 desc->apolar_asphere_prop = (float)nAlphaApol / (float)nvert ;
00273 desc->masph_sacc = masph_sacc / nvert ;
00274 desc->mean_asph_ray = mean_ashape_radius / (float)nvert ;
00275 desc->nb_asph = nvert ;
00276 desc->as_density = as_density / ((nvert*nvert - nvert) * 0.5) ;
00277
00278 desc->as_max_r = as_max_r ;
00279 if (nvert==0){
00280 desc->apolar_asphere_prop=0.0;
00281 desc->masph_sacc=0.0;
00282 desc->mean_asph_ray=0.0;
00283 desc->as_density=0.0;
00284 }
00285 }
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 int get_vert_apolar_density(s_vvertice **tvert, int nvert, s_vvertice *vert)
00310 {
00311 int apol_neighbours = 0,
00312 i = 0 ;
00313
00314 s_vvertice *vc = NULL ;
00315
00316 float vx = vert->x,
00317 vy = vert->y,
00318 vz = vert->z,
00319 vray = vert->ray ;
00320
00321 for(i = 0 ; i < nvert ; i++) {
00322 vc = tvert[i] ;
00323 if(vc != vert && vc->type == M_APOLAR_AS){
00324 if(dist(vx, vy, vz, vc->x, vc->y, vc->z)-(vc->ray + vray) <= 0.) {
00325 apol_neighbours += 1 ;
00326 }
00327 }
00328 }
00329
00330 return apol_neighbours ;
00331 }
00332
00333 int countResidues(s_atm *atoms, int natoms, char chain[2]){
00334 int i,
00335 n=0,
00336 curRes=-1,
00337 firstRes=-1,
00338 lastRes=-1;
00339 s_atm *curatom = NULL ;
00340 for(i=0;i<natoms;i++){
00341 curatom = &(atoms[i]) ;
00342 if(!strncmp(curatom->chain,chain,1) ){
00343 if(firstRes==-1) firstRes=curatom->res_id;
00344 lastRes=curatom->res_id;
00345 if(curRes!=curatom->res_id){
00346 curRes=curatom->res_id;
00347 n+=1;
00348 }
00349 }
00350 }
00351 return lastRes-firstRes;
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 void set_atom_based_descriptors(s_atm **atoms, int natoms, s_desc *desc,s_atm *all_atoms, int all_natoms)
00374 {
00375 s_atm *curatom = NULL ;
00376 s_atm *firstatom = NULL;
00377 int i,
00378 curChar = 0,
00379 res_ids[natoms],
00380 nb_res_ids = 0 ;
00381
00382 int nb_polar_atm = 0 ;
00383 char curChainName[2];
00384 if(atoms){
00385 firstatom=atoms[0];
00386 desc->interChain=0;
00387
00388 if(element_in_std_res(firstatom->res_name)) desc->characterChain1=0;
00389 else if(element_in_nucl_acid(firstatom->res_name)) desc->characterChain1=1;
00390 else if(element_in_kept_res(firstatom->res_name)) desc->characterChain1=2;
00391 strcpy(desc->nameChain1,firstatom->chain);
00392 strcpy(curChainName,firstatom->chain);
00393 desc->numResChain1 = countResidues(all_atoms,all_natoms,firstatom->chain);
00394
00395 for(i = 0 ; i < natoms ; i++) {
00396 curatom = atoms[i] ;
00397 if(curatom!=firstatom){
00398 if(strcmp(curatom->chain,firstatom->chain)!=0 && desc->interChain < 1) {
00399 desc->interChain = 1;
00400 if(!desc->numResChain2){
00401 desc->numResChain2 = countResidues(all_atoms,all_natoms,curatom->chain);
00402 strncpy(curChainName,curatom->chain,1);
00403 }
00404 }
00405
00406 if(element_in_std_res(curatom->res_name)){
00407 curChar=0;
00408
00409 }
00410 else if(element_in_nucl_acid(curatom->res_name)){
00411 curChar=1;
00412
00413 }
00414 else if(element_in_kept_res(curatom->res_name)){
00415 curChar=2;
00416
00417 }
00418 if(curChar!=desc->characterChain1){
00419 desc->characterChain2=curChar;
00420
00421 }
00422 }
00423
00424 if(in_tab(res_ids, nb_res_ids, curatom->res_id) == 0) {
00425 set_aa_desc(desc, atoms[i]->res_name) ;
00426 res_ids[nb_res_ids] = curatom->res_id ;
00427 nb_res_ids ++ ;
00428 }
00429
00430
00431 desc->flex += curatom->bfactor ;
00432 if(curatom->electroneg > 2.7) nb_polar_atm += 1 ;
00433 }
00434
00435 if(!desc->numResChain2) desc->numResChain2 = countResidues(all_atoms,all_natoms,curatom->chain);
00436 strcpy(desc->nameChain2,curChainName);
00437
00438
00439 desc->hydrophobicity_score = desc->hydrophobicity_score/ (float) nb_res_ids ;
00440 desc->volume_score = desc->volume_score / (float) nb_res_ids ;
00441
00442 desc->flex /= natoms ;
00443 desc->prop_polar_atm = ((float) nb_polar_atm) / ((float) natoms) * 100.0 ;
00444 }
00445 else {
00446 desc->hydrophobicity_score=0.0;
00447 desc->volume_score=0.0;
00448 desc->flex=0.0;
00449 desc->prop_polar_atm=0.0;
00450 }
00451
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469 void set_aa_desc(s_desc *desc, const char *aa_name)
00470 {
00471 int aa_idx = -1;
00472 char l1 = aa_name[0],
00473 l2 = aa_name[1],
00474 l3 = aa_name[2] ;
00475
00476
00477
00478
00479
00480 switch(l1) {
00481 case 'A' :
00482 if(l2 == 'L') aa_idx = M_ALA_IDX ;
00483 else if(l2 == 'R') aa_idx = M_ARG_IDX ;
00484 else if(l2 == 'S' && l3 == 'P')
00485 aa_idx = M_ASP_IDX ;
00486 else aa_idx = M_ASN_IDX ; break ;
00487
00488 case 'C' : aa_idx = M_CYS_IDX ; break ;
00489
00490 case 'G' :
00491 if(l3 == 'U') aa_idx = M_GLU_IDX ;
00492 else if(l3 == 'Y') aa_idx = M_GLY_IDX ;
00493 else aa_idx = M_GLN_IDX ; break ;
00494
00495 case 'H' : aa_idx = M_HIS_IDX ; break ;
00496 case 'I' : aa_idx = M_ILE_IDX ; break ;
00497
00498 case 'L' :
00499 if(l2 == 'Y') aa_idx = M_LYS_IDX ;
00500 else aa_idx = M_LEU_IDX ; break ;
00501
00502 case 'M' : aa_idx = M_MET_IDX ; break ;
00503 case 'P' :
00504 if(l2 == 'H') aa_idx = M_PHE_IDX ;
00505 else aa_idx = M_PRO_IDX ; break ;
00506
00507 case 'S' : aa_idx = M_SER_IDX ; break ;
00508
00509 case 'T' :
00510 if(l2 == 'H') aa_idx = M_THR_IDX ;
00511 else if(l2 == 'R') aa_idx = M_TRP_IDX ;
00512 else aa_idx = M_TYR_IDX ; break ;
00513
00514 case 'V' : aa_idx = M_VAL_IDX ; break ;
00515
00516 default:
00517 break ;
00518 }
00519
00520
00521
00522 if(aa_idx != -1) {
00523 desc->aa_compo[aa_idx] ++ ;
00524 desc->hydrophobicity_score += get_hydrophobicity_score_from_idx(aa_idx) ;
00525 desc->polarity_score += get_polarity_from_idx(aa_idx) ;
00526 desc->volume_score += get_volume_score_from_idx(aa_idx) ;
00527 desc->charge_score += get_charge_from_idx(aa_idx) ;
00528 }
00529 }
00530