pocket.h File Reference

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "voronoi_lst.h"
#include "pscoring.h"
#include "fparams.h"
#include "aa.h"
#include "utils.h"
#include "memhandler.h"

Go to the source code of this file.

Data Structures

struct  s_pocket
struct  node_pocket
struct  c_lst_pockets

Defines

#define MAX_CON_DIST   2.5
#define M_LIG_IN_POCKET_DIST   4.0

Functions

c_lst_pocketsclusterPockets (s_lst_vvertice *lvvert, s_fparams *params)
int updateIds (s_lst_vvertice *lvvert, int i, int *vNb, int resid, int curPocket, c_lst_pockets *pockets, s_fparams *params)
void addStats (int resid, int size, int **stats, int *lenStats)
void set_pockets_descriptors (c_lst_pockets *pockets, s_pdb *pdb, s_fparams *params, s_pdb *pdb_w_lig)
void set_normalized_descriptors (c_lst_pockets *pockets)
void set_pockets_bary (c_lst_pockets *pockets)
s_atm ** get_pocket_contacted_atms (s_pocket *pocket, int *natoms)
int count_pocket_contacted_atms (s_pocket *pocket)
s_vvertice ** get_pocket_pvertices (s_pocket *pocket)
void set_pocket_contacted_lig_name (s_pocket *pocket, s_pdb *pdb_w_lig)
float set_pocket_mtvolume (s_pocket *pocket, int niter)
float set_pocket_volume (s_pocket *pocket, int discret)
s_pocketalloc_pocket (void)
c_lst_pocketsc_lst_pockets_alloc (void)
node_pocketnode_pocket_alloc (s_pocket *pocket)
void c_lst_pocket_free (c_lst_pockets *lst)
node_pocketc_lst_pockets_add_first (c_lst_pockets *lst, s_pocket *pocket)
node_pocketc_lst_pockets_add_last (c_lst_pockets *lst, s_pocket *pocket, int cur_n_apol, int cur_n_pol)
void swap_pockets (c_lst_pockets *pockets, node_pocket *p1, node_pocket *p2)
void dropPocket (c_lst_pockets *pockets, node_pocket *pocket)
void mergePockets (node_pocket *pocket, node_pocket *pocket2, c_lst_pockets *pockets)
node_pocketsearchPocket (int resid, c_lst_pockets *pockets)
void reset_pocket (s_pocket *pocket)
void print_pocket (FILE *f, s_pocket *pocket)
void print_pockets (FILE *f, c_lst_pockets *pockets)
void print_pockets_inv (FILE *f, c_lst_pockets *pockets)


Define Documentation

#define M_LIG_IN_POCKET_DIST   4.0

maximum distance a ligand atom could have to a pocket barycenter to be considered inside the pocket

Definition at line 41 of file pocket.h.

Referenced by set_pocket_contacted_lig_name().

#define MAX_CON_DIST   2.5

COPYRIGHT DISCLAIMER

Vincent Le Guilloux, Peter Schmidtke and Pierre Tuffery, hereby disclaim all copyright interest in the program “fpocket” (which performs protein cavity detection) written by Vincent Le Guilloux and Peter Schmidtke.

Vincent Le Guilloux 28 November 2008 Peter Schmidtke 28 November 2008 Pierre Tuffery 28 November 2008

GNU GPL

This file is part of the fpocket package.

fpocket is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

fpocket is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with fpocket. If not, see <http://www.gnu.org/licenses/>.

Definition at line 39 of file pocket.h.


Function Documentation

void addStats ( int  resid,
int  size,
int **  stats,
int *  lenStats 
)

s_pocket* alloc_pocket ( void   ) 

================================================================================ ================================================================================

ALLOCATIONS AND DESALLOCATIONS FOR POCKET AND CHAINED LIST OF POCKET

================================================================================ ================================================================================ ## FUNCTION: alloc_pocket

## SPECIFICATION: Alloc memory for a pocket and reste values describing it.

## PARAMETRES:

## RETURN: s_pocket* : pointer to the pocket allocated.

Definition at line 1137 of file pocket.c.

References my_malloc(), s_pocket::pdesc, reset_pocket(), and s_pocket::v_lst.

Referenced by extract_wanted_vertices(), and updateIds().

01138 {
01139         s_pocket *p = (s_pocket*)my_malloc(sizeof(s_pocket)) ;
01140         p->pdesc = (s_desc*)my_malloc(sizeof(s_desc)) ;
01141         p->v_lst = NULL ;
01142 
01143         reset_pocket(p) ;
01144 
01145         return p ;
01146 }

void c_lst_pocket_free ( c_lst_pockets lst  ) 

## FONCTION: c_lst_pocket_free

## SPECIFICATION: Free a pocket list.

## PARAMETRES: @ c_lst_pockets *lst: The list to free.

## RETURN: void

Definition at line 1214 of file pocket.c.

References c_lst_pockets::current, dropPocket(), c_lst_pockets::first, free_vert_lst(), c_lst_pockets::last, my_free(), node_pocket::next, ptr_node::next, and c_lst_pockets::vertices.

Referenced by check_fpocket(), desc_pocket(), get_actual_pocket(), mdpocket_characterize(), mdpocket_detect(), process_pdb(), and test_set().

01215 {
01216         node_pocket *cur = NULL,
01217                                 *next = NULL ;
01218         
01219         if(lst) {
01220                 cur = lst->first ;
01221                 while(cur) {
01222                         next = cur->next ;
01223                         dropPocket(lst, cur) ;
01224                         cur = next ;
01225                 }
01226 
01227                 free_vert_lst(lst->vertices) ;
01228 
01229                 lst->vertices = NULL ;
01230                 lst->first = NULL ;     
01231                 lst->last = NULL ;
01232                 lst->current = NULL ;
01233 
01234                 my_free(lst) ;
01235         }
01236 
01237 }

node_pocket* c_lst_pockets_add_first ( c_lst_pockets lst,
s_pocket pocket 
)

================================================================================ ================================================================================

FUNCTIONS FOR POCKET CHAINED LIST OPERATIONS

================================================================================ ================================================================================ ## FONCTION: c_lst_pockets_add_first

## SPECIFICATION: Add a pocket on the first position of the list

## PARAMETRES: @ c_lst_pocket *lst : chained list of pockets @ s_pocket : pocket to add

## RETURN: node_pocket *: pointer to the new node.

Definition at line 810 of file pocket.c.

References c_lst_pockets::first, c_lst_pockets::n_pockets, node_pocket::next, node_pocket_alloc(), and node_pocket::prev.

00811 {
00812         node_pocket *newn = NULL ;
00813 
00814         if(lst) {
00815                 newn = node_pocket_alloc(pocket) ;
00816                 lst->first->prev = newn ;
00817                 newn->next = lst->first ;
00818 
00819                 lst->first = newn ;
00820                 lst->n_pockets += 1 ;
00821         }
00822         
00823         return newn ;
00824 }

node_pocket* c_lst_pockets_add_last ( c_lst_pockets lst,
s_pocket pocket,
int  cur_n_apol,
int  cur_n_pol 
)

## FONCTION: c_lst_pockets_add_last

## SPECIFICATION: Add a pocket at the end of the chained list

## PARAMETRES: @ c_lst_pocket *lst : chained list of pockets @ s_pocket : pocket to add

## RETURN: node_pocket *: Pointer to the new pocket.

Definition at line 841 of file pocket.c.

References c_lst_pockets::first, c_lst_pockets::last, c_lst_pockets::n_pockets, s_pocket::nAlphaApol, s_pocket::nAlphaPol, node_pocket::next, node_pocket_alloc(), node_pocket::pocket, and node_pocket::prev.

Referenced by mdpocket_characterize(), and updateIds().

