Commit 7b543ddb by Chloe Dequeker

adding getdataComplex for ATTRACT

parent ba6e9cf9
......@@ -44,8 +44,9 @@ struct docking_results* allocate_dockingResults(int nbConf){
perror("malloc");
exit(EXIT_FAILURE);
}
memset(dock_res,0,sizeof(struct docking_results));
dock_res->nbConf = nbConf;
dock_res->listEner = NULL;
/* dock_res->listEner = NULL;
dock_res->distCenters = NULL;
dock_res->theta = NULL;
dock_res->phi = NULL;
......@@ -56,6 +57,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
dock_res->trans_X = NULL;
dock_res->trans_Y = NULL;
dock_res->trans_Z = NULL;
*/
dock_res->listEner = malloc((2*nbConf)*sizeof(float));
if(dock_res->listEner == NULL){
......@@ -84,7 +86,73 @@ struct docking_results* allocate_dockingResults(int nbConf){
exit(EXIT_FAILURE);
}
/* Only HEX uses translation values */
dock_res->phi_R = malloc((2*nbConf)*sizeof(float));
if(dock_res->phi_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->ssi_R = malloc((2*nbConf)*sizeof(float));
if(dock_res->ssi_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->rot_R = malloc((2*nbConf)*sizeof(float));
if(dock_res->rot_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->phi_L = malloc((2*nbConf)*sizeof(float));
if(dock_res->phi_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->ssi_L = malloc((2*nbConf)*sizeof(float));
if(dock_res->ssi_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->rot_L = malloc((2*nbConf)*sizeof(float));
if(dock_res->rot_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_X_R = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_X_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_Y_R = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_Y_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_Z_R = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_Z_R == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_X_L = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_X_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_Y_L = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_Y_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->trans_Z_L = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_Z_L == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
/* Only HEX and ZDOCK use translation values */
if(HEX || ZDOCK){
dock_res->trans_X = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_X == NULL){
......@@ -121,7 +189,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
}
}
for(i=0;i<nbConf;i++){
for(i=0;i<1+nbConf;i++){
dock_res->listEner[i] = 0;
dock_res->alpha[i] = 0;
......
......@@ -26,19 +26,224 @@ char* deblank(char* input){
}
struct docking_results* getDataForComplex_ATTRACT(){
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;
int idConf = 0, i = 0;
int line = 1, auto_pivot = 0;
struct docking_results* dock_res = NULL;
const int MAXSIZE_LINE = 100000;
char buf[MAXSIZE_LINE] = "";
int nr = 0;
float pivot[2][3] = {{0,0,0},{0,0,0}};
condFile_stream = fopen(dockingFile,"r");
/* Read the header */
/*******************/
int done = 0, ok = 1;
while(!done){
done = 1;
/* If we are not able to read the line */
if(!fgets(buf, MAXSIZE_LINE, condFile_stream)){
ok = 0;
}
/* These are the lines before the pivot */
else if(strlen(buf) < 8 || strncmp(buf, "#pivot ", 7)){
if (strlen(buf) < 2 || buf[0] != '#' || buf[1] != '#') ok = 0;
else done = 0;
}
if(!ok){
fprintf(stderr, "Reading error in %s, line %d: expected pivot point or '#pivot auto'\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
if(!done)
continue;
/* Checking pivot */
/* If this is auto */
if(!(strncmp(buf+7,"auto", 4))){
auto_pivot = 1;
}else{
auto_pivot = 0;
ok = 1;
/* We only consider two structures docking */
for(i=0;i<2;i++){
if(ok){
/* This is not a pivot line */
if(strncmp(buf, "#pivot ", 7) != 0)
ok = 0;
/* Could not properly read the pivot line */
else if(sscanf(buf+7, "%d %f %f %f", &nr, &pivot[i][0], &pivot[i][1], &pivot[i][2]) < 4)
ok = 0;
/* Error in the pivot ID */
else if (nr != i+1)
ok = 0;
}
/* If some error occured */
if(!ok){
fprintf(stderr, "Reading error in %s, line %d: expected pivot point\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
if(i < 1){ /* get to next pivot line */
/* If we couldn't read properly */
if(!fgets(buf,MAXSIZE_LINE,condFile_stream))
ok = 0;
line++;
}
}
}
if(done)
break;
}
int centered_R = -1, centered_L = -1;
/* Check if the receptor is centered or not */
if(fgets(buf,MAXSIZE_LINE,condFile_stream)){
if (strlen(buf) >= 24 && strncmp(buf, "#centered receptor: true", 24) != 0)
centered_R = 1;
if (strlen(buf) >= 25 && strncmp(buf, "#centered receptor: false", 25) != 0)
centered_R = 0;
}
/* No valid value */
if(centered_R < 0){
fprintf(stderr, "Reading error in %s, line %d: expected '#centered receptor: true' or '#centered receptor: false'\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
/* Check if the ligand is centered or not */
if(fgets(buf,MAXSIZE_LINE,condFile_stream)){
if (strlen(buf) >= 23 && strncmp(buf, "#centered ligands: true", 23) != 0)
centered_L = 1;
if (strlen(buf) >= 24 && strncmp(buf, "#centered ligands: false", 24) != 0)
centered_L = 0;
if (strlen(buf) >= 22 && strncmp(buf, "#centered ligand: true", 22) != 0)
centered_L = 1;
if (strlen(buf) >= 23 && strncmp(buf, "#centered ligand: false", 23) != 0)
centered_L = 0;
}
/* No valid value */
if(centered_L < 0){
fprintf(stderr, "Reading error in %s, line %d: expected '#centered ligand: true' or '#centered ligand: false'\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
/* Now that we have read the header, we need to get the number of
* conformations
*/
long file_pos = ftell(condFile_stream);
while(!feof(condFile_stream)){
fgets(buf,MAXSIZE_LINE,condFile_stream);
/* This is not the line with the ID of the structure */
if(buf[0] != '#' || buf[1] == '#'){
continue;
}
/* Now, we know the line begins with only one '#' */
numberOfConf++;
}
return NULL;
if(fseek(condFile_stream,file_pos,SEEK_SET) != 0){
perror("fseek");
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
/* Now that we know how many conformations we are dealing with
* allocate a structure large enough
*/
dock_res = allocate_dockingResults(numberOfConf);
for(i=0;i<numberOfConf;i++){
dock_res->pivot_X_R = pivot[0][0];
dock_res->pivot_Y_R = pivot[0][1];
dock_res->pivot_Z_R = pivot[0][2];
dock_res->pivot_X_L = pivot[1][0];
dock_res->pivot_Y_L = pivot[1][1];
dock_res->pivot_Z_L = pivot[1][2];
dock_res->centered_R = centered_R;
dock_res->centered_L = centered_L;
}
int curConf = 0;
int mode = 0;
/* modes:
* 0 = expecting comment
* 1 = expecting data
*/
while(!feof(condFile_stream)){
line++;
if(!fgets(buf,MAXSIZE_LINE,condFile_stream)){
if(mode == 0)
continue;
else{
fprintf(stderr, "Reading error in %s, line %d: expecting #\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
}
if(mode == 0){
if(buf[0] != '#'){
fprintf(stderr, "Reading error in %s, line %d: expecting #\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
if(buf[1] == '#'){
continue;
}else{ /* We can read the ID of the conformation */
curConf = atoi(&buf[1]);
if(curConf == 0){
fprintf(stderr, "Reading error in %s, line %d: No valid conformation\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
mode = 1;
continue;
}
}
if(mode == 1){
if(buf[0] == '#')
continue;
sscanf(buf,"%f %f %f %f %f %f",&dock_res->phi_R[curConf],&dock_res->ssi_R[curConf],&dock_res->rot_R[curConf],
&dock_res->trans_X_R[curConf],&dock_res->trans_Y_R[curConf],&dock_res->trans_Z_R[curConf]);
line++;
if(!fgets(buf,MAXSIZE_LINE,condFile_stream)){
fprintf(stderr, "Reading error in %s, line %d\n", dockingFile, line);
fclose(condFile_stream);
exit(EXIT_FAILURE);
}
sscanf(buf,"%f %f %f %f %f %f",&dock_res->phi_L[curConf],&dock_res->ssi_L[curConf],&dock_res->rot_L[curConf],
&dock_res->trans_X_L[curConf],&dock_res->trans_Y_L[curConf],&dock_res->trans_Z_L[curConf]);
mode = 0;
}
}
fclose(condFile_stream);
return dock_res;
}
struct docking_results* getDataForComplex(){
......
......@@ -114,6 +114,27 @@ struct docking_results {
float* trans_Z;
int* t_conf; /* 1 for a conformation position if it exists, 0 otherwise */
int nbConf; /* Number of conformations */
float pivot_X_R; /* Pivot for X, Y, Z for the receptor and the ligand */
float pivot_Y_R; /* when considering ATTRACT docking */
float pivot_Z_R;
float pivot_X_L;
float pivot_Y_L;
float pivot_Z_L;
float* phi_R;
float* ssi_R;
float* rot_R;
float* phi_L;
float* ssi_L;
float* rot_L;
float* trans_X_R;
float* trans_Y_R;
float* trans_Z_R;
float* trans_X_L;
float* trans_Y_L;
float* trans_Z_L;
int centered_R;
int centered_L;
};
#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