mdpbase.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include "fpocket.h"
#include "fpout.h"
#include "writepocket.h"
#include "tpocket.h"
#include "dparams.h"
#include "descriptors.h"
#include "neighbor.h"
#include "pocket.h"
#include "cluster.h"
#include "refine.h"
#include "aa.h"
#include "utils.h"
#include "mdparams.h"
#include "memhandler.h"

Go to the source code of this file.

Data Structures

struct  s_mdconcat
struct  s_mdgrid
struct  s_min_max_pockets

Defines

#define M_MDP_GRID_RESOLUTION   1.0
#define M_MDP_CUBE_SIDE   2.0
#define M_MDP_WP_ATOM_DIST   4.0
#define M_MDP_ATOM_DENSITY_DIST   2.0
#define M_MIN_G_DENS   20.0

Functions

void store_vertice_positions (s_mdconcat *m, c_lst_pockets *pockets)
s_min_max_pocketsfloat_get_min_max_from_pockets (c_lst_pockets *pockets)
void calculate_md_dens_grid (s_mdgrid *g, c_lst_pockets *pockets, s_mdparams *par)
void update_md_grid (s_mdgrid *g, s_mdgrid *refg, c_lst_pockets *pockets, s_mdparams *par)
void project_grid_on_atoms (s_mdgrid *g, s_pdb *pdb)
s_mdconcatinit_md_concat (void)
void reset_grid (s_mdgrid *g)
s_mdgridinit_md_grid (c_lst_pockets *pockets)
void normalize_grid (s_mdgrid *g, int n)
void alloc_first_md_concat (s_mdconcat *m, size_t n)
void realloc_md_concat (s_mdconcat *m, size_t n)
void free_mdconcat (s_mdconcat *m)


Define Documentation

#define M_MDP_ATOM_DENSITY_DIST   2.0

max distance (for each dimension) for mapping pocket densities to neighbouring atoms

Definition at line 67 of file mdpbase.h.

Referenced by project_grid_on_atoms().

#define M_MDP_CUBE_SIDE   2.0

size of the side of the cube to count vvertices

Definition at line 65 of file mdpbase.h.

Referenced by calculate_md_dens_grid(), extract_wanted_vertices(), init_md_grid(), and update_md_grid().

#define M_MDP_GRID_RESOLUTION   1.0

grid resolution in Angstroems

Definition at line 64 of file mdpbase.h.

Referenced by init_md_grid().

#define M_MDP_WP_ATOM_DIST   4.0

max distance for constructing the atom set of the pocket with voronoi vertices

Definition at line 66 of file mdpbase.h.

Referenced by get_wanted_atom_ids().

#define M_MIN_G_DENS   20.0

minimum density of alpha spheres around a grid point for it to be taken into account for further processing using

Definition at line 68 of file mdpbase.h.


Function Documentation

void alloc_first_md_concat ( s_mdconcat m,
size_t  n 
)

## FUNCTION: alloc_first_md_concat

## SPECIFICATION: Allocate memory for the md concat structure (first snapshot)

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free, @ size_t n: Number of vertices in the snapshot to add to m

## RETURN: void

## FUNCTION: alloc_first_md_concat

## SPECIFICATION: Allocate memory for the md concat structure (first snapshot)

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free, @ size_t n: Number of vertices in the snapshot to add to m

## RETURN: void

Definition at line 490 of file mdpbase.c.

00490                                                     {
00491     size_t z;
00492     m->vertpos = (float **) my_malloc(sizeof (float *) * n);
00493     for (z = 0; z < n; z++) {
00494         m->vertpos[z] = (float *) my_malloc(sizeof (float) *4);
00495         m->vertpos[z][0] = 0.0;
00496         m->vertpos[z][1] = 0.0;
00497         m->vertpos[z][2] = 0.0;
00498         m->vertpos[z][3] = 0.0;
00499     }
00500     m->n_vertpos = n;
00501 }

void calculate_md_dens_grid ( s_mdgrid g,
c_lst_pockets pockets,
s_mdparams par 
)

## FUNCTION: calculate_md_dens_grid

