#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "pocket.h"
Go to the source code of this file.
Defines | |
#define | M_VOLUME_SORT_FUNCT &compare_pockets_volume |
#define | M_SCORE_SORT_FUNCT &compare_pockets_score |
#define | M_NASPH_SORT_FUNCT &compare_pockets_nasph |
Functions | |
void | sort_pockets (c_lst_pockets *pockets, int(*fcmp)(const node_pocket *, const node_pocket *)) |
int | compare_pockets_nasph (const node_pocket *p1, const node_pocket *p2) |
int | compare_pockets_volume (const node_pocket *p1, const node_pocket *p2) |
int | compare_pockets_score (const node_pocket *p1, const node_pocket *p2) |
int | compare_pockets_corresp (const node_pocket *p1, const node_pocket *p2) |
int | compare_pockets_vol_corresp (const node_pocket *p1, const node_pocket *p2) |
#define M_NASPH_SORT_FUNCT &compare_pockets_nasph |
Definition at line 60 of file psorting.h.
#define M_SCORE_SORT_FUNCT &compare_pockets_score |
#define M_VOLUME_SORT_FUNCT &compare_pockets_volume |
Definition at line 58 of file psorting.h.
int compare_pockets_corresp | ( | const node_pocket * | p1, | |
const node_pocket * | p2 | |||
) |
## FUNCTION: compare_pockets_corresp
## SPECIFICATION: Function comparing two pocket on there correspondance with the ligan (for the test programm). Uses this for quicksort, orwhatever you want...
## PARAMETRES: @ const node_pocket *p1: Pocket 1 @ const node_pocket *p2: Pocket 2
## RETURN: 1 if the correspondance of p2 is greater than the correspondance of p1, -1 else.
Definition at line 273 of file psorting.c.
References s_pocket::ovlp, and node_pocket::pocket.
int compare_pockets_nasph | ( | const node_pocket * | p1, | |
const node_pocket * | p2 | |||
) |
## FUNCTION: compare_pockets_nasph
## SPECIFICATION: Function comparing two pocket on there number of alpha spheres. Uses this for quicksort, or whatever you want...
## PARAMETRES: @ const node_pocket *p1: Pocket 1 @ const node_pocket *p2: Pocket 2
## RETURN:.
Definition at line 206 of file psorting.c.
References s_desc::nb_asph, s_pocket::pdesc, and node_pocket::pocket.
00207 { 00208 if(p1->pocket->pdesc->nb_asph < p2->pocket->pdesc->nb_asph) return 1 ; 00209 else return -1 ; 00210 }
int compare_pockets_score | ( | const node_pocket * | p1, | |
const node_pocket * | p2 | |||
) |
## FUNCTION: compare_pockets_score
## SPECIFICATION: Function comparing two pocket on there score. Uses this for quicksort, or whatever you want...
## PARAMETRES: @ const node_pocket *p1: Pocket 1 @ const node_pocket *p2: Pocket 2
## RETURN: 1 if the score of p2 is greater than the score of p1, -1 else.
Definition at line 251 of file psorting.c.
References node_pocket::pocket, and s_pocket::score.
int compare_pockets_vol_corresp | ( | const node_pocket * | p1, | |
const node_pocket * | p2 | |||
) |
## FUNCTION: compare_pockets_vol_corresp
## SPECIFICATION: Function comparing two pocket on there volume correspondance with the ligan (for the test programm). Uses this for quicksort, orwhatever you want...
## PARAMETRES: @ const node_pocket *p1: Pocket 1 @ const node_pocket *p2: Pocket 2
## RETURN: 1 if the volume correspondance of p2 is greater than the volume correspondance of p1, -1 else.
Definition at line 296 of file psorting.c.
References node_pocket::pocket, and s_pocket::vol_corresp.
00297 { 00298 if(p1->pocket->vol_corresp < p2->pocket->vol_corresp) return 1 ; 00299 else return -1 ; 00300 }
int compare_pockets_volume | ( | const node_pocket * | p1, | |
const node_pocket * | p2 | |||
) |
## FUNCTION: compare_pockets_volume
## SPECIFICATION: Function comparing two pocket on there volume. Uses this for quicksort, or whatever you want...
## PARAMETRES: @ const node_pocket *p1: Pocket 1 @ const node_pocket *p2: Pocket 2
## RETURN: 1 if the volume of p2 is greater than the volume of p1, -1 else.
Definition at line 229 of file psorting.c.
References s_pocket::pdesc, node_pocket::pocket, and s_desc::volume.
00230 { 00231 if(p1->pocket->pdesc->volume < p2->pocket->pdesc->volume) return 1 ; 00232 else return -1 ; 00233 }
void sort_pockets | ( | c_lst_pockets * | pockets, | |
int(*)(const node_pocket *, const node_pocket *) | fcmp | |||
) |
## FUNCTION: sort_pockets
## SPECIFICATION: Top function used to sort pockets. First we copy the chained list of pockets in a tab to make use of indices (for the quick sort algorithm), and then we will sort this tab, and update in the same time the chained list.
Finally, the given chained list will be modified and sorted using the function given in argument.
## PARAMETRES: @ c_lst_pockets *pockets: The list of pockets that will be updated @ int (*fcmp)(const node_pocket*, const node_pocket*): Comparison function
## RETURN:
Definition at line 87 of file psorting.c.
References c_lst_pockets::first, my_calloc(), my_free(), c_lst_pockets::n_pockets, node_pocket::next, and pock_qsort_rec().
Referenced by search_pocket().
00089 { 00090 size_t npock = 0 ; 00091 node_pocket **pocks = (node_pocket **)my_calloc(pockets->n_pockets, sizeof(node_pocket*)) ; 00092 node_pocket *cur = pockets->first ; 00093 00094 while(cur && npock < pockets->n_pockets) { 00095 pocks[npock] = cur ; 00096 cur = cur->next ; 00097 npock++ ; 00098 } 00099 pock_qsort_rec(pockets, pocks, 0, npock-1, fcmp) ; 00100 00101 my_free(pocks) ; 00102 }