Commit 8cd78e6e by Chloe Dequeker

fix errors and memory leaks. Reconstruction not quite working yet though

parent e5d6a8e6
...@@ -346,7 +346,7 @@ int main(int argc, char** argv){ ...@@ -346,7 +346,7 @@ int main(int argc, char** argv){
newPDB = rotate_ATTRACT(pdbL,newPDB,dock_res,target_conf,0); newPDB = rotate_ATTRACT(pdbL,newPDB,dock_res,target_conf,0);
/*For the receptor */ /*For the receptor */
newPDB_R = rotate_ATTRACT(pdbR,newPDB,dock_res,target_conf,1); newPDB_R = rotate_ATTRACT(pdbR,newPDB_R,dock_res,target_conf,1);
}else{ }else{
newPDB = rotate_global(pdbL,pdbR,newPDB,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],
...@@ -366,9 +366,12 @@ int main(int argc, char** argv){ ...@@ -366,9 +366,12 @@ int main(int argc, char** argv){
writePDB(newPDB, ligand,target_conf); writePDB(newPDB, ligand,target_conf);
} }
freePDB(newPDB); freePDB(newPDB);
freePDB(newPDB_R);
newPDB = NULL; newPDB = NULL;
if(newPDB_R != NULL){
freePDB(newPDB_R);
newPDB_R = NULL; newPDB_R = NULL;
}
}else{ /* For all conformations */ }else{ /* For all conformations */
for(i=1;i<=dock_res->nbConf;i++){ for(i=1;i<=dock_res->nbConf;i++){
...@@ -405,10 +408,10 @@ int main(int argc, char** argv){ ...@@ -405,10 +408,10 @@ int main(int argc, char** argv){
dock_res->gamma[i]); dock_res->gamma[i]);
}else if(ATTRACT){ }else if(ATTRACT){
/* For the ligand */ /* For the ligand */
newPDB = rotate_ATTRACT(pdbL,newPDB,dock_res,target_conf,0); newPDB = rotate_ATTRACT(pdbL,newPDB,dock_res,i,0);
/*For the receptor */ /*For the receptor */
newPDB_R = rotate_ATTRACT(pdbR,newPDB,dock_res,target_conf,1); newPDB_R = rotate_ATTRACT(pdbR,newPDB_R,dock_res,i,1);
}else{ }else{
newPDB = rotate_global(pdbL,pdbR,newPDB,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],
...@@ -429,10 +432,13 @@ int main(int argc, char** argv){ ...@@ -429,10 +432,13 @@ int main(int argc, char** argv){
} }
} }
freePDB(newPDB); freePDB(newPDB);
freePDB(newPDB_R);
newPDB = NULL; newPDB = NULL;
if(newPDB_R != NULL){
printf("point %p\n",newPDB_R);
freePDB(newPDB_R);
newPDB_R = NULL; newPDB_R = NULL;
} }
}
freePDB(pdbL); freePDB(pdbL);
freePDB(pdbR); freePDB(pdbR);
......
...@@ -19,6 +19,21 @@ void freeDock(struct docking_results* dock_res){ ...@@ -19,6 +19,21 @@ void freeDock(struct docking_results* dock_res){
free(dock_res->trans_X); free(dock_res->trans_X);
free(dock_res->trans_Y); free(dock_res->trans_Y);
free(dock_res->trans_Z); free(dock_res->trans_Z);
}else if(ATTRACT){
free(dock_res->phi_R);
free(dock_res->ssi_R);
free(dock_res->rot_R);
free(dock_res->phi_L);
free(dock_res->ssi_L);
free(dock_res->rot_L);
free(dock_res->trans_X_R);
free(dock_res->trans_Y_R);
free(dock_res->trans_Z_R);
free(dock_res->trans_X_L);
free(dock_res->trans_Y_L);
free(dock_res->trans_Z_L);
}else{ }else{
free(dock_res->distCenters); free(dock_res->distCenters);
free(dock_res->theta); free(dock_res->theta);
...@@ -46,7 +61,7 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -46,7 +61,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
} }
memset(dock_res,0,sizeof(struct docking_results)); memset(dock_res,0,sizeof(struct docking_results));
dock_res->nbConf = nbConf; dock_res->nbConf = nbConf;
/* dock_res->listEner = NULL; dock_res->listEner = NULL;
dock_res->distCenters = NULL; dock_res->distCenters = NULL;
dock_res->theta = NULL; dock_res->theta = NULL;
dock_res->phi = NULL; dock_res->phi = NULL;
...@@ -57,7 +72,6 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -57,7 +72,6 @@ struct docking_results* allocate_dockingResults(int nbConf){
dock_res->trans_X = NULL; dock_res->trans_X = NULL;
dock_res->trans_Y = NULL; dock_res->trans_Y = NULL;
dock_res->trans_Z = NULL; dock_res->trans_Z = NULL;
*/
dock_res->listEner = malloc((2*nbConf)*sizeof(float)); dock_res->listEner = malloc((2*nbConf)*sizeof(float));
if(dock_res->listEner == NULL){ if(dock_res->listEner == NULL){
...@@ -86,7 +100,7 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -86,7 +100,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if(ATTRACT){
dock_res->phi_R = malloc((2*nbConf)*sizeof(float)); dock_res->phi_R = malloc((2*nbConf)*sizeof(float));
if(dock_res->phi_R == NULL){ if(dock_res->phi_R == NULL){
perror("malloc"); perror("malloc");
...@@ -151,9 +165,7 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -151,9 +165,7 @@ struct docking_results* allocate_dockingResults(int nbConf){
perror("malloc"); perror("malloc");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
}else if(HEX || ZDOCK){
/* Only HEX and ZDOCK use translation values */
if(HEX || ZDOCK){
dock_res->trans_X = malloc((2*nbConf)*sizeof(int)); dock_res->trans_X = malloc((2*nbConf)*sizeof(int));
if(dock_res->trans_X == NULL){ if(dock_res->trans_X == NULL){
perror("malloc"); perror("malloc");
...@@ -189,9 +201,8 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -189,9 +201,8 @@ struct docking_results* allocate_dockingResults(int nbConf){
} }
} }
for(i=0;i<1+nbConf;i++){ for(i=0;i<nbConf+1;i++){
dock_res->listEner[i] = 0; dock_res->listEner[i] = 0;
dock_res->alpha[i] = 0; dock_res->alpha[i] = 0;
dock_res->beta[i] = 0; dock_res->beta[i] = 0;
dock_res->gamma[i] = 0; dock_res->gamma[i] = 0;
...@@ -200,6 +211,20 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -200,6 +211,20 @@ struct docking_results* allocate_dockingResults(int nbConf){
dock_res->trans_X[i] = 0; dock_res->trans_X[i] = 0;
dock_res->trans_Y[i] = 0; dock_res->trans_Y[i] = 0;
dock_res->trans_Z[i] = 0; dock_res->trans_Z[i] = 0;
}else if(ATTRACT){
dock_res->phi_R[i] = 0;
dock_res->ssi_R[i] = 0;
dock_res->rot_R[i] = 0;
dock_res->phi_L[i] = 0;
dock_res->ssi_L[i] = 0;
dock_res->rot_L[i] = 0;
dock_res->trans_X_R[i] = 0;
dock_res->trans_Y_R[i] = 0;
dock_res->trans_Z_R[i] = 0;
dock_res->trans_X_L[i] = 0;
dock_res->trans_Y_L[i] = 0;
dock_res->trans_Z_L[i] = 0;
}else{ }else{
dock_res->distCenters[i] = 0; dock_res->distCenters[i] = 0;
dock_res->theta[i] = 0; dock_res->theta[i] = 0;
......
...@@ -26,13 +26,12 @@ char* deblank(char* input){ ...@@ -26,13 +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; int numberOfConf = 0;
int 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;
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}};
...@@ -151,8 +150,9 @@ struct docking_results* getDataForComplex_ATTRACT(){ ...@@ -151,8 +150,9 @@ struct docking_results* getDataForComplex_ATTRACT(){
* conformations * conformations
*/ */
long file_pos = ftell(condFile_stream); long file_pos = ftell(condFile_stream);
while(!feof(condFile_stream)){ while(fgets(buf,MAXSIZE_LINE,condFile_stream)){
fgets(buf,MAXSIZE_LINE,condFile_stream); if(feof(condFile_stream))
break;
/* This is not the line with the ID of the structure */ /* This is not the line with the ID of the structure */
if(buf[0] != '#' || buf[1] == '#'){ if(buf[0] != '#' || buf[1] == '#'){
...@@ -220,6 +220,10 @@ struct docking_results* getDataForComplex_ATTRACT(){ ...@@ -220,6 +220,10 @@ struct docking_results* getDataForComplex_ATTRACT(){
fclose(condFile_stream); fclose(condFile_stream);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* We confirm that this conformation exists */
dock_res->t_conf[curConf] = 1;
mode = 1; mode = 1;
continue; continue;
} }
...@@ -404,10 +408,9 @@ struct docking_results* getDataForComplex_HEX(){ ...@@ -404,10 +408,9 @@ struct docking_results* getDataForComplex_HEX(){
struct docking_results* getDataForComplex_MAXDO(){ struct docking_results* getDataForComplex_MAXDO(){
char* buf = NULL; char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL; FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0; int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0; int idConf = 0, buf4 = 0;
float buf3 = 0; float buf3 = 0;
size_t len = 2000; size_t len = 2000;
struct docking_results* dock_res = NULL; struct docking_results* dock_res = NULL;
...@@ -483,10 +486,9 @@ struct docking_results* getDataForComplex_MAXDO(){ ...@@ -483,10 +486,9 @@ struct docking_results* getDataForComplex_MAXDO(){
struct docking_results* getDataForComplex_HCMD2(){ struct docking_results* getDataForComplex_HCMD2(){
char* buf = NULL; char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL; FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0; int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0; int idConf = 0;
float buf3 = 0; float buf3 = 0;
size_t len = 2000; size_t len = 2000;
struct docking_results* dock_res = NULL; struct docking_results* dock_res = NULL;
...@@ -563,10 +565,9 @@ struct docking_results* getDataForComplex_HCMD2(){ ...@@ -563,10 +565,9 @@ struct docking_results* getDataForComplex_HCMD2(){
struct docking_results* getDataForComplex_DEFAULT(){ struct docking_results* getDataForComplex_DEFAULT(){
char* buf = NULL; char* buf = NULL;
char buf2[100] = "";
FILE* condFile_stream = NULL; FILE* condFile_stream = NULL;
int numberOfConf = 0, rc = 0; int numberOfConf = 0, rc = 0;
int idConf = 0, buf4 = 0, i = 0; int idConf = 0;
float buf3 = 0; float buf3 = 0;
size_t len = 2000; size_t len = 2000;
struct docking_results* dock_res = NULL; struct docking_results* dock_res = NULL;
......
...@@ -116,9 +116,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new ...@@ -116,9 +116,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new
} }
if(dock_res->centered_R){ if(dock_res->centered_R){
trans_X = dock_res->trans_X_R[i] - pivot_X; trans_X = dock_res->trans_X_R[target_conf] - pivot_X;
trans_Y = dock_res->trans_Y_R[i] - pivot_Y; trans_Y = dock_res->trans_Y_R[target_conf] - pivot_Y;
trans_Z = dock_res->trans_Z_R[i] - pivot_Z; trans_Z = dock_res->trans_Z_R[target_conf] - pivot_Z;
} }
}else{ }else{
cp = cos(dock_res->phi_L[target_conf]); cp = cos(dock_res->phi_L[target_conf]);
...@@ -142,9 +142,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new ...@@ -142,9 +142,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new
} }
if(dock_res->centered_L){ if(dock_res->centered_L){
trans_X = dock_res->trans_X_L[i] - pivot_X; trans_X = dock_res->trans_X_L[target_conf] - pivot_X;
trans_Y = dock_res->trans_Y_L[i] - pivot_Y; trans_Y = dock_res->trans_Y_L[target_conf] - pivot_Y;
trans_Z = dock_res->trans_Z_L[i] - pivot_Z; trans_Z = dock_res->trans_Z_L[target_conf] - pivot_Z;
} }
} }
...@@ -166,7 +166,7 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new ...@@ -166,7 +166,7 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new
rot_mat[8] = cs; rot_mat[8] = cs;
for(i=0;i<newPDB->nbRes;i++){ for(i=0;i<newPDB->nbRes;i++){
for(j=0;i<newPDB->residues[i].nbAtom;j++){ for(j=0;j<newPDB->residues[i].nbAtom;j++){
xx = newPDB->residues[i].x[j]; xx = newPDB->residues[i].x[j];
yy = newPDB->residues[i].y[j]; yy = newPDB->residues[i].y[j];
zz = newPDB->residues[i].z[j]; zz = newPDB->residues[i].z[j];
...@@ -175,9 +175,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new ...@@ -175,9 +175,9 @@ struct pdb_values* rotate_ATTRACT(struct pdb_values* pdb, struct pdb_values* new
newPDB->residues[i].y[j] = xx * rot_mat[3] + yy * rot_mat[4] + zz * rot_mat[5]; newPDB->residues[i].y[j] = xx * rot_mat[3] + yy * rot_mat[4] + zz * rot_mat[5];
newPDB->residues[i].z[j] = xx * rot_mat[6] + yy * rot_mat[7] + zz * rot_mat[8]; newPDB->residues[i].z[j] = xx * rot_mat[6] + yy * rot_mat[7] + zz * rot_mat[8];
newPDB->residues[i].x[j] = newPDB->residues[i].x[j] + dock_res->trans_X_R[target_conf] + pivot_X; newPDB->residues[i].x[j] = newPDB->residues[i].x[j] + trans_X + pivot_X;
newPDB->residues[i].y[j] = newPDB->residues[i].y[j] + dock_res->trans_Y_R[target_conf] + pivot_Y; newPDB->residues[i].y[j] = newPDB->residues[i].y[j] + trans_Y + pivot_Y;
newPDB->residues[i].z[j] = newPDB->residues[i].z[j] + dock_res->trans_Z_R[target_conf] + pivot_Z; newPDB->residues[i].z[j] = newPDB->residues[i].z[j] + trans_Z + pivot_Z;
} }
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* the contact is a clash */ * 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_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_ZDOCK 5 /* Number of header lines at the top of a ZDOCK docking file */
#define MAXSIZE_LINE 100000
/* This is the format of a line in a PDB file */ /* This is the format of a line in a PDB file */
#define FORMAT_LINE_PDB_ATM "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f%s\n" #define FORMAT_LINE_PDB_ATM "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f%s\n"
......
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