00842 {
00843         node_pocket *newn = NULL ;
00844 
00845         if(lst) {
00846                 newn = node_pocket_alloc(pocket) ;
00847                 newn->pocket->nAlphaApol = cur_n_apol;
00848                 newn->pocket->nAlphaPol = cur_n_pol;
00849                 if(lst->last) {
00850                         newn->prev = lst->last ;
00851                         lst->last->next = newn ;
00852                 }
00853                 else {
00854                         lst->first = newn ;
00855 
00856                 }
00857                 lst->last = newn ;
00858                 lst->n_pockets += 1 ;
00859         }
00860 
00861         return newn ;
00862 }

c_lst_pockets* c_lst_pockets_alloc ( void   ) 

## FONCTION: c_lst_pockets_alloc

## SPECIFICATION: Allocate a list of pockets

## PARAMETRES:

## RETURN: c_lst_pockets*

Definition at line 1161 of file pocket.c.

References c_lst_pockets::current, c_lst_pockets::first, c_lst_pockets::last, my_malloc(), c_lst_pockets::n_pockets, and c_lst_pockets::vertices.

Referenced by clusterPockets(), and mdpocket_characterize().

01162 {
01163         c_lst_pockets *lst = (c_lst_pockets *)my_malloc(sizeof(c_lst_pockets)) ;
01164 
01165         lst->first = NULL ;
01166         lst->last = NULL ;
01167         lst->current = NULL ;
01168         lst->n_pockets = 0 ;
01169         lst->vertices = NULL ;
01170 
01171         return lst ;
01172 }

c_lst_pockets* clusterPockets ( s_lst_vvertice lvvert,
s_fparams params 
)

## FUNCTION: clusterPockets

## SPECIFICATION: This function takes in argument a list of vertice, and perform a first clusturing algorithm to merge vertices close from each others. The distance criteria is in the params struct.

## PARAMETRES: @ s_lst_vvertice *lvvert : The list of vertices. @ s_fparams *params : Parameters

## RETURN: list of pockets!

Definition at line 98 of file pocket.c.

References c_lst_pockets_alloc(), c_lst_pockets::first, my_free(), c_lst_pockets::n_pockets, c_lst_vertices::n_vertices, node_pocket::next, s_lst_vvertice::nvert, node_pocket::pocket, s_pocket::size, updateIds(), s_pocket::v_lst, s_lst_vvertice::vertices, and s_vvertice::vneigh.

Referenced by search_pocket().

00099 {
00100         int i = -1,
00101                 j = -1,
00102                 curPocketId=1,
00103                 vNb[4] = {0,0,0,0};
00104 
00105         
00106         s_vvertice *vertices = lvvert->vertices,
00107                            *vcur = NULL ;
00108        
00109 /*
00110         printf("alloc pockets");
00111         print_number_of_objects_in_memory();
00112 */
00113         
00114         c_lst_pockets *pockets = c_lst_pockets_alloc();         
00115 
00116 /*
00117         printf("outside");
00118 */
00119 /*
00120         print_number_of_objects_in_memory();
00121 */
00122 
00123         
00124         for(i=0;i<lvvert->nvert;i++) {
00125                 vcur = vertices + i ;
00126                 for(j=0;j<4;j++) vNb[j] = vcur->vneigh[j];
00127                 curPocketId=updateIds(lvvert,i,vNb,vcur->resid, curPocketId,pockets, params);
00128                 //printf("%d : %d in loop\n",i,get_number_of_objects_in_memory());
00129 
00130         }
00131         
00132 /*
00133         print_number_of_objects_in_memory();
00134 */
00135         
00136 
00137 
00138         node_pocket *p = pockets->first ;
00139         while(p) {
00140                 p->pocket->size = p->pocket->v_lst->n_vertices ;
00141                 p = p->next ;
00142         }
00143 
00144         if(pockets->n_pockets > 0) return pockets ;
00145         else {
00146                 my_free(pockets) ;
00147                 return NULL ;
00148         }
00149 }

int count_pocket_contacted_atms ( s_pocket pocket  ) 

## FUNCTION: count_pocket_contacted_atms

## SPECIFICATION: Count all uniq atoms contacted by the alpha spheres of a given pocket.

## PARAMETRES: @ s_pocket *pocket : The pocket

## RETURN: int: Number of atoms involed in the pocket

Definition at line 1325 of file pocket.c.

References c_lst_vertices::first, s_atm::id, in_tab(), c_lst_vertices::n_vertices, s_vvertice::neigh, node_vertice::next, s_pocket::v_lst, and node_vertice::vertice.

Referenced by check_pockets().

01326 {
01327         if(!pocket || !(pocket->v_lst) || pocket->v_lst->n_vertices <= 0) return -1 ;
01328 
01329         int nb_atoms = 0,
01330                 i = 0 ;
01331 
01332         node_vertice *nvcur = NULL ;
01333         s_vvertice *vcur = NULL ;
01334 
01335         /* Remember atoms already stored. */
01336         int atm_ids[pocket->v_lst->n_vertices * 4] ;
01337 
01338         /* Do the search  */
01339         nvcur = pocket->v_lst->first ;
01340         while(nvcur) {
01341                 vcur = nvcur->vertice ;
01342                 /*printf("ID in the pocket: %d (%.3f %.3f %.3f\n", vcur->id, vcur->x, vcur->y, vcur->z) ;*/
01343                 for(i = 0 ; i < 4 ; i++) {
01344                         if(in_tab(atm_ids,  nb_atoms, vcur->neigh[i]->id) == 0) {
01345                                 atm_ids[nb_atoms] = vcur->neigh[i]->id ;
01346                                 nb_atoms ++ ;
01347                         }
01348                 }
01349                 nvcur = nvcur->next ;
01350         }
01351 
01352         return nb_atoms ;
01353 }

void dropPocket ( c_lst_pockets pockets,
node_pocket pocket 
)

## FONCTION: void dropPocket(c_lst_pockets *pockets,node_pocket *pocket)

## SPECIFICATION: Drop a pocket from the list.

## PARAMETRES: @ c_lst_pockets *lst : The list. @ node_pocket *pocket : The pocket to drop

## RETURN: void

Definition at line 1016 of file pocket.c.

References c_lst_vertices_free(), c_lst_pockets::first, c_lst_pockets::last, my_free(), c_lst_pockets::n_pockets, node_pocket::next, s_pocket::pdesc, node_pocket::pocket, node_pocket::prev, and s_pocket::v_lst.

Referenced by c_lst_pocket_free(), drop_tiny(), and dropSmallNpolarPockets().

01017 {
01018         
01019         if(pocket->prev && pocket->next){
01020                 pocket->prev->next = pocket->next;
01021                 pocket->next->prev = pocket->prev;
01022         }
01023         else if(pocket->next){
01024                 pocket->next->prev = NULL;
01025                 pockets->first = pocket->next;
01026         }
01027         else if(pocket->prev){
01028                 pocket->prev->next = NULL;
01029                 pockets->last = pocket->prev;
01030         }
01031         c_lst_vertices_free(pocket->pocket->v_lst);
01032         pocket->next = NULL ;
01033         pocket->prev = NULL ;
01034         pockets->n_pockets -= 1;
01035         my_free(pocket->pocket->pdesc);
01036         pocket->pocket->pdesc = NULL ;
01037         my_free(pocket->pocket);
01038         pocket->pocket= NULL;
01039 
01040         my_free(pocket);
01041 
01042         if(pockets->n_pockets == 0) pockets->first = NULL ;
01043 }

s_atm** get_pocket_contacted_atms ( s_pocket pocket,
int *  natoms 
)

================================================================================ ================================================================================

OTHER FUNCTIONS (contacted atoms, print...)

================================================================================ ================================================================================ ## FUNCTION: get_pocket_contacted_atms

## SPECIFICATION: Get all atoms contacted by the alpha spheres of a given pocket.