## SPECIFICATION: Do the actual grid calculation (count number of vertices near a grid point) NOT USED ANYMORE ## PARAMETRES: @ s_mdgrid *g: Grid structure @ c_lst_pockets *pockets : Pocket chained list @ s_mdparams *par : Parameters of mdpocket

## RETURN: void

Definition at line 104 of file mdpbase.c.

References s_desc::drug_score, c_lst_vertices::first, c_lst_pockets::first, s_mdparams::flag_scoring, s_mdgrid::gridvalues, M_MDP_CUBE_SIDE, node_pocket::next, node_vertice::next, s_mdgrid::origin, s_pocket::pdesc, node_pocket::pocket, s_mdgrid::resolution, s_pocket::v_lst, node_vertice::vertice, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

Referenced by mdpocket_detect().

00104                                                                                   {
00105     int xidx = 0, yidx = 0, zidx = 0; /*direct indices of the positions in the grid*/
00106     int sxidx, syidx, szidx; /*indices nearby xidx,yidx,zidx that are within M_MDP_CUBE_SIDE of this point*/
00107     int sxi = 0, syi = 0, szi = 0;
00108     float vx, vy, vz;
00109     float incre = 1.0;
00110     node_pocket *cp = NULL;
00111     s_pocket *pocket = NULL;
00112     node_vertice *cnv = NULL;
00113     s_vvertice *cv = NULL;
00114     int s = (int) (((float) M_MDP_CUBE_SIDE / 2.0) / g->resolution); /*possible stepsize (resolution dependent) in the discrete grid*/
00115     /*loop over all known vertices and CALCULATE the grid positions and increment grid values by 1*/
00116     /*important : no distance calculations are done here, thus this routine is very fast*/
00117     cp = pockets->first;
00118     while (cp) { /*loop over pockets*/
00119         pocket = cp->pocket;
00120         cnv = pocket->v_lst->first;
00121         /*if(par->flag_scoring) incre=pocket->score;*/
00122         if (par->flag_scoring) incre = pocket->pdesc->drug_score; /*if we score by drug score, use it as increment here instead of the 1 by default*/
00123         while (cnv) { /*loop over all vertices of a pocket*/
00124             cv = cnv->vertice;
00125             vx = cv->x; /*tmp the vertice position*/
00126             vy = cv->y;
00127             vz = cv->z;
00128             xidx = (int) roundf((vx - g->origin[0]) / g->resolution); /*calculate the nearest grid point internal coordinates*/
00129             yidx = (int) roundf((vy - g->origin[1]) / g->resolution);
00130             zidx = (int) roundf((vz - g->origin[2]) / g->resolution);
00131             /*we use a cube of M_MDP_CUBE_SIDE**3 volume to check if there are grid points nearby,
00132              *thus a check in the neighbourhood is performed here...this looks a bit awful and should be changed later on*/
00133             for (sxi = -s; sxi <= s; sxi++) {
00134                 for (syi = -s; syi <= s; syi++) {
00135                     for (szi = -s; szi <= s; szi++) {
00136                         /*check if we are not on the point xidx,yidx, zidx....the square sum is just a little trick*/
00137                         if ((sxi * sxi + syi * syi + szi * szi) != 0) {
00138                             /*next we have to check in a discrete manner if we can include a new grid point or not.*/
00139                             if (sxi < 0) sxidx = (int) ceil(((float) sxi + vx - g->origin[0]) / g->resolution);
00140                             else if (sxi > 0) sxidx = (int) floor(((float) sxi + vx - g->origin[0]) / g->resolution);
00141                             else if (sxi == 0) sxidx = xidx;
00142                             if (syi < 0) syidx = (int) ceil(((float) syi + vy - g->origin[1]) / g->resolution);
00143                             else if (syi > 0) syidx = (int) floor(((float) syi + vy - g->origin[1]) / g->resolution);
00144                             else if (syi == 0) syidx = yidx;
00145                             if (szi < 0) szidx = (int) ceil(((float) szi + vz - g->origin[2]) / g->resolution);
00146                             else if (szi > 0) szidx = (int) floor(((float) szi + vz - g->origin[2]) / g->resolution);
00147                             else if (szi == 0) szidx = zidx;
00148                             /*double check if we are not on the already incremented grid point*/
00149                             if (((sxidx != xidx) || (syidx != yidx) || (szidx != zidx))
00150                                     && (sxidx >= 0 && syidx >= 0 && szidx >= 0 && sxidx < g->nx && syidx < g->ny && szidx < g->nz)) {
00151                                 g->gridvalues[sxidx][syidx][szidx] += incre;
00152                             } /*added condition if grid value already set, do not update, to better density measurements and match drug score*/
00153                         }
00154                     }
00155                 }
00156             }
00157             cnv = cnv->next;
00158         }
00159 
00160         if (xidx < g->nx && yidx < g->ny && zidx < g->nz && xidx >= 0 && yidx >= 0 && zidx >= 0) {
00161 
00162             g->gridvalues[xidx][yidx][zidx] += incre; /*increment the already known grid point value*/
00163 
00164         } else fprintf(stderr, "\n\nWarning (oh oh!!) : Your structure is not aligned or is moving a lot. Results might not reflect what you expect. Consider first structural alignemnt\nIf your structure is moving a lot, consider to split up analysis in two distinct parts.\n\n");
00165         cp = cp->next;
00166     }
00167 }

