Commit 472aa481 by Chloe Dequeker

comments almost done

parent e08ee47c
......@@ -192,7 +192,7 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
/* For each candidate residue of the ligand */
for(k=0;k<nbCandL;k++){
/* 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;
}
for(l=0;l<t_candidateL[k]->nbAtom;l++){
......@@ -213,14 +213,14 @@ void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
/* Output the ligand's interface */
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);
fflush(outputFile_lig);
}
}
/* Output the receptor's interface */
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);
fflush(outputFile_lig);
}
......@@ -312,6 +312,11 @@ struct docking_results* getDataForComplex(){
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 rc = 0, nbRes = 0, numCA = 0;
int curRes = 0, curAtom = 0, firstLine = 1;
......@@ -332,7 +337,7 @@ struct pdb_values* readPDB(char* protein) {
* Return NULL, which should be treated accordingly
*/
fprintf(stderr,"No such file : %s\n",totalFilePath);
exit(1);
exit(EXIT_FAILURE);
}
pdbFile_stream = fopen(totalFilePath,"r");
......@@ -341,6 +346,7 @@ struct pdb_values* readPDB(char* protein) {
exit(EXIT_FAILURE);
}
/* Get the number of residue for this protein */
strcpy(buf3,"\0");
while(!feof(pdbFile_stream)){
rc = getline(&buf,&len,pdbFile_stream);
......@@ -351,12 +357,16 @@ struct pdb_values* readPDB(char* protein) {
strncpy(buf2,buf+22,5);
buf2[5] = '\0';
/* We make sure that we don't count twice the
* same residue
*/
if(strcmp(buf2,buf3) != 0){
nbRes++;
strcpy(buf3,buf2);
}
}
}
/* Come back at the start of the file */
rewind(pdbFile_stream);
pdb_prot = allocate_pdb(nbRes);
......@@ -375,7 +385,7 @@ struct pdb_values* readPDB(char* protein) {
bufID[5] = '\0';
/* 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){
firstLine = 0;
}else{
......@@ -420,6 +430,9 @@ struct pdb_values* readPDB(char* protein) {
buf2[8] = '\0';
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){
numCA++;
if(numCA == 1){
......@@ -438,6 +451,8 @@ struct pdb_values* readPDB(char* protein) {
pdb_prot->nbAtom++;
}
/* Compute the geometric center of the protein */
for(i=0;i<pdb_prot->nbRes;i++){
for(j=0;j<pdb_prot->residues[i].nbAtom;j++){
pdb_prot->centerX = pdb_prot->centerX + pdb_prot->residues[i].x[j];
......@@ -454,22 +469,9 @@ struct pdb_values* readPDB(char* protein) {
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){
/* Output the PDB corresponding to the conformation nConf */
int i = 0, j = 0;
char buf[500];
FILE* fw = NULL;
......@@ -488,13 +490,13 @@ void writePDB(struct pdb_values* pdb, char* protName, int nConf){
}
}
fclose(fw);
}
int main(int argc, char** argv){
/* Starting point of the program */
int i = 0;
float alpha = 0, beta = 0, gamma = 0;
struct pdb_values* pdbL = NULL;
......@@ -503,21 +505,25 @@ int main(int argc, char** argv){
struct docking_results* dock_res = NULL;
float dalpha = 0, dbeta = 0, dgamma = 0;
/* Parse the line of arguments */
parseLineOfArgument(argc,argv);
printf("Computing %s and %s ...",receptor,ligand);
fflush(stdout);
if(HCMD2){
dock_res = getDataForComplex_HCMD2();
}else{
/* Get all the docking informations regarding our complex */
dock_res = getDataForComplex();
}
/* Get the PDB structure for the receptor and the ligand */
pdbR = readPDB(receptor);
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);
if(target_conf > 0){
if(target_conf > 0){ /* If we are building a specific conformation */
dalpha = dock_res->alpha[target_conf] - alpha;
dbeta = dock_res->beta[target_conf] - beta;
dgamma = dock_res->gamma[target_conf] - gamma;
......@@ -526,6 +532,9 @@ int main(int argc, char** argv){
dock_res->theta[target_conf],dock_res->phi[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);
fprintf(outputFile_lig,"\n");
fprintf(outputFile_rec,"\n");
......@@ -534,17 +543,26 @@ int main(int argc, char** argv){
writePDB(newPDB, ligand,target_conf);
}
freePDB(newPDB);
}else{
}else{ /* For all conformations */
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;
dbeta = dock_res->beta[i] - beta;
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],
dock_res->theta[i],dock_res->phi[i],
dalpha,dbeta,dgamma,dock_res,i);
/* Write the number of the conformation and get the interface */
fprintf(outputFile_lig,"%d ",i);
fprintf(outputFile_rec,"%d ",i);
getInterface(pdbR,newPDB);
......
......@@ -6,7 +6,6 @@
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);
struct docking_results* getDataForComplex();
struct docking_results* getDataForComplex_HCMD2();
struct pdb_values* readPDB(char* protein) ;
void removeSpace(char* string);
void writePDB(struct pdb_values* pdb, char* protName, int nbConf);
......
......@@ -9,6 +9,7 @@ void freePDB(struct pdb_values* pdb){
pdb = NULL;
}
void freeDock(struct docking_results* dock_res){
/* Free the docking interface */
free(dock_res->listEner);
......@@ -42,8 +43,6 @@ struct docking_results* allocate_dockingResults(int nbConf){
dock_res->alpha = NULL;
dock_res->beta = NULL;
dock_res->gamma = NULL;
dock_res->inter_rec = NULL;
dock_res->inter_lig = NULL;
dock_res->listEner = malloc((2*nbConf)*sizeof(float));
if(dock_res->listEner == NULL){
......@@ -156,3 +155,11 @@ void free_argLine(){
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);
void reset_dockingResults(struct docking_results* dock_res);
struct pdb_values* allocate_pdb(int nbRes);
void free_argLine();
void freeAll(struct pdb_values* pdbR, struct pdb_values* pdbL, struct docking_results* dock_res);
#endif
......@@ -37,7 +37,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
struct argLine* paramVals = NULL;
nbThreads = 1;
verbose = 0;
constructPDB = 0;
target_conf = -1;
......@@ -96,10 +95,6 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
exit(EXIT_FAILURE);
}
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){
target_conf = atoi(argv[i+1]);
if(target_conf <= 0){
......@@ -155,7 +150,7 @@ struct argLine* parseLineOfArgument(int argc, char** argv){
strcpy(outputDir,"./");
}
if(constructPDB == 1 && outputPDB == NULL){
if(constructPDB && outputPDB == NULL){
outputPDB = malloc(3*sizeof(char));
if(outputPDB == NULL){
perror("mallloc");
......
......@@ -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 angles alpha, beta, gamma in arguments correspond to the rotation angles that have to be applied to
* each residue.
* In the struct dock_res, we can find the angles alpha0, beta0 and gamma0. alpha0 corresponds to the angles alpha
* and beta for the first CA (from the axis x and y) + the rotation angles dalpha and dbeta respectively
* gamma0 corresponds to the angle gamma from the fifth CA of the protein after being rotated of alpha (NOT dalpha)
* then by beta (NOT dbeta).
* c_a0 can be seen as the unit vector of the axis X rotated by alpha0
* In the struct dock_res, we can find the angles alpha0, beta0 and gamma0.
* alpha0 corresponds to the final angle alpha of the CA 1 once it's been rotated by dalpha
* beta0 corresponds to the final angle beta of the CA 1 once it's been rotated by dbeta
* gamma0 corresponds to the final angle gamma of the CA 5 once it's been rotated by dalpha and then dbeta
*
* 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;
......
......@@ -9,111 +9,68 @@
* They are used to alter the way the program goes
*/
int nbThreads;
int verbose;
int constructPDB;
int target_conf;
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"
/*************************************************/
#define COEF_DEGREE_TO_RADIAN 0.017453293 /* Coefficient to convert degrees to radians */
#define NB_MAX_ATOM_PER_RES 20 /* No residue has more atoms than that */
#define DIST_FOR_CONTACT 10 /* Distance under which we consider
* two residues are in contact */
struct interface_data {
long key;
long nbRes;
};
struct interface {
char (*posID)[6];
char* chain;
long nbRes;
float* carac; /* Potentially add a caracteristic to each residue */
};
/* This is the format of a line in a PDB file */
#define FORMAT_LINE_PDB "ATOM %5d %3s %3s %c%5s %8.3f%8.3f%8.3f\n"
struct enerComplex {
int ID;
float ener;
};
int verbose; /* 1 if we are in verbose mode */
int constructPDB; /* 1 if we should build the PDB */
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 {
int nbRes;
int nbAtom;
struct residue* residues;
float centerX;
float centerY;
float centerZ;
float xCA1;
float yCA1;
float zCA1;
float xCA5;
float yCA5;
float zCA5;
int nbRes; /* Number of residue for this PDB */
int nbAtom; /* Number of atoms for this PDB */
struct residue* residues; /* Array containing all the PDBs */
float centerX; /* Geometric X center for this PDB */
float centerY; /* Geometric Y center for this PDB */
float centerZ; /* Geometric Z center for this PDB */
float xCA1; /* x value of the 1rst CA */
float yCA1; /* y value of the 1rst CA */
float zCA1; /* z value of the 1rst CA */
float xCA5; /* x value of the 5th CA */
float yCA5; /* y value of the 5th CA */
float zCA5; /* z value of the 5th CA */
};
/* Structure that contains all the informations we need for a residue */
struct residue {
char idRes[10];
char chain;
char resName[10];
float x[NB_MAX_ATOM_PER_RES];
float y[NB_MAX_ATOM_PER_RES];
float z[NB_MAX_ATOM_PER_RES];
char atomType[NB_MAX_ATOM_PER_RES][10];
int idAtom[NB_MAX_ATOM_PER_RES];
int nbAtom;
int isCandidate;
char idRes[10]; /* ID of the residue */
char chain; /* Chain to which the residue belongs */
char resName[10]; /* Name of the residue */
float x[NB_MAX_ATOM_PER_RES]; /* Array containing the x for each of its atom */
float y[NB_MAX_ATOM_PER_RES]; /* Array containing the y for each of its atom */
float z[NB_MAX_ATOM_PER_RES]; /* Array containing the z for each of its atom */
char atomType[NB_MAX_ATOM_PER_RES][10]; /* Array containing the type of atom */
int idAtom[NB_MAX_ATOM_PER_RES]; /* ID of the atom */
int nbAtom; /* Number of atom for this residue */
int isCandidate; /* 1 if this residue belongs to the docking interface */
};
struct docking_results {
float* listEner;
float* distCenters;
float* theta;
float* phi;
float* alpha;
float* listEner; /* Array containing the energy for each conformation */
float* distCenters; /* Distance between the center of the receptor and of the ligand */
float* theta; /* theta angle for the center of the ligand */
float* phi; /* phi angle for the center of the ligand */
float* alpha; /* */
float* beta;
float* gamma;
struct interface* inter_rec;
struct interface* inter_lig;
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
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