## PARAMETRES: @ s_pocket *pocket : The pocket @ int *natoms : OUTPUT Number of atoms found (modified)

## RETURN: s_atm** Modify the value of natoms, and return an array of pointer to atoms.

Definition at line 1269 of file pocket.c.

References c_lst_vertices::first, s_atm::id, in_tab(), my_malloc(), my_realloc(), c_lst_vertices::n_vertices, s_vvertice::neigh, node_vertice::next, s_pocket::v_lst, and node_vertice::vertice.

Referenced by check_pockets(), mdpocket_characterize(), and set_pockets_descriptors().

01270 {
01271         int actual_size = 10,
01272                 nb_atoms = 0,
01273                 i = 0 ;
01274         
01275         node_vertice *nvcur = NULL ;
01276         s_vvertice *vcur = NULL ;
01277 
01278         s_atm **catoms = NULL ;
01279         
01280         if(pocket && pocket->v_lst && pocket->v_lst->n_vertices > 0) {
01281         /* Remember atoms already stored. */
01282                 int atm_ids[pocket->v_lst->n_vertices * 4] ;
01283 
01284         /* Do the search  */
01285                 catoms = (s_atm **)my_malloc(actual_size*sizeof(s_atm*)) ;
01286                 nvcur = pocket->v_lst->first ;
01287                 while(nvcur) {
01288                         vcur = nvcur->vertice ;
01289                         /*printf("ID in the pocket: %d (%.3f %.3f %.3f\n", vcur->id, vcur->x, vcur->y, vcur->z) ;*/
01290                         for(i = 0 ; i < 4 ; i++) {
01291                                 if(in_tab(atm_ids,  nb_atoms, vcur->neigh[i]->id) == 0) {
01292                                         if(nb_atoms >= actual_size) {
01293                                                 catoms = (s_atm **)my_realloc(catoms, (actual_size+10)*sizeof(s_atm**)) ;
01294                                                 actual_size += 10 ;
01295                                         }
01296         
01297                                         atm_ids[nb_atoms] = vcur->neigh[i]->id ;
01298                                         catoms[nb_atoms] = vcur->neigh[i] ;
01299                                         nb_atoms ++ ;
01300                                 }
01301                         }
01302                         nvcur = nvcur->next ;
01303                 }
01304         }
01305 
01306         *natoms = nb_atoms ;
01307         
01308         return catoms ;
01309 }

s_vvertice** get_pocket_pvertices ( s_pocket pocket  ) 

## FUNCTION: get_pocket_contacted_atms

## SPECIFICATION: Get pocket vertices under the form of an array of pointer.

## PARAMETRES: @ s_pocket *pocket : The pocket

## RETURN: s_vvertice**: All pointers to vertices

Definition at line 1369 of file pocket.c.

References c_lst_vertices::first, my_calloc(), node_vertice::next, s_pocket::size, s_pocket::v_lst, and node_vertice::vertice.

Referenced by check_pockets(), desc_pocket(), and extract_wanted_vertices().

01370 {
01371         s_vvertice **pverts = my_calloc(pocket->size, sizeof(s_vvertice*)) ;
01372         int i = 0 ;
01373         node_vertice *nvcur = pocket->v_lst->first ;
01374         while(nvcur) {
01375                 pverts[i] = nvcur->vertice ;
01376                 nvcur = nvcur->next ;
01377                 i++ ;
01378         }
01379 
01380         return pverts ;
01381 }

void mergePockets ( node_pocket pocket,
node_pocket pocket2,
c_lst_pockets pockets 
)

## FUNCTION: mergePockets

## SPECIFICATION: Merge two pockets.

## PARAMETRES: @ node_pocket *pocket: The first pocket @ node_pocket *pocket2: The second pocket @ c_lst_pockets *pockets: The list of pockets

## RETURN: void

Definition at line 1061 of file pocket.c.

References c_lst_pockets::current, c_lst_pockets::first, c_lst_pockets::last, c_lst_vertices::last, my_free(), c_lst_pockets::n_pockets, c_lst_vertices::n_vertices, s_pocket::nAlphaApol, s_pocket::nAlphaPol, node_pocket::next, node_vertice::next, s_pocket::pdesc, node_pocket::pocket, node_pocket::prev, s_pocket::size, and s_pocket::v_lst.

Referenced by pck_final_clust(), pck_ml_clust(), pck_ml_clust_test(), refinePockets(), and updateIds().

01062 {
01063         s_pocket *pock =  pocket->pocket,
01064                          *pock2 = pocket2->pocket ;
01065 
01066         pockets->current=pocket2;
01067         pock->nAlphaApol += pock2->nAlphaApol;
01068         pock->nAlphaPol += pock2->nAlphaPol;
01069         pock->v_lst->n_vertices += pock2->v_lst->n_vertices;
01070         pock->size = pock->v_lst->n_vertices ;
01071 
01072         pock->v_lst->last->next = pock2->v_lst->first;
01073         pock->v_lst->last = pock2->v_lst->last;
01074 
01075         my_free(pocket2->pocket->v_lst);
01076         pocket2->pocket->v_lst = NULL;
01077         my_free(pocket2->pocket->pdesc);
01078         my_free(pocket2->pocket);
01079         pocket2->pocket=NULL;
01080         
01081         if(pocket2->prev && pocket2->next){
01082                 pocket2->prev->next = pocket2->next;
01083                 pocket2->next->prev = pocket2->prev;
01084         }
01085         else if(pocket2->next){
01086                 pockets->first=pocket2->next;
01087                 pocket2->next->prev=NULL;
01088         }
01089         else if(pocket2->prev){
01090                 pocket2->prev->next=NULL;
01091                 pockets->last=pocket2->prev;
01092         }
01093         else if(!pocket2->prev && !pocket2->next) my_free(pocket2);
01094 
01095         pockets->n_pockets-=1;
01096 
01097         
01098         
01099         my_free(pocket2);
01100 /*
01101 if(pocket2==0x80e8358){
01102             printf("%p\n",pocket2);
01103 
01104             c_lst_pocket_free(pockets);
01105             print_number_of_objects_in_memory();
01106             exit(0);
01107         }
01108 */
01109         
01110 
01111 
01112 }

node_pocket* node_pocket_alloc ( s_pocket pocket  ) 

## FONCTION: node_pocket_alloc

## SPECIFICATION: Allocate memory for one pocket node

## PARAMETRES: @ s_pocket *pocket : pointer to the pocket

## RETURN: node_pocket*

Definition at line 1188 of file pocket.c.

References my_malloc(), node_pocket::next, node_pocket::pocket, and node_pocket::prev.

Referenced by c_lst_pockets_add_first(), and c_lst_pockets_add_last().

01189 {
01190         node_pocket *n_pocket = (node_pocket*)my_malloc(sizeof(node_pocket)) ;
01191 
01192         n_pocket->next = NULL ;
01193         n_pocket->prev = NULL ;
01194         n_pocket->pocket = pocket ;
01195         
01196         return n_pocket ;
01197 }

void print_pocket ( FILE *  f,
s_pocket pocket 
)

## FUNCTION: void print_pocket(FILE *f, s_pocket *pocket)

## SPECIFICATION: Print one pocket info in the given buffer

## PARAMETRES: @ FILE *f : File to print in @ s_pocket *pocket : Pocket to print

## RETURN: void

Definition at line 1490 of file pocket.c.

References s_desc::aa_compo, s_desc::charge_score, c_lst_vertices::first, s_desc::flex, s_desc::hydrophobicity_score, M_NB_AA, s_desc::masph_sacc, s_desc::mean_asph_ray, s_desc::mean_loc_hyd_dens, s_pocket::nAlphaApol, s_desc::nb_asph, s_pocket::ovlp, s_pocket::pdesc, s_desc::polarity_score, s_vvertice::resid, s_pocket::score, s_pocket::v_lst, node_vertice::vertice, s_pocket::vol_corresp, s_desc::volume, and s_desc::volume_score.

