Commit 0f097225 by Chloe Dequeker

separating getDataForComplex functions for each docking algorithm

parent 9686c2b0
...@@ -26,12 +26,12 @@ char* deblank(char* input){ ...@@ -26,12 +26,12 @@ char* deblank(char* input){
} }
struct docking_results* getDataForComplex_ATTRACT(){ struct docking_results* getDataForComplex_ATTRACT(){
const int MAXSIZE_LINE = 100000;
FILE* condFile_stream = NULL; FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0; int numberOfConf = 0;
int idConf = 0, i = 0; int i = 0;
int line = 1, auto_pivot = 0; int line = 1, auto_pivot = 0;
struct docking_results* dock_res = NULL; struct docking_results* dock_res = NULL;
const int MAXSIZE_LINE = 100000;
char buf[MAXSIZE_LINE] = ""; char buf[MAXSIZE_LINE] = "";
int nr = 0; int nr = 0;
float pivot[2][3] = {{0,0,0},{0,0,0}}; float pivot[2][3] = {{0,0,0},{0,0,0}};
...@@ -107,6 +107,10 @@ struct docking_results* getDataForComplex_ATTRACT(){ ...@@ -107,6 +107,10 @@ struct docking_results* getDataForComplex_ATTRACT(){
break; break;
} }
/* The pivot has been read, now we need to check if any protein is
* centered
*/
int centered_R = -1, centered_L = -1; int centered_R = -1, centered_L = -1;
/* Check if the receptor is centered or not */ /* Check if the receptor is centered or not */
...@@ -247,11 +251,85 @@ struct docking_results* getDataForComplex_ATTRACT(){ ...@@ -247,11 +251,85 @@ struct docking_results* getDataForComplex_ATTRACT(){
return dock_res; return dock_res;
} }
struct docking_results* getDataForComplex(){ struct docking_results* getDataForComplex_ZDOCK(){
char* buf = NULL; char* buf = NULL;
char buf2[100] = ""; char buf2[100] = "";
FILE* condFile_stream = NULL; FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0; int numberOfConf = 0, rc = 0;
int idConf = 0, i = 0;
float buf3 = 0;
size_t len = 2000;
struct docking_results* dock_res = NULL;
condFile_stream = fopen(dockingFile,"r");
rc = fscanf(condFile_stream,"%d %f %d",&ZDOCK_GRID_SIZE,&ZDOCK_GRID_UNIT,&ZDOCK_PROT_FIXED);
rc = fscanf(condFile_stream,"%f %f %f",&ZDOCK_REC_A_ROT,&ZDOCK_REC_B_ROT,&ZDOCK_REC_G_ROT);
rc = fscanf(condFile_stream,"%f %f %f",&ZDOCK_LIG_A_ROT,&ZDOCK_LIG_B_ROT,&ZDOCK_LIG_G_ROT);
rc = fscanf(condFile_stream,"%s %f %f %f",buf2,&ZDOCK_REC_X_TRANS,&ZDOCK_REC_Y_TRANS,&ZDOCK_REC_Z_TRANS);
rc = fscanf(condFile_stream,"%s %f %f %f",buf2,&ZDOCK_LIG_X_TRANS,&ZDOCK_LIG_Y_TRANS,&ZDOCK_LIG_Z_TRANS);
/* Get the number of conformations */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
numberOfConf++;
while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%f",&buf3);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(feof(condFile_stream)){
break;
}
numberOfConf++;
numberOfConf = (int) buf3;
}
numberOfConf--;
rewind(condFile_stream);
/* This is with the first MAXDo format */
for(i=0;i<NB_HEADER_LINE_ZDOCK;i++)
rc = getline(&buf,&len,condFile_stream);
/* Now that we know how many conformations we are dealing with
* allocate a structure large enough
*/
dock_res = allocate_dockingResults(numberOfConf);
while(!feof(condFile_stream)){
idConf++;
/* We confirm that this conformation exists in the MAXDo file */
dock_res->t_conf[idConf] = 1;
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
}
rc = fscanf(condFile_stream,"%f %f %f %f %f %f",&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf],&dock_res->trans_X[idConf],&dock_res->trans_Y[idConf],&dock_res->trans_Z[idConf]);
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
*/
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
}
}
dock_res->nbConf = numberOfConf;
fclose(condFile_stream);
free(buf);
return dock_res;
}
struct docking_results* getDataForComplex_HEX(){
char* buf = NULL;
FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0; int idConf = 0, buf4 = 0, i = 0;
float buf3 = 0; float buf3 = 0;
size_t len = 2000; size_t len = 2000;
...@@ -265,56 +343,95 @@ struct docking_results* getDataForComplex(){ ...@@ -265,56 +343,95 @@ struct docking_results* getDataForComplex(){
} }
} }
if(ZDOCK){ /* Get the number of conformations */
rc = fscanf(condFile_stream,"%d %f %d",&ZDOCK_GRID_SIZE,&ZDOCK_GRID_UNIT,&ZDOCK_PROT_FIXED); rc = fscanf(condFile_stream,"%f %f",&buf3,&buf3);
rc = fscanf(condFile_stream,"%f %f %f",&ZDOCK_REC_A_ROT,&ZDOCK_REC_B_ROT,&ZDOCK_REC_G_ROT);
rc = fscanf(condFile_stream,"%f %f %f",&ZDOCK_LIG_A_ROT,&ZDOCK_LIG_B_ROT,&ZDOCK_LIG_G_ROT); if(buf3 > numberOfConf){
rc = fscanf(condFile_stream,"%s %f %f %f",buf2,&ZDOCK_REC_X_TRANS,&ZDOCK_REC_Y_TRANS,&ZDOCK_REC_Z_TRANS); numberOfConf = (int) buf3;
rc = fscanf(condFile_stream,"%s %f %f %f",buf2,&ZDOCK_LIG_X_TRANS,&ZDOCK_LIG_Y_TRANS,&ZDOCK_LIG_Z_TRANS);
} }
/* Get the number of conformations */ while(!feof(condFile_stream)){
if(HEX){
rc = fscanf(condFile_stream,"%f %f",&buf3,&buf3); rc = fscanf(condFile_stream,"%f %f",&buf3,&buf3);
}else{
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */ rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf)
numberOfConf = (int) buf3;
} }
if(ZDOCK){ rewind(condFile_stream);
numberOfConf++;
}else if(buf3 > numberOfConf){ /* This is with the first MAXDo format */
numberOfConf = (int) buf3; for(i=0;i<NB_HEADER_LINE_HEX;i++){
rc = getline(&buf,&len,condFile_stream);
} }
/* Now that we know how many conformations we are dealing with
* allocate a structure large enough
*/
dock_res = allocate_dockingResults(numberOfConf);
while(!feof(condFile_stream)){ while(!feof(condFile_stream)){
if(HEX){ rc = fscanf(condFile_stream,"%d %d %f %f",&buf4,&idConf,&buf3,&buf3);
rc = fscanf(condFile_stream,"%f %f",&buf3,&buf3);
}else{ /* We confirm that this conformation exists in the MAXDo file */
rc = fscanf(condFile_stream,"%f",&buf3); dock_res->t_conf[idConf] = 1;
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
} }
rc = fscanf(condFile_stream,"%f %f %f %f %f %f",&dock_res->trans_X[idConf],&dock_res->trans_Y[idConf],&dock_res->trans_Z[idConf],&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf]);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */ rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(ZDOCK){
if(feof(condFile_stream)){
break; /* theta and phi angles are written in Radian already
} * However that is not the case for alpha, beta and gamma angles
numberOfConf++; */
}else if(buf3 > numberOfConf)
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
}
}
dock_res->nbConf = numberOfConf;
fclose(condFile_stream);
free(buf);
return dock_res;
}
struct docking_results* getDataForComplex_MAXDO(){
char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0;
float buf3 = 0;
size_t len = 2000;
struct docking_results* dock_res = NULL;
condFile_stream = fopen(dockingFile,"r");
/* Get the number of conformations */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf){
numberOfConf = (int) buf3;
}
while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%f",&buf3);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf)
numberOfConf = (int) buf3; numberOfConf = (int) buf3;
} }
if(ZDOCK)
numberOfConf--;
rewind(condFile_stream); rewind(condFile_stream);
/* This is with the first MAXDo format */ /* This is with the first MAXDo format */
if(MAXDo){ rc = getline(&buf,&len,condFile_stream); /* Get rid of the first line */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the first line */
}else if(ZDOCK){
for(i=0;i<NB_HEADER_LINE_ZDOCK;i++)
rc = getline(&buf,&len,condFile_stream);
}else if(HEX){
for(i=0;i<NB_HEADER_LINE_HEX;i++){
rc = getline(&buf,&len,condFile_stream);
}
}
/* Now that we know how many conformations we are dealing with /* Now that we know how many conformations we are dealing with
* allocate a structure large enough * allocate a structure large enough
...@@ -323,20 +440,87 @@ struct docking_results* getDataForComplex(){ ...@@ -323,20 +440,87 @@ struct docking_results* getDataForComplex(){
while(!feof(condFile_stream)){ while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%d %d",&idConf,&buf4);
if(MAXDo){ /* First MAXDo format */ /* We confirm that this conformation exists in the MAXDo file */
rc = fscanf(condFile_stream,"%d %d",&idConf,&buf4); dock_res->t_conf[idConf] = 1;
}else if(HEX){
rc = fscanf(condFile_stream,"%d %d %f %f",&buf4,&idConf,&buf3,&buf3); /* This happens when we arrive on the last line */
}else if(ZDOCK){ if(feof(condFile_stream)){
idConf++; break;
}else { }
/* Else, that means that we have a format where
* values for distance between center follows directly 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]);
* the ID of the conformation. rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
*/
rc = fscanf(condFile_stream,"%d",&idConf);
/* theta and phi angles are written in Radian already
* However that is not the case for alpha, beta and gamma angles
*/
//dock_res->theta[idConf] = dock_res->theta[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.
* We need to convert those to radian for the rest of the program
*/
dock_res->alpha[idConf] = dock_res->alpha[idConf] * COEF_DEGREE_TO_RADIAN;
dock_res->beta[idConf] = dock_res->beta[idConf] * COEF_DEGREE_TO_RADIAN;
dock_res->gamma[idConf] = dock_res->gamma[idConf] * COEF_DEGREE_TO_RADIAN;
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
} }
}
dock_res->nbConf = numberOfConf;
fclose(condFile_stream);
free(buf);
return dock_res;
}
struct docking_results* getDataForComplex_HCMD2(){
char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0;
float buf3 = 0;
size_t len = 2000;
struct docking_results* dock_res = NULL;
condFile_stream = fopen(dockingFile,"r");
/* Get the number of conformations */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf){
numberOfConf = (int) buf3;
}
while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%f",&buf3);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf)
numberOfConf = (int) buf3;
}
rewind(condFile_stream);
/* Now that we know how many conformations we are dealing with
* allocate a structure large enough
*/
dock_res = allocate_dockingResults(numberOfConf);
while(!feof(condFile_stream)){
/* that means that we have a format where
* values for distance between center follows directly
* the ID of the conformation.
*/
rc = fscanf(condFile_stream,"%d",&idConf);
/* We confirm that this conformation exists in the MAXDo file */ /* We confirm that this conformation exists in the MAXDo file */
dock_res->t_conf[idConf] = 1; dock_res->t_conf[idConf] = 1;
...@@ -346,13 +530,7 @@ struct docking_results* getDataForComplex(){ ...@@ -346,13 +530,7 @@ struct docking_results* getDataForComplex(){
break; break;
} }
if(HEX){ 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->trans_X[idConf],&dock_res->trans_Y[idConf],&dock_res->trans_Z[idConf],&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf]);
}else if(ZDOCK){
rc = fscanf(condFile_stream,"%f %f %f %f %f %f",&dock_res->alpha[idConf],&dock_res->beta[idConf],&dock_res->gamma[idConf],&dock_res->trans_X[idConf],&dock_res->trans_Y[idConf],&dock_res->trans_Z[idConf]);
}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 = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */ rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
...@@ -366,11 +544,72 @@ struct docking_results* getDataForComplex(){ ...@@ -366,11 +544,72 @@ struct docking_results* getDataForComplex(){
/* 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 those 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;
dock_res->alpha[idConf] = dock_res->alpha[idConf] * COEF_DEGREE_TO_RADIAN; dock_res->beta[idConf] = dock_res->beta[idConf] * COEF_DEGREE_TO_RADIAN;
dock_res->beta[idConf] = dock_res->beta[idConf] * COEF_DEGREE_TO_RADIAN; dock_res->gamma[idConf] = dock_res->gamma[idConf] * COEF_DEGREE_TO_RADIAN;
dock_res->gamma[idConf] = dock_res->gamma[idConf] * COEF_DEGREE_TO_RADIAN;
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
} }
}
dock_res->nbConf = numberOfConf;
fclose(condFile_stream);
free(buf);
return dock_res;
}
struct docking_results* getDataForComplex_DEFAULT(){
char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0;
float buf3 = 0;
size_t len = 2000;
struct docking_results* dock_res = NULL;
condFile_stream = fopen(dockingFile,"r");
/* Get the number of conformations */
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf){
numberOfConf = (int) buf3;
}
while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%f",&buf3);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
if(buf3 > numberOfConf)
numberOfConf = (int) buf3;
}
rewind(condFile_stream);
/* Now that we know how many conformations we are dealing with
* allocate a structure large enough
*/
dock_res = allocate_dockingResults(numberOfConf);
while(!feof(condFile_stream)){
/* That means that we have a format where
* values for distance between center follows directly
* the ID of the conformation.
*/
rc = fscanf(condFile_stream,"%d",&idConf);
/* We confirm that this conformation exists in the MAXDo file */
dock_res->t_conf[idConf] = 1;
/* This happens when we arrive on the last line */
if(feof(condFile_stream)){
break;
}
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 = getline(&buf,&len,condFile_stream); /* Get rid of the rest of the line */
/* This happens when we arrive on the last line */ /* This happens when we arrive on the last line */
if(feof(condFile_stream)){ if(feof(condFile_stream)){
...@@ -385,6 +624,22 @@ struct docking_results* getDataForComplex(){ ...@@ -385,6 +624,22 @@ struct docking_results* getDataForComplex(){
return dock_res; return dock_res;
} }
struct docking_results* getDataForComplex(){
if(MAXDo){
return getDataForComplex_MAXDO();
}else if(HCMD2){
return getDataForComplex_HCMD2();
}else if(HEX){
return getDataForComplex_HEX();
}else if(ZDOCK){
return getDataForComplex_ZDOCK();
}else if(ATTRACT){
return getDataForComplex_ATTRACT();
}else{
return getDataForComplex_DEFAULT();
}
}
struct pdb_values* readPDB(char* protein) { struct pdb_values* readPDB(char* protein) {
/* This function reads a PDB file and fills a structure /* This function reads a PDB file and fills a structure
......
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