GLYLIB  0.3.0b
find_vdw_clashes_pairwize_between_Assemblies.c
Go to the documentation of this file.
00001 /*
00002  * Oliver Grant 14Mar11
00003  * Finds clashes between atoms in assemblies in a pairwize fashion. 
00004  * NOTE: xsA and xsB refer to the co-ord sets to use. This functionality is not implemented yet. so they are dead variables. It could be preferable to create a driver script to call this one for every frame.
00005 */
00006 #include <glylib.h> // this is clearly stupid and is giving me warnings.
00007 // Bondi definitions of VDW in Angstrom
00008 //#define H     1.09 // Rowland and Taylor modification
00009 //#define C     1.70
00010 //#define N     1.55
00011 //#define O     1.52
00012 //#define F     1.47
00013 //#define P     1.80
00014 //#define S     1.80
00015 //#define Cl    1.75
00016 
00017 void find_vdw_clashes_pairwize_between_Assemblies(assembly *A, int xsA, assembly *B, int xsB){ // xs is co-ord set to use. -1 for main co-ord set
00018 int mi=0,mii=0,ri=0,rii=0,ai=0,aii=0;//loop counters for A(i) and B(ii) assemblies
00019 double soa, total_soa=0.0,resid_soa,prev_soa; // Sphere Overlap Area
00020 double rA,rB; // radii
00021 double x,y,z,d; // xyz are holders to make code more readable. d is distance between two atoms
00022 FILE * pFile; // Clash results out file
00023 char filename[25]; // Name of out file
00024 //compare dist between each atom in A assembly and all atoms in B assembly
00025 
00026 printf("Entered the FUNction\n");
00027 for(mi=0;mi<(*A).nm;mi++){
00028         for(ri=0;ri<(*A).m[mi][0].nr;ri++){
00029                 for(ai=0;ai<(*A).m[mi][0].r[ri].na;ai++){// ai is now current atom to check against every atom in assembly B
00030                         for(mii=0;mii<(*B).nm;mii++){
00031                                 for(rii=0;rii<(*B).m[mii][0].nr;rii++){
00032                                         for(aii=0;aii<(*B).m[mii][0].r[rii].na;aii++){//for current atom check dist to every other atom within the assembly B
00033                                                 //printf("Comparing Values\n rA=%f\n",rA);
00034                                                 x=((*A).m[mi][0].r[ri].a[ai].x.i-(*B).m[mii][0].r[rii].a[aii].x.i);
00035                                                 y=((*A).m[mi][0].r[ri].a[ai].x.j-(*B).m[mii][0].r[rii].a[aii].x.j);
00036                                                 z=((*A).m[mi][0].r[ri].a[ai].x.k-(*B).m[mii][0].r[rii].a[aii].x.k);
00037                                                 d=sqrt((x*x)+(y*y)+(z*z)); //pythagorus square on hyp in 3D
00038                                                 //printf("\ndist is %f\n",d);
00039                                                 // set radii of the atoms
00040                                                 // radii are tuned to get 0 clash for natural substrate
00041                                                 if ((*A).m[mi][0].r[ri].a[ai].N[0]=='C'){rA=1.70;} 
00042                                                 if ((*A).m[mi][0].r[ri].a[ai].N[0]=='O'){rA=1.52;} 
00043                                                 if ((*A).m[mi][0].r[ri].a[ai].N[0]=='N'){rA=1.55;} 
00044                                                 if ((*A).m[mi][0].r[ri].a[ai].N[0]=='S'){rA=1.80;} 
00045 
00046                                                 if ((*B).m[mii][0].r[rii].a[aii].N[0]=='C'){rB=1.70;}
00047                                                 if ((*B).m[mii][0].r[rii].a[aii].N[0]=='O'){rB=1.52;}
00048                                                 if ((*B).m[mii][0].r[rii].a[aii].N[0]=='N'){rB=1.55;}
00049                                                 if ((*B).m[mii][0].r[rii].a[aii].N[0]=='S'){rB=1.80;}
00050                                                 
00051                                                 //printf("Dist is %f, rA is %f, rB is %f \n\n",d,rA,rB);
00052                                                 // if the sum of the radii is greater than the distance between them.
00053                                                 if (rA + rB > d + 0.4){ // 0.6 overlap is deemed acceptable. (Copying chimera:)
00054                                                         soa=2*PI*rA*(rA-d/2-(((rA*rA)-(rB*rB))/(2*d))); 
00055                                                                 // Eqn 1, Rychkov and Petukhov, J. Comput. Chem., 2006, Joint Neighbours...
00056                                                         total_soa=total_soa + soa;
00057                                                         strcpy(filename, "Clash_results_atoms.txt");
00058                                                         pFile = fopen (filename,"a+"); // open file and append
00059                                                         //if (pFile=NULL){ // this is always true...
00060                                                         //      printf("File open FAIL!\n");
00061                                                         //      break ;
00062                                                         fprintf(pFile,"Clash Area For Resid No.%d Atom_Name:%c%c is %5.1f \n",(*A).m[mi][0].r[ri].n,(*A).m[mi][0].r[ri].a[ai].N[0],(*A).m[mi][0].r[ri].a[ai].N[1],soa);
00063                                                         fprintf(pFile," ...Clashing with Resid No.%d Atom_Name:%c%c in the receptor.\n",(*B).m[mii][0].r[rii].n,(*B).m[mii][0].r[rii].a[aii].N[0],(*B).m[mii][0].r[rii].a[aii].N[1]);
00064                                                         fclose (pFile);
00065                                                 }
00066                                         }
00067                                 }
00068                         }
00069                 }
00070                 resid_soa=(total_soa - prev_soa);
00071                 strcpy(filename, "Clash_results_resid.txt");
00072                 pFile = fopen (filename,"a+");
00073                 fprintf(pFile,"Clash Area For Resid No.%d is %5.1f\n",(*A).m[mi][0].r[ri].n,resid_soa);
00074                 fclose (pFile);
00075                 prev_soa=total_soa;
00076         }
00077 }
00078 total_soa=(total_soa+0.5); // so can round off by truncation
00079 int total_soa_int;
00080 total_soa_int=total_soa;
00081 
00082 strcpy(filename, "Clash_results_total.txt");
00083 pFile = fopen (filename,"a+");
00084 fprintf(pFile,"\nTotal_Overlap=%d",total_soa_int);
00085 fclose (pFile);
00086 return;
00087 }
 All Classes Files Functions Variables Typedefs Defines