00001
00002 #include "../headers/writepocket.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 void write_each_pocket_for_DB(const char out_path[], c_lst_pockets *pockets,s_pdb *pdb)
00060 {
00061 int out_len = strlen(out_path) ;
00062 char out[out_len+20] ;
00063 out[0] = '\0' ;
00064
00065 node_pocket *pcur ;
00066
00067 int i = 0 ;
00068 if(pockets){
00069 pcur = pockets->first ;
00070
00071 while(pcur){
00072 sprintf(out, "%s/pocket%d_vert.pqr", out_path, i+1) ;
00073 write_pocket_pqr_DB(out, pcur->pocket) ;
00074
00075 sprintf(out, "%s/pocket%d_env_atm.pdb", out_path, i+1) ;
00076 write_pocket_pdb_DB(out, pcur->pocket,pdb) ;
00077 sprintf(out, "%s/pocket%d_atm.pdb", out_path, i+1) ;
00078 write_pocket_pdb(out, pcur->pocket) ;
00079
00080 pcur = pcur->next ;
00081 i++ ;
00082 }
00083 }
00084 else {
00085 fprintf(stderr, "! The file %s could not be opened!\n", out);
00086 }
00087 }
00088
00089
00090
00091 void write_pocket_pqr_DB(const char out[], s_pocket *pocket)
00092 {
00093 node_vertice *vcur = NULL ;
00094
00095 FILE *f = fopen(out, "w") ;
00096 if(f && pocket) {
00097 vcur = pocket->v_lst->first ;
00098
00099 while(vcur){
00100 write_pqr_vert(f, vcur->vertice) ;
00101
00102 vcur = vcur->next ;
00103 }
00104
00105 fprintf(f, "TER\nEND\n") ;
00106 fclose(f) ;
00107 }
00108 else {
00109 if(!f) fprintf(stderr, "! The file %s could not be opened!\n", out);
00110 else fprintf(stderr, "! Invalid pocket to write in write_pocket_pqr !\n");
00111 }
00112 }
00113
00114
00115 void write_pocket_pdb_DB(const char out[], s_pocket *pocket,s_pdb *pdb)
00116 {
00117 int i = 0,nvert=0 ;
00118 s_atm **atms = (s_atm **) my_malloc(sizeof(s_atm*)*10) ;
00119 s_atm *atom = NULL ;
00120 int n_sa=0;
00121 int *sa=NULL;
00122 s_vvertice **tab_vert =NULL;
00123
00124 FILE *f = fopen(out, "w") ;
00125 if(f && pocket) {
00126
00127 tab_vert = (s_vvertice **) my_malloc(pocket->v_lst->n_vertices*sizeof(s_vvertice*)) ;
00128
00129 node_vertice *nvcur = pocket->v_lst->first ;
00130
00131
00132
00133
00134 while(nvcur) {
00135
00136
00137
00138
00139
00140 tab_vert[nvert] = nvcur->vertice ;
00141 nvcur = nvcur->next ;
00142 nvert++ ;
00143 }
00144 sa=(int *)get_surrounding_atoms_idx(tab_vert,nvert,pdb, &n_sa);
00145 for(i=0;i<n_sa;i++){
00146
00147 atom=pdb->latoms_p[sa[i]];
00148 write_pdb_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
00149 atom->res_name, atom->chain, atom->res_id,
00150 atom->pdb_insert, atom->x, atom->y, atom->z,
00151 atom->occupancy, atom->bfactor, atom->symbol,
00152 atom->charge);
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
00183
00184 fprintf(f, "TER\nEND\n") ;
00185 fclose(f) ;
00186 }
00187 else {
00188 if(!f) fprintf(stderr, "! The file %s could not be opened!\n", out);
00189 else fprintf(stderr, "! Invalid pocket to write in write_pocket_pqr !\n");
00190 }
00191
00192 my_free(atms) ;
00193 }
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 void write_pockets_single_pdb(const char out[], s_pdb *pdb, c_lst_pockets *pockets)
00214 {
00215 node_pocket *nextPocket ;
00216 node_vertice *nextVertice ;
00217 FILE *f = fopen(out, "w") ;
00218 if(f) {
00219 if(pdb) {
00220 if(pdb->latoms) write_pdb_atoms(f, pdb->latoms, pdb->natoms ) ;
00221 }
00222
00223 if(pockets){
00224 pockets->current = pockets->first ;
00225
00226 while(pockets->current){
00227 pockets->current->pocket->v_lst->current = pockets->current->pocket->v_lst->first ;
00228
00229 while(pockets->current->pocket->v_lst->current){
00230 write_pdb_vert(f, pockets->current->pocket->v_lst->current->vertice) ;
00231
00232 nextVertice = pockets->current->pocket->v_lst->current->next;
00233 pockets->current->pocket->v_lst->current = nextVertice;
00234 }
00235
00236 nextPocket=pockets->current->next;
00237 pockets->current=nextPocket;
00238 }
00239 }
00240
00241 fclose(f) ;
00242 }
00243 else {
00244 fprintf(stderr, "! The file %s could not be opened!\n", out);
00245 }
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 void write_pdb_atoms(FILE *f, s_atm *atoms, int natoms)
00264 {
00265 s_atm *atom = NULL ;
00266 int i = 0 ;
00267 for(i = 0 ; i < natoms ; i++) {
00268 atom = atoms + i ;
00269 write_pdb_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
00270 atom->res_name, atom->chain, atom->res_id,
00271 atom->pdb_insert, atom->x, atom->y, atom->z,
00272 atom->occupancy, atom->bfactor, atom->symbol,
00273 atom->charge);
00274 }
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 void write_pockets_single_pqr(const char out[], c_lst_pockets *pockets)
00294 {
00295 node_pocket *nextPocket ;
00296 node_vertice *nextVertice ;
00297
00298 FILE *f = fopen(out, "w") ;
00299 if(f) {
00300
00301 if(pockets){
00302 fprintf(f, "HEADER\n") ;
00303 fprintf(f, "HEADER This is a pqr format file writen by the programm fpocket. \n") ;
00304 fprintf(f, "HEADER It contains all the pockets vertices found by fpocket. \n") ;
00305 pockets->current = pockets->first ;
00306
00307 while(pockets->current){
00308 pockets->current->pocket->v_lst->current = pockets->current->pocket->v_lst->first ;
00309
00310 while(pockets->current->pocket->v_lst->current){
00311 write_pqr_vert(f, pockets->current->pocket->v_lst->current->vertice) ;
00312
00313 nextVertice = pockets->current->pocket->v_lst->current->next;
00314 pockets->current->pocket->v_lst->current = nextVertice;
00315 }
00316
00317 nextPocket=pockets->current->next;
00318 pockets->current=nextPocket;
00319 }
00320 }
00321
00322 fprintf(f, "TER\nEND\n") ;
00323 fclose(f) ;
00324 }
00325 else {
00326 fprintf(stderr, "! The file %s could not be opened!\n", out);
00327 }
00328 }
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 void write_mdpockets_concat_pqr(FILE *f, c_lst_pockets *pockets)
00348 {
00349 node_pocket *nextPocket ;
00350 node_vertice *nextVertice ;
00351
00352 if(f) {
00353
00354 if(pockets){
00355 pockets->current = pockets->first ;
00356
00357 while(pockets->current){
00358 pockets->current->pocket->v_lst->current = pockets->current->pocket->v_lst->first ;
00359
00360 while(pockets->current->pocket->v_lst->current){
00361 write_pqr_vert(f, pockets->current->pocket->v_lst->current->vertice) ;
00362
00363 nextVertice = pockets->current->pocket->v_lst->current->next;
00364 pockets->current->pocket->v_lst->current = nextVertice;
00365 }
00366
00367 nextPocket=pockets->current->next;
00368 pockets->current=nextPocket;
00369 }
00370 }
00371 }
00372 else {
00373 fprintf(stderr, "! The pqr concat output file is not open!\n");
00374 }
00375 }
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 void write_each_pocket(const char out_path[], c_lst_pockets *pockets)
00393 {
00394 int out_len = strlen(out_path) ;
00395 char out[out_len+20] ;
00396 out[0] = '\0' ;
00397
00398 node_pocket *pcur ;
00399
00400 int i = 0 ;
00401 if(pockets){
00402 pcur = pockets->first ;
00403
00404 while(pcur){
00405 sprintf(out, "%s/pocket%d_vert.pqr", out_path, i) ;
00406 write_pocket_pqr(out, pcur->pocket) ;
00407
00408 sprintf(out, "%s/pocket%d_atm.pdb", out_path, i) ;
00409 write_pocket_pdb(out, pcur->pocket) ;
00410
00411 pcur = pcur->next ;
00412 i++ ;
00413 }
00414 }
00415 else {
00416 fprintf(stderr, "! The file %s could not be opened!\n", out);
00417 }
00418 }
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 void write_pocket_pqr(const char out[], s_pocket *pocket)
00436 {
00437 node_vertice *vcur = NULL ;
00438
00439 FILE *f = fopen(out, "w") ;
00440 if(f && pocket) {
00441 fprintf(f, "HEADER\n") ;
00442 fprintf(f, "HEADER This is a pqr format file writen by the programm fpocket. \n") ;
00443 fprintf(f, "HEADER It represent the voronoi vertices of a single pocket found by the \n") ;
00444 fprintf(f, "HEADER algorithm. \n") ;
00445 fprintf(f, "HEADER \n") ;
00446 fprintf(f, "HEADER Information about the pocket %5d:\n", pocket->v_lst->first->vertice->resid) ;
00447 fprintf(f, "HEADER 0 - Pocket Score : %.4f\n", pocket->score) ;
00448 fprintf(f, "HEADER 1 - Drug Score : %.4f\n", pocket->pdesc->drug_score) ;
00449 fprintf(f, "HEADER 2 - Number of V. Vertices : %5d\n", pocket->pdesc->nb_asph) ;
00450 fprintf(f, "HEADER 3 - Mean alpha-sphere radius : %.4f\n", pocket->pdesc->mean_asph_ray) ;
00451 fprintf(f, "HEADER 4 - Mean alpha-sphere SA : %.4f\n", pocket->pdesc->masph_sacc) ;
00452 fprintf(f, "HEADER 5 - Mean B-factor : %.4f\n", pocket->pdesc->flex) ;
00453 fprintf(f, "HEADER 6 - Hydrophobicity Score : %.4f\n", pocket->pdesc->hydrophobicity_score) ;
00454 fprintf(f, "HEADER 7 - Polarity Score : %5d\n", pocket->pdesc->polarity_score) ;
00455 fprintf(f, "HEADER 8 - Volume Score : %.4f\n", pocket->pdesc->volume_score) ;
00456 fprintf(f, "HEADER 9 - Real volume (approximation) : %.4f\n", pocket->pdesc->volume) ;
00457 fprintf(f, "HEADER 10 - Charge Score : %5d\n", pocket->pdesc->charge_score) ;
00458 fprintf(f, "HEADER 11 - Local hydrophobic density Score : %.4f\n", pocket->pdesc->mean_loc_hyd_dens) ;
00459 fprintf(f, "HEADER 12 - Number of apolar alpha sphere : %5d\n", pocket->nAlphaApol) ;
00460 fprintf(f, "HEADER 13 - Proportion of apolar alpha sphere : %.4f\n", pocket->pdesc->apolar_asphere_prop) ;
00461
00462 vcur = pocket->v_lst->first ;
00463
00464 while(vcur){
00465 write_pqr_vert(f, vcur->vertice) ;
00466
00467 vcur = vcur->next ;
00468 }
00469
00470 fprintf(f, "TER\nEND\n") ;
00471 fclose(f) ;
00472 }
00473 else {
00474 if(!f) fprintf(stderr, "! The file %s could not be opened!\n", out);
00475 else fprintf(stderr, "! Invalid pocket to write in write_pocket_pqr !\n");
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495 void write_pocket_pdb(const char out[], s_pocket *pocket)
00496 {
00497 node_vertice *vcur = NULL ;
00498 int i = 0 ;
00499 int cur_size = 0,
00500 cur_allocated = 10 ;
00501
00502 s_atm **atms = (s_atm**)my_malloc(sizeof(s_atm*)*10) ;
00503 s_atm *atom = NULL ;
00504
00505 FILE *f = fopen(out, "w") ;
00506 if(f && pocket) {
00507
00508 fprintf(f, "HEADER\n") ;
00509 fprintf(f, "HEADER This is a pdb format file writen by the programm fpocket. \n") ;
00510 fprintf(f, "HEADER It represents the atoms contacted by the voronoi vertices of the pocket. \n") ;
00511 fprintf(f, "HEADER \n") ;
00512 fprintf(f, "HEADER Information about the pocket %5d:\n", pocket->v_lst->first->vertice->resid) ;
00513 fprintf(f, "HEADER 0 - Pocket Score : %.4f\n", pocket->score) ;
00514 fprintf(f, "HEADER 1 - Drug Score : %.4f\n", pocket->pdesc->drug_score) ;
00515 fprintf(f, "HEADER 2 - Number of V. Vertices : %5d\n", pocket->pdesc->nb_asph) ;
00516 fprintf(f, "HEADER 3 - Mean alpha-sphere radius : %.4f\n", pocket->pdesc->mean_asph_ray) ;
00517 fprintf(f, "HEADER 4 - Mean alpha-sphere SA : %.4f\n", pocket->pdesc->masph_sacc) ;
00518 fprintf(f, "HEADER 5 - Mean B-factor : %.4f\n", pocket->pdesc->flex) ;
00519 fprintf(f, "HEADER 6 - Hydrophobicity Score : %.4f\n", pocket->pdesc->hydrophobicity_score) ;
00520 fprintf(f, "HEADER 7 - Polarity Score : %5d\n", pocket->pdesc->polarity_score) ;
00521 fprintf(f, "HEADER 8 - Volume Score : %.4f\n", pocket->pdesc->volume_score) ;
00522 fprintf(f, "HEADER 9 - Real volume (approximation) : %.4f\n", pocket->pdesc->volume) ;
00523 fprintf(f, "HEADER 10 - Charge Score : %5d\n", pocket->pdesc->charge_score) ;
00524 fprintf(f, "HEADER 11 - Local hydrophobic density Score : %.4f\n", pocket->pdesc->mean_loc_hyd_dens) ;
00525 fprintf(f, "HEADER 12 - Number of apolar alpha sphere : %5d\n", pocket->nAlphaApol) ;
00526 fprintf(f, "HEADER 13 - Proportion of apolar alpha sphere : %.4f\n", pocket->pdesc->apolar_asphere_prop) ;
00527
00528
00529 vcur = pocket->v_lst->first ;
00530
00531 while(vcur){
00532 for(i = 0 ; i < 4 ; i++) {
00533 if(!is_in_lst_atm(atms, cur_size, vcur->vertice->neigh[i]->id)) {
00534 if(cur_size >= cur_allocated-1) {
00535 cur_allocated *= 2 ;
00536 atms = (s_atm**)my_realloc(atms, sizeof(s_atm)*cur_allocated) ;
00537 }
00538 atms[cur_size] = vcur->vertice->neigh[i] ;
00539 cur_size ++ ;
00540 }
00541
00542 }
00543 vcur = vcur->next ;
00544 }
00545
00546
00547
00548 for(i = 0 ; i < cur_size ; i++) {
00549 atom = atms[i] ;
00550
00551 write_pdb_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
00552 atom->res_name, atom->chain, atom->res_id,
00553 atom->pdb_insert, atom->x, atom->y, atom->z,
00554 atom->occupancy, atom->bfactor, atom->symbol,
00555 atom->charge);
00556 }
00557
00558 fprintf(f, "TER\nEND\n") ;
00559 fclose(f) ;
00560 }
00561 else {
00562 if(!f) fprintf(stderr, "! The file %s could not be opened!\n", out);
00563 else fprintf(stderr, "! Invalid pocket to write in write_pocket_pqr !\n");
00564 }
00565
00566 my_free(atms) ;
00567 }