#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>
#include "fparams.h"
#include "utils.h"
#include "memhandler.h"
Go to the source code of this file.
Data Structures | |
struct | s_tparams |
Defines | |
#define | M_PAR_VALID_INPUT_FILE 'L' |
#define | M_PAR_LIG_NEIG_DIST 'd' |
#define | M_PAR_P_STATS_OUT 'o' |
#define | M_PAR_G_STATS_OUT 'e' |
#define | M_PAR_KEEP_FP_OUTPUT 'k' |
#define | M_STATS_OUTP "stats_p.txt" |
#define | M_STATS_OUTG "stats_g.txt" |
#define | M_MAX_FILE_NAME_LENGTH 300 |
#define | M_LIG_NEIG_DIST 4.0 |
#define | M_TP_USAGE "\\n***** USAGE (tpocket) *****\n\\n\The program needs as input a file containing at each \n\line a pdb file name (apo + complexe), a ligand code \n\(3 letters), all separeted by a tabulation. \n\The format of each line must therefore be: \n\n\{PATH/}APO.pdb {PATH/}HOLO.pdb LIG. \n\n\The ligand code is the resname of the ligand atoms in \n\the pdb file of the HOLO form of the protein. \n\n\See the manual for more information. \n\n\Example of command using default parameters: \n\\t./bin/tpocket -L file_path \n\n\Options: \n\\t-e string : Write global performance to this file \n\\t Default name: ./stats_g.txt. (./stats_g.txt)\n\\t-o string : Write pocket detailed statistics to . \n\\t this file Default name: ./stats_p.txt (./stats_p.txt)\n\\t-d float : Distance criteria for the 2 ways to \n\\t define the actual pocket (4.0) \n\n\Options specific to fpocket are usable too.\n\See the manual/documentation for mor information.\n\***************************\n" |
Functions | |
s_tparams * | init_def_tparams (void) |
s_tparams * | get_tpocket_args (int nargs, char **args) |
int | add_list_data (char *str_list_file, s_tparams *par) |
int | add_prot (char *apo, char *complex, char *ligan, s_tparams *par) |
int | parse_lig_neigh_dist (char *str, s_tparams *p) |
void | free_tparams (s_tparams *p) |
void | print_test_usage (FILE *f) |
void | print_params (s_tparams *p, FILE *f) |
#define M_LIG_NEIG_DIST 4.0 |
#define M_PAR_G_STATS_OUT 'e' |
general output prefix flag
Definition at line 56 of file tparams.h.
Referenced by get_tpocket_args().
#define M_PAR_KEEP_FP_OUTPUT 'k' |
flag to keep the fpocket output
Definition at line 57 of file tparams.h.
Referenced by get_tpocket_args().
#define M_PAR_LIG_NEIG_DIST 'd' |
ligand neighbour distance flag
Definition at line 54 of file tparams.h.
Referenced by get_tpocket_args().
#define M_PAR_P_STATS_OUT 'o' |
output prefix (particular) flag
Definition at line 55 of file tparams.h.
Referenced by get_tpocket_args().
#define M_PAR_VALID_INPUT_FILE 'L' |
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/>. input file flag
Definition at line 53 of file tparams.h.
Referenced by get_tpocket_args().
#define M_STATS_OUTG "stats_g.txt" |
standard general output name
Definition at line 62 of file tparams.h.
Referenced by get_tpocket_args(), and init_def_tparams().
#define M_STATS_OUTP "stats_p.txt" |
standard per pocket output name
Definition at line 61 of file tparams.h.
Referenced by get_tpocket_args(), and init_def_tparams().
#define M_TP_USAGE "\\n***** USAGE (tpocket) *****\n\\n\The program needs as input a file containing at each \n\line a pdb file name (apo + complexe), a ligand code \n\(3 letters), all separeted by a tabulation. \n\The format of each line must therefore be: \n\n\{PATH/}APO.pdb {PATH/}HOLO.pdb LIG. \n\n\The ligand code is the resname of the ligand atoms in \n\the pdb file of the HOLO form of the protein. \n\n\See the manual for more information. \n\n\Example of command using default parameters: \n\\t./bin/tpocket -L file_path \n\n\Options: \n\\t-e string : Write global performance to this file \n\\t Default name: ./stats_g.txt. (./stats_g.txt)\n\\t-o string : Write pocket detailed statistics to . \n\\t this file Default name: ./stats_p.txt (./stats_p.txt)\n\\t-d float : Distance criteria for the 2 ways to \n\\t define the actual pocket (4.0) \n\n\Options specific to fpocket are usable too.\n\See the manual/documentation for mor information.\n\***************************\n" |
output for the tpocket usage
Definition at line 68 of file tparams.h.
Referenced by print_test_usage().
int add_list_data | ( | char * | str_list_file, | |
s_tparams * | par | |||
) |
## FUNCTION: add_list_data
## SPECIFICATION: Load a list of apo-complex-ligand file. This file should have the following format: apo_file complex_file ligan_file
## PARAMETRES: @ char *str_list_file : Path of the file containing all data @ s_tparams *par : Structures that stores all thoses files
## RETURN: int: Number of file read.
Definition at line 243 of file tparams.c.
References add_prot(), M_MAX_PDB_NAME_LEN, and s_tparams::nfiles.
Referenced by get_tpocket_args().
00244 { 00245 FILE *f; 00246 int n, 00247 nread = 0, 00248 status ; 00249 00250 char buf[M_MAX_PDB_NAME_LEN*2 + 6], 00251 apobuf[M_MAX_PDB_NAME_LEN], 00252 complexbuf[M_MAX_PDB_NAME_LEN], 00253 ligbuf[5]; 00254 00255 /* Loading data. */ 00256 f = fopen(str_list_file, "r") ; 00257 if(f) { 00258 while(fgets(buf, 210, f)) { 00259 n = par->nfiles ; 00260 status = sscanf(buf, "%s\t%s\t%s", apobuf, complexbuf, ligbuf) ; 00261 00262 if(strlen(ligbuf) == 1) { 00263 ligbuf [2] = ligbuf[0] ; 00264 ligbuf [0] = ' ' ; 00265 ligbuf [1] = ' ' ; 00266 } 00267 00268 if(status < 3) { 00269 fprintf(stderr, "! Skipping row '%s' with bad format (status %d).\n", buf, status) ; 00270 } 00271 else { 00272 nread += add_prot(apobuf, complexbuf, ligbuf, par) ; 00273 } 00274 } 00275 } 00276 else { 00277 fprintf(stderr, "! File %s doesn't exists\n", str_list_file) ; 00278 } 00279 00280 /* print_params(par, stdout) ; */ 00281 00282 return nread ; 00283 }
int add_prot | ( | char * | apo, | |
char * | complex, | |||
char * | ligan, | |||
s_tparams * | par | |||
) |
## FUNCTION: add_prot
## SPECIFICATION: Add a set of data to the list of set of data in the parameters. this function is used for the tpocket program only.
The function will try to open each file, and data will be stored only if the two files exists, and if the name of the ligand is valid.
## PARAMETERS: @ char *apo : The apo path @ char *complex : The complex path @ char *ligan : The ligand resname: a 4 letter (max!) @ s_tparams *p : The structure than contains parameters.
## RETURN: int: Flag: 1 = ok, 0 : ko
Definition at line 306 of file tparams.c.
References s_tparams::fapo, s_tparams::fcomplex, s_tparams::fligan, fopen_pdb_check_case(), my_malloc(), my_realloc(), and s_tparams::nfiles.
Referenced by add_list_data(), and get_tpocket_args().
00307 { 00308 FILE *f = fopen_pdb_check_case(apo, "r") ; 00309 int nm1, l, i ; 00310 if(f) { 00311 fclose(f) ; 00312 f = fopen_pdb_check_case(complex, "r") ; 00313 if(f) { 00314 l = strlen(ligan) ; 00315 if(ligan && l >= 1) { 00316 00317 for(i = 0 ; i < l ; i++) ligan[i] = toupper(ligan[i]) ; 00318 00319 nm1 = par->nfiles ; 00320 par->nfiles += 1 ; 00321 par->fapo = (char**) my_realloc(par->fapo, (par->nfiles)*sizeof(char*)) ; 00322 par->fligan = (char**) my_realloc(par->fligan, (par->nfiles)*sizeof(char*)) ; 00323 par->fcomplex = (char**) my_realloc(par->fcomplex, (par->nfiles)*sizeof(char*)) ; 00324 00325 par->fapo[nm1] = (char *)my_malloc((strlen(apo)+1)*sizeof(char)) ; 00326 par->fcomplex[nm1] = (char *)my_malloc((strlen(complex)+1)*sizeof(char)) ; 00327 par->fligan[nm1] = (char *)my_malloc((strlen(ligan)+1)*sizeof(char)) ; 00328 00329 strcpy(par->fapo[nm1], apo) ; 00330 strcpy(par->fcomplex[nm1], complex) ; 00331 strcpy(par->fligan[nm1], ligan) ; 00332 00333 fclose(f) ; 00334 } 00335 else { 00336 fprintf(stdout, "! The name given for the ligand is invalid or absent.\n") ; 00337 return 0 ; 00338 } 00339 00340 } 00341 else { 00342 fprintf(stdout, "! The pdb complexe file '%s' doesn't exists.\n", complex) ; 00343 return 0 ; 00344 } 00345 } 00346 else { 00347 /* If the file does not exists, try with upper case */ 00348 fprintf(stdout, "! The pdb apo file '%s' doesn't exists.\n", apo) ; 00349 return 0 ; 00350 } 00351 00352 return 1 ; 00353 }
void free_tparams | ( | s_tparams * | p | ) |
## FUNCTION: free_tparams
## SPECIFICATION: Free parameters
## PARAMETRES: @ s_tparams *p: Pointer to the structure to free
## RETURN: void
Definition at line 397 of file tparams.c.
References s_tparams::fapo, s_tparams::fcomplex, s_tparams::fligan, s_tparams::fpar, free_fparams(), and my_free().
Referenced by get_tpocket_args(), and main().
00398 { 00399 if(p) { 00400 if(p->fapo) { 00401 my_free(p->fapo) ; 00402 p->fapo = NULL ; 00403 } 00404 00405 if(p->fligan) { 00406 my_free(p->fligan) ; 00407 p->fligan = NULL ; 00408 } 00409 00410 if(p->fcomplex) { 00411 my_free(p->fcomplex) ; 00412 p->fcomplex = NULL ; 00413 } 00414 00415 if(p->fpar) { 00416 free_fparams(p->fpar) ; 00417 p->fpar = NULL ; 00418 } 00419 00420 my_free(p) ; 00421 } 00422 }
s_tparams* get_tpocket_args | ( | int | nargs, | |
char ** | args | |||
) |
## FUNCTION: get_tpocket_args
## SPECIFICATION: This function analyse the user's command line and parse it to store parameters for the test programm.
## PARAMETRES: @ int nargs : Number of arguments @ char **args : Arguments of main program
## RETURN: s_tparams*: Pointer to parameters
Definition at line 108 of file tparams.c.
References add_list_data(), add_prot(), s_tparams::fpar, free_tparams(), s_tparams::g_output, get_fpocket_args(), init_def_tparams(), is_fpocket_opt(), s_tparams::keep_fpout, M_MAX_FILE_NAME_LENGTH, M_PAR_G_STATS_OUT, M_PAR_KEEP_FP_OUTPUT, M_PAR_LIG_NEIG_DIST, M_PAR_P_STATS_OUT, M_PAR_VALID_INPUT_FILE, M_STATS_OUTG, M_STATS_OUTP, s_tparams::p_output, parse_lig_neigh_dist(), print_test_usage(), s_tparams::stats_g, and s_tparams::stats_p.
Referenced by main().
00109 { 00110 int i, 00111 status = 0 ; 00112 00113 int nstats = 0; 00114 00115 char *str_lig = NULL, 00116 *str_complex_file = NULL, 00117 *str_apo_file = NULL, 00118 *str_list_file = NULL ; 00119 00120 s_tparams *par = init_def_tparams() ; 00121 par->fpar = get_fpocket_args(nargs, args) ; 00122 00123 if(!par->fpar) { 00124 free_tparams(par) ; 00125 print_test_usage(stdout); 00126 00127 return NULL ; 00128 } 00129 00130 /* Read arguments by flags */ 00131 for (i = 1; i < nargs; i++) { 00132 if (strlen(args[i]) == 2 && args[i][0] == '-' && 00133 (i < (nargs-1) || args[i][1] == M_PAR_KEEP_FP_OUTPUT) ) { 00134 switch (args[i][1]) { 00135 case M_PAR_LIG_NEIG_DIST : 00136 status += parse_lig_neigh_dist(args[++i], par) ; 00137 break ; 00138 case M_PAR_KEEP_FP_OUTPUT : 00139 par->keep_fpout = 1 ; 00140 break ; 00141 00142 case M_PAR_P_STATS_OUT : 00143 if(nstats >= 1) fprintf(stdout, "! More than one single file for the stats output file has been given. Ignoring this one.\n") ; 00144 else { 00145 if(i < nargs-1) { 00146 if(strlen(args[++i]) < M_MAX_FILE_NAME_LENGTH) strcpy(par->p_output, args[i]) ; 00147 else fprintf(stdout, "! Output file name is too long... Keeping default (%s).", M_STATS_OUTP) ; 00148 } 00149 else { 00150 fprintf(stdout, "! Invalid output file name argument missing.\n") ; 00151 status += 1 ; 00152 } 00153 } 00154 break ; 00155 case M_PAR_G_STATS_OUT : 00156 if(nstats >= 1) fprintf(stdout, "! More than one single file for the stats output file has been given. Ignoring this one.\n") ; 00157 else { 00158 if(i < nargs-1) { 00159 if(strlen(args[++i]) < M_MAX_FILE_NAME_LENGTH) strcpy(par->g_output, args[i]) ; 00160 else fprintf(stdout, "! Output file name is too long... Keeping default (%s).", M_STATS_OUTG) ; 00161 } 00162 else { 00163 fprintf(stdout, "! Invalid output file name argument missing.\n") ; 00164 status += 1 ; 00165 } 00166 } 00167 break ; 00168 case M_PAR_VALID_INPUT_FILE : str_list_file = args[++i] ; break ; 00169 default: 00170 // Check fpocket parameters!! 00171 if(!is_fpocket_opt(args[i][1])) { 00172 fprintf(stdout, "> Unknown option '%s'. Ignoring it.\n", 00173 args[i]) ; 00174 } 00175 break ; 00176 } 00177 } 00178 } 00179 00180 if(status > 0) { 00181 free_tparams(par) ; 00182 par = NULL ; 00183 print_test_usage(stdout); 00184 } 00185 else { 00186 if(str_list_file) { 00187 int res = add_list_data(str_list_file, par) ; 00188 if(res <= 0) { 00189 fprintf(stderr, "! No data has been read.\n") ; 00190 free_tparams(par) ; 00191 par = NULL ; 00192 print_test_usage(stdout); 00193 } 00194 else { 00195 strcpy (par->stats_g, M_STATS_OUTG) ; 00196 strcpy (par->stats_p, M_STATS_OUTP) ; 00197 00198 } 00199 } 00200 else { 00201 if(str_lig && str_apo_file && str_complex_file) { 00202 if(add_prot(str_apo_file, str_complex_file, str_lig, par) == 0){ 00203 fprintf(stderr, "! No data has been read.\n") ; 00204 free_tparams(par) ; 00205 par = NULL ; 00206 print_test_usage(stdout); 00207 } 00208 else { 00209 strcpy (par->stats_g, M_STATS_OUTG) ; 00210 strcpy (par->stats_p, M_STATS_OUTP) ; 00211 00212 } 00213 } 00214 else { 00215 fprintf(stdout, "! Argument is missing! \n"); 00216 free_tparams(par) ; 00217 par = NULL ; 00218 print_test_usage(stdout) ; 00219 } 00220 } 00221 } 00222 00223 return par; 00224 }
s_tparams* init_def_tparams | ( | void | ) |
## FUNCTION: s_tparams* init_def_tparams(void)
## SPECIFICATION: Initialisation of default parameters
## PARAMETRES: void
## RETURN: Pointer to allocated paramers.
Definition at line 75 of file tparams.c.
References s_tparams::fapo, s_tparams::fcomplex, s_tparams::fligan, s_tparams::g_output, s_tparams::keep_fpout, s_tparams::lig_neigh_dist, M_LIG_NEIG_DIST, M_MAX_FILE_NAME_LENGTH, M_STATS_OUTG, M_STATS_OUTP, my_malloc(), s_tparams::nfiles, and s_tparams::p_output.
Referenced by get_tpocket_args().
00076 { 00077 s_tparams *par = (s_tparams *)my_malloc(sizeof(s_tparams)) ; 00078 par->p_output = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00079 strcpy(par->p_output, M_STATS_OUTP) ; 00080 par->g_output = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00081 strcpy(par->g_output, M_STATS_OUTG) ; 00082 par->fapo = NULL ; 00083 par->fcomplex = NULL ; 00084 par->fligan = NULL ; 00085 par->nfiles = 0 ; 00086 par->keep_fpout = 0 ; 00087 par->lig_neigh_dist = M_LIG_NEIG_DIST ; 00088 00089 return par ; 00090 }
int parse_lig_neigh_dist | ( | char * | str, | |
s_tparams * | p | |||
) |
## FUNCTION: parse_lig_neigh_dist
## SPECIFICATION: Parsing function for the distance criteria to find ligand neighbours.
## PARAMETERS: @ char *str : The string to parse @ s_fparams *p : The structure than will contain the parsed parameter
## RETURN: int: 0 if the parameter is valid (here a valid float), 1 if not
Definition at line 370 of file tparams.c.
References s_tparams::lig_neigh_dist, M_NO_SIGN, and str_is_float().
Referenced by get_tpocket_args().
00371 { 00372 if(str_is_float(str, M_NO_SIGN)) { 00373 p->lig_neigh_dist = atof(str) ; 00374 } 00375 else { 00376 fprintf(stdout, "! Invalid value (%s) given for distance criteria to define interface atoms.\n", str) ; 00377 return 1 ; 00378 } 00379 00380 return 0 ; 00381 }
void print_params | ( | s_tparams * | p, | |
FILE * | f | |||
) |
## FUNCTION: print_params
## SPECIFICATION: Print function
## PARAMETRES: @ s_tparams *p : Pointer to parameters structure @ FILE *f : Buffer to write in
## RETURN:
Definition at line 458 of file tparams.c.
References s_fparams::asph_max_size, s_fparams::asph_min_size, s_fparams::basic_volume_div, s_fparams::clust_max_dist, s_tparams::fapo, s_tparams::fcomplex, s_tparams::fligan, s_tparams::fpar, s_fparams::min_apol_neigh, s_fparams::nb_mcv_iter, s_tparams::nfiles, s_fparams::refine_clust_dist, s_fparams::refine_min_apolar_asphere_prop, s_fparams::sl_clust_max_dist, and s_fparams::sl_clust_min_nneigh.
00459 { 00460 00461 if(p) { 00462 fprintf(f, "==============\nParameters of the program: \n"); 00463 int i ; 00464 for(i = 0 ; i < p->nfiles ; i++) { 00465 fprintf(f, "> Protein %d: '%s', '%s', '%s'\n", i+1, p->fapo[i], p->fcomplex[i], p->fligan[i]) ; 00466 } 00467 fprintf(f, "> Minimum alpha sphere radius: %f\n", p->fpar->asph_min_size); 00468 fprintf(f, "> Maximum alpha sphere radius: %f\n", p->fpar->asph_max_size); 00469 fprintf(f, "> Minimum number of apolar neighbor: %d\n", p->fpar->min_apol_neigh); 00470 fprintf(f, "> Maximum distance for first clustering algorithm: %f \n", p->fpar->clust_max_dist) ; 00471 fprintf(f, "> Single linkage clustering distance: %f\n", p->fpar->sl_clust_max_dist); 00472 fprintf(f, "> Single linkage clustering neighbor: %d\n", p->fpar->sl_clust_min_nneigh); 00473 fprintf(f, "> Refine clustering distance: %f\n", p->fpar->refine_clust_dist); 00474 fprintf(f, "> Min number of apolar sphere in refine to keep a pocket: %f\n", p->fpar->refine_min_apolar_asphere_prop) ; 00475 fprintf(f, "> Monte carlo iterations: %d\n", p->fpar->nb_mcv_iter); 00476 fprintf(f, "> Basic method for volume calculation: %d\n", p->fpar->basic_volume_div); 00477 fprintf(f, "==============\n"); 00478 } 00479 else fprintf(f, "> No parameters detected\n"); 00480 }
void print_test_usage | ( | FILE * | f | ) |
## FUNCTION: print_test_usage
## SPECIFICATION: Displaying usage of the programm in the given buffer
## PARAMETRES: @ FILE *f: buffer to print in
## RETURN: void
Definition at line 438 of file tparams.c.
References M_TP_USAGE.
Referenced by get_tpocket_args().
00439 { 00440 f = (f == NULL) ? stdout:f ; 00441 fprintf(f, M_TP_USAGE) ; 00442 }