Commit 4b6d8bba by Chloe Dequeker

ZDOCK finished

parent 36ae572f
......@@ -34,6 +34,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
centerZ = pdb2->centerZ;
for(i=0;i<nbCandInit1;i++){
if(t_candid1[i]->isHET) continue;
for(j=0;j<t_candid1[i]->nbAtom;j++){
x = t_candid1[i]->x[j];
y = t_candid1[i]->y[j];
......@@ -55,6 +56,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
farthestY = t_candid1[idxCand]->y[idxAtom];
farthestZ = t_candid1[idxCand]->z[idxAtom];
for(i=0;i<nbCandInit2;i++){
if(t_candid2[i]->isHET) continue;
for(j=0;j<t_candid2[i]->nbAtom;j++){
x = t_candid2[i]->x[j];
y = t_candid2[i]->y[j];
......@@ -78,6 +80,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
*nbCand1 = 0;
for(i=0;i<nbCandInit1;i++){
if(t_candid1[i]->isHET) continue;
for(j=0;j<t_candid1[i]->nbAtom;j++){
x = t_candid1[i]->x[j];
......@@ -144,8 +147,9 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int confID){
for(i=0;i<pdbR->nbRes;i++)
t_candidateR[i] = &pdbR->residues[i];
int totR = pdbR->nbRes, totL = pdbL->nbRes, step = 0;
printf("RSTEP 0 1.0\n");printf("LSTEP 0 1.0\n");
/* int totR = pdbR->nbRes, totL = pdbL->nbRes, step = 0;
printf("RSTEP 0 1.0\n");printf("LSTEP 0 1.0\n"); */
/* Start removing candidates */
while(oldCandL != nbCandL && oldCandR != nbCandR){
oldCandL = nbCandL;
......@@ -167,16 +171,16 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int confID){
nbCandR = 0;
break;
}
step++;
printf("RSTEP %d %d %d -- %f\n",step,nbCandR,totR,(float)(1-((float)(totR-nbCandR)/totR)));
printf("LSTEP %d %d %d -- %f\n",step,nbCandL,totL,(float)(1-((float)(totL-nbCandL)/totL)));
/* step++; */
/* printf("RSTEP %d %d %d -- %f\n",step,nbCandR,totR,(float)(1-((float)(totR-nbCandR)/totR))); */
/* printf("LSTEP %d %d %d -- %f\n",step,nbCandL,totL,(float)(1-((float)(totL-nbCandL)/totL))); */
}
while(step < 15){
/* while(step < 15){
step++;
printf("RSTEP %d %d %d -- %f\n",step,nbCandR,totR,(float)(1-((float)(totR-nbCandR)/totR)));
printf("LSTEP %d %d %d -- %f\n",step,nbCandL,totL,(float)(1-((float)(totL-nbCandL)/totL)));
}
printf("RSTEP %d %d %d -- %f\n",step,nbCandR,totR,(float)(1-((float)(totR-nbCandR)/totR)));
printf("LSTEP %d %d %d -- %f\n",step,nbCandL,totL,(float)(1-((float)(totL-nbCandL)/totL)));
}*/
/* The first nbCandR values of t_candidateR correspond to the possible candidates
* for the receptor
......@@ -206,6 +210,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int confID){
/* For each candidate residue of the receptor */
for(i=0;i<nbCandR;i++){
isClashed = 0;
if(t_candidateR[i]->isHET) continue;
for(j=0;j<t_candidateR[i]->nbAtom;j++){
x1 = t_candidateR[i]->x[j];
y1 = t_candidateR[i]->y[j];
......@@ -213,6 +218,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int confID){
/* For each candidate residue of the ligand */
for(k=0;k<nbCandL;k++){
if(t_candidateL[k]->isHET) continue;
for(l=0;l<t_candidateL[k]->nbAtom;l++){
x2 = t_candidateL[k]->x[l];
y2 = t_candidateL[k]->y[l];
......@@ -299,7 +305,11 @@ int main(int argc, char** argv){
/* Compute the angles for the first and fifth CA of the protein
* This is essential to compute the rotation angles
*/
getAnglesFromCA1andCA5_sophie(pdbL,&alpha,&beta,&gamma);
getAnglesFromCA1andCA5_MAXDo(pdbL,&alpha,&beta,&gamma);
}
if(ZDOCK){
init_ZDOCK(&pdbL);
}
if(complexPDB){ /* If we are building for a given complex, no rotation */
......@@ -317,7 +327,7 @@ int main(int argc, char** argv){
dgamma = dock_res->gamma[target_conf] - gamma;
newPDB = rotate_sophie(pdbL,pdbR,newPDB,dock_res->distCenters[target_conf],
newPDB = rotate_MAXDo(pdbL,pdbR,newPDB,dock_res->distCenters[target_conf],
dock_res->theta[target_conf],dock_res->phi[target_conf],
dalpha,dbeta,dgamma,dock_res,target_conf);
}else if(HEX){
......@@ -326,16 +336,6 @@ int main(int argc, char** argv){
dock_res->alpha[target_conf],dock_res->beta[target_conf],
dock_res->gamma[target_conf]);
}else if(ZDOCK){
printf("R %f %f %f\n",pdbR->centerX,pdbR->centerY,pdbR->centerZ);
printf("L %f %f %f\n",pdbL->centerX,pdbL->centerY,pdbL->centerZ);
init_ZDOCK(&pdbR,&pdbL);
printf("R %f %f %f\n",pdbR->centerX,pdbR->centerY,pdbR->centerZ);
printf("L %f %f %f\n",pdbL->centerX,pdbL->centerY,pdbL->centerZ);
if(constructPDB){
writePDB(pdbL, ligand,target_conf);
writePDB(pdbR, receptor,target_conf);
}
newPDB = rotate_ZDOCK(pdbL,newPDB,dock_res->trans_X[target_conf],
dock_res->trans_Y[target_conf],dock_res->trans_Z[target_conf],
dock_res->alpha[target_conf],dock_res->beta[target_conf],
......@@ -377,7 +377,7 @@ int main(int argc, char** argv){
/* This is the rotated PDB
* pdbL doesn't change throughout the program
*/
newPDB = rotate_sophie(pdbL, pdbR, newPDB, dock_res->distCenters[i],
newPDB = rotate_MAXDo(pdbL, pdbR, newPDB, dock_res->distCenters[i],
dock_res->theta[i], dock_res->phi[i],
dalpha, dbeta, dgamma, dock_res, i);
}else if(HEX){
......@@ -386,11 +386,6 @@ int main(int argc, char** argv){
dock_res->alpha[i],dock_res->beta[i],
dock_res->gamma[i]);
}else if(ZDOCK){
printf("%f %f %f\n",pdbR->centerX,pdbR->centerY,pdbR->centerZ);
init_ZDOCK(&pdbR,&pdbL);
printf("%f %f %f\n",pdbR->centerX,pdbR->centerY,pdbR->centerZ);
exit(1);
newPDB = rotate_ZDOCK(pdbL,newPDB,dock_res->trans_X[i],
dock_res->trans_Y[i],dock_res->trans_Z[i],
dock_res->alpha[i],dock_res->beta[i],
......
......@@ -6,7 +6,7 @@
void freePDB(struct pdb_values* pdb){
free(pdb->residues);
free(pdb);
pdb = NULL; /* Has not effect since the adress passed as argument
pdb = NULL; /* Has not effect since the adress passed as argument
* won't change
*/
}
......@@ -15,7 +15,7 @@ void freePDB(struct pdb_values* pdb){
void freeDock(struct docking_results* dock_res){
/* Free the docking interface */
free(dock_res->listEner);
if(HEX){
if(HEX || ZDOCK){
free(dock_res->trans_X);
free(dock_res->trans_Y);
free(dock_res->trans_Z);
......@@ -97,7 +97,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_Z = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_Z == NULL){
perror("malloc");
......
......@@ -3,8 +3,28 @@
#include <unistd.h>
#include <string.h>
#include "struct.h"
#include "fileIO.h"
#include "allocate.h"
/* Remove blank spaces */
char* deblank(char* input){
int i = 0, j = 0;
size_t len = 0;
char* output = NULL;
output = input;
len = strlen(input);
for (i = 0; i<(int)len; i++){
if (input[i]!=' '){
output[j]=input[i];
j++;
}
}
output[j]=0;
return output;
}
struct docking_results* getDataForComplex(){
char* buf = NULL;
char buf2[100] = "";
......@@ -183,9 +203,10 @@ struct pdb_values* readPDB(char* protein) {
strcpy(buf3,"\0");
while(!feof(pdbFile_stream)){
rc = getline(&buf,&len,pdbFile_stream);
strncpy(buf2,buf,4);
buf2[4] = '\0';
if(strcmp("ATOM",buf2) == 0){
strncpy(buf2,buf,6);
buf2[6] = '\0';
deblank(buf2);
if(strcmp("ATOM",buf2) == 0 || strcmp("HETATM",buf2) == 0){
/* get the residue ID */
strncpy(buf2,buf+22,5);
buf2[5] = '\0';
......@@ -209,9 +230,10 @@ struct pdb_values* readPDB(char* protein) {
rc = getline(&buf,&len,pdbFile_stream);
if(feof(pdbFile_stream)) break; /* else the last line is read twice */
strncpy(buf2,buf,4);
buf2[4] = '\0';
if(strcmp("ATOM",buf2) != 0){
strncpy(buf2,buf,6);
buf2[6] = '\0';
deblank(buf2);
if(strcmp("ATOM",buf2) != 0 && strcmp("HETATM",buf2) != 0){
continue;
}
strncpy(bufID,buf+22,5);
......@@ -237,6 +259,10 @@ struct pdb_values* readPDB(char* protein) {
/* atom chain */
pdb_prot->residues[curRes].chain = buf[21];
/* if it is an HETATM */
if(strcmp("HETATM",buf2) == 0)
pdb_prot->residues[curRes].isHET = 1;
}
/* atom type */
......@@ -316,10 +342,18 @@ void writePDB(struct pdb_values* pdb, char* protName, int nConf){
exit(EXIT_FAILURE);
}
for(i=0;i<pdb->nbRes;i++){
for(j=0;j<pdb->residues[i].nbAtom;j++){
fprintf(fw,FORMAT_LINE_PDB,pdb->residues[i].idAtom[j],
pdb->residues[i].atomType[j],pdb->residues[i].resName,pdb->residues[i].chain,
pdb->residues[i].idRes,pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]);
if(pdb->residues[i].isHET){
for(j=0;j<pdb->residues[i].nbAtom;j++){
fprintf(fw,FORMAT_LINE_PDB_HET,pdb->residues[i].idAtom[j],
pdb->residues[i].atomType[j],pdb->residues[i].resName,pdb->residues[i].chain,
pdb->residues[i].idRes,pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]);
}
}else{
for(j=0;j<pdb->residues[i].nbAtom;j++){
fprintf(fw,FORMAT_LINE_PDB_ATM,pdb->residues[i].idAtom[j],
pdb->residues[i].atomType[j],pdb->residues[i].resName,pdb->residues[i].chain,
pdb->residues[i].idRes,pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]);
}
}
}
fclose(fw);
......
......@@ -5,30 +5,23 @@
#include "allocate.h"
#include "rotation.h"
void init_ZDOCK(struct pdb_values** pdbR_addr, struct pdb_values** pdbL_addr){
struct pdb_values* pdbR = *pdbR_addr;
void init_ZDOCK(struct pdb_values** pdbL_addr){
struct pdb_values* pdbL = *pdbL_addr;
struct pdb_values* newPDB = NULL;
// newPDB = rotate_ZDOCK_init(pdbR,newPDB);
// (*pdbR_addr) = newPDB;
// newPDB = NULL;
// TODO : free pdbR
newPDB = rotate_ZDOCK_init(pdbL,newPDB);
(*pdbL_addr) = newPDB;
newPDB = NULL;
// TODO : free pdbL
freePDB(pdbL);
}
/**********************************************/
/* Function rotateAtom */
/* rotates around 3 euler angles */
/**********************************************/
void rotateAtom (float oldX, float oldY, float oldZ,
float *newX, float *newY, float *newZ,
float alpha, float beta, float gamma, int rev) {
/* This function rotates an atom with the 3 Euler angles,
* according to the center (0,0,0)
* The rev option indicates if the matrix has to be transposed or not
*/
float c_a = cos(alpha), s_a = sin(alpha);
float c_b = cos(beta), s_b = sin(beta);
float c_g = cos(gamma), s_g = sin(gamma);
......@@ -37,7 +30,7 @@ void rotateAtom (float oldX, float oldY, float oldZ,
r11 = c_a*c_g - s_a*c_b*s_g;
r21 = s_a*c_g + c_a*c_b*s_g;
r31 = s_b*s_g;
r12 = -c_a*s_g - s_a*c_b*c_g;
r22 = -s_a*s_g + c_a*c_b*c_g;
r32 = s_b*c_g;
......@@ -49,7 +42,7 @@ void rotateAtom (float oldX, float oldY, float oldZ,
r11 = c_a*c_g - s_a*c_b*s_g;
r12 = s_a*c_g + c_a*c_b*s_g;
r13 = s_b*s_g;
r21 = -c_a*s_g - s_a*c_b*c_g;
r22 = -s_a*s_g + c_a*c_b*c_g;
r23 = s_b*c_g;
......@@ -89,8 +82,6 @@ struct pdb_values* rotate_ZDOCK(struct pdb_values* pdb, struct pdb_values* newPD
* https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Eulerangles.svg/300px-Eulerangles.svg.png
*/
printf("rotate : T X/Y/Z : %f _%f _%f\nR A/B/G : %f %f %f\n",trans_X,trans_Y,trans_Z,alpha,beta,gamma);
float xi = 0, yi = 0, zi = 0;
float x1i = 0, y1i = 0, z1i = 0;
float x2i = 0, y2i = 0, z2i = 0;
......@@ -169,7 +160,6 @@ struct pdb_values* rotate_ZDOCK(struct pdb_values* pdb, struct pdb_values* newPD
newPDB->centerX = newX;
newPDB->centerY = newY;
newPDB->centerZ = newZ;
printf("NEW : %f %f %f\n",newPDB->centerX,newPDB->centerY,newPDB->centerZ);
return newPDB;
}
......@@ -224,7 +214,7 @@ struct pdb_values* rotate_ZDOCK_init(struct pdb_values* pdb, struct pdb_values*
zi -= ZDOCK_LIG_Z_TRANS;
rotateAtom(xi, yi, zi, &x1i, &y1i, &z1i, ZDOCK_LIG_A_ROT, ZDOCK_LIG_B_ROT, ZDOCK_LIG_G_ROT, 0);
}
newPDB->residues[i].x[j] = x1i;
newPDB->residues[i].y[j] = y1i;
newPDB->residues[i].z[j] = z1i;
......@@ -330,7 +320,7 @@ struct pdb_values* rotate_global(struct pdb_values* pdb, struct pdb_values* pdbR
/* Coordinates of the N axis */
float xN = c_a;
float yN = s_a;
float zN = 0;
/* float zN = 0; */
/* The coordinates of the unit vector for the axis Z can be computed as such :
*/
......@@ -407,7 +397,7 @@ struct pdb_values* rotate_global(struct pdb_values* pdb, struct pdb_values* pdbR
}
struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf){
struct pdb_values* rotate_MAXDo(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf){
/* This function rotates the PDB pdb given in argument and sets the new coordinates in newPDB.
* The final center of the xyz system is the geometric center of the PDB pdbR.
* The angles alpha, beta, gamma in arguments correspond to the rotation angles that have to be applied to
......@@ -453,7 +443,7 @@ struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR
float xN = c_a0;
float yN = s_a0;
float zN = 0;
/* float zN = 0; */
/* The coordinates of the unit vector for the axis Z can be computed as such :
* xZ : -s_a0 * c_b0
......@@ -528,7 +518,7 @@ struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR
void getAnglesFromCA1andCA5_sophie(struct pdb_values* pdb, float* alpha, float* beta, float* gamma){
void getAnglesFromCA1andCA5_MAXDo(struct pdb_values* pdb, float* alpha, float* beta, float* gamma){
/* In this function, we first need to find the initial angles alpha and beta that correspond
* to the angles alpha and beta for the first CA of the protein.
* Then, we need to apply a rotation alpha about the axis Z, then a rotation beta
......
......@@ -3,9 +3,9 @@
#ifndef ROTAT_HEADER
#define ROTAT_HEADER
struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf);
struct pdb_values* rotate_MAXDo(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf);
void getAnglesFromCA1andCA5_sophie(struct pdb_values* pdb, float* alpha, float* beta, float* gamma);
void getAnglesFromCA1andCA5_MAXDo(struct pdb_values* pdb, float* alpha, float* beta, float* gamma);
void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, float R, float theta, float phi);
......@@ -17,7 +17,7 @@ struct pdb_values* rotate_ZDOCK_init(struct pdb_values* pdb, struct pdb_values*
struct pdb_values* rotate_ZDOCK(struct pdb_values* pdb, struct pdb_values* newPDB, float trans_X, float trans_Y, float trans_Z, float alpha, float beta, float gamma);
void init_ZDOCK(struct pdb_values** pdbR_addr, struct pdb_values** pdbL_addr);
void init_ZDOCK(struct pdb_values** pdbL_addr);
void rotateAtom (float oldX, float oldY, float oldZ,
float *newX, float *newY, float *newZ,
......
......@@ -10,15 +10,17 @@
*/
#define COEF_DEGREE_TO_RADIAN 0.017453293 /* Coefficient to convert degrees to radians */
#define NB_MAX_ATOM_PER_RES 100 /* No residue has more atoms than that */
#define TOO_MANY_CLASHES 20 /* If not forcing, program will skip conformation after
* this number of clashes */
#define NB_MAX_ATOM_PER_RES 100 /* No residue has more atoms than that */
#define TOO_MANY_CLASHES 20 /* If not forcing, program will skip conformation after
* this number of clashes */
#define DIST_FOR_CLASH 2 /* Distance in Angstrom under which we consider
* the contact is a clash */
#define NB_HEADER_LINE_HEX 12 /* Number of header lines at the top of a hex docking file */
#define NB_HEADER_LINE_ZDOCK 5 /* Number of header lines at the top of a ZDOCK docking file */
#define NB_HEADER_LINE_HEX 12 /* Number of header lines at the top of a hex docking file */
#define NB_HEADER_LINE_ZDOCK 5 /* Number of header lines at the top of a ZDOCK docking file */
/* This is the format of a line in a PDB file */
#define FORMAT_LINE_PDB "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
#define FORMAT_LINE_PDB_ATM "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
#define FORMAT_LINE_PDB_HET "HETATM%5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
int verbose; /* 1 if we are in verbose mode */
int constructPDB; /* 1 if we should build the PDB */
......@@ -33,7 +35,10 @@ int atom_res; /* 1 if we want a resolution at atom's level */
int clash; /* Maybe be incremented in case of clashes */
int force; /* Will output even if clash, may increase computation time */
float DIST_FOR_CONTACT; /* Distance under which we consider two residues are in contact */
float ZDOCK_LIG_A_ROT; /* Initial rotations and translations if using ZDOCK */
/* Initial rotations and translations if using ZDOCK */
/*****************************************************/
float ZDOCK_LIG_A_ROT;
float ZDOCK_LIG_B_ROT;
float ZDOCK_LIG_G_ROT;
float ZDOCK_REC_A_ROT;
......@@ -45,9 +50,13 @@ float ZDOCK_LIG_Z_TRANS;
float ZDOCK_REC_X_TRANS;
float ZDOCK_REC_Y_TRANS;
float ZDOCK_REC_Z_TRANS;
float ZDOCK_GRID_UNIT;
int ZDOCK_GRID_SIZE;
int ZDOCK_PROT_FIXED;
/*****************************************************/
float ZDOCK_GRID_UNIT; /* The unit value for the grid used in ZDOCK */
int ZDOCK_GRID_SIZE; /* Number of unit for the grid (UNITxUNITxUNIT) */
int ZDOCK_PROT_FIXED; /* 1 if the receptor is fixed, 0 if the ligand is fixed.
* This is set from ZDOCK docking file, but the user should
* specify the right ligand and receptor in the command line
* of INTBuilder */
FILE* verbose_file; /* If verbose mode, the output file */
char* pdbDir; /* Directory containing the PDBs */
char* receptor; /* Name of the receptor */
......@@ -85,6 +94,7 @@ struct residue {
float z[NB_MAX_ATOM_PER_RES]; /* Array containing the z for each of its atom */
char atomType[NB_MAX_ATOM_PER_RES][10]; /* Array containing the type of atom */
int idAtom[NB_MAX_ATOM_PER_RES]; /* ID of the atom */
int isHET;
int nbAtom; /* Number of atom for this residue */
int isCandidate; /* 1 if this residue belongs to the docking interface */
int isAtomCandidate[NB_MAX_ATOM_PER_RES]; /* 1 if the atom belongs to the docking interface */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment