#include "../headers/mdparams.h"
Go to the source code of this file.
Functions | |
s_mdparams * | init_def_mdparams (void) |
s_mdparams * | get_mdpocket_args (int nargs, char **args) |
int | add_list_snapshots (char *str_list_file, s_mdparams *par) |
int | add_snapshot (char *snapbuf, s_mdparams *par) |
void | print_mdparams (s_mdparams *p, FILE *f) |
void | print_mdpocket_usage (FILE *f) |
void | free_mdparams (s_mdparams *p) |
int add_list_snapshots | ( | char * | str_list_file, | |
s_mdparams * | par | |||
) |
## FUNCTION: add_list_snapshots
## SPECIFICATION: Load a list of snapshot pdb file path. This file should have the following format:
snapshot_pdb_file snapshot_pdb_file2 snapshot_pdb_file3 (...)
Each snapshot file will be stored in the parameters structure.
## PARAMETRES: @ char *str_list_file : Path of the file containing all data @ s_mdparams *par : Structures that stores all thoses files
## RETURN: int: Number of file read.
Definition at line 244 of file mdparams.c.
References add_snapshot(), M_MAX_PDB_NAME_LEN, and s_mdparams::nfiles.
Referenced by get_mdpocket_args().
00245 { 00246 FILE *f; 00247 int n, 00248 nread = 0, 00249 status ; 00250 00251 char buf[M_MAX_PDB_NAME_LEN*2 + 6], 00252 snapbuf[M_MAX_PDB_NAME_LEN]; 00253 00254 /* Loading data. */ 00255 f = fopen(str_list_file, "r") ; 00256 /* 00257 printf(str_list_file); 00258 */ 00259 if(f) { 00260 while(fgets(buf, 210, f)) { 00261 /* 00262 printf("B: %s\n" , buf); 00263 */ 00264 n = par->nfiles ; 00265 status = sscanf(buf, "%s", snapbuf) ; 00266 if(status < 1) { 00267 00268 fprintf(stderr, "! Skipping row '%s' with bad format (status %d).\n", 00269 buf, status) ; 00270 } 00271 else { 00272 nread += add_snapshot(snapbuf, par) ; 00273 } 00274 00275 } 00276 } 00277 else { 00278 fprintf(stderr, "! File %s doesn't exists\n", str_list_file) ; 00279 } 00280 fclose(f); 00281 return nread ; 00282 }
int add_snapshot | ( | char * | snapbuf, | |
s_mdparams * | par | |||
) |
## FUNCTION: add_snapshot
## SPECIFICATION: Add a set of data to the list of set of data in the parameters. this function is used for the mdpocket program only.
The function will try to open the file, and data will be stored only if the file exists, and if the name of the ligand is valid.
## PARAMETERS: @ char *snapbuf : The snapshots path @ s_mdparams *par: The structure than contains parameters.
## RETURN: int: 1 if everything is OK, 0 if not.
Definition at line 303 of file mdparams.c.
References fopen_pdb_check_case(), s_mdparams::fsnapshot, my_malloc(), my_realloc(), and s_mdparams::nfiles.
Referenced by add_list_snapshots().
00304 { 00305 int nm1 ; 00306 00307 FILE *f = fopen_pdb_check_case(snapbuf, "r") ; 00308 if(f) { 00309 nm1 = par->nfiles ; 00310 par->nfiles += 1 ; 00311 00312 00313 par->fsnapshot = (char**) my_realloc(par->fsnapshot, (par->nfiles)*sizeof(char*)) ; 00314 00315 par->fsnapshot[nm1] = (char *)my_malloc((strlen(snapbuf)+1)*sizeof(char)) ; 00316 00317 strcpy(par->fsnapshot[nm1], snapbuf) ; 00318 00319 fclose(f) ; 00320 00321 } 00322 else { 00323 fprintf(stdout, "! The pdb file '%s' doesn't exists.\n", snapbuf) ; 00324 return 0 ; 00325 } 00326 00327 return 1 ; 00328 }
void free_mdparams | ( | s_mdparams * | p | ) |
## FUNCTION: free_params
## SPECIFICATION: Free parameters
## PARAMETRES: @ s_mdparams *p: Pointer to the structure to free
## RETURN: void
Definition at line 397 of file mdparams.c.
References s_mdparams::f_densdx, s_mdparams::f_desc, s_mdparams::f_freqdx, s_mdparams::f_pqr, s_mdparams::fpar, free_fparams(), s_mdparams::fsnapshot, and my_free().
Referenced by get_mdpocket_args(), and main().
00398 { 00399 if(p) { 00400 00401 if(p->fsnapshot) { 00402 my_free(p->fsnapshot); 00403 p->fsnapshot = NULL; 00404 } 00405 if(p->f_pqr) { 00406 my_free(p->f_pqr); 00407 p->f_pqr = NULL; 00408 } 00409 if(p->f_densdx) { 00410 my_free(p->f_densdx); 00411 p->f_densdx = NULL ; 00412 } 00413 if(p->f_freqdx) { 00414 my_free(p->f_freqdx); 00415 p->f_freqdx = NULL ; 00416 } 00417 if(p->f_desc) { 00418 my_free(p->f_desc); 00419 p->f_desc = NULL; 00420 } 00421 free_fparams(p->fpar); 00422 my_free(p) ; 00423 } 00424 }
s_mdparams* get_mdpocket_args | ( | int | nargs, | |
char ** | args | |||
) |
## FUNCTION: get_dpocket_args
## SPECIFICATION: This function analyse the user's command line and parse it to store parameters for the descriptor calculator programm.
## PARAMETRES: @ int nargs : Number of arguments @ char **args : Arguments of main program
## RETURN: s_mdparams*: Pointer to parameters
Definition at line 123 of file mdparams.c.
References add_list_snapshots(), s_mdparams::bfact_on_all, s_mdparams::f_apdb, s_mdparams::f_appdb, s_mdparams::f_densdx, s_mdparams::f_densiso, s_mdparams::f_desc, s_mdparams::f_freqdx, s_mdparams::f_freqiso, s_mdparams::f_ppdb, s_mdparams::f_pqr, s_mdparams::flag_scoring, s_mdparams::fpar, free_mdparams(), s_mdparams::fwantedpocket, get_fpocket_args(), init_def_mdparams(), is_fpocket_opt(), M_MAX_FILE_NAME_LENGTH, M_MDPAR_INPUT_FILE, M_MDPAR_INPUT_FILE2, M_MDPAR_OUTPUT_ALL_SNAPSHOTS, M_MDPAR_OUTPUT_FILE, M_MDPAR_SCORING_MODE, print_mdpocket_usage(), and remove_ext().
Referenced by main().
00124 { 00125 int i, 00126 status = 0, 00127 nstats = 0, 00128 npdb=0; 00129 00130 char *str_list_file = NULL ; 00131 00132 s_mdparams *par = init_def_mdparams() ; 00133 par->fpar = get_fpocket_args(nargs, args) ; 00134 00135 /* Read arguments by flags */ 00136 for (i = 1; i < nargs; i++) { 00137 if (strlen(args[i]) == 2 && args[i][0] == '-') { 00138 switch (args[i][1]) { 00139 case M_MDPAR_OUTPUT_FILE : 00140 if(nstats >= 1) fprintf(stdout, "! More than one single file for the stats output file has been given. Ignoring this one.\n") ; 00141 else { 00142 if(i < nargs-1) { 00143 if(strlen(args[++i]) < M_MAX_FILE_NAME_LENGTH) { 00144 remove_ext(args[i]) ; 00145 sprintf(par->f_pqr, "%s.pqr", args[i]) ; 00146 sprintf(par->f_freqdx, "%s.dx", args[i]) ; 00147 sprintf(par->f_densdx, "%s.dx", args[i]) ; 00148 sprintf(par->f_freqiso, "%s_freq_iso_0_5.pdb", args[i]) ; 00149 sprintf(par->f_densiso, "%s_dens_iso_8.pdb", args[i]) ; 00150 sprintf(par->f_desc, "%s_descriptors.txt", args[i]) ; 00151 sprintf(par->f_ppdb, "%s_mdpocket.pdb", args[i]) ; 00152 sprintf(par->f_apdb, "%s_mdpocket_atoms.pdb", args[i]) ; 00153 sprintf(par->f_appdb, "%s_all_atom_pdensities.pdb", args[i]) ; 00154 } 00155 else fprintf(stdout, "! Output file name is too long... Keeping default.") ; 00156 } 00157 else { 00158 fprintf(stdout, "! Invalid output file name argument missing.\n") ; 00159 status += 1 ; 00160 } 00161 } 00162 break ; 00163 00164 case M_MDPAR_INPUT_FILE : 00165 if(i < nargs-1) str_list_file = args[++i] ; 00166 else { 00167 fprintf(stdout, "! Input file name argument missing.\n") ; 00168 status += 1 ; 00169 } 00170 break ; 00171 case M_MDPAR_INPUT_FILE2 : 00172 if(npdb >= 1) fprintf(stderr, 00173 "! Only first input pdb will be used.\n") ; 00174 else { 00175 strcpy(par->fwantedpocket, args[++i]) ; npdb++ ; 00176 } 00177 break ; 00178 case M_MDPAR_SCORING_MODE : 00179 par->flag_scoring=1; 00180 break; 00181 case M_MDPAR_OUTPUT_ALL_SNAPSHOTS : 00182 par->bfact_on_all=1; 00183 break; 00184 default: 00185 // Check fpocket parameters! 00186 if(!is_fpocket_opt(args[i][1])) { 00187 fprintf(stdout, "> Unknown option '%s'. Ignoring it.\n", 00188 args[i]) ; 00189 } 00190 break ; 00191 } 00192 } 00193 } 00194 00195 if(status > 0) { 00196 free_mdparams(par) ; 00197 par = NULL ; 00198 print_mdpocket_usage(stdout); 00199 } 00200 else { 00201 if(str_list_file) { 00202 int res = add_list_snapshots(str_list_file, par) ; 00203 if(res <= 0) { 00204 fprintf(stdout, "! No data has been read.\n") ; 00205 free_mdparams(par) ; 00206 par = NULL ; 00207 print_mdpocket_usage(stdout); 00208 } 00209 } 00210 else { 00211 fprintf(stdout, "! No input file given... Try again :).\n") ; 00212 free_mdparams(par) ; 00213 par = NULL ; 00214 print_mdpocket_usage(stdout); 00215 } 00216 } 00217 00218 return par; 00219 }
s_mdparams* init_def_mdparams | ( | void | ) |
## GENERAL INFORMATION ## ## FILE mdparams.c ## AUTHORS P. Schmidtke and V. Le Guilloux ## LAST MODIFIED 28-11-08 ## ## SPECIFICATIONS ## ## Handle parameters (parse the command line and sore values) ## for the mdpocket programm. ## ## MODIFICATIONS HISTORY ## ## 28-11-08 (v) Comments UTD + relooking ## 27-11-08 (v) Minor Relooking ## 01-04-08 (v) Added comments and creation of history ## 01-01-08 (vp) Created (random date...) ## ## TODO or SUGGESTIONS ## ## (v) Check and update if necessary comments of each function!! ## (v) Review the main function and handle all possible crashes. ## 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/>. ## FUNCTION: init_def_mdparams
## SPECIFICATION: Initialisation of default parameters.
## PARAMETRES: void
## RETURN: s_mdparams*: Pointer to allocated paramers.
Definition at line 76 of file mdparams.c.
References s_mdparams::bfact_on_all, s_mdparams::f_apdb, s_mdparams::f_appdb, s_mdparams::f_densdx, s_mdparams::f_densiso, s_mdparams::f_desc, s_mdparams::f_freqdx, s_mdparams::f_freqiso, s_mdparams::f_ppdb, s_mdparams::f_pqr, s_mdparams::flag_scoring, s_mdparams::fsnapshot, s_mdparams::fwantedpocket, M_MAX_FILE_NAME_LENGTH, M_MDP_OUTPUT_FILE1_DEFAULT, M_MDP_OUTPUT_FILE2_DEFAULT, M_MDP_OUTPUT_FILE3_DEFAULT, M_MDP_OUTPUT_FILE4_DEFAULT, M_MDP_OUTPUT_FILE5_DEFAULT, M_MDP_OUTPUT_FILE6_DEFAULT, M_MDP_OUTPUT_FILE7_DEFAULT, M_MDP_OUTPUT_FILE8_DEFAULT, M_MDP_OUTPUT_FILE9_DEFAULT, my_malloc(), and s_mdparams::nfiles.
Referenced by get_mdpocket_args().
00077 { 00078 s_mdparams *par = (s_mdparams*) my_malloc(sizeof(s_mdparams)) ; 00079 00080 par->f_pqr = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00081 par->f_freqdx = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00082 par->f_densdx = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00083 par->f_freqiso = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00084 par->f_densiso = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00085 par->f_desc = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00086 par->f_ppdb = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00087 par->f_apdb = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)) ; 00088 par->f_appdb = (char *)my_malloc(M_MAX_FILE_NAME_LENGTH*sizeof(char)); 00089 strcpy(par->f_pqr, M_MDP_OUTPUT_FILE1_DEFAULT) ; 00090 strcpy(par->f_freqdx, M_MDP_OUTPUT_FILE2_DEFAULT) ; 00091 strcpy(par->f_freqiso, M_MDP_OUTPUT_FILE3_DEFAULT) ; 00092 strcpy(par->f_desc, M_MDP_OUTPUT_FILE4_DEFAULT) ; 00093 strcpy(par->f_ppdb, M_MDP_OUTPUT_FILE5_DEFAULT) ; 00094 strcpy(par->f_apdb, M_MDP_OUTPUT_FILE6_DEFAULT) ; 00095 strcpy(par->f_appdb, M_MDP_OUTPUT_FILE7_DEFAULT); 00096 strcpy(par->f_densdx, M_MDP_OUTPUT_FILE8_DEFAULT) ; 00097 strcpy(par->f_densiso, M_MDP_OUTPUT_FILE9_DEFAULT) ; 00098 par->fsnapshot = NULL ; 00099 par->fwantedpocket[0] = 0 ; 00100 par->nfiles = 0 ; 00101 par->flag_scoring=0; 00102 par->bfact_on_all=0; 00103 00104 return par ; 00105 }
void print_mdparams | ( | s_mdparams * | p, | |
FILE * | f | |||
) |
## FUNCTION: print_mdparams
## SPECIFICATION: Print function, usefull to debug
## PARAMETRES: @ s_mdparams *p : The structure than will contain the parsed parameter @ FILE *f : The file to write in
## RETURN: void
Definition at line 345 of file mdparams.c.
References s_mdparams::fsnapshot, s_mdparams::fwantedpocket, and s_mdparams::nfiles.
Referenced by main().
00346 { 00347 00348 if(p) { 00349 fprintf(f, "==============\nParameters of the program: \n"); 00350 int i ; 00351 for(i = 0 ; i < p->nfiles ; i++) { 00352 fprintf(f, "> Snaphot %d: '%s'\n", i+1, p->fsnapshot[i]) ; 00353 } 00354 fprintf(f, "==============\n"); 00355 if(p->fwantedpocket[0]!=0){ 00356 fprintf(f,"Wanted pocket given in file : %s\n",p->fwantedpocket); 00357 fprintf(f, "==============\n"); 00358 } 00359 } 00360 else fprintf(f, "> No parameters detected\n"); 00361 }
void print_mdpocket_usage | ( | FILE * | f | ) |
## FUNCTION: print_mdparams_usage
## SPECIFICATION: Displaying usage of the programm in the given buffer
## PARAMETRES: @ FILE *f: buffer to print in
## RETURN:
Definition at line 376 of file mdparams.c.
References M_MDP_USAGE.
Referenced by get_mdpocket_args().
00377 { 00378 f = (f == NULL) ? stdout:f ; 00379 00380 fprintf(f, M_MDP_USAGE) ; 00381 }