write_visu.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "utils.h"

Go to the source code of this file.

Functions

void write_visualization (char *pdb_name, char *pdb_out_name)
void write_vmd (char *pdb_name, char *pdb_out_name)
void write_pymol (char *pdb_name, char *pdb_out_name)


Function Documentation

void write_pymol ( char *  pdb_name,
char *  pdb_out_name 
)

## FUNCTION: write_pymol

## SPECIFICATION: write visualization script for PyMol

## PARAMETERS: @ char *pdb_name : pdb code @ char *pdb_out_name : name of the pdb output file

## RETURN: void

Definition at line 196 of file write_visu.c.

References remove_ext(), and remove_path().

Referenced by write_visualization().

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                         /* Write bash script for visualization using VMD */
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                         /* Write pml script */
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 }

void write_visualization ( char *  pdb_name,
char *  pdb_out_name 
)

## FUNCTION: write_visualization

## SPECIFICATION: Write visualization scripts for VMD and PyMol

## PARAMETERS: @ char *pdb_name : pdb code @ char *pdb_out_name : name of the pdb output file

## RETURN: void

Definition at line 76 of file write_visu.c.

References write_pymol(), and write_vmd().

Referenced by write_out_fpocket().

00077 {
00078         write_vmd(pdb_name,pdb_out_name);
00079         write_pymol(pdb_name,pdb_out_name);
00080 }

void write_vmd ( char *  pdb_name,
char *  pdb_out_name 
)

## FUNCTION: write_vmd

## SPECIFICATION: Write visualization script for VMD

## PARAMETERS: @ char *pdb_name : pdb code @ char *pdb_out_name : name of the pdb output file

## RETURN: void

Definition at line 98 of file write_visu.c.

References remove_ext(), and remove_path().

Referenced by write_visualization().

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                         /* Write bash script for visualization using VMD */
00118                         fprintf(f,"#!/bin/bash\nvmd %s -e %s.tcl\n",pdb_out_name,c_tmp);
00119                         fflush(f);
00120                         fclose(f);
00121                         
00122                         /* Make tcl script executable, and Write tcl script */
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 }


Generated on Mon Jun 7 16:44:23 2010 for fpocket by  doxygen 1.5.6