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 <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