s_min_max_pockets* float_get_min_max_from_pockets ( c_lst_pockets pockets  ) 

## FUNCTION: float_get_min_max_from_pockets

## SPECIFICATION: Get the absolute minimum and maximum point from pockets

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

## RETURN: @ s_min_max_pockets : Structure containing the minimum & maximum

Definition at line 397 of file mdpbase.c.

References s_min_max_pockets::maxx, s_min_max_pockets::maxy, s_min_max_pockets::maxz, s_min_max_pockets::minx, s_min_max_pockets::miny, s_min_max_pockets::minz, my_malloc(), s_lst_vvertice::nvert, s_lst_vvertice::vertices, c_lst_pockets::vertices, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

Referenced by init_md_grid().

00397                                                                           {
00398     if (pockets) {
00399         int z;
00400         float minx = 50000., maxx = -50000., miny = 50000., maxy = -50000., minz = 50000., maxz = -50000.;
00401         int n = pockets->vertices->nvert;
00402         /*if there a no vertices in m before, first allocate some space*/
00403         for (z = 0; z < n; z++) { /*loop over all vertices*/
00404             /*store the positions and radius of the vertices*/
00405             if (minx > pockets->vertices->vertices[z].x) minx = pockets->vertices->vertices[z].x;
00406             else if (maxx < pockets->vertices->vertices[z].x)maxx = pockets->vertices->vertices[z].x;
00407             if (miny > pockets->vertices->vertices[z].y) miny = pockets->vertices->vertices[z].y;
00408             else if (maxy < pockets->vertices->vertices[z].y)maxy = pockets->vertices->vertices[z].y;
00409             if (minz > pockets->vertices->vertices[z].z) minz = pockets->vertices->vertices[z].z;
00410             else if (maxz < pockets->vertices->vertices[z].z)maxz = pockets->vertices->vertices[z].z;
00411         }
00412         s_min_max_pockets *r = (s_min_max_pockets *) my_malloc(sizeof (s_min_max_pockets));
00413         r->maxx = maxx;
00414         r->maxy = maxy;
00415         r->maxz = maxz;
00416         r->minx = minx;
00417         r->miny = miny;
00418         r->minz = minz;
00419         return (r);
00420     }
00421     return (NULL);
00422 }

void free_mdconcat ( s_mdconcat m  ) 

## FUNCTION: free_mdconcat

## SPECIFICATION: Free the mdconcat structure

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free

## RETURN: void

## FUNCTION: free_mdconcat

## SPECIFICATION: Free the mdconcat structure

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free

## RETURN: void

Definition at line 545 of file mdpbase.c.

00545                                   {
00546     size_t i;
00547     for (i = 0; i < m->n_vertpos; i++) {
00548         my_free(m->vertpos[i]);
00549     }
00550     my_free(m->vertpos);
00551     my_free(m);
00552 }

s_mdconcat* init_md_concat ( void   ) 

## FUNCTION: init_md_concat

## SPECIFICATION: Initialize the md concat (alloc)

## PARAMETRES: void

## RETURN: s_mdconcat * : the md concat structure

