Commit df933e01 by Chloe Dequeker

debug HEX finished

parent 9b241008
......@@ -306,16 +306,16 @@ int main(int argc, char** argv){
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],
dalpha,dbeta,dgamma,dock_res,target_conf);
}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->alpha[target_conf],dock_res->beta[target_conf],
dock_res->gamma[target_conf]);
}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],
alpha,beta,gamma);
}
......@@ -355,12 +355,12 @@ int main(int argc, char** argv){
dock_res->theta[i], dock_res->phi[i],
dalpha, dbeta, dgamma, dock_res, i);
}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->alpha[i],dock_res->beta[i],
dock_res->gamma[i]);
}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],
alpha,beta,gamma);
}
......
......@@ -50,7 +50,6 @@ struct docking_results* getDataForComplex(){
}else if(HEX){
for(i=0;i<NB_HEADER_LINE_HEX;i++){
getline(&buf,&len,condFile_stream);
printf("%s\n",buf);
}
}
......@@ -81,7 +80,6 @@ struct docking_results* getDataForComplex(){
if(feof(condFile_stream)){
break;
}
/* printf("curConf : %d\n",idConf); */
if(HEX){
......@@ -89,8 +87,7 @@ struct docking_results* getDataForComplex(){
}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]);
}
// TODO : Is this necessary for HEX ?
/* rc = getline(&buf,&len,condFile_stream); /1* Get rid of the rest of the line *1/ */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
/* theta and phi angles are written in Radian already
* However that is not the case for alpha, beta and gamma angles
......@@ -100,7 +97,7 @@ struct docking_results* getDataForComplex(){
//dock_res->phi[idConf] = dock_res->phi[idConf]*COEF_DEGREE_TO_RADIAN;
/* 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){
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
*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
* 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.
* 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
* 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 x1i = 0, y1i = 0, z1i = 0;
float x2i = 0, y2i = 0, z2i = 0;
float x3i = 0, y3i = 0, z3i = 0;
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
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){
newPDB = allocate_pdb(pdb->nbRes);
newPDB->nbAtom = pdb->nbAtom;
}
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
* 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
for(i=0;i<pdb->nbRes;i++){
for(j=0;j<pdb->residues[i].nbAtom;j++){
xi = pdb->residues[i].x[j]; // - pdb->centerX;
yi = pdb->residues[i].y[j]; // - pdb->centerY;
zi = pdb->residues[i].z[j]; // - pdb->centerZ;
/* 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;
xi = pdb->residues[i].x[j];
yi = pdb->residues[i].y[j];
zi = pdb->residues[i].z[j];
/* 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;
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;
/* 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
*/
newPDB->residues[i].x[j] = x3i + trans_X;
newPDB->residues[i].y[j] = y3i + trans_Y;
newPDB->residues[i].z[j] = z3i + trans_Z;
/* We also translate the coordinates of the first and fifth CA, even
* though they are not used afterwards. This is for the sake of
* having the right values at the right places
*/
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;
newPDB->centerX += trans_X;
newPDB->centerY += trans_X;
newPDB->centerZ += trans_Z;
}
}
......
......@@ -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_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
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