#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "voronoi.h"
#include "atom.h"
#include "rpdb.h"
#include "sort.h"
#include "memhandler.h"
Go to the source code of this file.
Defines | |
#define | M_INTERFACE_SEARCH_DIST 8.0 |
#define | M_INTERFACE_SEARCH 1 |
#define | M_NO_INTERFACE_SEARCH 0 |
Functions | |
s_atm ** | get_mol_atm_neigh (s_atm **atoms, int natoms, s_atm **all, int nall, float dist_crit, int *nneigh) |
s_atm ** | get_mol_ctd_atm_neigh (s_atm **atoms, int natoms, s_vvertice **pvert, int nvert, float vdist_crit, int interface_search, int *nneigh) |
s_vvertice ** | get_mol_vert_neigh (s_atm **atoms, int natoms, s_vvertice **pvert, int nvert, float dist_crit, int *nneigh) |
float | count_pocket_lig_vert_ovlp (s_atm **lig, int nlig, s_vvertice **pvert, int nvert, float dist_crit) |
float | count_atm_prop_vert_neigh (s_atm **lig, int nlig, s_vvertice **pvert, int nvert, float dist_crit, int n_lig_molecules) |
int | count_vert_neigh_P (s_vvertice **pvert, int nvert, s_vvertice **pvert_all, int nvert_all, float dcrit) |
int | count_vert_neigh (s_vsort *lsort, s_vvertice **pvert, int nvert, float dcrit) |
#define M_INTERFACE_SEARCH 1 |
Definition at line 53 of file neighbor.h.
Referenced by get_actual_pocket(), and get_explicit_desc().
#define M_INTERFACE_SEARCH_DIST 8.0 |
#define M_NO_INTERFACE_SEARCH 0 |
Definition at line 54 of file neighbor.h.
float count_atm_prop_vert_neigh | ( | s_atm ** | lig, | |
int | nlig, | |||
s_vvertice ** | pvert, | |||
int | nvert, | |||
float | dcrit, | |||
int | n_lig_molecules | |||
) |
## FUNCTION: count_pocket_lig_vert_ovlp
## SPECIFICATION: Return the proportion of atoms given in parameter that have at least one vertice that lies within dcrit A
## PARAMETRES: @ s_atm **lig : The molecule. @ int nlig : Number of atoms in the molecule @ s_vvertice *pvert : List of vertices to check. @ int nvert : Number of verties (tipically in a given pocket) @ float dcrit : The distance criteria.s
## RETURN: The proportion of atoms with dcrit A of at least 1 vertice.
Definition at line 610 of file neighbor.c.
References dist(), free_s_vsort(), get_sorted_list(), M_VERTICE_TYPE, s_vsort::nelem, s_atm::res_id, s_atm::sort_x, s_vvertice::x, s_atm::x, s_vsort::xsort, s_vvertice::y, s_atm::y, s_vvertice::z, and s_atm::z.
Referenced by check_pockets(), and desc_pocket().
00612 { 00613 s_vsort *lsort = get_sorted_list(lig, nlig, pvert, nvert) ; 00614 s_vect_elem *xsort = lsort->xsort ; 00615 00616 int ip, im, i, 00617 stopm, stopp, 00618 nb_neigh, 00619 sort_x, 00620 ntest_x, 00621 dim = lsort->nelem ; 00622 00623 float vvalx, vvaly, vvalz ; 00624 int multi_nb_neigh[n_lig_molecules]; 00625 int multi_nb_lig_atoms[n_lig_molecules]; 00626 00627 int c_lig_mol=0; 00628 float max_prop=0.0; 00629 float tmp=0.0; 00630 char chain_tmp[2]; 00631 int resnumber_tmp; 00632 strcpy(chain_tmp,lig[0]->chain); 00633 resnumber_tmp = lig[0]->res_id; 00634 00635 s_vvertice *curvp = NULL, *curvm = NULL ; 00636 00637 nb_neigh = 0 ; 00638 multi_nb_neigh[0]=0; 00639 multi_nb_lig_atoms[0]=0; 00640 for(i = 0 ; i < nlig ; i++) { 00641 /*check if we are in a new ligand molecule*/ 00642 if(strcmp(chain_tmp,lig[i]->chain) !=0 || resnumber_tmp!=lig[i]->res_id){ 00643 c_lig_mol++; 00644 strcpy(chain_tmp,lig[i]->chain); 00645 resnumber_tmp =lig[i]->res_id; 00646 multi_nb_neigh[c_lig_mol]=0; 00647 multi_nb_lig_atoms[c_lig_mol]=0; 00648 } 00649 multi_nb_lig_atoms[c_lig_mol]++; 00650 s_atm *cur = lig[i] ; 00651 00652 /* Reinitialize variables */ 00653 stopm = 0; stopp = 0; 00654 sort_x = cur->sort_x ; 00655 ntest_x = 1 ; 00656 vvalx = cur->x ; vvaly = cur->y ; vvalz = cur->z ; 00657 00658 /* Search neighbors */ 00659 while(!stopm || !stopp) { 00660 /* Do the neighbor search while we are in tab and we dont reach a 00661 * distance up to our criteria */ 00662 ip = ntest_x + sort_x ; 00663 if(ip >= dim) stopp = 1 ; 00664 00665 if(stopp == 0 && xsort[ip].type == M_VERTICE_TYPE) { 00666 curvp = (s_vvertice*) xsort[ip].data ; 00667 00668 if(curvp->x - vvalx > dcrit) stopp = 1 ; 00669 else { 00670 /* OK we have an atom which is near our vertice on X, so 00671 * calculate real distance */ 00672 if(dist(curvp->x, curvp->y, curvp->z, vvalx, vvaly, vvalz) < dcrit) { 00673 /* Distance OK, break the loop */ 00674 multi_nb_neigh[c_lig_mol]++; 00675 nb_neigh ++ ; break ; 00676 } 00677 } 00678 } 00679 00680 im = sort_x - ntest_x ; 00681 if(im < 0) stopm = 1 ; 00682 00683 if(stopm == 0 && xsort[im].type == M_VERTICE_TYPE) { 00684 curvm = (s_vvertice*) xsort[im].data ; 00685 00686 if(vvalx - curvm->x > dcrit) stopm = 1 ; 00687 else { 00688 /* OK we have an atom which is near our vertice on X, so 00689 * calculate real distance */ 00690 if(dist(curvm->x, curvm->y, curvm->z, vvalx, vvaly, vvalz) < dcrit){ 00691 /* Distance OK, see if the molecule is not one part of the 00692 * input, and if we have not already seen it. */ 00693 multi_nb_neigh[c_lig_mol]++; 00694 nb_neigh++ ; break ; 00695 } 00696 } 00697 } 00698 00699 ntest_x += 1 ; 00700 } 00701 } 00702 /*get only the max proportion between overlap for different lig mols*/ 00703 for(i=0;i<n_lig_molecules;i++){ 00704 tmp=(float)multi_nb_neigh[i]/(float)multi_nb_lig_atoms[i]; 00705 if(tmp>max_prop) max_prop=tmp; 00706 } 00707 free_s_vsort(lsort); 00708 return max_prop; 00709 }
float count_pocket_lig_vert_ovlp | ( | s_atm ** | lig, | |
int | nlig, | |||
s_vvertice ** | pvert, | |||
int | nvert, | |||
float | dcrit | |||
) |
## FUNCTION: count_pocket_lig_vert_ovlp
## SPECIFICATION: Return the proportion of alpha sphere given in parameter that lies within dcrit A of the ligand -> we loop on each ligand atom and we count the number of unique vertices next to each atoms using dist-crit.
## PARAMETRES: @ s_atm **lig : The molecule. @ int nlig : Number of atoms in the molecule @ s_vvertice *pvert : List of vertices to check. @ int nvert : Number of verties (tipically in a given pocket) @ float dcrit : The distance criteria.s
## RETURN: A tab of pointers to the neighbours.
Definition at line 503 of file neighbor.c.
References dist(), free_s_vsort(), get_sorted_list(), M_VERTICE_TYPE, s_vsort::nelem, s_vvertice::seen, s_atm::sort_x, s_vvertice::x, s_atm::x, s_vsort::xsort, s_vvertice::y, s_atm::y, s_vvertice::z, and s_atm::z.
Referenced by check_pockets(), and desc_pocket().
00506 { 00507 s_vsort *lsort = get_sorted_list(lig, nlig, pvert, nvert) ; 00508 s_vect_elem *xsort = lsort->xsort ; 00509 00510 int ip, im, i, 00511 stopm, stopp, 00512 nb_neigh, 00513 sort_x, 00514 ntest_x, 00515 dim = lsort->nelem ; 00516 00517 float vvalx, vvaly, vvalz ; 00518 00519 s_vvertice *ids[nvert] ; 00520 for(i = 0 ; i < nvert ; i++) { 00521 pvert[i]->seen = 0 ; 00522 ids[i] = NULL ; 00523 } 00524 00525 s_vvertice *curvp = NULL, *curvm = NULL ; 00526 00527 nb_neigh = 0 ; 00528 for(i = 0 ; i < nlig ; i++) { 00529 s_atm *cur = lig[i] ; 00530 00531 /* Reinitialize variables */ 00532 stopm = 0; stopp = 0; 00533 sort_x = cur->sort_x ; 00534 ntest_x = 1 ; 00535 vvalx = cur->x ; vvaly = cur->y ; vvalz = cur->z ; 00536 00537 /* Search neighbors */ 00538 while(!stopm || !stopp) { 00539 /* Do the neighbor search while wa are in tab and we dont reach a 00540 * distance up to our criteria */ 00541 ip = ntest_x + sort_x ; 00542 if(ip >= dim) stopp = 1 ; 00543 00544 if(stopp == 0 && xsort[ip].type == M_VERTICE_TYPE) { 00545 curvp = (s_vvertice*) xsort[ip].data ; 00546 00547 if(curvp->x - vvalx > dcrit) stopp = 1 ; 00548 else { 00549 /* OK we have an atom which is near our vertice on X, so 00550 * calculate real distance */ 00551 if(dist(curvp->x, curvp->y, curvp->z, vvalx, vvaly, vvalz) < dcrit) { 00552 /* Distance OK, see if the molecule have not been already seen. */ 00553 if(! curvp->seen) { 00554 ids[nb_neigh] = curvp ; 00555 curvp->seen = 1 ; 00556 nb_neigh ++ ; 00557 } 00558 } 00559 } 00560 } 00561 00562 im = sort_x - ntest_x ; 00563 if(im < 0) stopm = 1 ; 00564 00565 if(stopm == 0 && xsort[im].type == M_VERTICE_TYPE) { 00566 curvm = (s_vvertice*) xsort[im].data ; 00567 00568 if(vvalx - curvm->x > dcrit) stopm = 1 ; 00569 else { 00570 /* OK we have an atom which is near our vertice on X, so 00571 * calculate real distance */ 00572 if(dist(curvm->x, curvm->y, curvm->z, vvalx, vvaly, vvalz) < dcrit){ 00573 /* Distance OK, see if the molecule is not one part of the 00574 * input, and if we have not already seen it. */ 00575 if(!curvm->seen) { 00576 ids[nb_neigh] = curvm ; 00577 curvm->seen = 1 ; 00578 nb_neigh ++ ; 00579 } 00580 } 00581 } 00582 } 00583 00584 ntest_x += 1 ; 00585 } 00586 } 00587 00588 free_s_vsort(lsort) ; 00589 return (float)nb_neigh/(float)nvert ; 00590 }
int count_vert_neigh | ( | s_vsort * | lsort, | |
s_vvertice ** | pvert, | |||
int | nvert, | |||
float | dcrit | |||
) |
## FUNCTION: count_vert_neigh
## SPECIFICATION: Count the number of vertices that lies within a distance <= dist_crit from a list of query vertices. The user must provide the list of sorted vertices (that should include the query vertices and all other vertices to consider), the query vertices and the distance criteria.
Note that if the query vertices are not present in the list of ordered vertices, the function will return 0.
## PARAMETRES: @ s_vsort *lsort : List of sorted vertices. @ s_vvertice **pvert : List of pointer to query vertices @ int nvert : Number of query vertices @ float dcrit : The distance criteria.
## RETURN: int: The total number of vertices lying within dist_crit A of the query vertices
Definition at line 770 of file neighbor.c.
References s_vect_elem::data, dist(), s_vsort::nelem, s_vvertice::seen, s_vvertice::sort_x, s_vvertice::x, s_vsort::xsort, s_vvertice::y, and s_vvertice::z.
Referenced by count_vert_neigh_P().
00771 { 00772 s_vect_elem *xsort = lsort->xsort ; 00773 00774 s_vvertice *vcur = NULL ; 00775 00776 int ip, im, i, 00777 stopm, stopp, 00778 nb_neigh, 00779 sort_x, 00780 ntest_x, 00781 dim = lsort->nelem ; 00782 00783 float vvalx, vvaly, vvalz; 00784 00785 /* Set all vertices to NOT SEEN, except the query vertices */ 00786 for(i = 0 ; i < dim ; i++) ((s_vvertice*) lsort->xsort[i].data)->seen = 0 ; 00787 for(i = 0 ; i < nvert ; i++) pvert[i]->seen = 2 ; 00788 00789 s_vvertice *curvp = NULL, *curvm = NULL ; 00790 nb_neigh = 0 ; 00791 for(i = 0 ; i < nvert ; i++) { 00792 vcur = pvert[i] ; 00793 00794 /* Reinitialize variables */ 00795 stopm = 0; stopp = 0; 00796 sort_x = vcur->sort_x ; 00797 ntest_x = 1 ; 00798 vvalx = vcur->x ; vvaly = vcur->y ; vvalz = vcur->z ; 00799 00800 /* Search neighbors */ 00801 while(!stopm || !stopp) { 00802 /* Do the neighbor search while wa are in tab and we dont reach a 00803 * distance up to our criteria */ 00804 ip = ntest_x + sort_x ; 00805 00806 /* Stop the search if we reach dim*/ 00807 if(ip >= dim) stopp = 1 ; 00808 00809 if(stopp == 0) { 00810 curvp = (s_vvertice*) xsort[ip].data ; 00811 00812 /* Stop the search the distance on X is > dcrit*/ 00813 if(curvp->x - vvalx > dcrit) stopp = 1 ; 00814 /* Check if the current vertice has not already been counted */ 00815 else if(curvp->seen == 0) { 00816 if(dist(curvp->x, curvp->y, curvp->z, vvalx, vvaly, vvalz) < dcrit) { 00817 /* Distance OK, count and mark the vertice */ 00818 curvp->seen = 1 ; 00819 nb_neigh ++ ; 00820 } 00821 } 00822 } 00823 00824 im = sort_x - ntest_x ; 00825 if(im < 0) stopm = 1 ; 00826 00827 if(stopm == 0) { 00828 curvm = (s_vvertice*) xsort[im].data ; 00829 00830 /* Stop the search the distance on X is > dcrit*/ 00831 if(vvalx - curvm->x > dcrit) stopm = 1 ; 00832 /* Check if the current vertice has not already been counted */ 00833 else if(curvp->seen == 0) { 00834 /* OK we have an atom which is near our vertice on X, so 00835 * calculate real distance */ 00836 if(dist(curvm->x, curvm->y, curvm->z, vvalx, vvaly, vvalz) < dcrit){ 00837 /* Distance OK, count and mark the vertice */ 00838 curvm->seen = 1 ; 00839 nb_neigh ++ ; 00840 } 00841 } 00842 } 00843 00844 ntest_x += 1 ; 00845 } 00846 } 00847 00848 return nb_neigh ; 00849 }
int count_vert_neigh_P | ( | s_vvertice ** | pvert, | |
int | nvert, | |||
s_vvertice ** | pvert_all, | |||
int | nvert_all, | |||
float | dcrit | |||
) |
## FUNCTION: count_vert_neigh_P
## SPECIFICATION: Count the number of vertices that lies within a distance <= dist_crit from a list of query vertices. The user must provide the query vertices, the full list of vertices to consider, and the distance criteria.
## PARAMETRES: @ s_vvertice *pvert : List of pointer to query vertices @ int nvert : Number of query vertices @ s_vvertice *pvert_all : List of pointer to all vertice to consider @ int nvert_all : Total number of vertices to consider @ float dcrit : The distance criteria.
## RETURN: int: The total number of vertices lying within dist_crit A of the query vertices
Definition at line 733 of file neighbor.c.
References count_vert_neigh(), free_s_vsort(), and get_sorted_list().
00736 { 00737 s_vsort *lsort = get_sorted_list(NULL, 0, pvert_all, nvert_all) ; 00738 int res = count_vert_neigh(lsort, pvert, nvert, dcrit) ; 00739 00740 free_s_vsort(lsort) ; 00741 00742 return res ; 00743 }
s_atm** get_mol_atm_neigh | ( | s_atm ** | atoms, | |
int | natoms, | |||
s_atm ** | all, | |||
int | nall, | |||
float | dcrit, | |||
int * | nneigh | |||
) |
## FUNCTION: get_mol_atm_neigh
## SPECIFICATION: Return a list of pointer to the atoms situated a distance lower or equal to dcrit from a molecule represented by a list of atoms.
This functon use a list of atoms that is sorted on the X dimension to accelerate the research.
## PARAMETRES: @ s_atm **atoms : The molecule atoms. @ int natoms : Number of atoms in the molecule @ s_pdb *pdb : The pdb structure containing all atoms of the system @ float dcrit : The distance criteria. @ int *nneigh : OUTPUT A pointer to the number of neighbour found, will be modified in the function...
## RETURN: A tab of pointers to the neighbours, with the number of neighbors stored in nneigh
Definition at line 90 of file neighbor.c.
References dist(), free_s_vsort(), get_sorted_list(), s_atm::id, is_in_lst_atm(), my_malloc(), my_realloc(), s_vsort::nelem, s_atm::sort_x, s_atm::x, s_vsort::xsort, s_atm::y, and s_atm::z.
Referenced by get_actual_pocket_DEPRECATED(), and get_explicit_desc().
00092 { 00093 /* No vertices, we only search atoms... */ 00094 s_vsort *lsort = get_sorted_list(all, nall, NULL, 0) ; 00095 s_vect_elem *xsort = lsort->xsort ; 00096 00097 int ip, im, 00098 stopm, stopp, 00099 nb_neigh, 00100 sort_x, 00101 ntest_x, 00102 dim = lsort->nelem ; 00103 00104 float vvalx, vvaly, vvalz; 00105 00106 int real_size = 10, 00107 i, seen ; 00108 00109 s_atm *curap = NULL, *curam = NULL ; 00110 s_atm **neigh = (s_atm**)my_malloc(sizeof(s_atm*)*real_size) ; 00111 00112 nb_neigh = 0 ; 00113 for(i = 0 ; i < natoms ; i++) { 00114 s_atm *cur = atoms[i] ; 00115 00116 /* Reinitialize variables */ 00117 stopm = 0; stopp = 0; 00118 sort_x = cur->sort_x ; 00119 ntest_x = 1 ; 00120 vvalx = cur->x ; vvaly = cur->y ; vvalz = cur->z ; 00121 00122 /* Search neighbors */ 00123 while(!stopm || !stopp) { 00124 /* Do the neighbor search while wa are in tab and we dont reach a 00125 * distance up to our criteria */ 00126 ip = ntest_x + sort_x ; 00127 if(ip >= dim) stopp = 1 ; 00128 00129 if(stopp == 0) { 00130 curap = (s_atm*) xsort[ip].data ; 00131 00132 if(curap->x - vvalx > dcrit) stopp = 1 ; 00133 else { 00134 /* OK we have an atom which is near our vertice on X, so 00135 * calculate real distance */ 00136 if(dist(curap->x, curap->y, curap->z, vvalx, vvaly, vvalz) < dcrit) { 00137 /* Distance OK, see if the molecule is not one part of the 00138 input, and if we have not already seen it. */ 00139 seen = is_in_lst_atm(atoms, natoms, curap->id) 00140 + is_in_lst_atm(neigh, nb_neigh, curap->id) ; 00141 if(!seen) { 00142 if(nb_neigh >= real_size-1) { 00143 real_size *= 2 ; 00144 neigh =(s_atm**) my_realloc(neigh, sizeof(s_atm)*real_size) ; 00145 } 00146 neigh[nb_neigh] = curap ; 00147 nb_neigh ++ ; 00148 } 00149 } 00150 } 00151 } 00152 00153 im = sort_x - ntest_x ; 00154 if(im < 0) stopm = 1 ; 00155 00156 if(stopm == 0) { 00157 curam = (s_atm*) xsort[im].data ; 00158 00159 if(vvalx - curam->x > dcrit) stopm = 1 ; 00160 else { 00161 /* OK we have an atom which is near our vertice on X, so 00162 * calculate real distance */ 00163 if(dist(curam->x, curam->y, curam->z, vvalx, vvaly, vvalz) < dcrit){ 00164 /* Distance OK, see if the molecule is not one part of the 00165 input, and if we have not already seen it. */ 00166 seen = is_in_lst_atm(atoms, natoms, curam->id) 00167 + is_in_lst_atm(neigh, nb_neigh, curam->id) ; 00168 if(!seen) { 00169 if(nb_neigh >= real_size-1) { 00170 real_size *= 2 ; 00171 neigh = (s_atm**)my_realloc(neigh, sizeof(s_atm)*real_size) ; 00172 } 00173 neigh[nb_neigh] = curam ; 00174 nb_neigh ++ ; 00175 } 00176 } 00177 } 00178 } 00179 00180 ntest_x += 1 ; 00181 } 00182 } 00183 00184 *nneigh = nb_neigh ; 00185 free_s_vsort(lsort) ; 00186 00187 return neigh ; 00188 }
s_atm** get_mol_ctd_atm_neigh | ( | s_atm ** | atoms, | |
int | natoms, | |||
s_vvertice ** | pvert, | |||
int | nvert, | |||
float | vdcrit, | |||
int | interface_search, | |||
int * | nneigh | |||
) |
## FUNCTION: get_mol_ctd_atm_neigh
## SPECIFICATION: Return a list of atoms contacted by voronoi vertices situated at dcrit of a given molecule represented by a list of its atoms.
## PARAMETRES: @ s_atm **atoms : The molecule. @ int natoms : Number of atoms in the molecule @ s_lst_vvertice *lvert : Full list of vertices present in the system @ float dcrit : The distance criteria. @ int interface_search : Perform an interface-type search ? @ int *nneigh : OUTPUT A pointer to the number of neighbour found, will be modified in the function...
## RETURN: A tab of pointers to atoms describing the pocket.
Definition at line 332 of file neighbor.c.
References dist(), free_s_vsort(), get_sorted_list(), M_INTERFACE_SEARCH_DIST, M_VERTICE_TYPE, my_malloc(), my_realloc(), s_vvertice::neigh, s_vsort::nelem, s_atm::seen, s_atm::sort_x, s_vvertice::x, s_atm::x, s_vsort::xsort, s_vvertice::y, s_atm::y, s_vvertice::z, and s_atm::z.
Referenced by get_actual_pocket(), and get_explicit_desc().
00335 { 00336 s_vsort *lsort = get_sorted_list(atoms, natoms, pvert, nvert) ; 00337 s_vect_elem *xsort = lsort->xsort ; 00338 00339 int ip, im, /* Current indexes in the tab (start at the current 00340 atom position, and check the tab in each directions */ 00341 stopm, stopp, /* Say weteher the algorithm has to continue the search 00342 in each direction */ 00343 nb_neigh = 0, 00344 sort_x = 0, /* Index of the current ligand atom in the sorted list.*/ 00345 ntest_x = 0, 00346 dim = lsort->nelem, 00347 real_size = 10, 00348 i, j ; 00349 00350 float lx, ly, lz; 00351 00352 s_vvertice *curvp = NULL, *curvm = NULL ; 00353 s_atm *curatm = NULL ; 00354 s_atm **neigh = (s_atm**)my_malloc(sizeof(s_atm*)*real_size) ; 00355 00356 for(i = 0 ; i < nvert ; i++) { 00357 for(j = 0 ; j < 4 ; j++) { 00358 pvert[i]->neigh[j]->seen = 0 ; 00359 } 00360 } 00361 00362 for(i = 0 ; i < natoms ; i++) { 00363 s_atm *cur = atoms[i] ; 00364 00365 /* Reinitialize variables */ 00366 stopm = 0; stopp = 0; /* We can search in each directions */ 00367 sort_x = cur->sort_x ; /* Get the index of the current lidang atom 00368 in the sorted list. */ 00369 ntest_x = 1 ; 00370 00371 /* Coordinates of the current atom of the ligand */ 00372 lx = cur->x ; ly = cur->y ; lz = cur->z ; 00373 00374 /* Search neighbors */ 00375 while(!stopm || !stopp) { 00376 /* Do the neighbor search while we are in tab and we dont reach a 00377 * distance up to our criteria */ 00378 ip = ntest_x + sort_x ; 00379 00380 /* If we are out of the tab, stop the search in this direction */ 00381 if(ip >= dim) stopp = 1 ; 00382 00383 if(stopp == 0 && xsort[ip].type == M_VERTICE_TYPE) { 00384 curvp = (s_vvertice*) xsort[ip].data ; 00385 00386 /* Stop when the distance reaches the criteria */ 00387 if(curvp->x - lx > vdcrit) stopp = 1 ; 00388 else { 00389 /*OK we have a vertice which is near our atom on the X axe, 00390 so calculate real distance */ 00391 if(dist(curvp->x, curvp->y, curvp->z, lx, ly, lz) < vdcrit) { 00392 /* If the distance from the atom to the vertice is small enough*/ 00393 for(j = 0 ; j < 4 ; j++) { 00394 curatm = curvp->neigh[j] ; 00395 if(! curatm->seen) { 00396 if(interface_search && 00397 dist(curatm->x, curatm->y, curatm->z, lx, ly, lz) 00398 < M_INTERFACE_SEARCH_DIST) { 00399 /* If we have not seen yet this atom and if he 00400 * is not too far away from the ligand, add it*/ 00401 if(nb_neigh >= real_size-1) { 00402 real_size *= 2 ; 00403 neigh = (s_atm**)my_realloc(neigh, sizeof(s_atm)*real_size) ; 00404 } 00405 neigh[nb_neigh] = curatm ; 00406 curatm->seen = 1 ; 00407 nb_neigh ++ ; 00408 } 00409 else if(!interface_search) { 00410 /* If we have not seen yet this atom and if he 00411 * is not too far away from the ligand, add it*/ 00412 if(nb_neigh >= real_size-1) { 00413 real_size *= 2 ; 00414 neigh = (s_atm**)my_realloc(neigh, sizeof(s_atm)*real_size) ; 00415 } 00416 curatm->seen = 1 ; 00417 neigh[nb_neigh] = curatm ; 00418 nb_neigh ++ ; 00419 } 00420 } 00421 } 00422 } 00423 } 00424 } 00425 00426 im = sort_x - ntest_x ; 00427 /* If we are out of the tab, stop the search in this direction */ 00428 if(im < 0) stopm = 1 ; 00429 00430 if(stopm == 0 && xsort[im].type == M_VERTICE_TYPE) { 00431 curvm = (s_vvertice*) xsort[im].data ; 00432 00433 if(lx - curvm->x > vdcrit) stopm = 1 ; 00434 else { 00435 /* OK we have a vertice which is near our atom on the X axe, 00436 * so calculate real distance*/ 00437 if(dist(curvm->x, curvm->y, curvm->z, lx, ly, lz) < vdcrit) { 00438 /* If the distance from the atom to the vertice is small enough */ 00439 for(j = 0 ; j < 4 ; j++) { 00440 curatm = curvm->neigh[j] ; 00441 if(! curatm->seen) { 00442 if(interface_search && 00443 dist(curatm->x, curatm->y, curatm->z, lx, ly, lz) 00444 < M_INTERFACE_SEARCH_DIST) { 00445 /* If we have not seen yet this atom and if he 00446 * is not too far away from the ligand, add it */ 00447 if(nb_neigh >= real_size-1) { 00448 real_size *= 2 ; 00449 neigh = (s_atm**) 00450 my_realloc(neigh, sizeof(s_atm)*real_size) ; 00451 } 00452 curatm->seen = 1 ; 00453 neigh[nb_neigh] = curatm ; 00454 nb_neigh ++ ; 00455 } 00456 else if(!interface_search) { 00457 /* If we have not seen yet this atom and if he 00458 * is not too far away from the ligand, add it */ 00459 if(nb_neigh >= real_size-1) { 00460 real_size *= 2 ; 00461 neigh = (s_atm**)my_realloc(neigh, sizeof(s_atm)*real_size) ; 00462 } 00463 curatm->seen = 1 ; 00464 neigh[nb_neigh] = curatm ; 00465 nb_neigh ++ ; 00466 } 00467 } 00468 } 00469 } 00470 } 00471 } 00472 00473 ntest_x += 1 ; 00474 } 00475 } 00476 00477 *nneigh = nb_neigh ; 00478 free_s_vsort(lsort) ; 00479 00480 return neigh ; 00481 }
s_vvertice** get_mol_vert_neigh | ( | s_atm ** | atoms, | |
int | natoms, | |||
s_vvertice ** | pvert, | |||
int | nvert, | |||
float | dcrit, | |||
int * | nneigh | |||
) |
## FUNCTION: get_mol_vert_neigh
## SPECIFICATION: Return a list of pointer to the vertices situated a distance lower or equal to dcrit of a molecule represented by it's list of atoms.
This functon use a list of atoms that is sorted on the X dimension to accelerate the research.
## PARAMETRES: @ s_atm **atoms : The molecule. @ int natoms : Number of atoms in the molecule @ s_lst_vvertice *lvert : Full list of vertices present in the system @ float dcrit : The distance criteria. @ int *nneigh : OUTPUT A pointer to the number of neighbour found, will be modified in the function...
## RETURN: A tab of pointers to the neighbours.
Definition at line 213 of file neighbor.c.
References dist(), free_s_vsort(), get_sorted_list(), s_vvertice::id, is_in_lst_vert(), M_VERTICE_TYPE, my_malloc(), my_realloc(), s_vsort::nelem, s_atm::sort_x, s_vvertice::x, s_atm::x, s_vsort::xsort, s_vvertice::y, s_atm::y, s_vvertice::z, and s_atm::z.
Referenced by get_explicit_desc().
00216 { 00217 s_vsort *lsort = get_sorted_list(atoms, natoms, pvert, nvert) ; 00218 s_vect_elem *xsort = lsort->xsort ; 00219 00220 int ip, im, 00221 stopm, stopp, 00222 nb_neigh, 00223 sort_x, 00224 ntest_x, 00225 dim = lsort->nelem ; 00226 00227 float vvalx, vvaly, vvalz; 00228 00229 int real_size = 10, 00230 i, seen ; 00231 00232 s_vvertice *curvp = NULL, *curvm = NULL ; 00233 s_vvertice **neigh = (s_vvertice**)my_malloc(sizeof(s_vvertice*)*real_size) ; 00234 00235 nb_neigh = 0 ; 00236 for(i = 0 ; i < natoms ; i++) { 00237 s_atm *cur = atoms[i] ; 00238 00239 /* Reinitialize variables */ 00240 stopm = 0; stopp = 0; 00241 sort_x = cur->sort_x ; 00242 ntest_x = 1 ; 00243 vvalx = cur->x ; vvaly = cur->y ; vvalz = cur->z ; 00244 00245 /* Search neighbors */ 00246 while(!stopm || !stopp) { 00247 /* Do the neighbor search while wa are in tab and we dont reach a 00248 * distance up to our criteria */ 00249 ip = ntest_x + sort_x ; 00250 if(ip >= dim) stopp = 1 ; 00251 00252 if(stopp == 0 && xsort[ip].type == M_VERTICE_TYPE) { 00253 curvp = (s_vvertice*) xsort[ip].data ; 00254 00255 if(curvp->x - vvalx > dcrit) stopp = 1 ; 00256 else { 00257 /* OK we have an atom which is near our vertice on X, so 00258 * calculate real distance */ 00259 if(dist(curvp->x, curvp->y, curvp->z, vvalx, vvaly, vvalz) < dcrit) { 00260 /* Distance OK, see if the molecule have not been already seen. */ 00261 seen = is_in_lst_vert(neigh, nb_neigh, curvp->id) ; 00262 if(!seen) { 00263 if(nb_neigh >= real_size-1) { 00264 real_size *= 2 ; 00265 neigh = (s_vvertice **)my_realloc(neigh, 00266 sizeof(s_vvertice)*real_size) ; 00267 } 00268 neigh[nb_neigh] = curvp ; 00269 nb_neigh ++ ; 00270 } 00271 } 00272 } 00273 } 00274 00275 im = sort_x - ntest_x ; 00276 if(im < 0) stopm = 1 ; 00277 00278 if(stopm == 0 && xsort[im].type == M_VERTICE_TYPE) { 00279 curvm = (s_vvertice*) xsort[im].data ; 00280 00281 if(vvalx - curvm->x > dcrit) stopm = 1 ; 00282 else { 00283 /* OK we have an atom which is near our vertice on X, so 00284 * calculate real distance */ 00285 if(dist(curvm->x, curvm->y, curvm->z, vvalx, vvaly, vvalz) < dcrit){ 00286 /* Distance OK, see if the molecule is not one part of the 00287 * input, and if we have not already seen it. */ 00288 seen = is_in_lst_vert(neigh, nb_neigh, curvm->id) ; 00289 if(!seen) { 00290 if(nb_neigh >= real_size-1) { 00291 real_size *= 2 ; 00292 neigh = (s_vvertice**)my_realloc(neigh, sizeof(s_vvertice)*real_size) ; 00293 } 00294 neigh[nb_neigh] = curvm ; 00295 nb_neigh ++ ; 00296 } 00297 } 00298 } 00299 } 00300 00301 ntest_x += 1 ; 00302 } 00303 } 00304 00305 *nneigh = nb_neigh ; 00306 free_s_vsort(lsort) ; 00307 00308 return neigh ; 00309 }