Commit 472aa481 by Chloe Dequeker

comments almost done

parent e08ee47c
...@@ -192,7 +192,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){ ...@@ -192,7 +192,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
/* For each candidate residue of the ligand */ /* For each candidate residue of the ligand */
for(k=0;k<nbCandL;k++){ for(k=0;k<nbCandL;k++){
/* If both the residues we are looking at are already selected */ /* If both the residues we are looking at are already selected */
if(t_candidateL[k]->isCandidate == 1 && t_candidateR[i]->isCandidate == 1){ if(t_candidateL[k]->isCandidate && t_candidateR[i]->isCandidate){
continue; continue;
} }
for(l=0;l<t_candidateL[k]->nbAtom;l++){ for(l=0;l<t_candidateL[k]->nbAtom;l++){
...@@ -213,14 +213,14 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){ ...@@ -213,14 +213,14 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
/* Output the ligand's interface */ /* Output the ligand's interface */
for(i=0;i<nbCandL;i++){ for(i=0;i<nbCandL;i++){
if(t_candidateL[i]->isCandidate == 1){ if(t_candidateL[i]->isCandidate){
fprintf(outputFile_lig,"'%s' '%c' ",strtok(t_candidateL[i]->idRes," "),t_candidateL[i]->chain); fprintf(outputFile_lig,"'%s' '%c' ",strtok(t_candidateL[i]->idRes," "),t_candidateL[i]->chain);
fflush(outputFile_lig); fflush(outputFile_lig);
} }
} }
/* Output the receptor's interface */ /* Output the receptor's interface */
for(i=0;i<nbCandR;i++){ for(i=0;i<nbCandR;i++){
if(t_candidateR[i]->isCandidate == 1){ if(t_candidateR[i]->isCandidate){
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);
fflush(outputFile_lig); fflush(outputFile_lig);
} }
...@@ -312,6 +312,11 @@ struct docking_results* getDataForComplex(){ ...@@ -312,6 +312,11 @@ struct docking_results* getDataForComplex(){
struct pdb_values* readPDB(char* protein) { struct pdb_values* readPDB(char* protein) {
/* This function reads a PDB file and fills a structure
* containing all the necessary information.
* The structure filled is of type struct pdb_values. It is
* allocated and a pointer to this structure is returned at the end
*/
int i = 0, j = 0; int i = 0, j = 0;
int rc = 0, nbRes = 0, numCA = 0; int rc = 0, nbRes = 0, numCA = 0;
int curRes = 0, curAtom = 0, firstLine = 1; int curRes = 0, curAtom = 0, firstLine = 1;
...@@ -332,7 +337,7 @@ struct pdb_values* readPDB(char* protein) { ...@@ -332,7 +337,7 @@ struct pdb_values* readPDB(char* protein) {
* 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(EXIT_FAILURE);
} }
pdbFile_stream = fopen(totalFilePath,"r"); pdbFile_stream = fopen(totalFilePath,"r");
...@@ -341,6 +346,7 @@ struct pdb_values* readPDB(char* protein) { ...@@ -341,6 +346,7 @@ struct pdb_values* readPDB(char* protein) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Get the number of residue for this protein */
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);
...@@ -351,12 +357,16 @@ struct pdb_values* readPDB(char* protein) { ...@@ -351,12 +357,16 @@ struct pdb_values* readPDB(char* protein) {
strncpy(buf2,buf+22,5); strncpy(buf2,buf+22,5);
buf2[5] = '\0'; buf2[5] = '\0';
/* We make sure that we don't count twice the
* same residue
*/
if(strcmp(buf2,buf3) != 0){ if(strcmp(buf2,buf3) != 0){
nbRes++; nbRes++;
strcpy(buf3,buf2); strcpy(buf3,buf2);
} }
} }
} }
/* Come back at the start of the file */
rewind(pdbFile_stream); rewind(pdbFile_stream);
pdb_prot = allocate_pdb(nbRes); pdb_prot = allocate_pdb(nbRes);
...@@ -375,7 +385,7 @@ struct pdb_values* readPDB(char* protein) { ...@@ -375,7 +385,7 @@ struct pdb_values* readPDB(char* protein) {
bufID[5] = '\0'; bufID[5] = '\0';
/* if this is not the same residue as previously */ /* if this is not the same residue as previously */
if(firstLine == 1 || strcmp(bufID,pdb_prot->residues[curRes].idRes) != 0){ if(firstLine || strcmp(bufID,pdb_prot->residues[curRes].idRes) != 0){
if(firstLine){ if(firstLine){
firstLine = 0; firstLine = 0;
}else{ }else{
...@@ -420,6 +430,9 @@ struct pdb_values* readPDB(char* protein) { ...@@ -420,6 +430,9 @@ struct pdb_values* readPDB(char* protein) {
buf2[8] = '\0'; buf2[8] = '\0';
pdb_prot->residues[curRes].z[curAtom] = atof(buf2); pdb_prot->residues[curRes].z[curAtom] = atof(buf2);
/* If we encounter the first or fifth CA, we note their coordinates
* specifically. We need them for the rotation
*/
if(strcmp("CA ",pdb_prot->residues[curRes].atomType[curAtom]) == 0){ if(strcmp("CA ",pdb_prot->residues[curRes].atomType[curAtom]) == 0){
numCA++; numCA++;
if(numCA == 1){ if(numCA == 1){
...@@ -438,6 +451,8 @@ struct pdb_values* readPDB(char* protein) { ...@@ -438,6 +451,8 @@ struct pdb_values* readPDB(char* protein) {
pdb_prot->nbAtom++; pdb_prot->nbAtom++;
} }
/* Compute the geometric center of the protein */
for(i=0;i<pdb_prot->nbRes;i++){ for(i=0;i<pdb_prot->nbRes;i++){
for(j=0;j<pdb_prot->residues[i].nbAtom;j++){ for(j=0;j<pdb_prot->residues[i].nbAtom;j++){
pdb_prot->centerX = pdb_prot->centerX + pdb_prot->residues[i].x[j]; pdb_prot->centerX = pdb_prot->centerX + pdb_prot->residues[i].x[j];
...@@ -454,22 +469,9 @@ struct pdb_values* readPDB(char* protein) { ...@@ -454,22 +469,9 @@ struct pdb_values* readPDB(char* protein) {
return pdb_prot; return pdb_prot;
} }
void removeSpace(char* string){
char* i = string;
char* j = string;
if(*j != '\0'){
while(*j != 0){
*i = *j++;
if(*i != ' '){
i++;
}
}
*i = 0;
}
}
void writePDB(struct pdb_values* pdb, char* protName, int nConf){ void writePDB(struct pdb_values* pdb, char* protName, int nConf){
/* Output the PDB corresponding to the conformation nConf */
int i = 0, j = 0; int i = 0, j = 0;
char buf[500]; char buf[500];
FILE* fw = NULL; FILE* fw = NULL;
...@@ -488,13 +490,13 @@ void writePDB(struct pdb_values* pdb, char* protName, int nConf){ ...@@ -488,13 +490,13 @@ void writePDB(struct pdb_values* pdb, char* protName, int nConf){
} }
} }
fclose(fw); fclose(fw);
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
/* Starting point of the program */
int i = 0; int i = 0;
float alpha = 0, beta = 0, gamma = 0; float alpha = 0, beta = 0, gamma = 0;
struct pdb_values* pdbL = NULL; struct pdb_values* pdbL = NULL;
...@@ -503,21 +505,25 @@ int main(int argc, char** argv){ ...@@ -503,21 +505,25 @@ int main(int argc, char** argv){
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;
/* Parse the line of arguments */
parseLineOfArgument(argc,argv); parseLineOfArgument(argc,argv);
printf("Computing %s and %s ...",receptor,ligand); printf("Computing %s and %s ...",receptor,ligand);
fflush(stdout); fflush(stdout);
if(HCMD2){ /* Get all the docking informations regarding our complex */
dock_res = getDataForComplex_HCMD2();
}else{
dock_res = getDataForComplex(); dock_res = getDataForComplex();
}
/* Get the PDB structure for the receptor and the ligand */
pdbR = readPDB(receptor); pdbR = readPDB(receptor);
pdbL = readPDB(ligand); pdbL = readPDB(ligand);
/* Compute the angles for the first and fifth CA of the protein
* This is essential to compute the rotation angles
*/
getAnglesFromCA1andCA5_sophie(pdbL,&alpha,&beta,&gamma); getAnglesFromCA1andCA5_sophie(pdbL,&alpha,&beta,&gamma);
if(target_conf > 0){
if(target_conf > 0){ /* If we are building a specific conformation */
dalpha = dock_res->alpha[target_conf] - alpha; dalpha = dock_res->alpha[target_conf] - alpha;
dbeta = dock_res->beta[target_conf] - beta; dbeta = dock_res->beta[target_conf] - beta;
dgamma = dock_res->gamma[target_conf] - gamma; dgamma = dock_res->gamma[target_conf] - gamma;
...@@ -526,6 +532,9 @@ int main(int argc, char** argv){ ...@@ -526,6 +532,9 @@ 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);
/* Write the number of the conformation and get the interface */
fprintf(outputFile_lig,"%d ",i);
fprintf(outputFile_rec,"%d ",i);
getInterface(pdbR,newPDB); getInterface(pdbR,newPDB);
fprintf(outputFile_lig,"\n"); fprintf(outputFile_lig,"\n");
fprintf(outputFile_rec,"\n"); fprintf(outputFile_rec,"\n");
...@@ -534,17 +543,26 @@ int main(int argc, char** argv){ ...@@ -534,17 +543,26 @@ int main(int argc, char** argv){
writePDB(newPDB, ligand,target_conf); writePDB(newPDB, ligand,target_conf);
} }
freePDB(newPDB); freePDB(newPDB);
}else{ }else{ /* For all conformations */
for(i=1;i<dock_res->nbConf;i++){ for(i=1;i<dock_res->nbConf;i++){
// For all conformations
/* compute the rotation angles dalpha, dbeta and dgamma
* from the angles alpha and beta of the CA 1 and the
* angle gamma computed after rotation of alpha and beta
* for the CA 5
*/
dalpha = dock_res->alpha[i] - alpha; dalpha = dock_res->alpha[i] - alpha;
dbeta = dock_res->beta[i] - beta; dbeta = dock_res->beta[i] - beta;
dgamma = dock_res->gamma[i] - gamma; dgamma = dock_res->gamma[i] - gamma;
/* This is the rotated PDB
* pdbL doesn't change throughout the program
*/
newPDB = rotate_sophie(pdbL,pdbR,NULL,dock_res->distCenters[i], newPDB = rotate_sophie(pdbL,pdbR,NULL,dock_res->distCenters[i],
dock_res->theta[i],dock_res->phi[i], dock_res->theta[i],dock_res->phi[i],
dalpha,dbeta,dgamma,dock_res,i); dalpha,dbeta,dgamma,dock_res,i);
/* Write the number of the conformation and get the interface */
fprintf(outputFile_lig,"%d ",i); fprintf(outputFile_lig,"%d ",i);
fprintf(outputFile_rec,"%d ",i); fprintf(outputFile_rec,"%d ",i);
getInterface(pdbR,newPDB); getInterface(pdbR,newPDB);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
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); 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, int nbConf); void writePDB(struct pdb_values* pdb, char* protName, int nbConf);
......
...@@ -9,6 +9,7 @@ void freePDB(struct pdb_values* pdb){ ...@@ -9,6 +9,7 @@ void freePDB(struct pdb_values* pdb){
pdb = NULL; pdb = NULL;
} }
void freeDock(struct docking_results* dock_res){ void freeDock(struct docking_results* dock_res){
/* Free the docking interface */ /* Free the docking interface */
free(dock_res->listEner); free(dock_res->listEner);
...@@ -42,8 +43,6 @@ struct docking_results* allocate_dockingResults(int nbConf){ ...@@ -42,8 +43,6 @@ struct docking_results* allocate_dockingResults(int nbConf){
dock_res->alpha = NULL; dock_res->alpha = NULL;
dock_res->beta = NULL; dock_res->beta = NULL;
dock_res->gamma = NULL; dock_res->gamma = NULL;
dock_res->inter_rec = NULL;
dock_res->inter_lig = 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){
...@@ -156,3 +155,11 @@ void free_argLine(){ ...@@ -156,3 +155,11 @@ void free_argLine(){
fclose(verbose_file); fclose(verbose_file);
} }
} }
void freeAll(struct pdb_values* pdbR, struct pdb_values* pdbL, struct docking_results* dock_res){
/* Free all the arguments passed to this function */
freePDB(pdbL);
freePDB(pdbR);
freeDock(dock_res);
free_argLine();
}
...@@ -9,5 +9,6 @@ struct docking_results* allocate_dockingResults(int nbConf); ...@@ -9,5 +9,6 @@ struct docking_results* allocate_dockingResults(int nbConf);
void reset_dockingResults(struct docking_results* dock_res); void reset_dockingResults(struct docking_results* dock_res);
struct pdb_values* allocate_pdb(int nbRes); struct pdb_values* allocate_pdb(int nbRes);
void free_argLine(); void free_argLine();
void freeAll(struct pdb_values* pdbR, struct pdb_values* pdbL, struct docking_results* dock_res);
#endif #endif
...@@ -37,7 +37,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){ ...@@ -37,7 +37,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
struct argLine* paramVals = NULL; struct argLine* paramVals = NULL;
nbThreads = 1;
verbose = 0; verbose = 0;
constructPDB = 0; constructPDB = 0;
target_conf = -1; target_conf = -1;
...@@ -96,10 +95,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){ ...@@ -96,10 +95,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(ligand,argv[i+1]); strcpy(ligand,argv[i+1]);
}else if(strcmp(argv[i],"-p") == 0){
nbThreads = atoi(argv[i+1]);
if(nbThreads <= 0)
nbThreads = 1;
}else if(strcmp(argv[i],"-pose") == 0){ }else if(strcmp(argv[i],"-pose") == 0){
target_conf = atoi(argv[i+1]); target_conf = atoi(argv[i+1]);
if(target_conf <= 0){ if(target_conf <= 0){
...@@ -155,7 +150,7 @@ struct argLine* parseLineOfArgument(int argc, char** argv){ ...@@ -155,7 +150,7 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
strcpy(outputDir,"./"); strcpy(outputDir,"./");
} }
if(constructPDB == 1 && outputPDB == NULL){ if(constructPDB && outputPDB == NULL){
outputPDB = malloc(3*sizeof(char)); outputPDB = malloc(3*sizeof(char));
if(outputPDB == NULL){ if(outputPDB == NULL){
perror("mallloc"); perror("mallloc");
......
...@@ -20,13 +20,13 @@ struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR ...@@ -20,13 +20,13 @@ struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR
* The final center of the repair is the geometric center of the PDB pdbR. * The final center of the repair is the geometric center of the PDB pdbR.
* The angles alpha, beta, gamma in arguments correspond to the rotation angles that have to be applied to * The angles alpha, beta, gamma in arguments correspond to the rotation angles that have to be applied to
* each residue. * each residue.
* In the struct dock_res, we can find the angles alpha0, beta0 and gamma0. alpha0 corresponds to the angles alpha * In the struct dock_res, we can find the angles alpha0, beta0 and gamma0.
* and beta for the first CA (from the axis x and y) + the rotation angles dalpha and dbeta respectively * alpha0 corresponds to the final angle alpha of the CA 1 once it's been rotated by dalpha
* gamma0 corresponds to the angle gamma from the fifth CA of the protein after being rotated of alpha (NOT dalpha) * beta0 corresponds to the final angle beta of the CA 1 once it's been rotated by dbeta
* then by beta (NOT dbeta). * gamma0 corresponds to the final angle gamma of the CA 5 once it's been rotated by dalpha and then dbeta
* c_a0 can be seen as the unit vector of the axis X rotated by alpha0
* *
* The rotation matrices are available at : https://en.wikipedia.org/wiki/Rotation_matrix in "Nested Dimensions" * The rotation matrices used are available at :
* https://en.wikipedia.org/wiki/Rotation_matrix in "Nested Dimensions"
*/ */
float xi = 0, yi = 0, zi = 0; float xi = 0, yi = 0, zi = 0;
......
...@@ -9,111 +9,68 @@ ...@@ -9,111 +9,68 @@
* They are used to alter the way the program goes * They are used to alter the way the program goes
*/ */
int nbThreads; #define COEF_DEGREE_TO_RADIAN 0.017453293 /* Coefficient to convert degrees to radians */
int verbose; #define NB_MAX_ATOM_PER_RES 20 /* No residue has more atoms than that */
int constructPDB; #define DIST_FOR_CONTACT 10 /* Distance under which we consider
int target_conf; * two residues are in contact */
int HCMD2;
FILE* verbose_file;
char* pdbDir;
char* receptor;
char* ligand;
char* dockingFile;
char* outputDir;
char* outputPDB;
FILE* outputFile_rec;
FILE* outputFile_lig;
#define COEF_DEGREE_TO_RADIAN 0.017453293
#define NB_MAX_ATOM_PER_RES 20
#define DIST_FOR_CONTACT 10
#define FORMAT_LINE_PDB "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
/*************************************************/
struct interface_data { /* This is the format of a line in a PDB file */
long key; #define FORMAT_LINE_PDB "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
long nbRes;
};
struct interface {
char (*posID)[6];
char* chain;
long nbRes;
float* carac; /* Potentially add a caracteristic to each residue */
};
struct enerComplex { int verbose; /* 1 if we are in verbose mode */
int ID; int constructPDB; /* 1 if we should build the PDB */
float ener; int target_conf; /* 1 if we are specific to one conformation */
}; int HCMD2; /* 1 if this is HCMD2 format */
FILE* verbose_file; /* If verbose mode, the output file */
char* pdbDir; /* Directory containing the PDBs */
char* receptor; /* Name of the receptor */
char* ligand; /* Name of the ligand */
char* dockingFile; /* Docking file name */
char* outputDir; /* Output directory for the interface files */
char* outputPDB; /* Output directory if we construct the PDB(s) */
FILE* outputFile_rec; /* Name of the interface output file for the receptor */
FILE* outputFile_lig; /* Name of the interface output file for the ligand */
struct value_complex { /*************************************************/
int ID;
float II;
};
struct pdb_values { struct pdb_values {
int nbRes; int nbRes; /* Number of residue for this PDB */
int nbAtom; int nbAtom; /* Number of atoms for this PDB */
struct residue* residues; struct residue* residues; /* Array containing all the PDBs */
float centerX; float centerX; /* Geometric X center for this PDB */
float centerY; float centerY; /* Geometric Y center for this PDB */
float centerZ; float centerZ; /* Geometric Z center for this PDB */
float xCA1; float xCA1; /* x value of the 1rst CA */
float yCA1; float yCA1; /* y value of the 1rst CA */
float zCA1; float zCA1; /* z value of the 1rst CA */
float xCA5; float xCA5; /* x value of the 5th CA */
float yCA5; float yCA5; /* y value of the 5th CA */
float zCA5; float zCA5; /* z value of the 5th CA */
}; };
/* Structure that contains all the informations we need for a residue */
struct residue { struct residue {
char idRes[10]; char idRes[10]; /* ID of the residue */
char chain; char chain; /* Chain to which the residue belongs */
char resName[10]; char resName[10]; /* Name of the residue */
float x[NB_MAX_ATOM_PER_RES]; float x[NB_MAX_ATOM_PER_RES]; /* Array containing the x for each of its atom */
float y[NB_MAX_ATOM_PER_RES]; float y[NB_MAX_ATOM_PER_RES]; /* Array containing the y for each of its atom */
float z[NB_MAX_ATOM_PER_RES]; float z[NB_MAX_ATOM_PER_RES]; /* Array containing the z for each of its atom */
char atomType[NB_MAX_ATOM_PER_RES][10]; char atomType[NB_MAX_ATOM_PER_RES][10]; /* Array containing the type of atom */
int idAtom[NB_MAX_ATOM_PER_RES]; int idAtom[NB_MAX_ATOM_PER_RES]; /* ID of the atom */
int nbAtom; int nbAtom; /* Number of atom for this residue */
int isCandidate; int isCandidate; /* 1 if this residue belongs to the docking interface */
}; };
struct docking_results { struct docking_results {
float* listEner; float* listEner; /* Array containing the energy for each conformation */
float* distCenters; float* distCenters; /* Distance between the center of the receptor and of the ligand */
float* theta; float* theta; /* theta angle for the center of the ligand */
float* phi; float* phi; /* phi angle for the center of the ligand */
float* alpha; float* alpha; /* */
float* beta; float* beta;
float* gamma; float* gamma;
struct interface* inter_rec;
struct interface* inter_lig;
int nbConf; int nbConf;
}; };
struct pthread_data {
int ID_thread;
int ID_rec;
int nbProt;
int* t_thread;
char** receptorsNames;
char** ligandsNames;
char* dockingDir;
char* docking;
char* wayFIR;
char* jetParentDir;
struct value_complex* lineOfMatrix;
struct interface** a3_predList;
struct interface** a4_predList;
struct interface** a5_predList;
struct interface** nip_predList;
struct interface** lig_predList;
struct interface* predRec;
struct docking_results** dockingRes;
};
#endif #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