00001
00002 #include "../headers/dpocket.h"
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
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 void dpocket(s_dparams *par)
00117 {
00118 int i, j ;
00119 FILE *fout[3] ;
00120
00121 if(par) {
00122
00123
00124 fout[0] = fopen(par->f_exp,"w") ;
00125 fout[1] = fopen(par->f_fpckp,"w") ;
00126 fout[2] = fopen(par->f_fpcknp,"w") ;
00127
00128 if(fout[0] && fout[1] && fout[2]) {
00129
00130
00131
00132 for( i = 0 ; i < 3 ; i++ ) {
00133 fprintf(fout[i], M_DP_OUTP_HEADER) ;
00134 for( j = 0 ; j < 20 ; j++ ) fprintf(fout[i], " %s", get_aa_name3(j));
00135 fprintf(fout[i], "\n");
00136 }
00137
00138
00139 for(i = 0 ; i < par->nfiles ; i++) {
00140 fprintf(stdout, "<dpocket>s %d/%d - %s:",
00141 i+1, par->nfiles, par->fcomplex[i]) ;
00142
00143 desc_pocket(par->fcomplex[i], par->ligs[i], par, fout) ;
00144 if(i == par->nfiles - 1) fprintf(stdout,"\n") ;
00145 else fprintf(stdout,"\r") ;
00146
00147 fflush(stdout) ;
00148 }
00149
00150 for( i = 0 ; i < 3 ; i++ ) fclose(fout[i]) ;
00151 }
00152 else {
00153 if(! fout[0]) {
00154 fprintf(stdout, "! Output file <%s> couldn't be opened.\n",
00155 par->f_exp) ;
00156 }
00157 else if (! fout[1]) {
00158 fprintf(stdout, "! Output file <%s> couldn't be opened.\n",
00159 par->f_fpckp) ;
00160 }
00161 else {
00162 fprintf(stdout, "! Output file <%s> couldn't be opened.\n",
00163 par->f_fpcknp) ;
00164 }
00165 }
00166 }
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 void desc_pocket(char fcomplexe[], const char ligname[], s_dparams *par,
00185 FILE *f[3])
00186 {
00187 c_lst_pockets *pockets = NULL ;
00188 s_lst_vvertice *verts = NULL ;
00189
00190 s_atm **interface = NULL ;
00191 s_desc *edesc ;
00192 s_atm **lig = NULL,
00193 **patoms ;
00194
00195 float vol, ovlp, dst = 0.0, tmp, c4, c5 ;
00196 int nal = 0,
00197 nai = 0,
00198 nbpa ;
00199 int j ;
00200
00201
00202
00203
00204 s_pdb *pdb_cplx_l = rpdb_open(fcomplexe, ligname, M_KEEP_LIG);
00205 s_pdb *pdb_cplx_nl = rpdb_open(fcomplexe, ligname, M_DONT_KEEP_LIG) ;
00206
00207 if(! pdb_cplx_l || !pdb_cplx_nl || pdb_cplx_l->natm_lig <= 0) {
00208 if(pdb_cplx_l->natm_lig <= 0) {
00209 fprintf(stdout, "ERROR - No ligand %s found in %s.\n", ligname, fcomplexe) ;
00210
00211 }
00212 else fprintf(stdout, "ERROR - PDB file %s could not be opened\n", fcomplexe) ;
00213
00214 return ;
00215 }
00216
00217 rpdb_read(pdb_cplx_l, ligname, M_KEEP_LIG) ;
00218 rpdb_read(pdb_cplx_nl, ligname, M_DONT_KEEP_LIG) ;
00219
00220
00221
00222
00223 lig = pdb_cplx_l->latm_lig ;
00224 nal = pdb_cplx_l->natm_lig ;
00225
00226
00227 int n_lig_molecules=1;
00228 char chain_tmp[2];
00229 int resnumber_tmp;
00230 strcpy(chain_tmp,lig[0]->chain);
00231 resnumber_tmp = lig[0]->res_id;
00232
00233 for (j = 1 ; j < nal ; j++) {
00234 if(strcmp(chain_tmp,lig[j]->chain) !=0 || resnumber_tmp!=lig[j]->res_id){
00235 n_lig_molecules++;
00236 strcpy(chain_tmp,lig[j]->chain);
00237 resnumber_tmp =lig[j]->res_id;
00238 }
00239 }
00240
00241
00242
00243
00244
00245
00246 pockets = search_pocket(pdb_cplx_nl, par->fpar,pdb_cplx_l) ;
00247 if(pockets == NULL) {
00248 fprintf(stdout, "ERROR - No pocket found for %s\n", fcomplexe) ;
00249 return ;
00250 }
00251
00252
00253
00254
00255
00256
00257 verts = pockets->vertices ;
00258 edesc = allocate_s_desc() ;
00259 interface = get_explicit_desc(pdb_cplx_l, verts, lig, nal, par,
00260 &nai, edesc) ;
00261
00262
00263 vol = get_mol_volume_ptr(lig, nal, par->fpar->nb_mcv_iter) ;
00264 write_pocket_desc(fcomplexe, ligname, edesc, vol, 100.0, 0.0, 1.0, 1.0, f[0]) ;
00265
00266 node_pocket *cur = pockets->first ;
00267 s_vvertice **pvert = NULL ;
00268 while(cur) {
00269
00270 patoms = get_vert_contacted_atms(cur->pocket->v_lst, &nbpa) ;
00271 ovlp = atm_corsp(interface, nai, patoms, nbpa) ;
00272
00273
00274
00275 for (j = 0 ; j < nal ; j++) {
00276 tmp = dist(lig[j]->x, lig[j]->y, lig[j]->z,
00277 cur->pocket->bary[0], cur->pocket->bary[1],
00278 cur->pocket->bary[2]) ;
00279 if(j == 0) dst = tmp ;
00280 else {
00281 if(tmp < dst) dst = tmp ;
00282 }
00283 }
00284
00285
00286 pvert = get_pocket_pvertices(cur->pocket) ;
00287
00288 c4 = count_atm_prop_vert_neigh( lig, pdb_cplx_l->natm_lig,
00289 pvert, cur->pocket->size, M_CRIT4_D,n_lig_molecules) ;
00290 c5 = count_pocket_lig_vert_ovlp(lig, pdb_cplx_l->natm_lig,
00291 pvert, cur->pocket->size, M_CRIT5_D) ;
00292
00293
00294 if(ovlp > 40.0 || dst < 4.0) {
00295 write_pocket_desc(fcomplexe, ligname, cur->pocket->pdesc, vol,
00296 ovlp, dst, c4, c5, f[1]) ;
00297 }
00298 else {
00299 write_pocket_desc(fcomplexe, ligname, cur->pocket->pdesc, vol,
00300 ovlp, dst, c4, c5, f[2]) ;
00301 }
00302 my_free(patoms) ;
00303 cur = cur->next ;
00304 }
00305
00306
00307 c_lst_pocket_free(pockets) ;
00308 my_free(interface) ;
00309 free_pdb_atoms(pdb_cplx_l) ;
00310 free_pdb_atoms(pdb_cplx_nl) ;
00311
00312 }
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 s_atm** get_explicit_desc(s_pdb *pdb_cplx_l, s_lst_vvertice *verts, s_atm **lig,
00337 int nal, s_dparams *par, int *nai, s_desc *desc)
00338 {
00339 int nvn = 0 ;
00340
00341 s_atm **interface = NULL ;
00342
00343
00344
00345
00346
00347
00348 if(par->interface_method == M_INTERFACE_METHOD2) {
00349
00350 interface = get_mol_atm_neigh( lig, nal, pdb_cplx_l->latoms_p,
00351 pdb_cplx_l->natoms,
00352 par->interface_dist_crit, nai) ;
00353 }
00354 else {
00355
00356
00357 interface = get_mol_ctd_atm_neigh(lig, nal, verts->pvertices, verts->nvert,
00358 par->interface_dist_crit,
00359 M_INTERFACE_SEARCH, nai) ;
00360 }
00361
00362
00363
00364 s_vvertice **tpverts = get_mol_vert_neigh(lig, nal, verts->pvertices, verts->nvert,
00365 par->interface_dist_crit, &nvn) ;
00366
00367
00368
00369
00370
00371
00372
00373 set_descriptors(interface, *nai, tpverts, nvn, desc, par->fpar->nb_mcv_iter,pdb_cplx_l,par->fpar->flag_do_asa_and_volume_calculations);
00374
00375
00376
00377
00378
00379 my_free(tpverts) ;
00380
00381 return interface ;
00382 }
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403 void write_pocket_desc(const char fc[], const char l[], s_desc *d, float lv,
00404 float ovlp, float dst, float c4, float c5, FILE *f)
00405 {
00406 int status = 0 ;
00407 if(dst < 4.0) status = 1 ;
00408
00409 int c6 = (c4 >= M_CRIT4_VAL && c5 >= M_CRIT5_VAL) ?1:0 ;
00410 float c6_c = ((c4 - M_CRIT4_VAL)/ (1-M_CRIT4_VAL)) + ((c5 - M_CRIT5_VAL)/ (1-M_CRIT5_VAL)) ;
00411
00412 fprintf(f, M_DP_OUTP_FORMAT, M_DP_OUTP_VAR(fc, l, ovlp, status, dst, c4, c5, c6, c6_c, lv, d)) ;
00413
00414 int i ;
00415 for(i = 0 ; i < 20 ; i++) fprintf(f, " %3d", d->aa_compo[i]) ;
00416
00417 fprintf(f, "\n") ;
00418 }