Commit edb7375b by Chloe Dequeker

adaptation to HCMD2 format. Modif of writePDB function (takes the num of the conformation)

parent 54033ab7
...@@ -16,7 +16,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str ...@@ -16,7 +16,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
* of P1. At the end of the function, the first *nbCand1 residues in t_candid1 will * of P1. At the end of the function, the first *nbCand1 residues in t_candid1 will
* correspond to P1 candidates * correspond to P1 candidates
*/ */
float x = 0, y = 0, z = 0; float x = 0, y = 0, z = 0;
float centerX = 0, centerY = 0, centerZ = 0; float centerX = 0, centerY = 0, centerZ = 0;
float dist = 0, minDist = -1, maxDist = -1, threshold_dist = 0; float dist = 0, minDist = -1, maxDist = -1, threshold_dist = 0;
...@@ -64,7 +64,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str ...@@ -64,7 +64,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
} }
} }
} }
/* We remove every residue on pdb1 that is closer than treshold_dist from the center /* We remove every residue on pdb1 that is closer than treshold_dist from the center
* of mass * of mass
*/ */
...@@ -74,10 +74,10 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str ...@@ -74,10 +74,10 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
} }
*nbCand1 = 0; *nbCand1 = 0;
for(i=0;i<nbCandInit1;i++){ for(i=0;i<nbCandInit1;i++){
for(j=0;j<t_candid1[i]->nbAtom;j++){ for(j=0;j<t_candid1[i]->nbAtom;j++){
x = t_candid1[i]->x[j]; x = t_candid1[i]->x[j];
y = t_candid1[i]->y[j]; y = t_candid1[i]->y[j];
z = t_candid1[i]->z[j]; z = t_candid1[i]->z[j];
...@@ -93,7 +93,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str ...@@ -93,7 +93,7 @@ void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, str
} }
} }
void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf){ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
int i = 0, j = 0, k = 0, l = 0; int i = 0, j = 0, k = 0, l = 0;
int oldCandL = -1, oldCandR = -1; int oldCandL = -1, oldCandR = -1;
float x1 = 0, y1 = 0, z1 = 0; float x1 = 0, y1 = 0, z1 = 0;
...@@ -129,10 +129,21 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf) ...@@ -129,10 +129,21 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf)
oldCandL = nbCandL; oldCandL = nbCandL;
oldCandR = nbCandR; oldCandR = nbCandR;
getCandidatesForP1(pdbR,t_candidateL,t_candidateR,&nbCandL,&nbCandR); getCandidatesForP1(pdbR,t_candidateL,t_candidateR,&nbCandL,&nbCandR);
if(nbCandL == 0 || nbCandR == 0){
nbCandL = 0;
nbCandR = 0;
break;
}
getCandidatesForP1(pdbL,t_candidateR,t_candidateL,&nbCandR,&nbCandL); getCandidatesForP1(pdbL,t_candidateR,t_candidateL,&nbCandR,&nbCandL);
if(nbCandL == 0 || nbCandR == 0){
nbCandL = 0;
nbCandR = 0;
break;
}
} }
//printf("NB_ITER %d\n",k); //printf("NB_ITER %d\n",k);
for(i=0;i<nbCandR;i++){ for(i=0;i<nbCandR;i++){
t_candidateR[i]->isCandidate = 0; t_candidateR[i]->isCandidate = 0;
} }
...@@ -140,7 +151,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf) ...@@ -140,7 +151,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf)
t_candidateL[i]->isCandidate = 0; t_candidateL[i]->isCandidate = 0;
} }
/* Don't worry for that, this is only O(n^2) over the remaining /* Don't worry for that, this is only O(n^2) over the remaining
* candidate residues for each protein * candidate residues for each protein
* for each receptor resdiue candidate, we look at each of its atoms * for each receptor resdiue candidate, we look at each of its atoms
* for each ligand residue candidate, we llok at each of its atoms * for each ligand residue candidate, we llok at each of its atoms
...@@ -180,12 +191,85 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf) ...@@ -180,12 +191,85 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf)
fprintf(outputFile_rec,"'%s' '%c' ",strtok(t_candidateR[i]->idRes," "),t_candidateR[i]->chain); fprintf(outputFile_rec,"'%s' '%c' ",strtok(t_candidateR[i]->idRes," "),t_candidateR[i]->chain);
} }
free(t_candidateL); free(t_candidateL);
free(t_candidateR); free(t_candidateR);
} }
struct docking_results* getDataForComplex_HCMD2(){
char* buf = NULL;
char buf2[5];
FILE* condFile_stream = NULL;
int numberOfConf = 0, rc;
size_t len = 2000;
struct docking_results* dock_res = NULL;
strncpy(buf2,receptor,4);
buf2[4] = '\0';
//sprintf(totalFilePath,"%s/%s/Cond.%s.%s.UB.global.dat",dockingFile,buf2,receptor,ligand);
if(access(dockingFile,F_OK) == -1){
/* File does not exists, 4 file in this case
* Return NULL, which should be treated accordingly
*/
fprintf(stderr,"No such file : %s\n",dockingFile);
exit(EXIT_FAILURE);
}
condFile_stream = fopen(dockingFile,"r");
/* Get the number of conformations */
float buf3 = 0;
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;
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++;
rewind(condFile_stream);
rc = getline(&buf,&len,condFile_stream); /* Get rid of the first line */
dock_res = allocate_dockingResults(numberOfConf);
int idConf = 0, buf4, prevID = -1;
while(!feof(condFile_stream)){
/* We take the first value as it is the ID of the conformation */
rc = fscanf(condFile_stream,"%d %d %d %d",&idConf,&buf4, &buf4, &buf4);
if(prevID == idConf){
break;
}else{
prevID = 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]);
/* printf("%d %f %f %f %f %f %f\n",idConf,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 */
//dock_res->theta[idConf] = dock_res->theta[idConf]*cdr;
//dock_res->phi[idConf] = dock_res->phi[idConf]*cdr;
dock_res->alpha[idConf] = dock_res->alpha[idConf]*CDR;
dock_res->beta[idConf] = dock_res->beta[idConf]*CDR;
dock_res->gamma[idConf] = dock_res->gamma[idConf]*CDR;
}
dock_res->nbConf = numberOfConf;
fclose(condFile_stream);
free(buf);
return dock_res;
}
struct docking_results* getDataForComplex(){ struct docking_results* getDataForComplex(){
char* buf = NULL; char* buf = NULL;
...@@ -201,13 +285,13 @@ struct docking_results* getDataForComplex(){ ...@@ -201,13 +285,13 @@ struct docking_results* getDataForComplex(){
//sprintf(totalFilePath,"%s/%s/Cond.%s.%s.UB.global.dat",dockingFile,buf2,receptor,ligand); //sprintf(totalFilePath,"%s/%s/Cond.%s.%s.UB.global.dat",dockingFile,buf2,receptor,ligand);
if(access(dockingFile,F_OK) == -1){ if(access(dockingFile,F_OK) == -1){
/* File does not exists, 4 file in this case /* File does not exists, 4 file in this case
* Return NULL, which should be treated accordingly * Return NULL, which should be treated accordingly
*/ */
fprintf(stderr,"No such file : %s\n",dockingFile); fprintf(stderr,"No such file : %s\n",dockingFile);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
condFile_stream = fopen(dockingFile,"r"); condFile_stream = fopen(dockingFile,"r");
rc = getline(&buf,&len,condFile_stream); /* Get rid of first line */ rc = getline(&buf,&len,condFile_stream); /* Get rid of first line */
...@@ -232,7 +316,7 @@ struct docking_results* getDataForComplex(){ ...@@ -232,7 +316,7 @@ struct docking_results* getDataForComplex(){
int idConf = 0, buf4, prevID = -1; int idConf = 0, buf4, prevID = -1;
while(!feof(condFile_stream)){ while(!feof(condFile_stream)){
rc = fscanf(condFile_stream,"%d %d",&idConf,&buf4); rc = fscanf(condFile_stream,"%d %d",&idConf,&buf4);
if(prevID == idConf){ if(prevID == idConf){
...@@ -243,7 +327,7 @@ struct docking_results* getDataForComplex(){ ...@@ -243,7 +327,7 @@ struct docking_results* getDataForComplex(){
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]);
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 */
//dock_res->theta[idConf] = dock_res->theta[idConf]*cdr; //dock_res->theta[idConf] = dock_res->theta[idConf]*cdr;
//dock_res->phi[idConf] = dock_res->phi[idConf]*cdr; //dock_res->phi[idConf] = dock_res->phi[idConf]*cdr;
...@@ -252,7 +336,7 @@ struct docking_results* getDataForComplex(){ ...@@ -252,7 +336,7 @@ struct docking_results* getDataForComplex(){
dock_res->beta[idConf] = dock_res->beta[idConf]*CDR; dock_res->beta[idConf] = dock_res->beta[idConf]*CDR;
dock_res->gamma[idConf] = dock_res->gamma[idConf]*CDR; dock_res->gamma[idConf] = dock_res->gamma[idConf]*CDR;
} }
dock_res->nbConf = numberOfConf; dock_res->nbConf = numberOfConf;
fclose(condFile_stream); fclose(condFile_stream);
...@@ -267,32 +351,32 @@ struct pdb_values* readPDB(char* protein) { ...@@ -267,32 +351,32 @@ struct pdb_values* readPDB(char* protein) {
size_t len = 2000; size_t len = 2000;
char totalFilePath[200]; char totalFilePath[200];
char buf2[15]; char buf2[15];
char buf3[50]; char buf3[50];
char bufID[10] = "\0"; char bufID[10] = "\0";
char* buf = NULL; char* buf = NULL;
FILE* pdbFile_stream = NULL; FILE* pdbFile_stream = NULL;
struct pdb_values* pdb_prot = NULL; struct pdb_values* pdb_prot = NULL;
sprintf(totalFilePath,"%s/%s.pdb",pdbDir,protein); sprintf(totalFilePath,"%s/%s.pdb",pdbDir,protein);
if(access(totalFilePath,F_OK) == -1){ if(access(totalFilePath,F_OK) == -1){
/* File does not exists, 4 file in this case /* File does not exists, 4 file in this case
* Return NULL, which should be treated accordingly * Return NULL, which should be treated accordingly
*/ */
fprintf(stderr,"No such file : %s\n",totalFilePath); fprintf(stderr,"No such file : %s\n",totalFilePath);
exit(1); exit(1);
} }
pdbFile_stream = fopen(totalFilePath,"r"); pdbFile_stream = fopen(totalFilePath,"r");
if(pdbFile_stream == NULL){ if(pdbFile_stream == NULL){
perror("fopen"); perror("fopen");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(buf3,"\0"); strcpy(buf3,"\0");
while(!feof(pdbFile_stream)){ while(!feof(pdbFile_stream)){
rc = getline(&buf,&len,pdbFile_stream); rc = getline(&buf,&len,pdbFile_stream);
strncpy(buf2,buf,4); strncpy(buf2,buf,4);
buf2[4] = '\0'; buf2[4] = '\0';
if(strcmp("ATOM",buf2) == 0){ if(strcmp("ATOM",buf2) == 0){
...@@ -397,7 +481,7 @@ struct pdb_values* readPDB(char* protein) { ...@@ -397,7 +481,7 @@ struct pdb_values* readPDB(char* protein) {
pdb_prot->centerX /= pdb_prot->nbAtom; pdb_prot->centerX /= pdb_prot->nbAtom;
pdb_prot->centerY /= pdb_prot->nbAtom; pdb_prot->centerY /= pdb_prot->nbAtom;
pdb_prot->centerZ /= pdb_prot->nbAtom; pdb_prot->centerZ /= pdb_prot->nbAtom;
free(buf); free(buf);
fclose(pdbFile_stream); fclose(pdbFile_stream);
return pdb_prot; return pdb_prot;
...@@ -418,21 +502,20 @@ void removeSpace(char* string){ ...@@ -418,21 +502,20 @@ void removeSpace(char* string){
} }
} }
void writePDB(struct pdb_values* pdb, char* protName){ void writePDB(struct pdb_values* pdb, char* protName, int nConf){
int i = 0, j = 0; int i = 0, j = 0;
char buf[500]; char buf[500];
FILE* fw = NULL; FILE* fw = NULL;
sprintf(buf,"%s/%s.pdb",outputPDB,protName); sprintf(buf,"%s/%s_%d.pdb",outputPDB,protName,nConf);
fw = fopen(buf,"w"); fw = fopen(buf,"w");
if(fw == NULL){ if(fw == NULL){
perror("fopen"); perror("fopen");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
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++){
fprintf(fw,"ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n",pdb->residues[i].idAtom[j], fprintf(fw,FORMAT_LINE_PDB,pdb->residues[i].idAtom[j],
pdb->residues[i].atomType[j],pdb->residues[i].resName,pdb->residues[i].chain, pdb->residues[i].atomType[j],pdb->residues[i].resName,pdb->residues[i].chain,
pdb->residues[i].idRes,pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]); pdb->residues[i].idRes,pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]);
} }
...@@ -450,14 +533,18 @@ int main(int argc, char** argv){ ...@@ -450,14 +533,18 @@ int main(int argc, char** argv){
struct pdb_values* pdbL = NULL; struct pdb_values* pdbL = NULL;
struct pdb_values* pdbR = NULL; struct pdb_values* pdbR = NULL;
struct pdb_values* newPDB = NULL; struct pdb_values* newPDB = NULL;
struct docking_results* dock_res = NULL; struct docking_results* dock_res = NULL;
float dalpha = 0, dbeta = 0, dgamma = 0; float dalpha = 0, dbeta = 0, dgamma = 0;
parseLineOfArgument(argc,argv); parseLineOfArgument(argc,argv);
printf("Computing %s and %s ...",receptor,ligand); printf("Computing %s and %s ...",receptor,ligand);
fflush(stdout); fflush(stdout);
dock_res = getDataForComplex(); if(HCMD2){
dock_res = getDataForComplex_HCMD2();
}else{
dock_res = getDataForComplex();
}
pdbR = readPDB(receptor); pdbR = readPDB(receptor);
pdbL = readPDB(ligand); pdbL = readPDB(ligand);
...@@ -472,10 +559,10 @@ int main(int argc, char** argv){ ...@@ -472,10 +559,10 @@ int main(int argc, char** argv){
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);
getInterface(pdbR,newPDB,target_conf); getInterface(pdbR,newPDB);
if(constructPDB){ if(constructPDB){
writePDB(newPDB, ligand); writePDB(newPDB, ligand,target_conf);
} }
freePDB(newPDB); freePDB(newPDB);
}else{ }else{
...@@ -491,12 +578,12 @@ int main(int argc, char** argv){ ...@@ -491,12 +578,12 @@ int main(int argc, char** argv){
fprintf(outputFile_lig,"%d ",i); fprintf(outputFile_lig,"%d ",i);
fprintf(outputFile_rec,"%d ",i); fprintf(outputFile_rec,"%d ",i);
getInterface(pdbR,newPDB,i); getInterface(pdbR,newPDB);
fprintf(outputFile_lig,"\n"); fprintf(outputFile_lig,"\n");
fprintf(outputFile_rec,"\n"); fprintf(outputFile_rec,"\n");
if(constructPDB){ if(constructPDB){
writePDB(newPDB, ligand); writePDB(newPDB, ligand,i);
} }
freePDB(newPDB); freePDB(newPDB);
} }
......
#ifndef INTB_HEADER #include "struct.h"
#ifndef INTB_HEADER
#define INTB_HEADER #define INTB_HEADER
void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, struct residue** t_candid2, int* nbCand1, int* nbCand2); void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, struct residue** t_candid2, int* nbCand1, int* nbCand2);
void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL, int numConf); void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL);
struct docking_results* getDataForComplex(); struct docking_results* getDataForComplex();
struct docking_results* getDataForComplex_HCMD2();
struct pdb_values* readPDB(char* protein) ; struct pdb_values* readPDB(char* protein) ;
void removeSpace(char* string); void removeSpace(char* string);
void writePDB(struct pdb_values* pdb, char* protName); void writePDB(struct pdb_values* pdb, char* protName, int nbConf);
int main(int argc, char** argv); int main(int argc, char** argv);
#endif #endif
...@@ -35,6 +35,7 @@ struct argLine* parseLineOfArgument(int argc, char** argv){ ...@@ -35,6 +35,7 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
verbose = 0; verbose = 0;
constructPDB = 0; constructPDB = 0;
target_conf = -1; target_conf = -1;
HCMD2 = 0;
outputDir = NULL; outputDir = NULL;
outputPDB = NULL; outputPDB = NULL;
verbose_file = NULL; verbose_file = NULL;
...@@ -99,6 +100,8 @@ struct argLine* parseLineOfArgument(int argc, char** argv){ ...@@ -99,6 +100,8 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
fprintf(stderr,"Specific conformation not valid\n"); fprintf(stderr,"Specific conformation not valid\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
}else if(strcmp(argv[i],"-HCMD2") == 0){
HCMD2 = 1;
}else if(strcmp(argv[i],"-h") == 0 || }else if(strcmp(argv[i],"-h") == 0 ||
strcmp(argv[i],"--help") == 0){ strcmp(argv[i],"--help") == 0){
print_help = 1; print_help = 1;
......
...@@ -13,6 +13,7 @@ int nbThreads; ...@@ -13,6 +13,7 @@ int nbThreads;
int verbose; int verbose;
int constructPDB; int constructPDB;
int target_conf; int target_conf;
int HCMD2;
FILE* verbose_file; FILE* verbose_file;
char* pdbDir; char* pdbDir;
char* receptor; char* receptor;
...@@ -25,6 +26,7 @@ FILE* outputFile_lig; ...@@ -25,6 +26,7 @@ FILE* outputFile_lig;
#define CDR 0.017453293 #define CDR 0.017453293
#define NB_MAX_ATOM_PER_RES 20 #define NB_MAX_ATOM_PER_RES 20
#define DIST_FOR_CONTACT 10 #define DIST_FOR_CONTACT 10
#define FORMAT_LINE_PDB "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\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