## FUNCTION: init_md_concat

## SPECIFICATION: Allocate memory for the concatenated voronoi vertice structure Currently NOT USED

## PARAMETRES: void

## RETURN: s_mdconcat * : Structure containing allocated memory

Definition at line 374 of file mdpbase.c.

00374                                  {
00375     s_mdconcat *m = (s_mdconcat *) my_malloc(sizeof (s_mdconcat));
00376     m->n_vertpos = 0;
00377     m->vertpos = NULL;
00378     m->n_snapshots = 0;
00379     return m;
00380 }

s_mdgrid* init_md_grid ( c_lst_pockets pockets  ) 

## FUNCTION: init_md_grid

## SPECIFICATION: Initialize the md grid (allocate + 0)

## PARAMETRES: @ s_mdconcat *mdc: Pointer to the mdconcat structure (vertices),

## RETURN: s_mdgrid * : the grid

Definition at line 438 of file mdpbase.c.

References float_get_min_max_from_pockets(), s_mdgrid::gridvalues, M_MDP_CUBE_SIDE, M_MDP_GRID_RESOLUTION, s_min_max_pockets::maxx, s_min_max_pockets::maxy, s_min_max_pockets::maxz, s_min_max_pockets::minx, s_min_max_pockets::miny, s_min_max_pockets::minz, my_free(), my_malloc(), s_mdgrid::nx, s_mdgrid::ny, s_mdgrid::nz, s_mdgrid::origin, and s_mdgrid::resolution.

Referenced by mdpocket_detect().

00438                                                {
00439     s_mdgrid *g = (s_mdgrid *) my_malloc(sizeof (s_mdgrid));
00440     s_min_max_pockets *mm = float_get_min_max_from_pockets(pockets);
00441     float xmax = mm->maxx;
00442     float ymax = mm->maxy;
00443     float zmax = mm->maxz;
00444     float xmin = mm->minx;
00445     float ymin = mm->miny;
00446     float zmin = mm->minz;
00447     float initvalue = 0.0;
00448     my_free(mm);
00449     int cx, cy, cz;
00450     float span = (M_MDP_CUBE_SIDE / 2.0) / M_MDP_GRID_RESOLUTION;
00451     g->resolution = M_MDP_GRID_RESOLUTION;
00452 
00453     g->nx = 1 + (int) (xmax + 30. * span - xmin) / (g->resolution);
00454     g->ny = 1 + (int) (ymax + 30. * span - ymin) / (g->resolution);
00455     g->nz = 1 + (int) (zmax + 30. * span - zmin) / (g->resolution);
00456 
00457     g->gridvalues = (float ***) my_malloc(sizeof (float **) * g->nx);
00458     for (cx = 0; cx < g->nx; cx++) {
00459         g->gridvalues[cx] = (float **) my_malloc(sizeof (float *) * g->ny);
00460         for (cy = 0; cy < g->ny; cy++) {
00461             g->gridvalues[cx][cy] = (float *) my_malloc(sizeof (float) * g->nz);
00462             for (cz = 0; cz < g->nz; cz++) {
00463                 g->gridvalues[cx][cy][cz] = initvalue;
00464 
00465             }
00466         }
00467     }
00468 
00469     g->origin = (float *) my_malloc(sizeof (float) *3);
00470     g->origin[0] = xmin - 15. * span;
00471     g->origin[1] = ymin - 15. * span;
00472     g->origin[2] = zmin - 15. * span;
00473     return g;
00474 }

void normalize_grid ( s_mdgrid g,
int  n 
)

## FUNCTION: normalize_grid

## SPECIFICATION: Normalize all grid values by the number of snapshots

## PARAMETRES: @ s_mdgrid *g: Grid structure @ int n : Number of snapshots ## RETURN: void

Definition at line 348 of file mdpbase.c.

References s_mdgrid::gridvalues, s_mdgrid::nx, s_mdgrid::ny, and s_mdgrid::nz.

Referenced by mdpocket_detect().

00348                                         {
00349     int x, y, z;
00350     for (x = 0; x < g->nx; x++) {
00351         for (y = 0; y < g->ny; y++) {
00352             for (z = 0; z < g->nz; z++) {
00353                 g->gridvalues[x][y][z] /= (float) n;
00354             }
00355         }
00356     }
00357 }

