00001 #include "../headers/write_visu.h"
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
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 void write_visualization(char *pdb_name,char *pdb_out_name)
00077 {
00078 write_vmd(pdb_name,pdb_out_name);
00079 write_pymol(pdb_name,pdb_out_name);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 void write_vmd(char *pdb_name,char *pdb_out_name)
00099 {
00100 char fout[250] = "" ;
00101 char fout2[250] = "" ;
00102 char sys_cmd[250] ="";
00103 char c_tmp[255];
00104 int status ;
00105
00106 strcpy(c_tmp,pdb_name);
00107 remove_ext(c_tmp) ;
00108 remove_path(c_tmp) ;
00109 FILE *f,*f_tcl;
00110 sprintf(fout,"%s_VMD.sh",pdb_name);
00111 f = fopen(fout, "w") ;
00112 if(f){
00113 sprintf(fout2,"%s.tcl",pdb_name);
00114
00115 f_tcl=fopen(fout2,"w");
00116 if(f_tcl){
00117
00118 fprintf(f,"#!/bin/bash\nvmd %s -e %s.tcl\n",pdb_out_name,c_tmp);
00119 fflush(f);
00120 fclose(f);
00121
00122
00123 sprintf(sys_cmd,"chmod +x %s",fout);
00124 status = system(sys_cmd);
00125
00126
00127 fprintf(f_tcl,"proc highlighting { colorId representation id selection } {\n");
00128 fprintf(f_tcl," set id [[atomselect $id $selection] molid]\n");
00129 fprintf(f_tcl," puts \"highlighting $id\"\n");
00130 fprintf(f_tcl," mol delrep 0 $id\n");
00131 fprintf(f_tcl," mol representation $representation\n");
00132 fprintf(f_tcl," mol color $colorId\n");
00133 fprintf(f_tcl," mol selection $selection\n");
00134 fprintf(f_tcl," mol addrep $id\n}\n\n");
00135 fprintf(f_tcl,"set repr \"Points 10\"\n");
00136 fprintf(f_tcl,"highlighting ResID \"Points 10\" 0 \"resname STP\"\n");
00137 fprintf(f_tcl,"set id [[atomselect 0 \"protein\"] molid]\n");
00138 fprintf(f_tcl,"puts \"highlighting $id\"\n");
00139 fprintf(f_tcl,"mol representation \"Lines\"\n");
00140 fprintf(f_tcl,"mol material \"Transparent\"\n");
00141 fprintf(f_tcl,"mol color Element\n");
00142 fprintf(f_tcl,"mol selection \"protein\"\n");
00143 fprintf(f_tcl,"mol addrep $id\n");
00144 fprintf(f_tcl,"set id [[atomselect 0 \"not protein and not resname STP\"] molid]\n");
00145 fprintf(f_tcl,"puts \"highlighting $id\"\n");
00146 fprintf(f_tcl,"mol representation \"Bonds\"\n");
00147 fprintf(f_tcl,"mol color Element\n");
00148 fprintf(f_tcl,"mol selection \"not protein and not resname STP\"\n");
00149 fprintf(f_tcl,"mol addrep $id\n\n");
00150
00151
00152 fprintf(f_tcl,"mol new \"../%s.pdb\"\n",c_tmp);
00153 fprintf(f_tcl,"mol selection \"not protein and not water\" \n \
00154 mol material \"Opaque\" \n \
00155 mol delrep 0 1 \n \
00156 mol representation \"Lines 10\" \n \
00157 mol addrep 1 \n \
00158 highlighting Element \"NewCartoon\" 1 \"protein\"\n \
00159 mol representation \"NewCartoon\" \n \
00160 mol addrep $id \n \
00161 mol new \"%s_pockets.pqr\"\n \
00162 mol selection \"all\" \n \
00163 mol material \"Glass1\" \n \
00164 mol delrep 0 2 \n \
00165 mol representation \"VDW\" \n \
00166 mol color ResID 2 \n \
00167 mol addrep 2 \n",c_tmp);
00168 fclose(f_tcl);
00169
00170 }
00171 else {
00172 fprintf(stderr, "! The file %s could not be opened!\n", fout2);
00173 }
00174
00175 }
00176 else{
00177 fprintf(stderr, "! The file %s could not be opened!\n", fout);
00178 }
00179
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 void write_pymol(char *pdb_name,char *pdb_out_name)
00197 {
00198 char fout[250] = "" ;
00199 char fout2[250] = "" ;
00200 char sys_cmd[250] ="";
00201 FILE *f,*f_pml;
00202 char c_tmp[255];
00203 int status ;
00204
00205 strcpy(c_tmp,pdb_name);
00206 remove_ext(c_tmp) ;
00207 remove_path(c_tmp) ;
00208 sprintf(fout,"%s_PYMOL.sh",pdb_name);
00209 f = fopen(fout, "w") ;
00210 if(f){
00211 sprintf(fout2,"%s.pml",pdb_name);
00212 f_pml=fopen(fout2,"w");
00213 if(f_pml){
00214
00215 fprintf(f,"#!/bin/bash\npymol %s.pml\n",c_tmp);
00216 fflush(f);
00217 fclose(f);
00218
00219 sprintf(sys_cmd,"chmod +x %s",fout);
00220 status = system(sys_cmd);
00221
00222 fprintf(f_pml,"from pymol import cmd,stored\n");
00223 fprintf(f_pml,"load %s\n",pdb_out_name);
00224 fprintf(f_pml,"#select pockets, resn STP\n");
00225 fprintf(f_pml,"stored.list=[]\n");
00226 fprintf(f_pml,"cmd.iterate(\"(resn STP)\",\"stored.list.append(resi)\") #read info about residues STP\n");
00227 fprintf(f_pml,"#print stored.list\n");
00228 fprintf(f_pml,"lastSTP=stored.list[-1] #get the index of the last residu\n");
00229 fprintf(f_pml,"hide lines, resn STP\n\n");
00230 fprintf(f_pml,"#show spheres, resn STP\n");
00231 fprintf(f_pml,"for my_index in range(1,int(lastSTP)+1): cmd.select(\"pocket\"+str(my_index), \"resn STP and resi \"+str(my_index))\n");
00232 fprintf(f_pml,"for my_index in range(2,int(lastSTP)+2): cmd.color(my_index,\"pocket\"+str(my_index))\n");
00233 fprintf(f_pml,"for my_index in range(1,int(lastSTP)+1): cmd.show(\"spheres\",\"pocket\"+str(my_index))\n");
00234 fprintf(f_pml,"for my_index in range(1,int(lastSTP)+1): cmd.set(\"sphere_scale\",\"0.3\",\"pocket\"+str(my_index))\n");
00235 fprintf(f_pml,"for my_index in range(1,int(lastSTP)+1): cmd.set(\"sphere_transparency\",\"0.1\",\"pocket\"+str(my_index))\n");
00236
00237 fclose(f_pml);
00238 }
00239 else {
00240 fprintf(stderr, "! The file %s could not be opened!\n", fout2);
00241 }
00242 }
00243 else{
00244 fprintf(stderr, "! The file %s could not be opened!\n", fout);
00245 }
00246 }