Referenced by print_pockets(), and print_pockets_inv().

01491 {
01492         if(pocket) {
01493                 fprintf(f, "\n## POCKET %d ##\n",pocket->v_lst->first->vertice->resid);
01494                 
01495                 if(pocket->ovlp > -1.0) fprintf(f, "\t Correspondance: %f\n", pocket->ovlp) ;
01496                 if(pocket->vol_corresp > -1.0) fprintf(f, "\t Volume Correspondance: %f\n", pocket->vol_corresp) ;
01497                 fprintf(f, "\t 0  - Pocket Score:                %.4f\n", pocket->score) ;
01498                 fprintf(f, "\t 1  - Number of Voronoi vertices:  %d\n", pocket->pdesc->nb_asph) ;
01499                 fprintf(f, "\t 2  - Mean alpha-sphere radius:    %f\n", pocket->pdesc->mean_asph_ray) ;
01500                 fprintf(f, "\t 3  - Mean alpha-sphere solvent accessibility: %f\n", pocket->pdesc->masph_sacc) ;
01501                 fprintf(f, "\t 4  - Flexibility:                 %f\n", pocket->pdesc->flex) ;
01502                 fprintf(f, "\t 5  - Hydrophobicity Score:        %f\n", pocket->pdesc->hydrophobicity_score) ;
01503                 fprintf(f, "\t 6  - Polarity Score:              %d\n", pocket->pdesc->polarity_score) ;
01504                 fprintf(f, "\t 7  - Volume Score:                %f\n", pocket->pdesc->volume_score) ;
01505                 fprintf(f, "\t 8  - Real volume (approximation): %f\n", pocket->pdesc->volume) ;
01506                 fprintf(f, "\t 9  - Charge Score:                %d\n", pocket->pdesc->charge_score) ;
01507                 fprintf(f, "\t 10 - Local hydrophobic density Score: %f\n", pocket->pdesc->mean_loc_hyd_dens) ;
01508                 fprintf(f, "\t 11 - Number of apolar alpha sphere: %d\n", pocket->nAlphaApol) ;
01509                 fprintf(f, "\t 12 - Amino acid composition:\n") ;
01510                 int i ;
01511                 fprintf(f, "\t 12 - ") ;
01512                 for(i = 0 ; i < M_NB_AA ; i++) fprintf(f, "%3d ", pocket->pdesc->aa_compo[i]) ;
01513                 fprintf(f, "\n") ;
01514         }
01515 }

void print_pockets ( FILE *  f,
c_lst_pockets pockets 
)

## FUNCTION: print_pockets

## SPECIFICATION: Print pockets info in the given buffer

## PARAMETRES: @ FILE *f : File to print in @ c_lst_pockets *pockets : All pockets

## RETURN: void

Definition at line 1428 of file pocket.c.

References c_lst_pockets::first, node_pocket::next, node_pocket::pocket, and print_pocket().

01429 {
01430         node_pocket *cur = pockets->first ;
01431         if(pockets) {
01432                 fprintf(f, "\n## FPOCKET RESULTS ##\n");
01433                 cur = pockets->first;
01434                 while(cur) {
01435                         print_pocket(f, cur->pocket) ;
01436                         cur = cur->next ;
01437                 }
01438         }
01439         else {
01440                 fprintf(f, "\n## NO POCKETS IN THE LIST ##\n");
01441         }
01442 }

void print_pockets_inv ( FILE *  f,
c_lst_pockets pockets 
)

## FUNCTION: print_pockets_inv

## SPECIFICATION: Print pockets info in the given buffer, starting with the last pocket of the chained list.

## PARAMETRES: @ FILE *f : File to print in @ c_lst_pockets *pockets: Pockets to print

## RETURN: void

Definition at line 1460 of file pocket.c.

References c_lst_pockets::last, node_pocket::pocket, node_pocket::prev, and print_pocket().

01461 {
01462         if(pockets) {
01463                 fprintf(f, "\n## POCKET ##\n");
01464                 node_pocket *cur = pockets->last ;
01465                 while(cur) {
01466                         print_pocket(f, cur->pocket) ;
01467                         cur = cur->prev ;
01468                 }
01469         }
01470         else {
01471                 fprintf(f, "\n## NO POCKETS IN THE LIST ##\n");
01472         }
01473 }

void reset_pocket ( s_pocket pocket  ) 

## FUNCTION: reset_pocket

## SPECIFICATION: Reset pocket descriptors

## PARAMETRES: @ s_pocket *pocket: The pocket.

## RETURN: void

Definition at line 1398 of file pocket.c.

References s_pocket::nAlphaApol, s_pocket::nAlphaPol, s_pocket::ovlp, s_pocket::ovlp2, s_pocket::pdesc, s_pocket::rank, reset_desc(), s_pocket::score, and s_pocket::vol_corresp.

Referenced by alloc_pocket().

01399 {
01400         pocket->rank = -1 ;
01401 
01402         pocket->score = 0.0 ;
01403         pocket->ovlp = -2.0 ;
01404         pocket->ovlp2 = -2.0 ;
01405         pocket->vol_corresp = -2.0 ;
01406 
01407         pocket->nAlphaPol = 0 ;
01408         pocket->nAlphaApol = 0 ;
01409 
01410         reset_desc(pocket->pdesc) ;
01411 }

node_pocket* searchPocket ( int  resid,
c_lst_pockets lst 
)

## FUNCTION: searchPocket

## SPECIFICATION: Search a pocket

## PARAMETRES: @ int resid : ID of the pocket @ c_lst_pockets *lst : The list of pockets

## RETURN: node_pocket *: pointer to the pocket found.

Definition at line 972 of file pocket.c.

References c_lst_vertices::first, c_lst_pockets::first, node_pocket::next, node_pocket::pocket, s_vvertice::resid, s_pocket::v_lst, and node_vertice::vertice.

Referenced by updateIds().

00973 {
00974         node_pocket *cur = NULL ;
00975         
00976         if(lst) {
00977                 cur = lst->first ;
00978                 while(cur && cur->pocket->v_lst->first->vertice->resid != resid) {
00979                         cur = cur->next ;
00980         }
00981         }
00982 
00983         return cur;
00984 }

void set_normalized_descriptors ( c_lst_pockets pockets  ) 

## FUNCTION: set_normalized_descriptors

## SPECIFICATION: Perform normalisation for some descriptors, so that the maximum value of a given descriptor become 1 and the minimum value 0. This way, each descriptor is normalized and take into account relative differences between pockets. To do so, we use the simple formula: Dnorm = (D - Dmin) / (Dmax - Dmin) with Dmin (resp. dmax) being the minimum (resp. maximum) value of the descriptor D observed in all detected pockets.

WARNING: It is assumed that basic descriptors have been normalized before calling this function!

## PARAMETRES: @ c_lst_pockets *pockets : The list of pockets

## RETURN: void: s_desc is filled

Definition at line 668 of file pocket.c.

References s_desc::apolar_asphere_prop, s_desc::as_density, s_desc::as_density_norm, s_desc::as_max_dst, s_desc::as_max_dst_norm, c_lst_pockets::first, s_desc::flex, s_desc::mean_loc_hyd_dens, s_desc::mean_loc_hyd_dens_norm, c_lst_pockets::n_pockets, s_desc::nas_norm, s_desc::nb_asph, node_pocket::next, s_pocket::pdesc, node_pocket::pocket, s_desc::polarity_score, s_desc::polarity_score_norm, and s_desc::prop_asapol_norm.

Referenced by set_pockets_descriptors().