void project_grid_on_atoms ( s_mdgrid g,
s_pdb pdb 
)

## FUNCTION: project_grid_on_atoms

## SPECIFICATION: Project grid values to atoms to store these into the bfactor column of the pdb

## PARAMETRES: @ s_mdgrid *g: Grid structure ## RETURN: void

Definition at line 295 of file mdpbase.c.

References s_atm::bfactor, s_mdgrid::gridvalues, s_pdb::latoms_p, M_MDP_ATOM_DENSITY_DIST, s_mdgrid::n_snapshots, s_pdb::natoms, s_mdgrid::origin, s_mdgrid::resolution, s_atm::x, s_atm::y, and s_atm::z.

Referenced by mdpocket_detect().

00295                                                     {
00296     s_atm *ca = NULL;
00297     float x, y, z;
00298     int ix, iy, iz;
00299     float maxix, maxiy, maxiz;
00300     int i;
00301     float density;
00302     float ngridpoints1D = (float) M_MDP_ATOM_DENSITY_DIST / g->resolution;
00303     for (i = 0; i < pdb->natoms; i++) {/*for all protein atoms*/
00304         density = 0.0;
00305         ca = pdb->latoms_p[i];  /*set up the current atom*/
00306         /*get the coordinates*/
00307         x = ca->x;
00308         y = ca->y;
00309         z = ca->z;
00310         /*nearest position of the atom in x in the grid*/
00311         ix = (int) floor((x - M_MDP_ATOM_DENSITY_DIST - g->origin[0]) / g->resolution);
00312 
00313         maxix = (int) ceil((x + M_MDP_ATOM_DENSITY_DIST - g->origin[0]) / g->resolution);
00314         maxiy = (int) ceil((y + M_MDP_ATOM_DENSITY_DIST - g->origin[1]) / g->resolution);
00315         maxiz = (int) ceil((z + M_MDP_ATOM_DENSITY_DIST - g->origin[2]) / g->resolution);
00316         while (ix <= maxix && g->nx > ix) {
00317             iy = (int) floor((y - M_MDP_ATOM_DENSITY_DIST - g->origin[1]) / g->resolution);
00318             while (iy <= maxiy && g->ny > iy) {
00319                 iz = (int) floor((z - M_MDP_ATOM_DENSITY_DIST - g->origin[2]) / g->resolution);
00320                 while (iz <= maxiz && g->nz > iz) {
00321                     density += g->gridvalues[ix][iy][iz];
00322                     iz++;
00323                 }
00324                 iy++;
00325             }
00326             ix++;
00327         }
00328         /*transform the density to something more contrasted for the bfactor column*/
00329         ca->bfactor = log(1 + density / (ngridpoints1D) / (float) g->n_snapshots);
00330     }
00331 }

void realloc_md_concat ( s_mdconcat m,
size_t  n 
)

## FUNCTION: realloc_md_concat

## SPECIFICATION: Reallocate memory for the md concat structure (to add a new snapshot)

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free, @ size_t n: Number of vertices in the snapshot to add to m

## RETURN: void

## FUNCTION: realloc_md_concat

## SPECIFICATION: Reallocate memory for the md concat structure (to add a new snapshot)

## PARAMETRES: @ s_mdconcat *m: Pointer to the structure to free, @ size_t n: Number of vertices in the snapshot to add to m

## RETURN: void

Definition at line 518 of file mdpbase.c.

00518                                                 {
00519     size_t z;
00520     m->vertpos = (float **) my_realloc(m->vertpos, sizeof (float *) *(m->n_vertpos + n));
00521     for (z = 0; z < n; z++) {
00522         m->vertpos[m->n_vertpos + z] = (float *) my_malloc(sizeof (float) *4);
00523         m->vertpos[m->n_vertpos + z][0] = 0.0;
00524         m->vertpos[m->n_vertpos + z][1] = 0.0;
00525         m->vertpos[m->n_vertpos + z][2] = 0.0;
00526         m->vertpos[m->n_vertpos + z][3] = 0.0;
00527     }
00528     m->n_vertpos += n;
00529 }

