00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #include "../headers/check.h"
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 int main(void)
00069 {
00070 fprintf(stdout, "\n*** TESTING FPOCKET PACKAGE ***\n") ;
00071 int nfailure = check_fparams() ;
00072
00073 nfailure += check_pdb_reader() ;
00074 nfailure += check_fpocket () ;
00075
00076 fprintf(stdout, "\n*** TESTING ENDS WITH %d FAILURES ***\n", nfailure) ;
00077
00078 return (EXIT_SUCCESS) ;
00079 }
00080
00081 int check_qhull(void)
00082 {
00083 fprintf(stdout, "\n--> TESTING QHULL INSTALLATION <--\n") ;
00084 fprintf(stdout, " IS QVORONOI HERE ............... ") ;
00085 int status = system("qvoronoi > /dev/null") ;
00086 if (status != 0) {
00087 fprintf(stdout, "NO -> FPOCKET CANNOT BE TESTED\n") ;
00088 status = 1 ;
00089 }
00090 else{
00091 fprintf(stdout, "YES\n") ;
00092 }
00093
00094 return status ;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 int check_fpocket (void)
00106 {
00107 fprintf(stdout, "\n--> TESTING FPOCKET ALGORITHM <--\n") ;
00108
00109 int N = 3, i = 0, nfail = 0 ;
00110 char targs[][100] = {"fpocket", "-f", "sample/3LKF.pdb"} ;
00111
00112 char **args = my_malloc(N*sizeof(char*)) ;
00113 for(i = 0 ; i < N ; i++) {
00114 args[i] = my_malloc(sizeof(char)*strlen(targs[i])) ;
00115 strcpy(args[i], targs[i]) ;
00116 }
00117
00118
00119 fprintf(stdout, " PARSING COMMAND LINE ........... ") ;
00120 s_fparams *params = get_fpocket_args(N, args) ;
00121 if(!params) {
00122 fprintf(stdout, "FAILED \n") ;
00123 return 1 ;
00124 }
00125 fprintf(stdout, "OK \n") ;
00126
00127 fprintf(stdout, " OPENING PDB FILE................ ") ;
00128 s_pdb *pdb = rpdb_open(params->pdb_path, NULL, M_DONT_KEEP_LIG) ;
00129 s_pdb *pdb_w_lig = rpdb_open(params->pdb_path, NULL, M_KEEP_LIG) ;
00130
00131 if(pdb) {
00132
00133 fprintf(stdout, "OK \n") ;
00134 fprintf(stdout, " READING PDB FILE ............... ") ;
00135 rpdb_read(pdb, NULL, M_DONT_KEEP_LIG) ;
00136 rpdb_read(pdb_w_lig, NULL, M_KEEP_LIG) ;
00137 fprintf(stdout, "OK \n") ;
00138
00139 fprintf(stdout, " RUNNING FPOCKET ................ ") ;
00140 c_lst_pockets *pockets = search_pocket(pdb, params,pdb_w_lig);
00141 if(pockets && pockets->n_pockets > 0) {
00142 fprintf(stdout, "OK \n") ;
00143 fprintf(stdout, " WRITING FPOCKET OUTPUT ......... ") ;
00144 write_out_fpocket(pockets, pdb, params->pdb_path);
00145 fprintf(stdout, "OK \n") ;
00146 c_lst_pocket_free(pockets) ;
00147 }
00148 else {
00149 nfail++ ;
00150 fprintf(stdout, "NO POCKET FOUND\n") ;
00151 }
00152 }
00153 else {
00154 nfail++ ;
00155 fprintf(stdout, "FAILED (%s) \n", params->pdb_path) ;
00156 }
00157
00158 for(i = 0 ; i < N ; i++) my_free(args[i]) ;
00159 my_free(args) ;
00160 free_fparams(params) ;
00161
00162 return nfail ;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 int check_fparams(void)
00174 {
00175 fprintf(stdout, "\n--> TESTING FPOCKET PARAMETERS <--\n") ;
00176
00177 int N = 21 ;
00178 int i ;
00179 char targs[][100] = { "fpocket",
00180 "-f", "sample/3LKF.pdb",
00181 "-m", "3.1",
00182 "-M", "6.1",
00183 "-A", "2",
00184 "-D", "1.5",
00185 "-s", "4.0",
00186 "-n", "5",
00187 "-i", "1000",
00188 "-r", "10.0",
00189 "-p", "0.0001"} ;
00190
00191 char **args = my_malloc(N*sizeof(char*)) ;
00192 for(i = 0 ; i < N ; i++) {
00193 args[i] = my_malloc(sizeof(char)*strlen(targs[i])) ;
00194 strcpy(args[i], targs[i]) ;
00195 }
00196
00197
00198 fprintf(stdout, " PARSING COMMAND LINE ........... ") ;
00199 s_fparams *params = get_fpocket_args(N, (char**)args) ;
00200 if(!params) {
00201 fprintf(stdout, "FAILED \n") ;
00202 return 1 ;
00203 }
00204 fprintf(stdout, "OK \n") ;
00205
00206 int nfails = 0 ;
00207 if(strcmp(args[2], params->pdb_path) == 0)
00208 fprintf(stdout, " TEST FPARAM f .................. OK \n") ;
00209 else {
00210 nfails ++ ;
00211 fprintf(stdout, " TEST FPARAM f .................. FAILED \n") ;
00212 }
00213
00214 if( params->asph_min_size <= atof(args[4])+0.001
00215 && params->asph_min_size >= atof(args[4])-0.001)
00216 fprintf(stdout, " TEST FPARAM m .................. OK \n") ;
00217 else{
00218 nfails ++ ;
00219 fprintf(stdout, " TEST FPARAM m .................. FAILED \n") ;
00220 }
00221
00222 if( params->asph_max_size <= atof(args[6])+0.001
00223 && params->asph_max_size >= atof(args[6])-0.001)
00224 fprintf(stdout, " TEST FPARAM M .................. OK \n") ;
00225 else{
00226 nfails ++ ;
00227 fprintf(stdout, " TEST FPARAM M .................. FAILED \n") ;
00228 }
00229
00230 if(atoi(args[8]) == params->min_apol_neigh)
00231 fprintf(stdout, " TEST FPARAM A .................. OK \n") ;
00232 else{
00233 nfails ++ ;
00234 fprintf(stdout, " TEST FPARAM A .................. FAILED \n") ;
00235 }
00236
00237 if( atof(args[10]) <= params->clust_max_dist + 0.001 &&
00238 atof(args[10]) >= params->clust_max_dist - 0.001)
00239 fprintf(stdout, " TEST FPARAM D .................. OK \n") ;
00240 else{
00241 nfails ++ ;
00242 fprintf(stdout, " TEST FPARAM D .................. FAILED \n") ;
00243 }
00244
00245 if( atof(args[12]) <= params->sl_clust_max_dist + 0.001 &&
00246 atof(args[12]) >= params->sl_clust_max_dist - 0.001)
00247 fprintf(stdout, " TEST FPARAM S .................. OK \n") ;
00248 else{
00249 nfails ++ ;
00250 fprintf(stdout, " TEST FPARAM S .................. FAILED \n") ;
00251 }
00252
00253 if(atoi(args[14]) == params->sl_clust_min_nneigh)
00254 fprintf(stdout, " TEST FPARAM n .................. OK \n") ;
00255 else{
00256 nfails ++ ;
00257 fprintf(stdout, " TEST FPARAM n .................. FAILED \n") ;
00258 }
00259
00260 if(atoi(args[16]) == params->min_pock_nb_asph)
00261 fprintf(stdout, " TEST FPARAM i .................. OK \n") ;
00262 else{
00263 nfails ++ ;
00264 fprintf(stdout, " TEST FPARAM i .................. FAILED \n") ;
00265 }
00266
00267 if( atof(args[18]) <= params->refine_clust_dist + 0.001 &&
00268 atof(args[18]) >= params->refine_clust_dist - 0.001)
00269 fprintf(stdout, " TEST FPARAM r .................. OK \n") ;
00270 else{
00271 nfails ++ ;
00272 fprintf(stdout, " TEST FPARAM r .................. FAILED \n") ;
00273 }
00274
00275 if( atof(args[20]) <= params->refine_min_apolar_asphere_prop + 0.001 &&
00276 atof(args[20]) >= params->refine_min_apolar_asphere_prop - 0.001)
00277 fprintf(stdout, " TEST FPARAM p .................. OK \n") ;
00278 else{
00279 nfails ++ ;
00280 fprintf(stdout, " TEST FPARAM p .................. FAILED \n") ;
00281 }
00282
00283 for(i = 0 ; i < N ; i++) my_free(args[i]) ;
00284 my_free(args) ;
00285
00286 return nfails ;
00287 }
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 int check_pdb_reader(void)
00298 {
00299 int nfails = 0 ;
00300
00301 fprintf(stdout, "\n--> TESTING PDB READER <--\n") ;
00302
00303
00304 nfails += check_is_valid_element() ;
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 char test_case1[] = "ATOM 1 N BALA A 1 11.104 6.134 -6.504 1.00 0.00 N " ;
00321 test_pdb_line( test_case1, "ATOM", 1, "N", 'B', 'A', 1, ' ',
00322 11.104, 6.134, -6.504, 1.0, 0.0, "N", 0, 1) ;
00323
00324 char test_case2[] = "ATOM 2 CA ALA A 1 11.639 6.071 -5.147 1.00 0.00 C-1" ;
00325 test_pdb_line( test_case2, "ATOM", 2, "CA", ' ', 'A', 1, ' ',
00326 11.639, 6.071, -5.147, 1.0, 0.0, "C", -1, 2) ;
00327
00328 return nfails ;
00329
00330 }
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 void test_pdb_line( char test_case[], const char entry[], int id, const char name[],
00341 char aloc, char chain, int resid, char insert,
00342 float x, float y, float z, float occ, float bfactor,
00343 const char symbol[], int charge, int N)
00344 {
00345
00346
00347
00348 s_atm *atom = my_calloc(1, sizeof(s_atm)) ;
00349 load_pdb_line(atom, test_case) ;
00350
00351 fprintf(stdout, "\n TEST PDB READER (%d) ............ \n", N) ;
00352
00353 fprintf(stdout, " *TEST PDB READER (ENTRY) ..... ") ;
00354 if( strcmp(atom->type, entry) == 0) fprintf(stdout, "OK \n") ;
00355 else fprintf(stdout, "FAILED (%s VS %s)\n", atom->type, entry) ;
00356
00357
00358 fprintf(stdout, " *TEST PDB READER (ID) ........ ") ;
00359 if(atom->id == id) fprintf(stdout, "OK \n") ;
00360 else fprintf(stdout, "FAILED (%d VS %d)\n", atom->id, id) ;
00361
00362 fprintf(stdout, " *TEST PDB READER (NAME) ...... ") ;
00363 if(strcmp(atom->name, name) == 0) fprintf(stdout, "OK \n") ;
00364 else fprintf(stdout, "FAILED (%s VS %s)\n", atom->name, name) ;
00365
00366 fprintf(stdout, " *TEST PDB READER (ALTLOC) .... ") ;
00367 if(atom->pdb_aloc == aloc) fprintf(stdout, "OK \n") ;
00368 else fprintf(stdout, "FAILED (%c VS %c)\n", atom->pdb_aloc, aloc) ;
00369
00370 fprintf(stdout, " *TEST PDB READER (CHAIN) ..... ") ;
00371 if(atom->chain[0] == chain) fprintf(stdout, "OK \n") ;
00372 else fprintf(stdout, "FAILED (%c VS %c)\n", atom->chain[0], chain) ;
00373
00374 fprintf(stdout, " *TEST PDB READER (RESID) ..... ") ;
00375 if(atom->res_id == resid) fprintf(stdout, "OK \n") ;
00376 else fprintf(stdout, "FAILED (%d VS %d)\n", atom->res_id , resid) ;
00377
00378 fprintf(stdout, " *TEST PDB READER (INSERT) .... ") ;
00379 if(atom->pdb_insert == insert) fprintf(stdout, "OK \n") ;
00380 else fprintf(stdout, "FAILED (%c VS %c)\n", atom->pdb_insert, insert) ;
00381
00382 fprintf(stdout, " *TEST PDB READER (X) ......... ") ;
00383 if((atom->x < x+0.001 && atom->x > x-0.001)) fprintf(stdout, "OK \n") ;
00384 else fprintf(stdout, "FAILED (%.2f VS %.2f)\n", atom->x, x) ;
00385
00386 fprintf(stdout, " *TEST PDB READER (Y) ......... ") ;
00387 if((atom->y < y+0.001 && atom->y > y-0.001)) fprintf(stdout, "OK \n") ;
00388 else fprintf(stdout, "FAILED (%.2f VS %.2f)\n", atom->y, y) ;
00389
00390 fprintf(stdout, " *TEST PDB READER (Z) ......... ") ;
00391 if((atom->z < z+0.001 && atom->z > z-0.001)) fprintf(stdout, "OK \n") ;
00392 else fprintf(stdout, "FAILED (%.2f VS %.2f)\n", atom->z, z) ;
00393
00394 fprintf(stdout, " *TEST PDB READER (OCCUPANCY) . ") ;
00395 if((atom->occupancy < occ+0.001 && atom->occupancy > occ-0.001)) fprintf(stdout, "OK \n") ;
00396 else fprintf(stdout, "FAILED (%.2f VS %.2f)\n", atom->occupancy, occ) ;
00397
00398 fprintf(stdout, " *TEST PDB READER (BFACTOR) ... ") ;
00399 if((atom->bfactor < bfactor+0.001 && atom->bfactor > bfactor-0.001)) fprintf(stdout, "OK \n") ;
00400 else fprintf(stdout, "FAILED (%.2f VS %.2f)\n", atom->bfactor, bfactor) ;
00401
00402 fprintf(stdout, " *TEST PDB READER (SYMBOL) .... ") ;
00403 if(strcmp(atom->symbol, symbol) == 0) fprintf(stdout, "OK \n") ;
00404 else fprintf(stdout, "FAILED (%s VS %s)\n", atom->symbol, symbol) ;
00405
00406 fprintf(stdout, " *TEST PDB READER (CHARGE) .... ") ;
00407 if(atom->charge == charge) fprintf(stdout, "OK \n") ;
00408 else fprintf(stdout, "FAILED (%d VS %d)\n", atom->charge, charge) ;
00409
00410 my_free(atom) ;
00411 }
00412
00413
00414 void load_pdb_line(s_atm *atom, char *line)
00415 {
00416
00417 int guess_flag=0;
00418 rpdb_extract_pdb_atom(line, atom->type, &(atom->id),
00419 atom->name, &(atom->pdb_aloc), atom->res_name,
00420 atom->chain, &(atom->res_id), &(atom->pdb_insert),
00421 &(atom->x), &(atom->y), &(atom->z),
00422 &(atom->occupancy), &(atom->bfactor), atom->symbol,
00423 &(atom->charge),&guess_flag) ;
00424
00425 str_trim(atom->type) ;
00426 str_trim(atom->name) ;
00427 str_trim(atom->chain) ;
00428 str_trim(atom->symbol) ;
00429 }
00430
00431 int check_is_valid_element(void)
00432 {
00433 int nfails = 0 ;
00434
00435
00436 fprintf(stdout, " TEST ELEMENT COMPARATOR (1) .... ") ;
00437 int idx1 = is_valid_element("He", 1) ;
00438 int idx2 = is_valid_element("He", 0) ;
00439 int idx3 = is_valid_element("he", 1) ;
00440 int idx4 = is_valid_element("he", 0) ;
00441
00442 if(idx1 != 2 || idx2 != 2 || idx3 != 2 || idx4 != -1) {
00443 nfails ++ ;
00444 fprintf(stdout, "FAILED \n") ;
00445 }
00446 else fprintf(stdout, "OK \n") ;
00447
00448
00449 fprintf(stdout, " TEST ELEMENT COMPARATOR (2) .... ") ;
00450 int idx5 = is_valid_element("Fe ", 1) ;
00451 int idx6 = is_valid_element(" Fe ", 1) ;
00452 int idx7 = is_valid_element(" S", 1) ;
00453 int idx8 = is_valid_element(" S ", 1) ;
00454 if(idx5 == -1 || idx6 == -1 || idx7 == -1 || idx8 == -1) {
00455 nfails ++ ;
00456 fprintf(stdout, "FAILED \n") ;
00457 }
00458 else fprintf(stdout, "OK \n") ;
00459
00460
00461 fprintf(stdout, " TEST ELEMENT COMPARATOR (3) .... ") ;
00462 int idx9 = is_valid_element(" sdzqqs ", 1) ;
00463 int idx10 = is_valid_element(" 92 ", 1) ;
00464
00465 if(idx9 != -1 || idx10 != -1) {
00466 nfails ++ ;
00467 fprintf(stdout, "FAILED \n") ;
00468 }
00469 else fprintf(stdout, "OK \n") ;
00470
00471 return nfails ;
00472 }