00669 {
00670         
00671         if(!pockets || pockets->n_pockets <= 0) return ;
00672 
00673         node_pocket *cur = NULL ;
00674         s_desc *dcur = NULL ;
00675 
00676         /* Some boundaries to help normalisation */
00677         float flex_M = 0.0, flex_m = 1.0,
00678                   nas_apolp_M = 0.0, nas_apolp_m = 1.0,
00679                   density_M = 0.0, density_m = 100.0,
00680                   mlhd_M = 0.0, mlhd_m = 1000.0,
00681                   as_max_dst_M = 0.0, as_max_dst_m = 1000.0 ;
00682 
00683         int nas_M = 0, nas_m = 1000,
00684                 polarity_M = -1, polarity_m = 10000 ;
00685 
00686         cur = pockets->first ;
00687         /* Perform a first processing step, to set min and max for example */
00688         while(cur) {
00689                 dcur = cur->pocket->pdesc ;
00690                 /* Initialize boundaries if it's the first turn */
00691                 if(cur == pockets->first) {
00692                         as_max_dst_M = as_max_dst_m = dcur->as_max_dst ;
00693                         density_M = density_m = dcur->as_density ;
00694                         polarity_M = polarity_m = dcur->polarity_score ;
00695                         flex_M = flex_m = dcur->flex ;
00696                         nas_apolp_M = nas_apolp_m = dcur->apolar_asphere_prop ;
00697                         mlhd_M = mlhd_m = dcur->mean_loc_hyd_dens ;
00698                         nas_M = nas_m = dcur->nb_asph ;
00699                 }
00700                 else {
00701                 /* Update several boundaries */
00702                         if(dcur->as_max_dst > as_max_dst_M)
00703                                 as_max_dst_M = dcur->as_max_dst ;
00704                         else if(dcur->as_max_dst < as_max_dst_m)
00705                                 as_max_dst_m = dcur->as_max_dst ;
00706 
00707                         if(dcur->as_density > density_M)
00708                                 density_M = dcur->as_density ;
00709                         else if(dcur->as_density < density_m)
00710                                 density_m = dcur->as_density ;
00711 
00712                         if(dcur->polarity_score > polarity_M)
00713                                 polarity_M = dcur->polarity_score ;
00714                         else if(dcur->polarity_score < polarity_m)
00715                                 polarity_m = dcur->polarity_score ;
00716 
00717                         if(dcur->mean_loc_hyd_dens > mlhd_M)
00718                                 mlhd_M =dcur->mean_loc_hyd_dens ;
00719                         else if(dcur->mean_loc_hyd_dens < mlhd_m)
00720                                 mlhd_m =dcur->mean_loc_hyd_dens ;
00721 
00722                         if(dcur->flex > flex_M) flex_M = dcur->flex ;
00723                         else if(dcur->flex < flex_m) flex_m = dcur->flex ;
00724 
00725                         if(dcur->nb_asph > nas_M) nas_M = dcur->nb_asph ;
00726                         else if(dcur->nb_asph < nas_m) nas_m = dcur->nb_asph ;
00727 
00728                         if(dcur->apolar_asphere_prop > nas_apolp_M)
00729                                 nas_apolp_M = dcur->apolar_asphere_prop ;
00730                         else if(dcur->apolar_asphere_prop < nas_apolp_m)
00731                                 nas_apolp_m = dcur->apolar_asphere_prop;
00732                 }
00733 
00734                 cur = cur->next ;
00735         }
00736 
00737         /* Perform a second loop to do the actual normalisation */
00738         cur = pockets->first ;
00739         if(pockets->n_pockets> 1){
00740             while(cur) {
00741                     dcur = cur->pocket->pdesc ;
00742                     /* Calculate normalized descriptors */
00743                     if(as_max_dst_M - as_max_dst_m!=0.0){
00744                         dcur->as_max_dst_norm =
00745                                 (dcur->as_max_dst - as_max_dst_m) / (as_max_dst_M - as_max_dst_m) ;
00746                     }
00747                     if(density_M - density_m!=0.0){
00748                         dcur->as_density_norm =
00749                                 (dcur->as_density - density_m) / (density_M - density_m) ;
00750                     }
00751                     if(polarity_M - polarity_m!=0.0){
00752                         dcur->polarity_score_norm =
00753                                 (float)(dcur->polarity_score - polarity_m) /
00754                                 (float)(polarity_M - polarity_m) ;
00755                     }
00756                     if(mlhd_M - mlhd_m!=0.0){
00757                         dcur->mean_loc_hyd_dens_norm =
00758                                 (dcur->mean_loc_hyd_dens - mlhd_m) / (mlhd_M - mlhd_m) ;
00759                     }
00760                     if(flex_M - flex_m!=0.0) dcur->flex = (dcur->flex - flex_m) / (flex_M - flex_m) ;
00761                     if(nas_M - nas_m!=0.0) dcur->nas_norm = (float) (dcur->nb_asph - nas_m) /
00762                                                                     (float) (nas_M - nas_m) ;
00763                     if(nas_apolp_M - nas_apolp_m!=0.0){
00764                         dcur->prop_asapol_norm =
00765                             (dcur->apolar_asphere_prop - nas_apolp_m)
00766                             / (nas_apolp_M - nas_apolp_m);
00767                     }
00768 
00769                     cur = cur->next ;
00770             }
00771         }
00772         else {
00773             dcur = cur->pocket->pdesc ;
00774             dcur->polarity_score_norm=0.0;
00775             dcur->as_density_norm=0.0;
00776             dcur->as_max_dst_norm=0.0;
00777             dcur->mean_loc_hyd_dens_norm=0.0;
00778             dcur->flex=0.0;
00779             dcur->nas_norm=0.0;
00780             dcur->prop_asapol_norm=0.0;
00781         }
00782 }

void set_pocket_contacted_lig_name ( s_pocket pocket,
s_pdb pdb_w_lig 
)

Definition at line 542 of file pocket.c.

References s_pocket::bary, dist(), element_in_kept_res(), s_pdb::lhetatm, s_desc::ligTag, M_LIG_IN_POCKET_DIST, s_pdb::nhetatm, s_pocket::pdesc, s_atm::res_name, s_atm::x, s_atm::y, and s_atm::z.

Referenced by set_pockets_descriptors().

00543 {
00544         s_atm *curatom = NULL ;
00545         int natoms=pdb_w_lig->nhetatm;
00546         int i;
00547         s_atm ** atoms=pdb_w_lig->lhetatm;
00548         //printf("rahhhh %d %p\n",pdb_w_lig->nhetatm,pdb_w_lig->lhetatm);
00549         for(i=0;i<natoms;i++){
00550             curatom=atoms[i];
00551             if(pocket) {
00552                 
00553             // Remember atoms already stored.
00554                 if(dist(pocket->bary[0],pocket->bary[1],pocket->bary[2],curatom->x,curatom->y,curatom->z) < M_LIG_IN_POCKET_DIST && !element_in_kept_res(curatom->res_name)) {
00555                     strncpy(pocket->pdesc->ligTag,curatom->res_name,7);
00556                     pocket->pdesc->ligTag[7]='\0';
00557                     
00558                     return;
00559                 }
00560             }
00561             
00562         }
00563         
00564         strncpy(pocket->pdesc->ligTag,"NULL\0",5);
00565         return ;
00566 }

float set_pocket_mtvolume ( s_pocket pocket,
int  niter 
)

## FUNCTION: set_pocket_mtvolume

## SPECIFICATION: Get an monte carlo approximation of the volume occupied by the pocket given in argument.

## PARAMETRES: @ s_pocket *pocket: Pockets to print @ int niter : Number of monte carlo iteration

## RETURN: float: volume.

Definition at line 320 of file pocket.c.

References c_lst_vertices::first, node_vertice::next, s_pocket::pdesc, rand_uniform(), s_vvertice::ray, s_pocket::v_lst, node_vertice::vertice, s_desc::volume, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