void reset_grid ( s_mdgrid g  ) 

## FUNCTION: reset_grid

## SPECIFICATION: Reset all grid values to 0

## PARAMETRES: @ s_mdgrid *g: Grid structure ## RETURN: void

Definition at line 269 of file mdpbase.c.

References s_mdgrid::gridvalues, s_mdgrid::nx, s_mdgrid::ny, and s_mdgrid::nz.

Referenced by mdpocket_detect().

00269                              {
00270     int x, y, z;
00271     for (x = 0; x < g->nx; x++) {
00272         for (y = 0; y < g->ny; y++) {
00273             for (z = 0; z < g->nz; z++) {
00274                 g->gridvalues[x][y][z] = 0.0;
00275             }
00276         }
00277     }
00278 }

void store_vertice_positions ( s_mdconcat m,
c_lst_pockets pockets 
)

## FUNCTION: store_vertice_positions

## SPECIFICATION: Store vertice positions of current pockets in the mdconcat structure

## PARAMETRES: @ s_mdconcat *m: Pointer to the mdconcat structure (vertices), @ c_lst_pockets *pockets : Pointer to all pockets found by fpocket

## RETURN: void

Definition at line 70 of file mdpbase.c.

References alloc_first_md_concat(), s_mdconcat::n_vertpos, s_lst_vvertice::nvert, s_vvertice::ray, realloc_md_concat(), s_lst_vvertice::vertices, c_lst_pockets::vertices, s_mdconcat::vertpos, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

00070                                                                     {
00071     if (pockets) {
00072         int z;
00073         int n = pockets->vertices->nvert;
00074         size_t old_n = m->n_vertpos;
00075         /*if there a no vertices in m before, first allocate some space*/
00076         if (m->n_vertpos == 0) alloc_first_md_concat(m, n);
00077         else realloc_md_concat(m, n); /*else, reallocate the object size*/
00078         for (z = 0; z < n; z++) { /*loop over all vertices*/
00079             /*store the positions and radius of the vertices*/
00080             m->vertpos[old_n + z][0] = pockets->vertices->vertices[z].x;
00081             m->vertpos[old_n + z][1] = pockets->vertices->vertices[z].y;
00082             m->vertpos[old_n + z][2] = pockets->vertices->vertices[z].z;
00083             m->vertpos[old_n + z][3] = pockets->vertices->vertices[z].ray;
00084         }
00085     }
00086 }

void update_md_grid ( s_mdgrid g,
s_mdgrid refg,
c_lst_pockets pockets,
s_mdparams par 
)

## FUNCTION: update_md_dens_grid

## SPECIFICATION: Do the actual grid calculation (count number of vertices near a grid point)

## PARAMETRES: @ s_mdgrid *g: Grid structure @ c_lst_pockets *pockets : Pocket chained list @ s_mdparams *par : Parameters of mdpocket ## RETURN: void

Definition at line 184 of file mdpbase.c.

References s_desc::drug_score, c_lst_vertices::first, c_lst_pockets::first, s_mdparams::flag_scoring, s_mdgrid::gridvalues, M_MDP_CUBE_SIDE, node_pocket::next, node_vertice::next, s_mdgrid::origin, s_pocket::pdesc, node_pocket::pocket, s_mdgrid::resolution, s_pocket::v_lst, node_vertice::vertice, s_vvertice::x, s_vvertice::y, and s_vvertice::z.

Referenced by mdpocket_detect().

