00001
00002 #include "../headers/fpmain.h"
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
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 int main(int argc, char *argv[])
00072 {
00073
00074
00075 s_fparams *params = get_fpocket_args(argc, argv) ;
00076 if(!params->db_run) fprintf(stdout, "***** POCKET HUNTING BEGINS ***** \n") ;
00077
00078 if(params) {
00079 if(params->pdb_lst != NULL) {
00080
00081 int i ;
00082 for (i = 0 ; i < params->npdb ; i++) {
00083
00084 printf("> Protein %d / %d : %s", i, params->npdb,
00085 params->pdb_lst[i]) ;
00086 if(i == params->npdb - 1) fprintf(stdout, "\n") ;
00087 else fprintf(stdout, "\r") ;
00088 fflush(stdout) ;
00089 process_pdb(params->pdb_lst[i], params) ;
00090 }
00091 }
00092 else {
00093 if(params->pdb_path == NULL || strlen(params->pdb_path) <= 0) {
00094 fprintf(stdout, "! Invalid pdb name given.\n");
00095 print_pocket_usage(stdout) ;
00096 }
00097 else {
00098
00099 process_pdb(params->pdb_path, params) ;
00100 }
00101 }
00102
00103 free_fparams(params) ;
00104 }
00105 else {
00106 print_pocket_usage(stdout) ;
00107 }
00108
00109 if(!params->db_run)fprintf(stdout, "***** POCKET HUNTING ENDS ***** \n") ;
00110 free_all() ;
00111
00112 return 0;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 void process_pdb(char *pdbname, s_fparams *params)
00131 {
00132
00133 if(pdbname == NULL) return ;
00134
00135 int len = strlen(pdbname) ;
00136 if(len >= M_MAX_PDB_NAME_LEN || len <= 0) {
00137 fprintf(stderr, "! Invalid length for the pdb file name. (Max: %d, Min 1)\n",
00138 M_MAX_PDB_NAME_LEN) ;
00139 return ;
00140 }
00141
00142
00143 s_pdb *pdb = rpdb_open(pdbname, NULL, M_DONT_KEEP_LIG) ;
00144 s_pdb *pdb_w_lig = rpdb_open(pdbname, NULL, M_KEEP_LIG) ;
00145
00146 if(pdb) {
00147
00148 rpdb_read(pdb, NULL, M_DONT_KEEP_LIG) ;
00149 rpdb_read(pdb_w_lig, NULL, M_KEEP_LIG) ;
00150 c_lst_pockets *pockets = search_pocket(pdb, params,pdb_w_lig);
00151 if(pockets) {
00152
00153 if(params->db_run) {
00154 write_descriptors_DB(pockets,stdout);
00155 write_out_fpocket_DB(pockets, pdb, pdbname);
00156 }
00157 else write_out_fpocket(pockets, pdb, pdbname);
00158 c_lst_pocket_free(pockets) ;
00159 }
00160 fclose(pdb->fpdb);
00161 }
00162 else fprintf(stderr, "! PDB reading failed!\n");
00163 }