00001 00002 #include "../headers/fpout.h" 00003 00004 /* 00005 00006 ## GENERAL INFORMATION 00007 ## 00008 ## FILE fpout.h 00009 ## AUTHORS P. Schmidtke and V. Le Guilloux 00010 ## LAST MODIFIED 28-11-08 00011 ## 00012 ## SPECIFICATIONS 00013 ## 00014 ## Write output for fpocket. 00015 ## 00016 ## MODIFICATIONS HISTORY 00017 ## 00018 ## 12-02-09 (v) No more pocket.info output (useless...) 00019 ## 15-12-08 (v) Minor bug corrected (output dir in the current dir...) 00020 ## 28-11-08 (v) Last argument of write_out_fpocket changed to char * 00021 ## Comments UTD 00022 ## 01-04-08 (v) Added comments and creation of history 00023 ## 01-01-08 (vp) Created (random date...) 00024 ## 00025 ## TODO or SUGGESTIONS 00026 ## 00027 ## (v) Handle system command failure, clean! 00028 00029 */ 00030 00031 00032 /* 00033 COPYRIGHT DISCLAIMER 00034 00035 Vincent Le Guilloux, Peter Schmidtke and Pierre Tuffery, hereby 00036 disclaim all copyright interest in the program “fpocket” (which 00037 performs protein cavity detection) written by Vincent Le Guilloux and Peter 00038 Schmidtke. 00039 00040 Vincent Le Guilloux 28 November 2008 00041 Peter Schmidtke 28 November 2008 00042 Pierre Tuffery 28 November 2008 00043 00044 GNU GPL 00045 00046 This file is part of the fpocket package. 00047 00048 fpocket is free software: you can redistribute it and/or modify 00049 it under the terms of the GNU General Public License as published by 00050 the Free Software Foundation, either version 3 of the License, or 00051 (at your option) any later version. 00052 00053 fpocket is distributed in the hope that it will be useful, 00054 but WITHOUT ANY WARRANTY; without even the implied warranty of 00055 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00056 GNU General Public License for more details. 00057 00058 You should have received a copy of the GNU General Public License 00059 along with fpocket. If not, see <http://www.gnu.org/licenses/>. 00060 00061 **/ 00062 00063 /** 00064 ## FUNCTION: 00065 write_out_fpocket 00066 00067 ## SPECIFICATION: 00068 Output routine. See the documentation for more information. 00069 00070 ## PARAMETRES: 00071 * @ c_lst_pockets *pockets : All pockets found and kept. 00072 * @ c_lst_pockets *pockets : The (input) pdb structure 00073 @ char *pdbname : Name of the pdb 00074 00075 ## RETURN: 00076 void 00077 00078 */ 00079 void write_out_fpocket(c_lst_pockets *pockets, s_pdb *pdb, char *pdbname) 00080 { 00081 char pdb_code[350] = "" ; 00082 char pdb_path[350] = "" ; 00083 char out_path[350] = "" ; 00084 char pdb_out_path[350] = "" ; 00085 char fout[350] = "" ; 00086 char command[370] = "" ; 00087 int status ; 00088 00089 if(pockets) { 00090 /* Extract path, pdb code... */ 00091 strcpy(pdb_code, pdbname) ; 00092 extract_path(pdbname, pdb_path) ; 00093 remove_ext(pdb_code) ; 00094 remove_path(pdb_code) ; 00095 00096 if(strlen(pdb_path) > 0) sprintf(out_path, "%s/%s_out", pdb_path, pdb_code) ; 00097 else sprintf(out_path, "%s_out", pdb_code) ; 00098 00099 sprintf(command, "mkdir %s", out_path) ; 00100 status = system(command) ; 00101 /*if(status != 0) { 00102 return ; 00103 }*/ 00104 00105 sprintf(out_path, "%s/%s", out_path, pdb_code) ; 00106 sprintf(pdb_out_path, "%s_out.pdb", out_path) ; 00107 00108 /* Write vmd and pymol scripts */ 00109 sprintf(fout, "%s_out.pdb", pdb_code) ; 00110 write_visualization(out_path, fout); 00111 00112 /* Writing full pdb */ 00113 sprintf(pdb_out_path, "%s_out.pdb", out_path) ; 00114 00115 write_pockets_single_pdb(pdb_out_path, pdb, pockets) ; 00116 00117 /* Writing pockets as a single pqr */ 00118 sprintf(fout, "%s_pockets.pqr", out_path) ; 00119 write_pockets_single_pqr(fout, pockets) ; 00120 00121 /* Writing individual pockets pqr */ 00122 if(strlen(pdb_path) > 0) sprintf(out_path, "%s/%s_out", pdb_path, pdb_code) ; 00123 else sprintf(out_path, "%s_out", pdb_code) ; 00124 00125 sprintf(out_path, "%s/pockets", out_path) ; 00126 sprintf(command, "mkdir %s", out_path) ; 00127 status = system(command) ; 00128 /*if(status != 0) { 00129 return ; 00130 }*/ 00131 00132 write_each_pocket(out_path, pockets) ; 00133 } 00134 } 00135 00136 00137 /**----------------------------------------------------------------------------- 00138 ## FUNCTION: 00139 void write_out(c_lst_pockets *pockets) 00140 ----------------------------------------------------------------------------- 00141 ## SPECIFICATION: 00142 Output routine. 00143 ----------------------------------------------------------------------------- 00144 */ 00145 void write_out_fpocket_DB(c_lst_pockets *pockets, s_pdb *pdb, char *input_name)//s_fparams *params) 00146 { 00147 char pdb_code[350] = "" ; 00148 char pdb_path[350] = "" ; 00149 char out_path[350] = "" ; 00150 char pdb_out_path[350] = "" ; 00151 char command[370] = "" ; 00152 00153 if(pockets) { 00154 // Extract path, pdb code... 00155 strcpy(pdb_code, input_name) ; 00156 extract_path(input_name, pdb_path) ; 00157 remove_ext(pdb_code) ; 00158 remove_path(pdb_code) ; 00159 /*sprintf(out_path, "%s/%s_out", pdb_path, pdb_code) ;*/ 00160 if(strlen(pdb_path) > 0) sprintf(out_path, "%s/%s_out", pdb_path, pdb_code) ; 00161 else sprintf(out_path, "%s_out", pdb_code) ; 00162 sprintf(command, "mkdir %s", out_path) ; 00163 system(command) ; 00164 /* 00165 sprintf(out_path, "%s/%s_out/%s", pdb_path, pdb_code, pdb_code) ; 00166 sprintf(pdb_out_path, "%s_out.pdb", out_path) ; 00167 */ 00168 //Write vmd and pymol scripts 00169 /* 00170 sprintf(fout, "%s_out.pdb", pdb_code) ; 00171 write_visualization(out_path, fout); 00172 // Print the whole pockets informations in a single file 00173 */ 00174 /*sprintf(fout, "%s_pockets.info", out_path) ; 00175 FILE *f = fopen(fout, "w") ; 00176 if(f) { 00177 print_pockets(f, pockets) ; 00178 fclose(f) ; 00179 } 00180 */ 00181 // Writing full pdb 00182 sprintf(pdb_out_path, "%s_out.pdb", out_path) ; 00183 00184 //write_pockets_single_pdb(pdb_out_path, pdb, pockets) ; 00185 00186 // Writing topology clusters 00187 /* sprintf(pdb_out_path, "%s_topo_connect.pdb", out_path) ; 00188 00189 write_topology_pdb(pdb_out_path,pockets) ;*/ 00190 // Writing pockets as a single pqr 00191 /*sprintf(fout, "%s_pockets.pqr", out_path) ; 00192 write_pockets_single_pqr(fout, pockets) ;*/ 00193 00194 // Writing pocket distance matrix to a file 00195 // sprintf(fout, "%s_dist_mat.txt", out_path) ; 00196 00197 00198 // Writing individual pockets pqr 00199 00200 /* sprintf(out_path, "%s/%s_out/", pdb_path, pdb_code) ; 00201 sprintf(command, "mkdir %s", out_path) ; 00202 system(command) ;*/ 00203 00204 write_each_pocket_for_DB(out_path, pockets,pdb) ; 00205 //write_each_matrix(out_path,pockets); 00206 } 00207 } 00208 00209 00210 00211 00212 void write_descriptors_DB(c_lst_pockets *pockets, FILE *f){ 00213 00214 /*Todo adapt things here*/ 00215 00216 int n=1; 00217 s_pocket *p; 00218 node_pocket *npcur; 00219 npcur=pockets->first; 00220 int r=1,i; 00221 fprintf(f,"cav_id drug_score nb_asph inter_chain apol_asph_proportion mean_asph_radius " 00222 "mean_asph_solv_acc mean_loc_hyd_dens flex hydrophobicity_score volume_score charge_score " 00223 "polarity_score a0_apol a0_pol af_apol af_pol n_abpa " 00224 "ala cys asp glu phe gly his ile lys ley met asn pro gln arg ser thr val trp tyr " 00225 "chain_1_type chain_2_type num_res_chain_1 " 00226 "num_res_chain_2 lig_het_tag name_chain_1 name_chain_2\n"); 00227 while(npcur){ 00228 p=npcur->pocket; 00229 // python counter part entry={"pdb_id":pdbFile,"cav_id":int(r[0]),"drug_score":r[1],"nb_asph":int(r[2]),"inter_chain":int(r[3]),"apol_asph_proportion": 00230 //float(r[4]),"mean_asph_radius":float(r[5]),"mean_asph_solv_acc":float(r[6]),"mean_loc_hyd_dens":float(r[7]),"flex":r[8],"hydrophobicity_score":float(r[9]), 00231 //"volume_score":float(r[10]),"charge_score":int(r[11]),"polarity_score":int(r[12]),"a0_apol":float(r[13]),"a0_pol":float(r[14]),"af_apol":float(r[15]), 00232 //"af_pol":float(r[16]),"n_abpa":int(r[17]),"ala":int(r[18]),"cys":int(r[19]),"asp":int(r[20]),"glu":int(r[21]),"phe":int(r[22]),"gly":int(r[23]), 00233 //"his":int(r[24]),"ile":int(r[25]),"lys":int(r[26]),"leu":int(r[27]),"met":int(r[28]),"asn":int(r[29]),"pro":int(r[30]),"gln":int(r[31]),"arg":int(r[32]), 00234 //"ser":int(r[33]),"thr":int(r[34]),"val":int(r[35]),"trp":int(r[36]),"tyr":int(r[37])} 00235 //entry={"pdb_id":pdbFile,"cav_id":int(r[0]),"chain_1_type":int(r[38]), "chain_2_type":int(r[39]), "num_res_chain_1":int(r[40]),"num_res_chain_2":int(r[41])} 00236 // entry={"pdb_id":pdbFile,"cav_id":int(r[0]),"lig_het_tag":str(r[42])} 00237 fprintf(f,"%d %.4f %d %d %.4f %.4f",r,p->pdesc->drug_score,\ 00238 p->pdesc->nb_asph,p->pdesc->interChain,(float)p->nAlphaApol/(float)p->pdesc->nb_asph,p->pdesc->mean_asph_ray); 00239 fprintf(f," %.4f %.4f %.4f %.4f %.4f %d",p->pdesc->masph_sacc,p->pdesc->mean_loc_hyd_dens,p->pdesc->flex,p->pdesc->hydrophobicity_score,\ 00240 p->pdesc->volume_score,p->pdesc->charge_score); 00241 fprintf(f," %d %.4f %.4f %.4f %.4f %d",p->pdesc->polarity_score,p->pdesc->surf_apol_vdw14,p->pdesc->surf_pol_vdw14,\ 00242 p->pdesc->surf_apol_vdw22,p->pdesc->surf_pol_vdw22,p->pdesc->n_abpa); 00243 for(i = 0 ; i < 20 ; i++) fprintf(f, " %d", p->pdesc->aa_compo[i]) ; 00244 fprintf(f," %d %d %d %d %s %s %s",p->pdesc->characterChain1, p->pdesc->characterChain2, p->pdesc->numResChain1, p->pdesc->numResChain2, p->pdesc->ligTag, p->pdesc->nameChain1, p->pdesc->nameChain2); 00245 //fprintf(f,"%s %s %s",p->pdesc->nameChain1,p->pdesc->nameChain2); 00246 fprintf(f,"\n"); 00247 fflush(f); 00248 00249 00250 00251 00252 /* sprintf(filename,"pocket_%d.txt",n); 00253 f=fopen(filename,"w"); 00254 fprintf(f,"probe apolar_surface polar_surface\n"); 00255 00256 int i; 00257 for(i=0;i<l;i++){ 00258 fprintf(f,"%.3f %.3f %.3f\n",p->probe_size[i], p->apol_asa_probe[i],p->pol_asa_probe[i]); 00259 } 00260 fclose(f);*/ 00261 npcur=npcur->next; 00262 n++; 00263 r++; 00264 } 00265 00266 }