-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_Hbonds_energy.c
executable file
·314 lines (207 loc) · 6.59 KB
/
Get_Hbonds_energy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
double getEnergy(char *,char *);
int main(int argc, char *argv[]) {
char filename[70];
char filename2[70];
char hbondFile[]="hbonds.out";
sprintf(filename,"%s",argv[1]);
sprintf(filename2,"%s",argv[1]);
int steps;
int startconf;
int totalconf;
char sys_command[170];
char froda_files[170];
int dot;
int x,y;
int filename_length;
double Lowest_Energy=100;
double hbond_Energy;
///////aromatic energy varaiables///
FILE *arom_energy;
double arom_energy_temp;
double Lowest_arom_energy=100;
char Arom_Energy_cmd[170];
///////PD_DOCK energy varaiables///
FILE *PD_DOCK_energy;
double PD_DOCK_energy_temp;
double Lowest_PD_DOCK_energy=100;
char PD_DOCK_Energy_cmd[170];
////////////////////////////////////
steps=atoi(argv[2]);
totalconf=atoi(argv[3]);
filename_length=strlen(filename);
puts(filename);
for(x=filename_length-1;x>=0;x--)
if (filename[x]=='.')
{dot=x;x=-1;}
filename[dot]='\0';
puts(filename);
system("rm hbonds.out");
for(x=steps;x<=totalconf;x+=steps)
{
if(x<10)sprintf(froda_files,"%s_froda_0000000%d.pdb",filename,x);
if((x<100)&&(x>=10))sprintf(froda_files,"%s_froda_000000%d.pdb",filename,x);
if((x<1000)&&(x>=100))sprintf(froda_files,"%s_froda_00000%d.pdb",filename,x);
if((x<10000)&&(x>=1000))sprintf(froda_files,"%s_froda_0000%d.pdb",filename,x);
sprintf(sys_command,"FIRST -L $FIRST_LIB -E -0.1 -non -hbout %s",froda_files);
printf("froda files:%s\n",froda_files);
///////////////////////////////////////////////////////
//////////////// - Aromatic Energy - /////////////////
/////////////////////////////////////////////////////
Arom_Energy_cmd[0]='\0';
sprintf(Arom_Energy_cmd,"./NEW_Aromatic_Energy12.o %s > arom_energy.txt",froda_files);
system(Arom_Energy_cmd);
arom_energy = fopen("arom_energy.txt","r");
fscanf(arom_energy,"%lf",&arom_energy_temp);
if (arom_energy_temp < Lowest_arom_energy)
Lowest_arom_energy = arom_energy_temp;
fclose(arom_energy);
/////////////////////////////////////////////////////////////
///////////////////// - PD_DOCK Energy - ///////////////////
///////////////////////////////////////////////////////////
PD_DOCK_Energy_cmd[0]='\0';
sprintf(PD_DOCK_Energy_cmd,"reduce.3.14.080821.linuxi386 -trim %s > noH%s",froda_files,froda_files);
printf("%s",PD_DOCK_Energy_cmd);
system(PD_DOCK_Energy_cmd);
PD_DOCK_Energy_cmd[0]='\0';
sprintf(PD_DOCK_Energy_cmd,"./CalculateBindingEnergies.o noH%s",froda_files);
system(PD_DOCK_Energy_cmd);
printf("%s",PD_DOCK_Energy_cmd);
PD_DOCK_energy = fopen("PDDEnergy.txt","r");
fscanf(PD_DOCK_energy,"%lf",&PD_DOCK_energy_temp);
if (PD_DOCK_energy_temp < Lowest_PD_DOCK_energy)
Lowest_PD_DOCK_energy = PD_DOCK_energy_temp;
fclose(PD_DOCK_energy);
//////////////////////////////////////////////////////////
/////////////////// - Hbonds - //////////////////////////
////////////////////////////////////////////////////////
system(sys_command);
sys_command[0]='\0';
sprintf(sys_command,"cp %s TempPdbfile.pdb",froda_files);
system(sys_command);
sys_command[0]='\0';
hbond_Energy=getEnergy(froda_files,"hbonds.out");
printf("\n%lf\n",hbond_Energy);
sprintf(sys_command,"rm %s_*",froda_files);
system(sys_command);
sys_command[0]='\0';
if(hbond_Energy<Lowest_Energy)
Lowest_Energy=hbond_Energy;
}
FILE *LowestENERGY;
LowestENERGY = fopen("LowEnergy.dat","w");
char sequence[10];
fprintf(LowestENERGY,"%lf\t%lf\t%lf\n",Lowest_Energy,Lowest_arom_energy,Lowest_PD_DOCK_energy);
fclose(LowestENERGY);
return EXIT_SUCCESS;
}
double getEnergy(char *pdbFile,char *HBondFile) {
FILE *PDB;
FILE *HBond_out;
char Line[190];
char atom[6];
float aNUM;
char aNAME[4];
char rNAME[4];
float rNUM;
char chain;
int DNAMax=0,DNAMin=10000000, ProtMax=0,ProtMin=10000000;
PDB =fopen(pdbFile,"r");
HBond_out=fopen(HBondFile,"r");
/////// //new stuff//
int Prot;
int flexRes;
int NRes;
int CARes;
int CRes;
double flex;
double flex1;
double flex2;
int atm1,atm2;
FILE *BondFlexFile;
char bond_flex[150];
char bondflex[150];
sprintf(bond_flex,"%s",pdbFile);
int x;
for(x=strlen(bond_flex);x>0;x--)
{
if(bond_flex[x]=='.')
{
bond_flex[x]='\0';
x=-1;
}
}
sprintf(bondflex,"%s_bond.txt",bond_flex);
///////
while (!feof(PDB))
{
fgets(Line,150,PDB);
sscanf(Line,"%s %f %s %s",atom, &aNUM,aNAME,rNAME);
if ((atom[0]=='A')&&(rNAME[0]=='D')&&(aNUM<DNAMin))DNAMin=aNUM;
if ((atom[0]=='A')&&(rNAME[0]=='D')&&(aNUM>DNAMax))DNAMax=aNUM;
if ((atom[0]=='A')&&(rNAME[0]!='D')&&(aNUM<ProtMin))ProtMin=aNUM;
if ((atom[0]=='A')&&(rNAME[0]!='D')&&(aNUM>ProtMax))ProtMax=aNUM;
}
fclose(PDB);
printf("DNA:%d-%d; Prot:%d-%d",DNAMin,DNAMax,ProtMin,ProtMax);
int Hydrogen=0,Acceptor=0;
double Total_HBEnergy=0;
double HBondEnergy=0;
while (!feof(HBond_out))
{
fgets(Line,150,HBond_out);
sscanf(Line," %d %d %lf",&Hydrogen,&Acceptor,&HBondEnergy);
if(((Hydrogen>=DNAMin)&&(Hydrogen<=DNAMax)&&(Acceptor>=ProtMin)&&(Acceptor<=ProtMax))
||
((Acceptor>=DNAMin)&&(Acceptor<=DNAMax)&&(Hydrogen>=ProtMin)&&(Hydrogen<=ProtMax)))
{
/////////New stuff//////
if((Acceptor>=ProtMin)&&(Acceptor<=ProtMax))Prot=Acceptor;
if((Hydrogen>=ProtMin)&&(Hydrogen<=ProtMax))Prot=Hydrogen;
aNUM=0;
PDB =fopen(pdbFile,"r");
while(Prot!=aNUM)
{
fgets(Line,150,PDB);
sscanf(Line,"%s %f %s %s %c %f",atom, &aNUM,aNAME,rNAME,&chain,&rNUM);
//if(Prot==aNUM)printf("yay %f",rNUM);
}
fclose(PDB);
flexRes=rNUM;
PDB =fopen(pdbFile,"r");
while((!feof(PDB))&&(rNUM<=flexRes))
{
fgets(Line,150,PDB);
sscanf(Line,"%s %f %s %s %c %f",atom, &aNUM,aNAME,rNAME,&chain,&rNUM);
if((rNUM==flexRes)&&(strcmp(aNAME,"N")==0)) NRes=aNUM;
if((rNUM==flexRes)&&(strcmp(aNAME,"CA")==0)) CARes=aNUM;
if((rNUM==flexRes)&&(strcmp(aNAME,"C")==0)) CRes=aNUM;
}
fclose(PDB);
//printf("\n%d %d %d %d %d\n%lf\n",Prot,NRes,CARes,CRes,HBondEnergy,flexRes);
BondFlexFile=fopen(bondflex,"r");
flex1=1;
flex2=1;
for(x=0;x<4;x++) fgets(Line,150,BondFlexFile);
while(!feof(BondFlexFile))
{
fgets(Line,150,BondFlexFile);
sscanf(Line,"%d %d %lf",&atm1,&atm2,&flex);
if((atm1==NRes)&&(atm2==CARes)) flex1=flex;
if((atm1==CARes)&&(atm2==CRes)) flex2=flex;
}
fclose(BondFlexFile);
/////////
//if(HBondEnergy<-6.2)
//if ((flex1<0.2)&&(flex2<0.2))
Total_HBEnergy+=HBondEnergy;
}
}
//printf("\n%lf",Total_HBEnergy);
//fclose(PDB);
if (Total_HBEnergy>0)Total_HBEnergy=0;
fclose(HBond_out);
return Total_HBEnergy;
}