Commit df933e01 by Chloe Dequeker

debug HEX finished

parent 9b241008
...@@ -306,16 +306,16 @@ int main(int argc, char** argv){ ...@@ -306,16 +306,16 @@ int main(int argc, char** argv){
dgamma = dock_res->gamma[target_conf] - gamma; dgamma = dock_res->gamma[target_conf] - gamma;
newPDB = rotate_sophie(pdbL,pdbR,NULL,dock_res->distCenters[target_conf], newPDB = rotate_sophie(pdbL,pdbR,newPDB,dock_res->distCenters[target_conf],
dock_res->theta[target_conf],dock_res->phi[target_conf], dock_res->theta[target_conf],dock_res->phi[target_conf],
dalpha,dbeta,dgamma,dock_res,target_conf); dalpha,dbeta,dgamma,dock_res,target_conf);
}else if(HEX){ }else if(HEX){
newPDB = rotate_HEX(pdbL,pdbR,NULL,dock_res->trans_X[target_conf], newPDB = rotate_HEX(pdbL,newPDB,dock_res->trans_X[target_conf],
dock_res->trans_Y[target_conf],dock_res->trans_Z[target_conf], dock_res->trans_Y[target_conf],dock_res->trans_Z[target_conf],
dock_res->alpha[target_conf],dock_res->beta[target_conf], dock_res->alpha[target_conf],dock_res->beta[target_conf],
dock_res->gamma[target_conf]); dock_res->gamma[target_conf]);
}else{ }else{
newPDB = rotate_global(pdbL,pdbR,NULL,dock_res->distCenters[target_conf], newPDB = rotate_global(pdbL,pdbR,newPDB,dock_res->distCenters[target_conf],
dock_res->theta[target_conf],dock_res->phi[target_conf], dock_res->theta[target_conf],dock_res->phi[target_conf],
alpha,beta,gamma); alpha,beta,gamma);
} }
...@@ -355,12 +355,12 @@ int main(int argc, char** argv){ ...@@ -355,12 +355,12 @@ int main(int argc, char** argv){
dock_res->theta[i], dock_res->phi[i], dock_res->theta[i], dock_res->phi[i],
dalpha, dbeta, dgamma, dock_res, i); dalpha, dbeta, dgamma, dock_res, i);
}else if(HEX){ }else if(HEX){
newPDB = rotate_HEX(pdbL,pdbR,NULL,dock_res->trans_X[i], newPDB = rotate_HEX(pdbL,newPDB,dock_res->trans_X[i],
dock_res->trans_Y[i],dock_res->trans_Z[i], dock_res->trans_Y[i],dock_res->trans_Z[i],
dock_res->alpha[i],dock_res->beta[i], dock_res->alpha[i],dock_res->beta[i],
dock_res->gamma[i]); dock_res->gamma[i]);
}else{ }else{
newPDB = rotate_global(pdbL,pdbR,NULL,dock_res->distCenters[i], newPDB = rotate_global(pdbL,pdbR,newPDB,dock_res->distCenters[i],
dock_res->theta[i],dock_res->phi[i], dock_res->theta[i],dock_res->phi[i],
alpha,beta,gamma); alpha,beta,gamma);
} }
......
...@@ -50,7 +50,6 @@ struct docking_results* getDataForComplex(){ ...@@ -50,7 +50,6 @@ struct docking_results* getDataForComplex(){
}else if(HEX){ }else if(HEX){
for(i=0;i<NB_HEADER_LINE_HEX;i++){ for(i=0;i<NB_HEADER_LINE_HEX;i++){
getline(&buf,&len,condFile_stream); getline(&buf,&len,condFile_stream);
printf("%s\n",buf);
} }
} }
...@@ -81,7 +80,6 @@ struct docking_results* getDataForComplex(){ ...@@ -81,7 +80,6 @@ struct docking_results* getDataForComplex(){
if(feof(condFile_stream)){ if(feof(condFile_stream)){
break; break;
} }
/* printf("curConf : %d\n",idConf); */
if(HEX){ if(HEX){
...@@ -89,8 +87,7 @@ struct docking_results* getDataForComplex(){ ...@@ -89,8 +87,7 @@ struct docking_results* getDataForComplex(){
}else{ }else{
rc = fscanf(condFile_stream,"%f %f %f %f %f %f",&dock_res->distCenters[idConf],&dock_res->theta[idConf],&dock_res->phi[idConf],&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf]); rc = fscanf(condFile_stream,"%f %f %f %f %f %f",&dock_res->distCenters[idConf],&dock_res->theta[idConf],&dock_res->phi[idConf],&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf]);
} }
// TODO : Is this necessary for HEX ? rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
/* rc = getline(&buf,&len,condFile_stream); /1* Get rid of the rest of the line *1/ */
/* theta and phi angles are written in Radian already /* theta and phi angles are written in Radian already
* However that is not the case for alpha, beta and gamma angles * However that is not the case for alpha, beta and gamma angles
...@@ -100,7 +97,7 @@ struct docking_results* getDataForComplex(){ ...@@ -100,7 +97,7 @@ struct docking_results* getDataForComplex(){
//dock_res->phi[idConf] = dock_res->phi[idConf]*COEF_DEGREE_TO_RADIAN; //dock_res->phi[idConf] = dock_res->phi[idConf]*COEF_DEGREE_TO_RADIAN;
/* MAXDo will output the values of alpha, beta and gamma in degrees. /* MAXDo will output the values of alpha, beta and gamma in degrees.
* We need to convert these to radian for the rest of the program * We need to convert those to radian for the rest of the program
*/ */
if(HCMD2 || MAXDo){ if(HCMD2 || MAXDo){
dock_res->alpha[idConf] = dock_res->alpha[idConf] * COEF_DEGREE_TO_RADIAN; dock_res->alpha[idConf] = dock_res->alpha[idConf] * COEF_DEGREE_TO_RADIAN;
......
...@@ -15,11 +15,9 @@ void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, fl ...@@ -15,11 +15,9 @@ void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, fl
*z = z0 + R * cos(theta); *z = z0 + R * cos(theta);
} }
struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float trans_X, float trans_Y, float trans_Z, float alpha,float beta,float gamma){ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* newPDB, float trans_X, float trans_Y, float trans_Z, float alpha,float beta,float gamma){
/* This function aims at rotating the pdb parameter and gets its new coordinates /* This function aims at rotating the pdb parameter and gets its new coordinates
* in the newPDB parameter. * in the newPDB parameter.
* Let the N axis the rotation of the x axis about the z axis by an alpha angle.
* Let the Z axis the rotation of the z axis about the N axis by a beta angle.
* *
* The xyz system is centered on the center of mass of the pdb parameter. * The xyz system is centered on the center of mass of the pdb parameter.
* We then rotate the pdb by an alpha angle about the axis z, then by a beta * We then rotate the pdb by an alpha angle about the axis z, then by a beta
...@@ -28,11 +26,7 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s ...@@ -28,11 +26,7 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s
* https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Eulerangles.svg/300px-Eulerangles.svg.png * https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Eulerangles.svg/300px-Eulerangles.svg.png
*/ */
printf("%f %f %f\n",alpha,beta,gamma);
float xi = 0, yi = 0, zi = 0; float xi = 0, yi = 0, zi = 0;
float x1i = 0, y1i = 0, z1i = 0;
float x2i = 0, y2i = 0, z2i = 0;
float x3i = 0, y3i = 0, z3i = 0; float x3i = 0, y3i = 0, z3i = 0;
float c_a=cos(alpha),s_a=sin(alpha); float c_a=cos(alpha),s_a=sin(alpha);
...@@ -40,31 +34,12 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s ...@@ -40,31 +34,12 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s
float c_g=cos(gamma),s_g=sin(gamma); float c_g=cos(gamma),s_g=sin(gamma);
/* Coordinates of the N axis */
float xN = c_a;
float yN = s_a;
float zN = 0;
/* The coordinates of the unit vector for the axis Z can be computed as such :
* xZ : c_b
* yZ : c_a * s_b
* zZ : s_a * s_b
*/
float xZ = c_b;
float yZ = c_a * s_b;
float zZ = s_a * s_b;
if(newPDB == NULL){ if(newPDB == NULL){
newPDB = allocate_pdb(pdb->nbRes); newPDB = allocate_pdb(pdb->nbRes);
newPDB->nbAtom = pdb->nbAtom; newPDB->nbAtom = pdb->nbAtom;
} }
memcpy(newPDB->residues,pdb->residues,pdb->nbRes*sizeof(struct residue)); memcpy(newPDB->residues,pdb->residues,pdb->nbRes*sizeof(struct residue));
float newX = pdbR->centerX + trans_X;
float newY = pdbR->centerY + trans_Y;
float newZ = pdbR->centerZ + trans_Z;
/* This is now the part where we actually compute the rotations, given /* This is now the part where we actually compute the rotations, given
* the coordinates for the rotation axis N and Z * the coordinates for the rotation axis N and Z
*/ */
...@@ -72,53 +47,26 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s ...@@ -72,53 +47,26 @@ struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, s
for(i=0;i<pdb->nbRes;i++){ for(i=0;i<pdb->nbRes;i++){
for(j=0;j<pdb->residues[i].nbAtom;j++){ for(j=0;j<pdb->residues[i].nbAtom;j++){
xi = pdb->residues[i].x[j]; // - pdb->centerX; xi = pdb->residues[i].x[j];
yi = pdb->residues[i].y[j]; // - pdb->centerY; yi = pdb->residues[i].y[j];
zi = pdb->residues[i].z[j]; // - pdb->centerZ; zi = pdb->residues[i].z[j];
/* alpha rotation of the residue */
x1i=c_a*xi-s_a*yi;
y1i=c_a*yi+s_a*xi;
z1i=zi;
/* beta rotation of the residue */
x2i = (xN*xN+(1.0-xN*xN)*c_b)*x1i + xN*yN*(1.0-c_b)*y1i + yN*s_b*z1i;
y2i = xN*yN*(1.0-c_b)*x1i + (yN*yN+(1.0-yN*yN)*c_b)*y1i - xN*s_b*z1i;
z2i = -yN*s_b*x1i + xN*s_b*y1i + c_b*z1i;
/* gamma rotation of the residue */
x3i = (xZ*xZ+(1.0-xZ*xZ)*c_g) *x2i + (xZ*yZ*(1.0-c_g)-zZ*s_g)*y2i + (xZ*zZ*(1.0-c_g)+yZ*s_g)*z2i;
y3i = (xZ*yZ*(1.0-c_g)+zZ*s_g)*x2i + (yZ*yZ+(1.0-yZ*yZ)*c_g) *y2i + (yZ*zZ*(1.0-c_g)-xZ*s_g)*z2i;
z3i = (xZ*zZ*(1.0-c_g)-yZ*s_g)*x2i + (yZ*zZ*(1.0-c_g)+xZ*s_g)*y2i + (zZ*zZ+(1.0-zZ*zZ)*c_g) *z2i;
/* Rotation matrix for HEX */
x3i = (c_a*c_b*c_g-s_a*s_g) * xi + (-c_a*c_b*s_g-s_a*c_g) * yi + (c_a*s_b) * zi; x3i = (c_a*c_b*c_g-s_a*s_g) * xi + (-c_a*c_b*s_g-s_a*c_g) * yi + (c_a*s_b) * zi;
y3i = (c_a*s_g+s_a*c_b*c_g) * xi + (-s_a*c_b*s_g+c_a*c_g) * yi + (s_a*s_b) * zi; y3i = (c_a*s_g+s_a*c_b*c_g) * xi + (-s_a*c_b*s_g+c_a*c_g) * yi + (s_a*s_b) * zi;
z3i = (-s_b*c_g) * xi + (s_b*s_g) * yi + (c_b) * zi; z3i = (-s_b*c_g) * xi + (s_b*s_g) * yi + (c_b) * zi;
/* Now the residue has been rotated, and we need to translate it /* Now the atom has been rotated, and we need to translate it
* to its final destination * to its final destination
*/ */
newPDB->residues[i].x[j] = x3i + trans_X; newPDB->residues[i].x[j] = x3i + trans_X;
newPDB->residues[i].y[j] = y3i + trans_Y; newPDB->residues[i].y[j] = y3i + trans_Y;
newPDB->residues[i].z[j] = z3i + trans_Z; newPDB->residues[i].z[j] = z3i + trans_Z;
/* We also translate the coordinates of the first and fifth CA, even newPDB->centerX += trans_X;
* though they are not used afterwards. This is for the sake of newPDB->centerY += trans_X;
* having the right values at the right places newPDB->centerZ += trans_Z;
*/
newPDB->xCA1 = (newPDB->xCA1 - pdb->centerX) + newX;
newPDB->yCA1 = (newPDB->yCA1 - pdb->centerY) + newY;
newPDB->zCA1 = (newPDB->zCA1 - pdb->centerZ) + newZ;
newPDB->xCA5 = (newPDB->xCA5 - pdb->centerX) + newX;
newPDB->yCA5 = (newPDB->yCA5 - pdb->centerY) + newY;
newPDB->zCA5 = (newPDB->zCA5 - pdb->centerZ) + newZ;
newPDB->centerX = newX;
newPDB->centerY = newY;
newPDB->centerZ = newZ;
} }
} }
......
...@@ -11,5 +11,5 @@ void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, fl ...@@ -11,5 +11,5 @@ void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, fl
struct pdb_values* rotate_global(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 pdb_values* rotate_global(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 pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float trans_X, float trans_Y, float trans_Z, float alpha,float beta,float gamma); struct pdb_values* rotate_HEX(struct pdb_values* pdb, struct pdb_values* newPDB, float trans_X, float trans_Y, float trans_Z, float alpha,float beta,float gamma);
#endif #endif
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