00321 {
00322         int i = 0,
00323                 nb_in = 0,
00324                 nit = 0 ;
00325 
00326         float xmin = 0.0, xmax = 0.0,
00327                   ymin = 0.0, ymax = 0.0,
00328                   zmin = 0.0, zmax = 0.0,
00329                   xtmp = 0.0, ytmp = 0.0, ztmp = 0.0,
00330                   xr = 0.0, yr = 0.0, zr = 0.0,
00331                   vbox = 0.0 ;
00332 
00333         c_lst_vertices *vertices = pocket->v_lst ;
00334         node_vertice *cur = vertices->first ;
00335         s_vvertice *vcur = NULL ;
00336 
00337         /* First, search extrems coordinates */
00338         while(cur) {
00339                 vcur = cur->vertice ;
00340                 
00341                 /* Update min: */
00342                 if(nit == 0) {
00343                         xmin = vcur->x - vcur->ray ; xmax = vcur->x + vcur->ray ;
00344                         ymin = vcur->y - vcur->ray ; ymax = vcur->y + vcur->ray ;
00345                         zmin = vcur->z - vcur->ray ; zmax = vcur->z + vcur->ray ;
00346                 }
00347                 else {
00348                         if(xmin > (xtmp = vcur->x - vcur->ray)) xmin = xtmp ;
00349                         else if(xmax < (xtmp = vcur->x + vcur->ray)) xmax = xtmp ;
00350         
00351                         if(ymin > (ytmp = vcur->y - vcur->ray)) ymin = ytmp ;
00352                         else if(ymax < (ytmp = vcur->y + vcur->ray)) ymax = ytmp ;
00353         
00354                         if(zmin > (ztmp = vcur->z - vcur->ray)) zmin = ztmp ;
00355                         else if(zmax < (ztmp = vcur->z + vcur->ray)) zmax = ztmp ;
00356                 }
00357 
00358                 cur = cur->next ;
00359                 nit++ ;
00360         }
00361 
00362         /* Next calculate the box volume */
00363         vbox = (xmax - xmin)*(ymax - ymin)*(zmax - zmin) ;
00364         
00365         /* Then apply monte carlo approximation of the volume.   */
00366         for(i = 0 ; i < niter ; i++) {
00367                 xr = rand_uniform(xmin, xmax) ;
00368                 yr = rand_uniform(ymin, ymax) ;
00369                 zr = rand_uniform(zmin, zmax) ;
00370                 cur = vertices->first ;
00371                 
00372                 while(cur) {
00373                         vcur = cur->vertice ;
00374                 /* Distance between the center of curent vertice and the random point */
00375                         xtmp = vcur->x - xr ;
00376                         ytmp = vcur->y - yr ;
00377                         ztmp = vcur->z - zr ;
00378 
00379                 /* Compare r^2 and dist(center, random_point)^2  to avoid a call to sqrt() function */
00380                         if((vcur->ray*vcur->ray) > (xtmp*xtmp + ytmp*ytmp + ztmp*ztmp)) {
00381                         /* The point is inside one of the vertice!! */
00382                                 nb_in ++ ; break ;
00383                         }
00384                         cur = cur->next ;
00385                 }
00386         }
00387 
00388         pocket->pdesc->volume = ((float)nb_in)/((float)niter)*vbox ;
00389 
00390         /* Ok lets just return the volume Vpok = Nb_in/Niter*Vbox */
00391         return pocket->pdesc->volume ;
00392 }

float set_pocket_volume ( s_pocket pocket,
int  idiscret 
)

## FUNCTION: set_pocket_volume

## SPECIFICATION: Get an approximation of the volume occupied by the pocket given in argument, using a discretized space.

## PARAMETRES: @ s_pocket *pocket: Pockets to print @ int idiscret : Discretisation: the cube containing all vertices will be divided in idiscret*idiscret*idiscret cubes.

## RETURN: float: volume.

Definition at line 411 of file pocket.c.

References c_lst_vertices::first, node_vertice::next, s_pocket::pdesc, s_vvertice::ray, s_pocket::v_lst, node_vertice::vertice, s_desc::volume, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

00412 {
00413         int niter = 0,
00414                 nb_in = 0,
00415                 nit = 0 ;
00416 
00417         float discret = 1.0/(float)idiscret ;
00418 
00419         float x = 0.0, y = 0.0, z = 0.0,
00420                   xstep = 0.0, ystep = 0.0, zstep = 0.0 ;
00421 
00422         float xmin = 0.0, xmax = 0.0,
00423                   ymin = 0.0, ymax = 0.0,
00424                   zmin = 0.0, zmax = 0.0,
00425                   xtmp = 0.0, ytmp = 0.0, ztmp = 0.0,
00426                   vbox = 0.0 ;
00427 
00428         c_lst_vertices *vertices = pocket->v_lst ;
00429         node_vertice *cur = vertices->first ;
00430         s_vvertice *vcur = NULL ;
00431 
00432         /* First, search extrems coordinates */
00433         while(cur) {
00434                 vcur = cur->vertice ;
00435                 
00436                 /* Update min: */
00437                 if(nit == 0) {
00438                         xmin = vcur->x - vcur->ray ; xmax = vcur->x + vcur->ray ;
00439                         ymin = vcur->y - vcur->ray ; ymax = vcur->y + vcur->ray ;
00440                         zmin = vcur->z - vcur->ray ; zmax = vcur->z + vcur->ray ;
00441                 }
00442                 else {
00443                         if(xmin > (xtmp = vcur->x - vcur->ray)) xmin = xtmp ;
00444                         else if(xmax < (xtmp = vcur->x + vcur->ray)) xmax = xtmp ;
00445         
00446                         if(ymin > (ytmp = vcur->y - vcur->ray)) ymin = ytmp ;
00447                         else if(ymax < (ytmp = vcur->y + vcur->ray)) ymax = ytmp ;
00448         
00449                         if(zmin > (ztmp = vcur->z - vcur->ray)) zmin = ztmp ;
00450                         else if(zmax < (ztmp = vcur->z + vcur->ray)) zmax = ztmp ;
00451                 }
00452 
00453                 cur = cur->next ;
00454                 nit++ ;
00455         }
00456 
00457         /* Next calculate the box volume */
00458         vbox = (xmax - xmin)*(ymax - ymin)*(zmax - zmin) ;
00459 
00460         xstep = discret * (xmax - xmin) ;
00461         ystep = discret * (ymax - ymin) ;
00462         zstep = discret * (zmax - zmin) ;
00463 
00464         /* Then apply monte carlo approximation of the volume.   */
00465         for(x = xmin ; x < xmax ; x += xstep) {
00466                 for(y = ymin ; y < ymax ; y += ystep) { 
00467                         for(z = zmin ; z < zmax ; z += zstep) {
00468                                 cur = vertices->first ;
00469                                 while(cur) {
00470                                         vcur = cur->vertice ;
00471                                         xtmp = vcur->x - x ;
00472                                         ytmp = vcur->y - y ;
00473                                         ztmp = vcur->z - z ;
00474                 
00475                                 /* Compare r^2 and dist(center, random_point)^2 */
00476                                         if((vcur->ray*vcur->ray) > (xtmp*xtmp + ytmp*ytmp + ztmp*ztmp)) {
00477                                         /*the point is inside one of the vertice!! */
00478                                                 nb_in ++ ; break ;
00479                                         }
00480                                         cur = cur->next ;
00481                                 }
00482                                 niter ++ ;
00483                         }
00484                 }
00485         }
00486 
00487         pocket->pdesc->volume = ((float)nb_in)/((float)niter)*vbox ;
00488 
00489         /* Ok lets just return the volume Vpok = Nb_in/Niter*Vbox */
00490         return pocket->pdesc->volume ;
00491 }

void set_pockets_bary ( c_lst_pockets pockets  ) 

## FUNCTION: set_pockets_bary

## SPECIFICATION: Set barycenter of each pockets. Use vertices to do so.

## PARAMETRES: @ c_lst_pockets *pockets: The list of pockets to handle

## RETURN: void

Definition at line 507 of file pocket.c.

References s_pocket::bary, c_lst_vertices::first, c_lst_pockets::first, c_lst_pockets::n_pockets, node_pocket::next, node_vertice::next, node_pocket::pocket, s_pocket::v_lst, node_vertice::vertice, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

Referenced by test_set().

00508 {
00509         node_pocket *cur = NULL ;
00510         s_pocket *pcur = NULL ;
00511 
00512         float xsum, ysum, zsum ;
00513         int n ;
00514 
00515         if(pockets && pockets->n_pockets > 0) {
00516                 cur = pockets->first ;
00517                 while(cur) {
00518                         pcur = cur->pocket ;
00519                 /* Reset values and calculate barycenter */
00520                         xsum = 0.0 ; ysum = 0.0 ; zsum = 0.0 ; 
00521                         n = 0 ;
00522 
00523                         node_vertice *nvcur = pcur->v_lst->first ;
00524                         while(nvcur) {
00525                                 xsum += nvcur->vertice->x ;
00526                                 ysum += nvcur->vertice->y ;
00527                                 zsum += nvcur->vertice->z ;
00528                                 n ++ ;
00529 
00530                                 nvcur = nvcur->next ;
00531                         }
00532 
00533                         pcur->bary[0] = xsum / (float) n ;
00534                         pcur->bary[1] = ysum / (float) n ;
00535                         pcur->bary[2] = zsum / (float) n ;
00536 
00537                         cur = cur->next ;
00538                 }
00539         }
00540 }

void set_pockets_descriptors ( c_lst_pockets pockets,
s_pdb pdb,
s_fparams params,
s_pdb pdb_w_lig 
)

## FUNCTION: set_descriptors

## SPECIFICATION: Set descriptors for a list of pockets.

## PARAMETRES: @ c_lst_pockets *pockets: The list of pockets to handle

## RETURN: void

Definition at line 582 of file pocket.c.

References s_desc::drug_score, drug_score_pocket(), c_lst_vertices::first, c_lst_pockets::first, s_fparams::flag_do_asa_and_volume_calculations, get_pocket_contacted_atms(), my_free(), my_malloc(), c_lst_pockets::n_pockets, c_lst_vertices::n_vertices, s_fparams::nb_mcv_iter, node_pocket::next, node_vertice::next, s_pocket::pdesc, node_pocket::pocket, reset_desc(), s_pocket::score, score_pocket(), set_descriptors(), set_normalized_descriptors(), set_pocket_contacted_lig_name(), s_pocket::v_lst, and node_vertice::vertice.

Referenced by pck_final_clust(), and search_pocket().

00583 {
00584         node_pocket *cur = NULL ;
00585         s_pocket *pcur = NULL ;
00586         int niter=params->nb_mcv_iter;
00587         int natms = 0, i ;
00588         
00589         if(pockets && pockets->n_pockets > 0) {
00590                 cur = pockets->first ;
00591                 /* Perform a first loop to calculate atom and vertice based descriptors */
00592                 while(cur) {
00593                         pcur = cur->pocket ;
00594                         reset_desc(pcur->pdesc);
00595                         /* Get a list of vertices in a tab of pointer */
00596                         s_vvertice **tab_vert = (s_vvertice **)
00597                                                 my_malloc(pcur->v_lst->n_vertices*sizeof(s_vvertice*)) ;
00598                         i = 0 ;
00599                         node_vertice *nvcur = pcur->v_lst->first ;
00600                         
00601 /*
00602                         fprintf(stdout, "A Pocket:\n") ;
00603 */
00604                         while(nvcur) {
00605 /*
00606                                 fprintf(stdout, "Vertice %d: %p %d %f\n", i, nvcur->vertice, nvcur->vertice->id, nvcur->vertice->ray) ;
00607                                 fprintf(stdout, "Atom %s\n", nvcur->vertice->neigh[0]->name) ;
00608 */
00609 
00610                                 tab_vert[i] = nvcur->vertice ;
00611                                 nvcur = nvcur->next ;
00612                                 i++ ;
00613                         }
00614 
00615                         /* Get atoms contacted by vertices, and calculate descriptors */
00616                         s_atm **pocket_atoms = get_pocket_contacted_atms(pcur, &natms) ;
00617                         /*fprintf(stdout,"%s\n",get_pocket_contacted_lig_name(pcur,pdb_w_lig));
00618                         fflush(stdout);*/
00619                         if(pdb_w_lig) set_pocket_contacted_lig_name(pcur,pdb_w_lig);
00620                         
00621                         /* Calculate descriptors*/
00622                         set_descriptors(pocket_atoms, natms, tab_vert,pcur->v_lst->n_vertices, pcur->pdesc,niter,pdb,params->flag_do_asa_and_volume_calculations) ;
00623                         
00624                         my_free(pocket_atoms) ;
00625                         my_free(tab_vert) ;
00626 
00627                         cur = cur->next ;
00628                         
00629                 }
00630 
00631                 /* Set normalized descriptors */
00632                 set_normalized_descriptors(pockets) ;
00633 
00634                 /* Score all pockets */
00635                 cur = pockets->first ;
00636                 while(cur) {
00637                         cur->pocket->score = score_pocket(cur->pocket->pdesc) ;
00638                         cur->pocket->pdesc->drug_score = drug_score_pocket(cur->pocket->pdesc);
00639                         cur = cur->next ;
00640                 }
00641         }
00642 }

void swap_pockets ( c_lst_pockets pockets,
node_pocket p1,
node_pocket p2 
)

## FUNCTION: swap_pockets

## SPECIFICATION: Swap two pockets in the given list (not that easy !!! ;) )

## PARAMETRES: @ c_lst_pockets *pockets : The list of pockets @ const node_pocket *p1 : Pocket 1 @ const node_pocket *p2 : Pocket 2

## RETURN: void

Definition at line 880 of file pocket.c.

References c_lst_pockets::first, c_lst_pockets::last, node_pocket::next, and node_pocket::prev.

Referenced by pock_partition().

00881 {
00882         node_pocket *p1prev = p1->prev,
00883                                 *p1next = p1->next,
00884                                 *p2prev = p2->prev,
00885                                 *p2next = p2->next ;
00886         
00887         if(p1->next == p2) {
00888         /* If p1 is just before p2 (p1 can't be the last one and p2 can't be
00889          * the first one) */
00890                 if(p1->prev) p1->prev->next = p2 ;
00891                 else pockets->first = p2 ; /* P1 is the first of the list */
00892 
00893                 if(p2->next) p2->next->prev = p1 ;
00894                 else pockets->last = p2 ; /* P2 is the last one */
00895 
00896                 p2->next = p1 ;
00897                 p2->prev = p1prev ;
00898                 p1->prev = p2 ;
00899                 p1->next = p2next ;
00900         }
00901         else if(p1->prev == p2) {
00902         /* If p1 is just after p2 (p2 can't be the last one and p1 can't be
00903          * the first one) */
00904                 if(p1->next) p1->next->prev = p2 ;
00905                 else pockets->last = p2 ; /* p1 is the last one */
00906                 
00907                 if(p2->prev) p2->prev->next = p1 ;
00908                 else pockets->first = p1 ;
00909 
00910                 p1->next = p2 ;
00911                 p1->prev = p2prev ;
00912                 p2->prev = p1 ;
00913                 p2->next = p1next;
00914         }
00915         else {
00916         /* If p1 and p2 are far away from each others in the list */
00917         /* Handle p1 */
00918                 if(p1->next) {
00919                 /* If there is a pocket after p1, p1 is not the last one */
00920                         p1->next->prev = p2 ;   /* p2 should be the new prev of p1's next */
00921                         if(p1->prev) p1->prev->next = p2 ;
00922                         else pockets->first = p2 ;
00923                 }
00924                 else {
00925                 /* p1 is the last pocket of the list */
00926                         
00927                         pockets->last = p2 ;
00928                         if(p1->prev) {
00929                                 p1->prev->next = p2 ;
00930                         }
00931                 }
00932 
00933         /* Handle P2 */
00934                 if(p2->next) {
00935                 /* If there is a pocket after p1, p1 is not the last one */
00936                         p2->next->prev = p1 ;   /* p2 should be the new prev of p1's next */
00937                         if(p2->prev) p2->prev->next = p1 ;
00938                         else pockets->first = p1 ;
00939                 }
00940                 else {
00941                 /* p1 is the last pocket of the list */
00942                         if(p2->prev) {
00943                                 p2->prev->next = p1 ;
00944                                 pockets->last = p1 ;
00945                         }
00946                 }
00947 
00948                 p1->next = p2next ;
00949                 p1->prev = p2prev ;
00950 
00951                 p2->next = p1next ;
00952                 p2->prev = p1prev ;
00953                 
00954         }
00955 }

