Commit 1e546371 by Chloe Dequeker

first commit

parents
CC=gcc
CFLAGS=-c -Wall -g -O3
LDFLAGS=-lm -pthread
SOURCES=INTBuilder.c rotation.c allocate.c param.c
SRC_DIR=src
OBJECTS=$(SOURCES:.c=.o)
BINARY=INTBuilder
all: $(BINARY)
$(BINARY): $(SRC_DIR)/$(OBJECTS)
cd $(SRC_DIR) && $(CC) $(OBJECTS) -o $@ $(LDFLAGS)
%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) $< -o $(SRC_DIR)/$@
clean :
rm -f $(SRC_DIR)/*.o
.PHONY: all clean
ALA 8 A
LYS 41 A
GLY 43 A
LEU 72 A
ARG 74 A
TYR 94 A
GLU 95 A
ASN 96 A
SER 97 A
PRO 98 A
GLU 99 A
GLU 105 A
THR 197 A
VAL 198 A
LYS 31 L
TYR 49 L
TYR 50 L
THR 52 L
SER 53 L
LEU 54 L
ALA 55 L
GLY 57 L
PRO 59 L
SER 60 L
SER 65 L
GLY 66 L
SER 67 L
TYR 102 H
TYR 103 H
GLN 39 L
LYS 41 L
LEU 45 L
THR 47 L
ARG 56 L
GLY 59 L
ALA 62 L
THR 82 L
GLU 83 L
PRO 112 L
ASP 141 L
GLN 170 L
SER 171 L
ASN 172 L
ASN 173 L
LYS 174 L
GLN 1 H
SER 143 H
MET 144 H
GLY 166 H
SER 169 H
SER 170 H
GLY 171 H
HIS 173 H
THR 191 H
PRO 193 H
GLU 200 H
GLN 39 L
LYS 41 L
LEU 45 L
THR 47 L
ARG 56 L
GLY 59 L
ALA 62 L
THR 82 L
GLU 83 L
PRO 112 L
ASP 141 L
GLN 170 L
SER 171 L
ASN 172 L
ASN 173 L
LYS 174 L
GLN 1 H
SER 143 H
MET 144 H
GLY 166 H
SER 169 H
SER 170 H
GLY 171 H
HIS 173 H
THR 191 H
PRO 193 H
GLU 200 H
File added
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "struct.h"
#include "allocate.h"
#include "rotation.h"
#include "param.h"
void getCandidatesForP1(struct pdb_values* pdb2, struct residue** t_candid1, struct residue** t_candid2, int* nbCand1, int* nbCand2) {
/* This function will update the t_candid1 array including all candidate residues
* of P1. At the end of the function, the first *nbCand1 residues in t_candid1 will
* correspond to P1 candidates
*/
float x = 0, y = 0, z = 0;
float centerX = 0, centerY = 0, centerZ = 0;
float dist = 0, minDist = -1, maxDist = -1, threshold_dist = 0;
int i = 0, j = 0, idxCand = -1, idxAtom = -1;
int nbCandInit1 = *nbCand1;
int nbCandInit2 = *nbCand2;
/* get the farthest atom according to the center of mass of the receptor */
centerX = pdb2->centerX;
centerY = pdb2->centerY;
centerZ = pdb2->centerZ;
for(i=0;i<nbCandInit1;i++){
for(j=0;j<t_candid1[i]->nbAtom;j++){
x = t_candid1[i]->x[j];
y = t_candid1[i]->y[j];
z = t_candid1[i]->z[j];
dist = sqrt((x-centerX)*(x-centerX) + (y-centerY)*(y-centerY) + (z-centerZ)*(z-centerZ));
//printf("dist %f\n",dist);
if(dist > maxDist){
maxDist = dist;
idxAtom = j;
idxCand = i;
}
}
}
/* Then we get the closest distance from that residue to a residue of the receptor */
/* Not center of P1, but farthest residue from P2 */
centerX = t_candid1[idxCand]->x[idxAtom];
centerY = t_candid1[idxCand]->y[idxAtom];
centerZ = t_candid1[idxCand]->z[idxAtom];
for(i=0;i<nbCandInit2;i++){
for(j=0;j<t_candid2[i]->nbAtom;j++){
x = t_candid2[i]->x[j];
y = t_candid2[i]->y[j];
z = t_candid2[i]->z[j];
dist = sqrt((x-centerX)*(x-centerX) + (y-centerY)*(y-centerY) + (z-centerZ)*(z-centerZ));
if(dist < minDist || minDist < 0){
minDist = dist;
}
}
}
/* We remove every residue on pdb1 that is closer than treshold_dist from the center
* of mass
*/
threshold_dist = minDist - DIST_FOR_CONTACT;
for(i=0;i<nbCandInit1;i++){
t_candid1[i]->isCandidate = 0;
}
*nbCand1 = 0;
for(i=0;i<nbCandInit1;i++){
for(j=0;j<t_candid1[i]->nbAtom;j++){
x = t_candid1[i]->x[j];
y = t_candid1[i]->y[j];
z = t_candid1[i]->z[j];
dist = sqrt((x-centerX)*(x-centerX) + (y-centerY)*(y-centerY) + (z-centerZ)*(z-centerZ));
if(dist > threshold_dist){
t_candid1[*nbCand1] = t_candid1[i];
(*nbCand1)++;
break;
}
}
}
}
void getInterface(struct pdb_values* pdbR, struct pdb_values* pdbL){
int i = 0, j = 0, k = 0, l = 0;
int oldCandL = -1, oldCandR = -1;
float x1 = 0, y1 = 0, z1 = 0;
float x2 = 0, y2 = 0, z2 = 0;
float dist = -1;
struct residue** t_candidateL = NULL;
struct residue** t_candidateR = NULL;
int nbCandR = pdbR->nbRes, nbCandL = pdbL->nbRes;
t_candidateL = malloc((2*pdbL->nbRes)*sizeof(struct residue*));
if(t_candidateL == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
t_candidateR = malloc((2*pdbR->nbRes)*sizeof(struct residue*));
if(t_candidateR == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
//memset(t_candidateL,0,(1+pdbL->nbRes)*sizeof(struct residue));
//memset(t_candidateR,0,(1+pdbR->nbRes)*sizeof(struct residue));
for(i=0;i<pdbL->nbRes;i++)
t_candidateL[i] = &pdbL->residues[i];
for(i=0;i<pdbR->nbRes;i++)
t_candidateR[i] = &pdbR->residues[i];
while(oldCandL != nbCandL && oldCandR != nbCandR){
k++;
oldCandL = nbCandL;
oldCandR = nbCandR;
getCandidatesForP1(pdbR,t_candidateL,t_candidateR,&nbCandL,&nbCandR);
getCandidatesForP1(pdbL,t_candidateR,t_candidateL,&nbCandR,&nbCandL);
}
printf("NB_ITER %d\n",k);
for(i=0;i<nbCandR;i++){
t_candidateR[i]->isCandidate = 0;
}
for(i=0;i<nbCandL;i++){
t_candidateL[i]->isCandidate = 0;
}
/* Don't worry for that, this is only O(n^2) over the remaining
* candidate residues for each protein
* 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(i=0;i<nbCandR;i++){
for(j=0;j<t_candidateR[i]->nbAtom;j++){
x1 = t_candidateR[i]->x[j];
y1 = t_candidateR[i]->y[j];
z1 = t_candidateR[i]->z[j];
for(k=0;k<nbCandL;k++){
for(l=0;l<t_candidateL[k]->nbAtom;l++){
x2 = t_candidateL[k]->x[l];
y2 = t_candidateL[k]->y[l];
z2 = t_candidateL[k]->z[l];
dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
if(dist <= DIST_FOR_CONTACT){
t_candidateR[i]->isCandidate = 1;
t_candidateL[k]->isCandidate = 1;
break;
}
}
if(t_candidateR[i]->isCandidate == 1)
break;
}
if(t_candidateR[i]->isCandidate == 1)
break;
}
}
FILE* ligOut = NULL;
FILE* recOut = NULL;
char buf[500];
sprintf(buf,"%s/%s_inter.txt",outputDir,ligand);
ligOut = fopen(buf,"w");
for(i=0;i<nbCandL;i++){
if(t_candidateL[i]->isCandidate == 1)
fprintf(ligOut,"%s %s %c\n",t_candidateL[i]->resName,t_candidateL[i]->idRes,t_candidateL[i]->chain);
}
fclose(ligOut);
printf("-------------------\n");
sprintf(buf,"%s/%s_inter.txt",outputDir,receptor);
recOut = fopen(buf,"w");
for(i=0;i<nbCandR;i++){
if(t_candidateR[i]->isCandidate == 1)
fprintf(recOut,"%s %s %c\n",t_candidateR[i]->resName,t_candidateR[i]->idRes,t_candidateR[i]->chain);
}
fclose(recOut);
free(t_candidateL);
free(t_candidateR);
}
//void writeInterface(struct )
struct docking_results* getDataForComplex(){
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");
rc = getline(&buf,&len,condFile_stream); /* Get rid of first line */
/* 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)){
rc = fscanf(condFile_stream,"%d %d",&idConf,&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]);
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 pdb_values* readPDB(char* protein) {
int i = 0, j = 0;
int rc = 0, nbRes = 0, numCA = 0;
int curRes = 0, curAtom = 0, firstLine = 1;
size_t len = 2000;
char totalFilePath[200];
char buf2[15];
char buf3[50];
char bufID[10] = "\0";
char* buf = NULL;
FILE* pdbFile_stream = NULL;
struct pdb_values* pdb_prot = NULL;
sprintf(totalFilePath,"%s/%s.pdb",pdbDir,protein);
if(access(totalFilePath,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",totalFilePath);
exit(1);
}
pdbFile_stream = fopen(totalFilePath,"r");
if(pdbFile_stream == NULL){
perror("fopen");
exit(EXIT_FAILURE);
}
strcpy(buf3,"\0");
while(!feof(pdbFile_stream)){
rc = getline(&buf,&len,pdbFile_stream);
strncpy(buf2,buf,4);
buf2[4] = '\0';
if(strcmp("ATOM",buf2) == 0){
/* get the residue ID */
strncpy(buf2,buf+22,5);
buf2[5] = '\0';
if(strcmp(buf2,buf3) != 0){
nbRes++;
strcpy(buf3,buf2);
}
}
}
rewind(pdbFile_stream);
pdb_prot = allocate_pdb(nbRes);
while(!feof(pdbFile_stream)){
rc = getline(&buf,&len,pdbFile_stream);
if(feof(pdbFile_stream)) break; /* else the last line is read twice */
strncpy(buf2,buf,4);
buf2[4] = '\0';
if(strcmp("ATOM",buf2) != 0){
continue;
}
strncpy(bufID,buf+22,5);
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){
firstLine = 0;
}else{
curRes++;
}
curAtom = 0;
/* res name */
strncpy(pdb_prot->residues[curRes].resName,buf+17,3);
pdb_prot->residues[curRes].resName[3] = '\0';
/* res ID */
strncpy(pdb_prot->residues[curRes].idRes,buf+22,5);
pdb_prot->residues[curRes].idRes[5] = '\0';
/* atom chain */
pdb_prot->residues[curRes].chain = buf[21];
}
/* atom type */
strncpy(pdb_prot->residues[curRes].atomType[curAtom],buf+13,3);
pdb_prot->residues[curRes].atomType[curAtom][3] = '\0';
/* atom ID */
strncpy(buf2,buf+6,5);
buf2[5] = '\0';
pdb_prot->residues[curRes].idAtom[curAtom] = atoi(buf2);
/* atom X */
strncpy(buf2,buf+30,8);
buf2[8] = '\0';
pdb_prot->residues[curRes].x[curAtom] = atof(buf2);
/* atom Y */
strncpy(buf2,buf+38,8);
buf2[8] = '\0';
pdb_prot->residues[curRes].y[curAtom] = atof(buf2);
/* atom Z */
strncpy(buf2,buf+46,8);
buf2[8] = '\0';
pdb_prot->residues[curRes].z[curAtom] = atof(buf2);
if(strcmp("CA ",pdb_prot->residues[curRes].atomType[curAtom]) == 0){
numCA++;
if(numCA == 1){
pdb_prot->xCA1 = pdb_prot->residues[curRes].x[curAtom];
pdb_prot->yCA1 = pdb_prot->residues[curRes].y[curAtom];
pdb_prot->zCA1 = pdb_prot->residues[curRes].z[curAtom];
}else if(numCA == 5){
pdb_prot->xCA5 = pdb_prot->residues[curRes].x[curAtom];
pdb_prot->yCA5 = pdb_prot->residues[curRes].y[curAtom];
pdb_prot->zCA5 = pdb_prot->residues[curRes].z[curAtom];
}
}
curAtom++;
pdb_prot->residues[curRes].nbAtom++;
pdb_prot->nbAtom++;
}
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];
pdb_prot->centerY = pdb_prot->centerY + pdb_prot->residues[i].y[j];
pdb_prot->centerZ = pdb_prot->centerZ + pdb_prot->residues[i].z[j];
}
}
pdb_prot->centerX /= pdb_prot->nbAtom;
pdb_prot->centerY /= pdb_prot->nbAtom;
pdb_prot->centerZ /= pdb_prot->nbAtom;
free(buf);
fclose(pdbFile_stream);
return pdb_prot;
}
void writePDB(struct pdb_values* pdb, char* protName){
int i = 0, j = 0;
char buf[500];
FILE* fw = NULL;
sprintf(buf,"%s/%s.pdb",outputPDB,protName);
fw = fopen(buf,"w");
if(fw == NULL){
perror("fopen");
exit(EXIT_FAILURE);
}
for(i=0;i<pdb->nbRes;i++){
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],
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]);
}
}
fclose(fw);
}
int main(int argc, char** argv){
int i = 0;
float alpha = 0, beta = 0, gamma = 0;
struct pdb_values* pdbL = NULL;
struct pdb_values* pdbR = NULL;
struct pdb_values* newPDB = NULL;
struct docking_results* dock_res = NULL;
float dalpha = 0, dbeta = 0, dgamma = 0;
parseLineOfArgument(argc,argv);
dock_res = getDataForComplex();
pdbR = readPDB(receptor);
pdbL = readPDB(ligand);
if(target_conf > 0){
getAnglesFromCA1andCA5_sophie(pdbL,&alpha,&beta,&gamma);
dalpha = dock_res->alpha[target_conf] - alpha;
dbeta = dock_res->beta[target_conf] - beta;
dgamma = dock_res->gamma[target_conf] - gamma;
newPDB = rotate_sophie(pdbL,pdbR,NULL,dock_res->distCenters[target_conf],
dock_res->theta[target_conf],dock_res->phi[target_conf],
dalpha,dbeta,dgamma,dock_res,target_conf);
getInterface(pdbR,newPDB);
if(constructPDB){
writePDB(newPDB, ligand);
}
freePDB(newPDB);
}else{
for(i=0;i<dock_res->nbConf;i++){
// For all conformations
getAnglesFromCA1andCA5_sophie(pdbL,&alpha,&beta,&gamma);
dalpha = dock_res->alpha[i] - alpha;
dbeta = dock_res->beta[i] - beta;
dgamma = dock_res->gamma[i] - gamma;
newPDB = rotate_sophie(pdbL,pdbR,NULL,dock_res->distCenters[i],
dock_res->theta[i],dock_res->phi[i],
dalpha,dbeta,dgamma,dock_res,i);
getInterface(pdbR,newPDB);
if(constructPDB){
writePDB(newPDB, ligand);
}
freePDB(newPDB);
}
}
freePDB(pdbL);
freePDB(pdbR);
freeDock(dock_res);
free_argLine();
return 0;
}
#include <stdlib.h>
#include <string.h>
#include "struct.h"
#include "allocate.h"
void freePDB(struct pdb_values* pdb){
free(pdb->residues);
free(pdb);
pdb = NULL;
}
void freeDock(struct docking_results* dock_res){
free(dock_res->listEner);
free(dock_res->distCenters);
free(dock_res->theta);
free(dock_res->phi);
free(dock_res->alpha);
free(dock_res->beta);
free(dock_res->gamma);
free(dock_res);
dock_res = NULL;
}
struct docking_results* allocate_dockingResults(int nbConf){
int i = 0;
struct docking_results* dock_res = NULL;
dock_res = malloc(sizeof(struct docking_results));
if(dock_res == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->nbConf = nbConf;
dock_res->listEner = NULL;
dock_res->distCenters = NULL;
dock_res->theta = NULL;
dock_res->phi = NULL;
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){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->distCenters = malloc((2*nbConf)*sizeof(float));
if(dock_res->distCenters == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->theta = malloc((2*nbConf)*sizeof(float));
if(dock_res->theta == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->phi = malloc((2*nbConf)*sizeof(float));
if(dock_res->phi == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->alpha = malloc((2*nbConf)*sizeof(float));
if(dock_res->alpha == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->beta = malloc((2*nbConf)*sizeof(float));
if(dock_res->beta == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
dock_res->gamma = malloc((2*nbConf)*sizeof(float));
if(dock_res->gamma == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
for(i=0;i<nbConf;i++){
dock_res->listEner[i] = 0;
dock_res->distCenters[i] = 0;
dock_res->theta[i] = 0;
dock_res->phi[i] = 0;
dock_res->alpha[i] = 0;
dock_res->beta[i] = 0;
dock_res->gamma[i] = 0;
}
return dock_res;
}
void reset_dockingResults(struct docking_results* dock_res){
int i = 0;
for(i=0;i<dock_res->nbConf;i++){
dock_res->listEner[i] = 0;
dock_res->distCenters[i] = 0;
dock_res->theta[i] = 0;
dock_res->phi[i] = 0;
dock_res->alpha[i] = 0;
dock_res->beta[i] = 0;
dock_res->gamma[i] = 0;
}
dock_res->nbConf = 0;
}
struct pdb_values* allocate_pdb(int nbRes){
struct pdb_values* pdb = NULL;
pdb = malloc(sizeof(struct pdb_values));
if(pdb == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
memset(pdb,0,sizeof(struct pdb_values));
pdb->nbRes = nbRes;
pdb->residues = malloc(1+pdb->nbRes*sizeof(struct residue));
if(pdb->residues == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
memset(pdb->residues,0,pdb->nbRes*sizeof(struct residue));
return pdb;
}
void free_argLine(){
free(outputDir);
free(dockingFile);
free(pdbDir);
free(receptor);
free(ligand);
if(constructPDB){
free(outputPDB);
}
if(verbose){
fclose(verbose_file);
}
}
#include "struct.h"
#ifndef ALLOC_HEADER
#define ALLOC_HEADER
void freePDB(struct pdb_values* pdb);
void freeDock(struct docking_results* dock_res);
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();
#endif
File added
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "struct.h"
void print_usage() {
printf("Usage: \n"
"Mandatory\n"
"=========\n\n"
"<-dockingFile> MAXDo file that needs to be analysed\n"
"<-pdbDir> PDB directory containing the name of the receptor/ligand .pdb\n"
"<-rec> name of the receptor\n"
"<-lig> name of the ligand\n"
"OPTIONNAL\n"
"=========\n\n"
"<-constructPDB> Specify if the ligand should be output for each docking conformation\n"
"<-outputPDB> Output directory for the constructed PDB (ligand)\n"
" If nothing is specified, the current directory is used\n"
"<-o> Output directory for the docking interface\n"
" If nothing is specified, the current directory is used\n"
"<-pose> Desired conformation. Default will compute all conformations\n"
);
}
struct argLine* parseLineOfArgument(int argc, char** argv){
int i = 0, print_help = 0;
struct argLine* paramVals = NULL;
nbThreads = 1;
verbose = 0;
constructPDB = 0;
target_conf = -1;
outputDir = NULL;
outputPDB = NULL;
verbose_file = NULL;
dockingFile = NULL;
pdbDir = NULL;
receptor = NULL;
ligand = NULL;
for(i=1; i<argc; i++){
if(strcmp(argv[i],"-dockingFile") == 0){
dockingFile = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(dockingFile == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
strcpy(dockingFile,argv[i+1]);
}else if(strcmp(argv[i],"-pdbDir") == 0){
pdbDir = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(pdbDir == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
strcpy(pdbDir,argv[i+1]);
}else if(strcmp(argv[i],"-o") == 0){
outputDir = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(outputDir == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
strcpy(outputDir,argv[i+1]);
}else if(strcmp(argv[i],"-outputPDB") == 0){
outputPDB = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(outputPDB == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
strcpy(outputPDB,argv[i+1]);
constructPDB = 1;
}else if(strcmp(argv[i],"-rec") == 0){
receptor = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(receptor == NULL){
perror("malloc");
exit(EXIT_FAILURE);
}
strcpy(receptor,argv[i+1]);
}else if(strcmp(argv[i],"-lig") == 0){
ligand = malloc((strlen(argv[i+1])+1)*sizeof(char));
if(ligand == NULL){
perror("malloc");
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){
fprintf(stderr,"Specific conformation not valid\n");
exit(EXIT_SUCCESS);
}
}else if(strcmp(argv[i],"-h") == 0 ||
strcmp(argv[i],"--help") == 0){
print_help = 1;
}else if(strcmp(argv[i],"-v") == 0 ||
strcmp(argv[i],"--verbose") == 0){
verbose = 1;
verbose_file = fopen("INTbuilder.log","w");
}
}
if(dockingFile == NULL){
fprintf(stderr,"The docking file has to be provided\n\n");
if(!print_help)
print_usage();
exit(EXIT_SUCCESS);
}
if(pdbDir == NULL){
fprintf(stderr,"The PDB directory has to be provided\n\n");
if(!print_help)
print_usage();
exit(EXIT_SUCCESS);
}
if(receptor == NULL){
fprintf(stderr,"The receptor has to be provided\n\n");
if(!print_help)
print_usage();
exit(EXIT_SUCCESS);
}
if(ligand == NULL){
fprintf(stderr,"The ligand has to be provided\n\n");
if(!print_help)
print_usage();
exit(EXIT_SUCCESS);
}
if(print_help)
print_usage();
if(outputDir == NULL){
outputDir = malloc(3*sizeof(char));
if(outputDir == NULL){
perror("mallloc");
exit(EXIT_FAILURE);
}
strcpy(outputDir,"./");
}
if(constructPDB == 1 && outputPDB == NULL){
outputPDB = malloc(3*sizeof(char));
if(outputDir == NULL){
perror("mallloc");
exit(EXIT_FAILURE);
}
strcpy(outputPDB,"./");
}
return paramVals;
}
#ifndef PARAM_HEADER
#define PARAM_HEADER
void print_usage();
struct argLine* parseLineOfArgument(int argc, char** argv);
#endif
File added
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "struct.h"
#include "allocate.h"
void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, float R, float theta, float phi){
*x = x0 + R * sin(theta) * cos(phi);
*y = y0 + R * sin(theta) * sin(phi);
*z = z0 + R * cos(theta);
}
struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf){
float xi = 0, yi = 0, zi = 0;
float x1i = 0, y1i = 0, z1i = 0;
float x2i = 0, y2i = 0, z2i = 0;
float x3i = 0, y3i = 0, z3i = 0;
// cosinuses and sinuses of d_angle
float c_a=cos(alpha),s_a=sin(alpha);
float c_b=cos(beta),s_b=sin(beta);
float c_g=cos(gamma),s_g=sin(gamma);
float c_a0=cos(dock_res->alpha[nConf]),s_a0=sin(dock_res->alpha[nConf]);
float c_b0=cos(dock_res->beta[nConf]), s_b0=sin(dock_res->beta[nConf]);
float rx = 0, ry = 0, rz = 0;
if(newPDB == NULL){
newPDB = allocate_pdb(pdb->nbRes);
newPDB->nbAtom = pdb->nbAtom;
memcpy(newPDB->residues,pdb->residues,pdb->nbRes*sizeof(struct residue));
}
float newX = pdbR->centerX + R*sin(theta)*cos(phi);
float newY = pdbR->centerY + R*sin(theta)*sin(phi);
float newZ = pdbR->centerZ + R*cos(theta);
int i = 0, j = 0;
for(i=0;i<pdb->nbRes;i++){
for(j=0;j<pdb->residues[i].nbAtom;j++){
// printf("a/b/g %f %f %f\n",alpha,beta,gamma);
// printf("MAXa/b/g %f %f %f\n",dock_res->alpha[nConf],dock_res->beta[nConf],dock_res->gamma[nConf]);
xi = pdb->residues[i].x[j] - pdb->centerX;
yi = pdb->residues[i].y[j] - pdb->centerY;
zi = pdb->residues[i].z[j] - pdb->centerZ;
// printf("xi/yi/zi %f %f %f\n",xi,yi,zi);
// alpha rotation
x1i=c_a*xi-s_a*yi;
y1i=c_a*yi+s_a*xi;
z1i=zi;
// printf("x1i/y1i/z1i %f %f %f\n",x1i,y1i,z1i);
// beta rotation
x2i=(c_a0*c_a0+(1.0-c_a0*c_a0)*c_b)*x1i+c_a0*s_a0*(1.0-c_b)*y1i+s_a0*s_b*z1i;
y2i=c_a0*s_a0*(1.0-c_b)*x1i+(s_a0*s_a0+(1.0-s_a0*s_a0)*c_b)*y1i-c_a0*s_b*z1i;
z2i=-s_a0*s_b*x1i+c_a0*s_b*y1i+c_b*z1i;
// printf("x2i/y2i/z2i %f %f %f\n",x2i,y2i,z2i);
rx = -s_a0*c_b0;
ry = c_a0*c_b0;
rz = s_b0;
// gamma rotation
x3i=(rx*rx+(1.0-rx*rx)*c_g)*x2i+(rx*ry*(1.0-c_g)-rz*s_g)*y2i+(rx*rz*(1.0-c_g)+ry*s_g)*z2i;
y3i=(rx*ry*(1.0-c_g)+rz*s_g)*x2i+(ry*ry+(1.0-ry*ry)*c_g)*y2i+(ry*rz*(1.0-c_g)-rx*s_g)*z2i;
z3i=(rx*rz*(1.0-c_g)-ry*s_g)*x2i+(ry*rz*(1.0-c_g)+rx*s_g)*y2i+(rz*rz+(1.0-rz*rz)*c_g)*z2i;
// printf("x3i/y3i/z3i %f %f %f\n",x3i,y3i,z3i);
newPDB->residues[i].x[j] = x3i + newX;
newPDB->residues[i].y[j] = y3i + newY;
newPDB->residues[i].z[j] = z3i + newZ;
// printf("x/y/z %f %f %f\n",pdb->residues[i].x[j],pdb->residues[i].y[j],pdb->residues[i].z[j]);
newPDB->xCA1 = (newPDB->xCA1 - pdb->centerX) + newX;
newPDB->yCA1 = (newPDB->yCA1 - pdb->centerY) + newY;
newPDB->zCA1 = (newPDB->zCA1 - pdb->centerZ) + newZ;
newPDB->centerX = newX;
newPDB->centerY = newY;
newPDB->centerZ = newZ;
// printf("x/y/z %f %f %f\n",newPDB->residues[i].x[j],newPDB->residues[i].y[j],newPDB->residues[i].z[j]);
}
}
return newPDB;
}
void getAnglesFromCA1andCA5_sophie(struct pdb_values* pdb, float* alpha, float* beta, float* gamma){
*alpha = 0;
*beta = 0;
*gamma = 0;
float x1 = 0, y1 = 0, z1 = 0;
float x2 = 0, y2 = 0, z2 = 0;
float x1i = 0, y1i = 0, z1i = 0;
float x2i = 0, y2i = 0, z2i = 0;
float p1 = 0, r1 = 0, p2 = 0;
float c_a = 0, s_a = 0;
float c_b = 0, s_b = 0;
float c_g = 0, s_g = 0;
// CA 1
x1 = pdb->xCA1 - pdb->centerX;
y1 = pdb->yCA1 - pdb->centerY;
z1 = pdb->zCA1 - pdb->centerZ;
// CA 5
x2 = pdb->xCA5 - pdb->centerX;
y2 = pdb->yCA5 - pdb->centerY;
z2 = pdb->zCA5 - pdb->centerZ;
// Lenght of the projection on the plane X,Y
p1 = sqrt(x1*x1+y1*y1);
r1 = sqrt(x1*x1+y1*y1+z1*z1);
c_a = y1/p1;
s_a = -x1/p1;
c_b = p1/r1;
s_b = z1/r1;
*(alpha)= acos(c_a);
if(s_a<0.0)
*alpha = -(*alpha);
*(beta)= acos(c_b);
if(s_b<0.0)
*beta = -(*beta);
/* Clockwise rotation matrix for alpha */
x1i = x2*c_a - y2*s_a;
y1i = y2*c_a + x2*s_a;
z1i = z2;
x2i = x1i;
y2i = y1i*c_b + z1i*s_b;
z2i = z1i*c_b - y1i*s_b;
p2 = sqrt(x2i*x2i+z2i*z2i);
c_g = z2i/p2;
s_g = x2i/p2;
*gamma = acos(c_g);
if(s_g<0.0)
*gamma = -(*gamma);
}
#include "struct.h"
#ifndef ROTAT_HEADER
#define ROTAT_HEADER
struct pdb_values* rotate_sophie(struct pdb_values* pdb, struct pdb_values* pdbR, struct pdb_values* newPDB, float R, float theta, float phi, float alpha,float beta,float gamma, struct docking_results* dock_res, int nConf);
void getAnglesFromCA1andCA5_sophie(struct pdb_values* pdb, float* alpha, float* beta, float* gamma);
void sphericToxyz(float *x, float *y, float *z, float x0, float y0, float z0, float R, float theta, float phi);
#endif
File added
#include <stdio.h>
#ifndef STRUCT_HEADER
#define STRUCT_HEADER
/* Global variables
* They are never modified, and are specified
* when the parameters are parsed.
* They are used to alter the way the program goes
*/
int nbThreads;
int verbose;
int constructPDB;
int target_conf;
FILE* verbose_file;
char* pdbDir;
char* receptor;
char* ligand;
char* dockingFile;
char* outputDir;
char* outputPDB;
#define CDR 0.017453293
#define NB_MAX_ATOM_PER_RES 20
#define DIST_FOR_CONTACT 10
/*************************************************/
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 */
};
struct enerComplex {
int ID;
float ener;
};
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;
};
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;
};
struct docking_results {
float* listEner;
float* distCenters;
float* theta;
float* phi;
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