00184                                                                                           {
00185     int xidx = 0, yidx = 0, zidx = 0; /*direct indices of the positions in the grid*/
00186     int sxidx = 0, syidx = 0, szidx = 0; /*indices nearby xidx,yidx,zidx that are within M_MDP_CUBE_SIDE of this point*/
00187     int sxi = 0, syi = 0, szi = 0;
00188     float vx, vy, vz;
00189     float incre = 1.0;
00190     node_pocket *cp = NULL;
00191     s_pocket *pocket = NULL;
00192     node_vertice *cnv = NULL;
00193     s_vvertice *cv = NULL;
00194     int s = (int) (((float) M_MDP_CUBE_SIDE / 2.0) / g->resolution); /*possible stepsize (resolution dependent) in the discrete grid*/
00195     /*loop over all known vertices and CALCULATE the grid positions and increment grid values by 1*/
00196     /*important : no distance calculations are done here, thus this routine is very fast*/
00197     cp = pockets->first;
00198     while (cp) { /*loop over pockets*/
00199         pocket = cp->pocket;
00200         cnv = pocket->v_lst->first;
00201         /*if(par->flag_scoring) incre=pocket->score;*/
00202         if (par->flag_scoring) incre = pocket->pdesc->drug_score;
00203         while (cnv) { /*loop over vertices*/
00204             cv = cnv->vertice;
00205             vx = cv->x; /*tmp the vertice position*/
00206             vy = cv->y;
00207             vz = cv->z;
00208             xidx = (int) roundf((vx - g->origin[0]) / g->resolution); /*calculate the nearest grid point internal coordinates*/
00209             yidx = (int) roundf((vy - g->origin[1]) / g->resolution);
00210             zidx = (int) roundf((vz - g->origin[2]) / g->resolution);
00211             /*we use a cube of M_MDP_CUBE_SIDE**3 volume to check if there are grid points nearby,
00212              *thus a check in the neighbourhood is performed here...this looks a bit awful and should be changed later on*/
00213 
00214             for (sxi = -s; sxi <= s; sxi++) {
00215                 for (syi = -s; syi <= s; syi++) {
00216                     for (szi = -s; szi <= s; szi++) {
00217                         /*check if we are not on the point xidx,yidx, zidx....the square sum is just a little trick*/
00218                         if ((sxi * sxi + syi * syi + szi * szi) != 0) {
00219                             /*next we have to check in a discrete manner if we can include a new grid point or not.*/
00220                             if (sxi < 0) sxidx = (int) ceil(((float) sxi + vx - g->origin[0]) / g->resolution);
00221                             else if (sxi > 0) sxidx = (int) floor(((float) sxi + vx - g->origin[0]) / g->resolution);
00222                             else if (sxi == 0) sxidx = xidx;
00223                             if (syi < 0) syidx = (int) ceil(((float) syi + vy - g->origin[1]) / g->resolution);
00224                             else if (syi > 0) syidx = (int) floor(((float) syi + vy - g->origin[1]) / g->resolution);
00225                             else if (syi == 0) syidx = yidx;
00226                             if (szi < 0) szidx = (int) ceil(((float) szi + vz - g->origin[2]) / g->resolution);
00227                             else if (szi > 0) szidx = (int) floor(((float) szi + vz - g->origin[2]) / g->resolution);
00228                             else if (szi == 0) szidx = zidx;
00229                             /*double check if we are not on the already incremented grid point*/
00230                             if (((sxidx != xidx) || (syidx != yidx) || (szidx != zidx))
00231                                     && (sxidx >= 0 && syidx >= 0 && szidx >= 0 && sxidx < g->nx && syidx < g->ny && szidx < g->nz)) {
00232                                 if (refg->gridvalues[sxidx][syidx][szidx] < 1.0) {
00233                                     g->gridvalues[sxidx][syidx][szidx] += incre;
00234                                     refg->gridvalues[sxidx][syidx][szidx] = 1.0;
00235 
00236                                 }
00237                             } /*added condition if grid value already set, do not update, to better density measurements and match drug score*/
00238                         }
00239                     }
00240                 }
00241             }
00242             cnv = cnv->next;
00243         }
00244 
00245         if (xidx < g->nx && yidx < g->ny && zidx < g->nz && xidx >= 0 && yidx >= 0 && zidx >= 0) {
00246             if (refg->gridvalues[xidx][yidx][zidx] < 1.0) {
00247                 g->gridvalues[xidx][yidx][zidx] += incre; /*increment the already known grid point value*/
00248                 refg->gridvalues[xidx][yidx][zidx] = 1.0;
00249             }
00250         } else fprintf(stderr, "\n\nWarning (oh oh!!) : Your structure is not aligned or is moving a lot. Results might not reflect what you expect. Consider first structural alignemnt\nIf your structure is moving a lot, consider to split up analysis in two distinct parts.\n\n");
00251         cp = cp->next;
00252     }
00253     //return g;
00254 }


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