int updateIds ( s_lst_vvertice lvvert,
int  i,
int *  vNb,
int  resid,
int  curPocket,
c_lst_pockets pockets,
s_fparams params 
)

## FUNCTION: updateIds

## SPECIFICATION: Update ids.

## PARAMETRES: @ s_lst_vvertice *lvvert : The list of vertices. @ int i : @ int *vNb : @ int resid : @ int curPocket : @ c_lst_pockets *pockets : The current list of pockets. @ s_fparams *params : Parameters

int

Definition at line 170 of file pocket.c.

References alloc_pocket(), c_lst_pockets_add_last(), c_lst_vertices_add_last(), c_lst_vertices_alloc(), s_fparams::clust_max_dist, dist(), M_APOLAR_AS, mergePockets(), s_pocket::nAlphaApol, s_pocket::nAlphaPol, s_lst_vvertice::nvert, node_pocket::pocket, s_lst_vvertice::qhullSize, s_vvertice::resid, searchPocket(), s_lst_vvertice::tr, s_vvertice::type, s_pocket::v_lst, s_lst_vvertice::vertices, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

Referenced by clusterPockets().

00172 {
00173 /*      s_pocket *curPocket; */
00174         int filteredIdx,j,z;
00175         int groupCreatedFlag=0;
00176         int cur_n_apol=0;
00177         int cur_n_pol=0;
00178 /*
00179         print_number_of_objects_in_memory();
00180 */
00181 
00182         s_vvertice *vertices = lvvert->vertices ;
00183         s_vvertice *vert = &(vertices[i]),
00184                            *fvert = NULL ;
00185 
00186 
00187         for(j=0;j<4;j++) {
00188                 if(vNb[j] < lvvert->qhullSize && vNb[j] > 0) {
00189                         filteredIdx = lvvert->tr[vNb[j]];
00190                         if(filteredIdx!=-1 && filteredIdx < lvvert->nvert){
00191                                 fvert = &(vertices[filteredIdx]) ;
00192 
00193                                 if(dist(vert->x, vert->y, vert->z, fvert->x, fvert->y, fvert->z) <= params->clust_max_dist){
00194                                     
00195                                         groupCreatedFlag=1;
00196                                         /* Add a new pocket */
00197                                         if(resid == -1 && fvert->resid==-1){
00198                                                 resid=++curPocket;
00199                                                 vert->resid=resid;
00200                                                 fvert->resid=curPocket; 
00201                                                 /* Create a new pocket */
00202                                                 s_pocket *pocket = alloc_pocket();                              
00203                                                 pocket->v_lst=c_lst_vertices_alloc();
00204                                                 /* Add vertices to the pocket */
00205                                                 c_lst_vertices_add_last(pocket->v_lst, vert);
00206                                                 c_lst_vertices_add_last(pocket->v_lst, fvert);
00207 
00208                                                 if(vert->type==M_APOLAR_AS) cur_n_apol++;
00209                                                 else cur_n_pol++;
00210 
00211                                                 if(fvert->type==M_APOLAR_AS)cur_n_apol++;
00212                                                 else cur_n_pol++;
00213 
00214                                                 c_lst_pockets_add_last(pockets, pocket,cur_n_apol,cur_n_pol);
00215 
00216                                         }
00217                                         /* Add new vertice to existing pocket */
00218                                         else if(resid!=-1 && fvert->resid==-1)                                          
00219                                         {
00220                                                 fvert->resid=resid;
00221                                                 node_pocket *pocket=searchPocket(resid,pockets);
00222                                                 if(pocket) c_lst_vertices_add_last(pocket->pocket->v_lst, fvert);
00223 
00224                                                 if(fvert->type==M_APOLAR_AS) pocket->pocket->nAlphaApol+=1;
00225                                                 else pocket->pocket->nAlphaPol+=1;
00226 
00227 
00228 
00229                                         }
00230                                         else if(resid==-1 && fvert->resid!=-1) {
00231                                                 vert->resid = fvert->resid;
00232                                                 resid=fvert->resid;
00233                                                 node_pocket *pocket = searchPocket(resid,pockets);
00234                                                 if(pocket) c_lst_vertices_add_last(pocket->pocket->v_lst, vert);
00235                                                 if(vert->type==M_APOLAR_AS) pocket->pocket->nAlphaApol+=1;
00236                                                 else pocket->pocket->nAlphaPol+=1;
00237 
00238                                         }
00239                                         else if((resid!=-1 && fvert->resid!=-1) && (resid!=fvert->resid)) {
00240                                                 node_pocket *pocket=searchPocket(resid,pockets);
00241 
00242                                                 node_pocket *pocket2=searchPocket(fvert->resid,pockets);
00243 
00244                                                 /* Write content of pocket1 into pocket2 */
00245                                                 mergePockets(pocket,pocket2,pockets);
00246 
00247                                                 for(z=0;z<lvvert->nvert;z++){
00248                                                         /* Merge two clusters -> to optimize */
00249                                                         if(vertices[z].resid==resid) vertices[z].resid=fvert->resid;    
00250                                                 }
00251                                                 resid=fvert->resid;
00252                                                 
00253                                         }
00254                                 }
00255                         }
00256                         else {
00257                             
00258                                 if(filteredIdx >= lvvert->nvert) {
00259                                         fprintf(stdout, "INDEX ERROR\n") ;
00260                                 }
00261                         }
00262                 }
00263 /*
00264 
00265                                                         if(i==43){
00266                                                     printf("finished loop %d",j);
00267                                                     c_lst_pocket_free(pockets);
00268                                                     print_number_of_objects_in_memory();
00269                                                     exit(0);
00270                                                 }
00271 */
00272         }
00273 
00274         /* if a pocket was created return the pocket */
00275                 
00276 
00277         if(groupCreatedFlag) return curPocket;
00278 
00279         /* if no vertice neighbours were found, still build a new pocket containing 
00280          * only one vertice */
00281 
00282         cur_n_apol=0;
00283         cur_n_pol=0;
00284         resid=++curPocket;
00285         vert->resid=resid;
00286         s_pocket *pocket=alloc_pocket();                                /* Create a new pocket */
00287         pocket->v_lst=c_lst_vertices_alloc();
00288         c_lst_vertices_add_last(pocket->v_lst, vert);   /* Add vertices to the pocket */
00289         if(vert->type==M_APOLAR_AS) cur_n_apol++;
00290         else cur_n_pol++;
00291         c_lst_pockets_add_last(pockets,pocket,cur_n_apol,cur_n_pol);
00292 
00293         
00294         return curPocket;
00295         
00296 }


Generated on Mon Jun 7 16:44:23 2010 for fpocket by  doxygen 1.5.6