forked from adavtyan/awsemmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_backbone.cpp
6961 lines (5840 loc) · 236 KB
/
fix_backbone.cpp
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ----------------------------------------------------------------------
Copyright (2010) Aram Davtyan and Garegin Papoian
Papoian's Group, University of Maryland at Collage Park
http://papoian.chem.umd.edu/
Solvent Separated Barrier Potential was contributed by Nick Schafer
Last Update: 12/20/2017
------------------------------------------------------------------------- */
#include "math.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "fix_backbone.h"
#include "atom.h"
#include "update.h"
#include "output.h"
#include "respa.h"
#include "error.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "neigh_request.h"
#include "group.h"
#include "domain.h"
#include "memory.h"
#include "atom_vec_awsemmd.h"
#include "comm.h"
#include "timer.h"
#include <fstream>
#include <time.h>
using std::ifstream;
#define delta 0.00001
#define DEBUGFORCES
#define vfm_small 0.0001
using namespace LAMMPS_NS;
using namespace FixConst;
//double fm_f[100][2][3], tfm_f[100][2][3];
//double err=0.0, err_max=0.0, err_max2=0.0;
/* ---------------------------------------------------------------------- */
// {"ALA", "ARG", "ASN", "ASP", "CYS", "GLN", "GLU", "GLY", "HIS", "ILE", "LEU", "LYS", "MET", "PHE", "PRO", "SER", "THR", "TRP", "TYR", "VAL"};
// {"A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"};
int se_map[] = {0, 0, 4, 3, 6, 13, 7, 8, 9, 0, 11, 10, 12, 2, 0, 14, 5, 1, 15, 16, 0, 19, 17, 0, 18, 0};
char one_letter_code[] = {'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'};
// Four letter classes
// 1) SHL: Small Hydrophilic (ALA, GLY, PRO, SER THR) or (A, G, P, S, T) or {0, 7, 14, 15, 16}
// 2) AHL: Acidic Hydrophilic (ASN, ASP, GLN, GLU) or (N, D, Q, E) or {2, 3, 5, 6}
// 3) BAS: Basic (ARG HIS LYS) or (R, H, K) or {1, 8, 11}
// 4) HPB: Hydrophobic (CYS, ILE, LEU, MET, PHE, TRP, TYR, VAL) or (C, I, L, M, F, W, Y, V) or {4, 9, 10, 12, 13, 17, 18, 19}
int bb_four_letter_map[] = {1, 3, 2, 2, 4, 2, 2, 1, 3, 4, 4, 3, 4, 4, 1, 1, 1, 4, 4, 4};
bool firsttimestep = true;
void itoa(int a, char *buf, int s)
{
int b = abs(a);
int c, i;
i=0;
while (b>0) {
c = b - int(b/10)*10;
b = b/10;
buf[i] = c + '0';
i++;
}
buf[i]='\0';
}
inline void FixBackbone::print_log(char *line)
{
if (screen) fprintf(screen, line);
if (logfile) fprintf(logfile, line);
}
FixBackbone::FixBackbone(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
{
if (narg != 7) error->all(FLERR,"Illegal fix backbone command");
efile = fopen("energy.log", "w");
fmenergiesfile = fopen("fmenergies.log", "w");
char buff[5];
char forcefile[20]="";
itoa(comm->me+1,buff,10);
strcpy(forcefile,"forces\0");
if (comm->nprocs>1) strcat(forcefile, buff);
strcat(forcefile, ".dat");
dout = fopen(forcefile, "w");
char eheader[] = "Step \tChain \tShake \tChi \tRama \tExcluded\tDSSP \tP_AP \tWater \tBurial \tHelix \tAMH-Go \tFrag_Mem\tVec_FM \tMembrane\tSSB \tElectro.\tVTotal\n";
fprintf(efile, "%s", eheader);
scalar_flag = 1;
vector_flag = 1;
thermo_energy = 1;
size_vector = nEnergyTerms-1;
global_freq = 1;
extscalar = 1;
extvector = 1;
abc_flag = chain_flag = shake_flag = chi_flag = rama_flag = rama_p_flag = excluded_flag = p_excluded_flag = r6_excluded_flag = 0;
ssweight_flag = dssp_hdrgn_flag = p_ap_flag = water_flag = burial_flag = helix_flag = amh_go_flag = frag_mem_flag = vec_frag_mem_flag = 0;
ssb_flag = frag_mem_tb_flag = phosph_flag = amylometer_flag = memb_flag = selection_temperature_flag = 0;
frag_frust_flag = tert_frust_flag = nmer_frust_flag = optimization_flag = burial_optimization_flag = 0;
huckel_flag = debyehuckel_optimization_flag = 0;
shuffler_flag = 0;
mutate_sequence_flag = 0;
monte_carlo_seq_opt_flag = 0;
epsilon = 1.0; // general energy scale
p = 2; // for excluded volume
int i, j;
for (i=0;i<12;i++) ssweight[i] = false;
for (i=0;i<TIME_N;i++) ctime[i] = 0.0;
// backbone geometry coefficients
an = 0.4831806; bn = 0.7032820; cn = -0.1864262;
ap = 0.4436538; bp = 0.2352006; cp = 0.3211455;
ah = 0.8409657; bh = 0.8929599; ch = -0.7338894;
// Default value for fm_sigma_exp
fm_sigma_exp = 0.15;
n_wells = 0;
n_helix_wells = 0;
igroup2 = group->find(arg[3]);
if (igroup2 == -1)
error->all(FLERR,"Could not find fix backbone beta atoms group ID");
igroup3 = group->find(arg[4]);
if (igroup3 == -1)
error->all(FLERR,"Could not find fix backbone oxygen atoms group ID");
if (igroup2 == igroup || igroup3 == igroup || igroup2 == igroup3)
error->all(FLERR,"Two groups cannot be the same in fix backbone");
if (group->count(igroup)!=group->count(igroup2) || group->count(igroup2)!=group->count(igroup3))
error->all(FLERR,"All groups must contain the same # of atoms in fix backbone");
group2bit = group->bitmask[igroup2];
group3bit = group->bitmask[igroup3];
char varsection[30];
ifstream in(arg[5]);
if (!in) error->all(FLERR,"Coefficient file was not found!");
while (!in.eof()) {
in >> varsection;
if (strcmp(varsection, "[ABC]")==0) {
abc_flag = 1;
if (comm->me==0) print_log("ABC flag on\n");
in >> an >> bn >> cn;
in >> ap >> bp >> cp;
in >> ah >> bh >> ch;
} else if (strcmp(varsection, "[Chain]")==0) {
chain_flag = 1;
if (comm->me==0) print_log("Chain flag on\n");
in >> k_chain[0] >> k_chain[1] >> k_chain[2];
in >> r_ncb0 >> r_cpcb0 >> r_ncp0;
} else if (strcmp(varsection, "[Shake]")==0) {
shake_flag = 1;
if (comm->me==0) print_log("Shake flag on\n");
in >> k_shake >> r_sh1 >> r_sh2 >> r_sh3;
} else if (strcmp(varsection, "[Chi]")==0) {
chi_flag = 1;
if (comm->me==0) print_log("Chi flag on\n");
in >> k_chi >> chi0;
} else if (strcmp(varsection, "[Excluded]")==0) {
excluded_flag = 1;
if (comm->me==0) print_log("Excluded flag on\n");
in >> k_excluded_C >> rC_ex0;
in >> k_excluded_O >> rO_ex0;
} else if (strcmp(varsection, "[Excluded_P]")==0) {
p_excluded_flag = 1;
if (comm->me==0) print_log("Excluded_P flag on\n");
in >> p;
in >> k_excluded_C >> rC_ex0;
in >> k_excluded_O >> rO_ex0;
} else if (strcmp(varsection, "[Excluded_R6]")==0) {
r6_excluded_flag = 1;
if (comm->me==0) print_log("Excluded_R6 flag on\n");
in >> k_excluded_C >> rC_ex0;
in >> k_excluded_O >> rO_ex0;
} else if (strcmp(varsection, "[Rama]")==0) {
rama_flag = 1;
if (comm->me==0) print_log("Rama flag on\n");
in >> k_rama;
in >> n_rama_par;
for (int j=0;j<n_rama_par;j++) {
in >> w[j] >> sigma[j] >> phiw[j] >> phi0[j] >> psiw[j] >> psi0[j];
}
} else if (strcmp(varsection, "[Rama_P]")==0) {
rama_p_flag = 1;
if (comm->me==0) print_log("Rama_P flag on\n");
in >> n_rama_p_par;
for (int j=0;j<n_rama_p_par;j++) {
in >> w[j+i_rp] >> sigma[j+i_rp] >> phiw[j+i_rp] >> phi0[j+i_rp] >> psiw[j+i_rp] >> psi0[j+i_rp];
}
} else if (strcmp(varsection, "[SSWeight]")==0) {
ssweight_flag = 1;
if (comm->me==0) print_log("SSWeight flag on\n");
for (int j=0;j<12;++j)
in >> ssweight[j];
} else if (strcmp(varsection, "[Dssp_Hdrgn]")==0) {
dssp_hdrgn_flag = 1;
if (comm->me==0) print_log("Dssp_Hdrgn flag on\n");
in >> k_dssp;
in >> hbscl[0][0] >> hbscl[0][1];
for (int j=0;j<7;++j) in >> hbscl[1][j];
for (int j=0;j<9;++j) in >> hbscl[2][j];
for (int j=0;j<9;++j) in >> hbscl[3][j];
in >> sigma_HO >> sigma_NO;
in >> HO_zero >> NO_zero;
in >> dssp_hdrgn_cut;
in >> pref[0] >> pref[1];
in >> d_nu0;
} else if (strcmp(varsection, "[P_AP]")==0) {
p_ap_flag = 1;
if (comm->me==0) print_log("P_AP flag on\n");
in >> k_global_P_AP;
in >> k_betapred_P_AP;
in >> k_P_AP[0] >> k_P_AP[1] >> k_P_AP[2];
in >> P_AP_cut;
in >> P_AP_pref;
in >> i_med_min >> i_med_max;
in >> i_diff_P_AP;
} else if (strcmp(varsection, "[Water]")==0) {
water_flag = 1;
if (comm->me==0) print_log("Water flag on\n");
in >> k_water;
in >> water_kappa >> water_kappa_sigma;
in >> treshold;
in >> contact_cutoff;
in >> n_wells;
for (int j=0;j<n_wells;++j)
in >> well_r_min[j] >> well_r_max[j] >> well_flag[j];
} else if (strcmp(varsection, "[Burial]")==0) {
burial_flag = 1;
if (comm->me==0) print_log("Burial flag on\n");
in >> k_burial;
in >> burial_kappa;
in >> burial_ro_min[0] >> burial_ro_max[0];
in >> burial_ro_min[1] >> burial_ro_max[1];
in >> burial_ro_min[2] >> burial_ro_max[2];
} else if (strcmp(varsection, "[Helix]")==0) {
helix_flag = 1;
if (comm->me==0) print_log("Helix flag on\n");
in >> k_helix;
in >> helix_gamma_p >> helix_gamma_w;
in >> helix_kappa >> helix_kappa_sigma;
in >> helix_treshold;
in >> helix_i_diff;
in >> helix_cutoff;
n_helix_wells = 1;
helix_well_flag[0] = 1;
in >> helix_well_r_min[0] >> helix_well_r_max[0];
for (int j=0;j<20;++j)
in >> h4prob[j];
// h4prob coefficent for proline if it is aceptor
// It will be used only if pro_accepter_flag=1
in >> pro_accepter_flag >> h4prob_pro_accepter;
in >> helix_sigma_HO >> helix_sigma_NO;
in >> helix_HO_zero >> helix_NO_zero;
} else if (strcmp(varsection, "[AMH-Go]")==0) {
amh_go_flag = 1;
if (comm->me==0) print_log("AMH-Go flag on\n");
in >> k_amh_go;
in >> amh_go_p;
in >> amh_go_rc;
in >> frustration_censoring_flag;
} else if (strcmp(varsection, "[Fragment_Memory]")==0) {
frag_mem_flag = 1;
if (comm->me==0) print_log("Fragment_Memory flag on\n");
in >> k_frag_mem;
in >> frag_mems_file;
in >> fm_gamma_file;
} else if (strcmp(varsection, "[Fragment_Memory_Table]")==0) {
frag_mem_tb_flag = 1;
if (comm->me==0) print_log("Fragment_Memory_Table flag on\n");
in >> k_frag_mem;
in >> frag_mems_file;
in >> fm_gamma_file;
in >> tb_rmin >> tb_rmax >> tb_dr;
tb_size = (int)((tb_rmax-tb_rmin)/tb_dr)+2;
in >> frag_table_well_width;
in >> fm_energy_debug_flag;
in >> fm_sigma_exp;
} else if (strcmp(varsection, "[Vector_Fragment_Memory]")==0) {
vec_frag_mem_flag = 1;
if (comm->me==0) print_log("Vector_Fragment_Memory flag on\n");
in >> k_vec_frag_mem;
in >> vfm_sigma;
vfm_sigma_sq = vfm_sigma*vfm_sigma;
} else if (strcmp(varsection, "[Solvent_Barrier]")==0) {
ssb_flag = 1;
if (comm->me==0) print_log("Solvent separated barrier flag on\n");
in >> k_solventb1;
in >> ssb_rmin1 >> ssb_rmax1;
in >> k_solventb2;
in >> ssb_rmin2 >> ssb_rmax2;
in >> ssb_kappa;
in >> ssb_ij_sep;
in >> ssb_rad_cor;
for (int j=0;j<20;++j)
in >> ssb_rshift[j];
} else if (strcmp(varsection, "[Membrane]")==0) {
memb_flag = 1;
print_log("Membrane flag on\n");
in >> k_overall_memb;
in >> k_bin;
in >> memb_xo[0] >> memb_xo[1] >> memb_xo[2];
in >> memb_pore_type;
in >> memb_len;
in >> rho0_max;
in >> rho0_distor;
for (int i=0;i<3;++i)
for (int j=0;j<4;++j)
in >> g_memb[i][j];
} else if (strcmp(varsection, "[Fragment_Frustratometer]")==0) {
// The fragment frustratometer requires the fragment memory potential to be active
if (!frag_mem_flag && !frag_mem_tb_flag) error->all(FLERR,"Cannot run Fragment_Frustratometer without Fragment_Memory or Fragment_Memory_Table.");
frag_frust_flag = 1; // activate flag for fragment frustratometer
if (comm->me==0) print_log("Fragment_Frustratometer flag on\n");
in >> frag_frust_mode; // the possible modes are "read" and "shuffle"
if (strcmp(frag_frust_mode, "shuffle")==0) {
if (comm->me==0) print_log("Fragment_Frustratometer in shuffle mode\n");
frag_frust_shuffle_flag=1; // activate "shuffle" specific flag
in >> decoy_mems_file; // read in the decoy fragments that will be shuffled to generated decoy energies
in >> num_decoy_calcs; // this is the number of times that the decoy fragments will be shuffled
in >> frag_frust_output_freq; // this is the number of steps between frustration calculations
}
else if (strcmp(frag_frust_mode, "read")==0) {
if (comm->me==0) print_log("Fragment_Frustratometer in read mode\n");
frag_frust_read_flag=1; // activate "read" specific flag
in >> decoy_mems_file; // read in the decoy structures that will be used to generate the decoy energies
in >> frag_frust_output_freq; // this is the number of steps between frustration calculations
in >> frag_frust_well_width; // parameter to tune well width, default is 1.0
in >> frag_frust_seqsep_flag >> frag_frust_seqsep_gamma; // flag and parameter to tune sequence separation dependent gamma
in >> frag_frust_normalizeInteraction; // flag that determines whether or not the fragment interaction is normalized by the width of the interaction
}
else {
// throw an error if the "mode" is anything but "read" or "shuffle"
error->all(FLERR,"Only \"shuffle\" and \"read\" are acceptable modes for the Fragment_Frustratometer.");
}
} else if (strcmp(varsection, "[Tertiary_Frustratometer]")==0) {
tert_frust_flag = 1;
if (comm->me==0) print_log("Tertiary_Frustratometer flag on\n");
in >> tert_frust_cutoff;
in >> tert_frust_ndecoys;
in >> tert_frust_output_freq;
in >> tert_frust_mode;
// Set the value of this flag to 0 so that the configurational decoy statistics will be computed at least once
already_computed_configurational_decoys = 0;
if (strcmp(tert_frust_mode, "configurational")!=0 && strcmp(tert_frust_mode, "mutational")!=0 && strcmp(tert_frust_mode, "singleresidue")!=0) {
// throw an error if the "mode" is anything but "configurational" or "mutational"
error->all(FLERR,"Only \"configurational\", \"mutational\", \"singleresidue\" are acceptable modes for the Tertiary_Frustratometer.");
}
} else if (strcmp(varsection, "[Nmer_Frustratometer]")==0) {
nmer_frust_flag = 1;
if (comm->me==0) print_log("Nmer_Frustratometer flag on\n");
in >> nmer_frust_size;
in >> nmer_frust_cutoff;
in >> nmer_contacts_cutoff;
in >> nmer_frust_ndecoys;
in >> nmer_frust_output_freq;
in >> nmer_frust_min_frust_threshold >> nmer_frust_high_frust_threshold >> nmer_output_neutral_flag;
in >> nmer_frust_trap_flag >> nmer_frust_draw_trap_flag >> nmer_frust_trap_num_sigma >> nmer_frust_ss_frac;
in >> nmer_frust_mode;
if (strcmp(nmer_frust_mode, "pairwise")!=0 && strcmp(nmer_frust_mode, "singlenmer")!=0) {
// throw an error if the "mode" is anything but "configurational" or "mutational"
error->all(FLERR,"Only \"pairwise\", \"singlenmer\" are acceptable modes for the Nmer_Frustratometer.");
}
} else if (strcmp(varsection, "[Phosphorylation]")==0) {
if (!water_flag) error->all(FLERR,"Cannot run phosphorylation without water potential");
phosph_flag = 1;
if (comm->me==0) print_log("Phosphorylation flag on\n");
in >> k_hypercharge;
in >> n_phosph_res;
if (n_phosph_res > 20) error->all(FLERR,"Number of phosphorylated residues may not exceed 20");
for (int i=0;i<n_phosph_res;++i)
in >> phosph_res[i];
} else if (strcmp(varsection, "[Epsilon]")==0) {
in >> epsilon;
} else if (strcmp(varsection, "[Amylometer]")==0) {
amylometer_flag = 1;
if (comm->me==0) print_log("Amylometer flag on\n");
in >> amylometer_sequence_file;
in >> amylometer_nmer_size;
// 1 == self-only, 2 == heterogeneous
in >> amylometer_mode;
if (amylometer_mode == 2) {
in >> amylometer_structure_file;
in >> amylometer_contact_cutoff;
}
read_amylometer_sequences(amylometer_sequence_file, amylometer_nmer_size, amylometer_mode);
} else if (strcmp(varsection, "[Selection_Temperature]")==0) {
selection_temperature_flag = 1;
if (comm->me==0) print_log("Selection_Temperature flag on \n");
// outputting interaction energies
in >> selection_temperature_output_frequency;
in >> selection_temperature_output_interaction_energies_flag;
in >> selection_temperature_file_name;
// evaluating multiple sequence energies
in >> selection_temperature_evaluate_sequence_energies_flag;
in >> selection_temperature_sequences_file_name;
in >> selection_temperature_residues_file_name;
in >> selection_temperature_sequence_energies_output_file_name;
// outputting contact lists
in >> selection_temperature_output_contact_list_flag;
in >> selection_temperature_rij_cutoff;
in >> selection_temperature_min_seq_sep;
in >> selection_temperature_output_contact_list_file_name;
} else if (strcmp(varsection, "[Monte_Carlo_Seq_Opt]")==0) {
monte_carlo_seq_opt_flag = 1;
if (comm->me==0) print_log("Monte_Carlo_Seq_Opt flag on \n");
in >> mcso_start_temp >> mcso_end_temp >> mcso_num_steps;
in >> mcso_seq_output_file_name;
in >> mcso_energy_output_file_name;
} else if (strcmp(varsection, "[Optimization]")==0) {
optimization_flag = 1;
if (comm->me==0) print_log("Optimization flag on\n");
in >> optimization_output_freq;
}
else if (strcmp(varsection, "[Burial_Optimization]")==0) {
burial_optimization_flag = 1;
if (comm->me==0) print_log("Burial Optimization flag on\n");
in >> burial_optimization_output_freq;
} else if (strcmp(varsection, "[DebyeHuckel]")==0) {
huckel_flag = 1;
if (comm->me==0) print_log("DebyeHuckel on\n");
in >> k_PlusPlus >> k_MinusMinus >> k_PlusMinus;
in >> k_screening;
in >> screening_length;
fprintf(screen, "Debye-Huckel Screening Length = %8.6f Angstroms\n", screening_length);
in >> debye_huckel_min_sep;
} else if (strcmp(varsection, "[DebyeHuckel_Optimization]")==0) {
debyehuckel_optimization_flag = 1;
if (comm->me==0) print_log("DebyeHuckel_Optimization flag on\n");
in >> debyehuckel_optimization_output_freq;
} else if (strcmp(varsection, "[Shuffler]")==0) {
in >> shuffler_flag;
in >> shuffler_mode;
if ( shuffler_flag == 1 ) {
if (comm->me==0) print_log("Shuffler flag on\n");
}
} else if (strcmp(varsection, "[Mutate_Sequence]")==0) {
in >> mutate_sequence_flag;
in >> mutate_sequence_sequences_file_name;
if ( mutate_sequence_flag == 1 ) {
if (comm->me==0) print_log("Mutate_Sequence flag on\n");
}
}
varsection[0]='\0'; // Clear buffer
}
in.close();
if (comm->me==0) print_log("\n");
// Do senity check to make sure that e.g. water potential is on when needed by other function
force_flag = 0;
n = (int)(group->count(igroup)+1e-12);
for (int i=0;i<nEnergyTerms;++i) energy[i] = 0.0;
x = atom->x;
f = atom->f;
image = atom->image;
prd[0] = domain->xprd;
prd[1] = domain->yprd;
prd[2] = domain->zprd;
half_prd[0] = prd[0]/2;
half_prd[1] = prd[1]/2;
half_prd[2] = prd[2]/2;
periodicity = domain->periodicity;
allocated = false;
allocate();
// Read sequance file
ifstream ins(arg[6]);
if (!ins) error->all(FLERR,"Sequence file was not found");
char *buf = new char[n+2];
se[0]='\0';
nch = 0;
while (!ins.eof()) {
ins >> buf;
if (buf[0]=='#' || isEmptyString(buf)) continue;
ch_pos[nch] = strlen(se)+1;
strcat(se, buf);
ch_len[nch] = strlen(buf);
nch++;
buf[0]='\0';
}
ins.close();
delete [] buf;
if (dssp_hdrgn_flag) {
ifstream in_anti_HB("anti_HB");
ifstream in_anti_NHB("anti_NHB");
ifstream in_para_HB("para_HB");
ifstream in_para_one("para_one");
ifstream in_anti_one("anti_one");
if (!in_anti_HB) error->all(FLERR,"File anti_HB doesn't exist");
if (!in_anti_NHB) error->all(FLERR,"File anti_NHB doesn't exist");
if (!in_para_HB) error->all(FLERR,"File para_HB doesn't exist");
if (!in_para_one) error->all(FLERR,"File para_one doesn't exist");
if (!in_anti_one) error->all(FLERR,"File anti_one doesn't exist");
for (i=0;i<20;++i) {
in_para_one >> m_para_one[i];
in_anti_one >> m_anti_one[i];
for (j=0;j<20;++j) {
in_anti_HB >> m_anti_HB[i][j][0];
in_anti_NHB >> m_anti_NHB[i][j][0];
in_para_HB >> m_para_HB[i][j][0];
}
}
for (i=0;i<20;++i) {
for (j=0;j<20;++j) {
in_anti_HB >> m_anti_HB[i][j][1];
in_anti_NHB >> m_anti_NHB[i][j][1];
in_para_HB >> m_para_HB[i][j][1];
}
}
in_anti_HB.close();
in_anti_NHB.close();
in_para_HB.close();
in_para_one.close();
in_anti_one.close();
}
if (ssweight_flag) {
ifstream in_ssw("ssweight");
if (!in_ssw) error->all(FLERR,"File ssweight doesn't exist");
for (j=0;j<n;++j) {
for (i=0;i<12;++i) {
if (ssweight[i]) in_ssw >> aps[i][j]; else aps[i][j] = 0.0;
}
}
in_ssw.close();
}
if (memb_flag) {
ifstream in_memb_zim("zim");
if (!in_memb_zim) error->all(FLERR,"File zim doesn't exist");
// what's happen if zim file is not correct
for (i=0;i<n;++i) {
in_memb_zim >> z_res[i];
}
in_memb_zim.close();
}
if (water_flag) {
ifstream in_wg("gamma.dat");
if (!in_wg) error->all(FLERR,"File gamma.dat doesn't exist");
for (int i_well=0;i_well<n_wells;++i_well) {
for (i=0;i<20;++i) {
for (j=i;j<20;++j) {
in_wg >> water_gamma[i_well][i][j][0] >> water_gamma[i_well][i][j][1];
water_gamma[i_well][j][i][0] = water_gamma[i_well][i][j][0];
water_gamma[i_well][j][i][1] = water_gamma[i_well][i][j][1];
}
}
}
in_wg.close();
}
if (phosph_flag) {
for (int i_well=0;i_well<n_wells;++i_well) {
for (i=0;i<20;++i) {
for (j=i;j<20;++j) {
phosph_water_gamma[i_well][i][j][0] = phosph_water_gamma[i_well][j][i][0] = water_gamma[i_well][i][j][0];
phosph_water_gamma[i_well][i][j][1] = phosph_water_gamma[i_well][j][i][1] = water_gamma[i_well][i][j][1];
}
}
}
//replacing serine interaction gammas with hypercharged glutamate interaction gammas
for (int i_well=0;i_well<n_wells;++i_well) {
for (i=0;i<20;++i) {
if (bb_four_letter_map[i]==1) {
phosph_water_gamma[i_well][i][15][0] = phosph_water_gamma[i_well][15][i][0] = phosph_water_gamma[i_well][i][6][0]*k_hypercharge;
phosph_water_gamma[i_well][i][15][1] = phosph_water_gamma[i_well][15][i][1] = phosph_water_gamma[i_well][i][6][1]*k_hypercharge;
}
else if (bb_four_letter_map[i]==2 || bb_four_letter_map[i]==3) {
phosph_water_gamma[i_well][i][15][0] = phosph_water_gamma[i_well][15][i][0] = phosph_water_gamma[i_well][i][6][0]*pow(k_hypercharge,2);
phosph_water_gamma[i_well][i][15][1] = phosph_water_gamma[i_well][15][i][1] = phosph_water_gamma[i_well][i][6][1]*pow(k_hypercharge,2);
}
else {
phosph_water_gamma[i_well][i][15][0] = phosph_water_gamma[i_well][15][i][0] = phosph_water_gamma[i_well][i][6][0];
phosph_water_gamma[i_well][i][15][1] = phosph_water_gamma[i_well][15][i][1] = phosph_water_gamma[i_well][i][6][1];
}
}
}
//create map of phosphorylated residues
phosph_map = new int[n];
for (int i=0;i<n;++i) {
phosph_map[i]=0;
}
for (int j=0;j<n_phosph_res;++j) {
if (phosph_res[j]!=0) {
int dummy = phosph_res[j]-1;
phosph_map[dummy]=1;
}
}
}
if (burial_flag) {
ifstream in_brg("burial_gamma.dat");
if (!in_brg) error->all(FLERR,"File burial_gamma.dat doesn't exist");
for (i=0;i<20;++i) {
in_brg >> burial_gamma[i][0] >> burial_gamma[i][1] >> burial_gamma[i][2];
}
in_brg.close();
}
if (amh_go_flag) {
char amhgo_gamma_file[] = "amh-go.gamma";
amh_go_gamma = new Gamma_Array(amhgo_gamma_file);
if (amh_go_gamma->error==amh_go_gamma->ERR_FILE) error->all(FLERR,"Cannot read file amh-go.gamma");
if (amh_go_gamma->error==amh_go_gamma->ERR_CLASS_DEF) error->all(FLERR,"AMH_Go: Wrong definition of sequance separation classes");
if (amh_go_gamma->error==amh_go_gamma->ERR_GAMMA) error->all(FLERR,"AMH_Go: Incorrect entery in gamma file");
if (amh_go_gamma->error==amh_go_gamma->ERR_G_CLASS) error->all(FLERR,"AMH_Go: Wrong sequance separation class tag");
if (amh_go_gamma->error==amh_go_gamma->ERR_ASSIGN) error->all(FLERR,"AMH_Go: Cannot build gamma array");
char amhgo_mem_file[] = "amh-go.gro";
m_amh_go = new Fragment_Memory(0, 0, n, 1.0, amhgo_mem_file);
if (m_amh_go->error==m_amh_go->ERR_FILE) error->all(FLERR,"Cannot read file amh-go.gro");
if (m_amh_go->error==m_amh_go->ERR_ATOM_COUNT) error->all(FLERR,"AMH_Go: Wrong atom count in memory structure file");
if (m_amh_go->error==m_amh_go->ERR_RES) error->all(FLERR,"AMH_Go: Unknown residue");
// if frustration censoring flag is 1, read in frustration censored interactions
if (frustration_censoring_flag == 1) {
std::ifstream infile("frustration_censored_contacts.dat");
int i, j;
while(infile >> i >> j) {
frustration_censoring_map[i-1][j-1] = 1;
}
}
//if frustration censoring is 2, read in rnative distances for DCA predicted Go
if (frustration_censoring_flag == 2) {
std::ifstream in_rnativeCACA("go_rnativeCACA.dat");
std::ifstream in_rnativeCBCB("go_rnativeCBCB.dat");
std::ifstream in_rnativeCACB("go_rnativeCACB.dat");
if (!in_rnativeCACA || !in_rnativeCACB || !in_rnativeCBCB) error->all(FLERR,"Go native distance file can't be read");
for (i=0;i<n;++i) {
for (j=0;j<n;++j) {
in_rnativeCACA >> r_nativeCACA[i][j];
in_rnativeCBCB >> r_nativeCBCB[i][j];
in_rnativeCACB >> r_nativeCACB[i][j];
}
}
in_rnativeCACA.close();
in_rnativeCBCB.close();
in_rnativeCACB.close();
}
// Calculate normalization factor for AMH-GO potential
compute_amhgo_normalization();
}
if (frag_mem_flag || frag_mem_tb_flag) {
if (comm->me==0) print_log("Reading fragments...\n");
fm_gamma = new Gamma_Array(fm_gamma_file);
if (fm_gamma->error==fm_gamma->ERR_FILE) error->all(FLERR,"Fragment_Memory: Cannot read gamma file");
if (fm_gamma->error==fm_gamma->ERR_CLASS_DEF) error->all(FLERR,"Fragment_Memory: Wrong definition of sequance separation classes");
if (fm_gamma->error==fm_gamma->ERR_GAMMA) error->all(FLERR,"Fragment_Memory: Incorrect entery in gamma file");
if (fm_gamma->error==fm_gamma->ERR_G_CLASS) error->all(FLERR,"Fragment_Memory: Wrong sequance separation class tag");
if (fm_gamma->error==fm_gamma->ERR_ASSIGN) error->all(FLERR,"Fragment_Memory: Cannot build gamma array");
// read frag_mems_file and create a list of the fragments
frag_mems = read_mems(frag_mems_file, n_frag_mems);
// allocate frag_mem_map and ilen_fm_map
ilen_fm_map = new int[n]; // Number of fragments for residue i
frag_mem_map = new int*[n]; // Memory Fragments map
for (i=0;i<n;++i) {
ilen_fm_map[i] = 0;
frag_mem_map[i] = NULL;
}
// Fill Fragment Memory map
int k, pos, len, min_sep;
min_sep = fm_gamma->minSep();
for (k=0;k<n_frag_mems;++k) {
pos = frag_mems[k]->pos;
len = frag_mems[k]->len;
if (pos+len>n) {
fprintf(stderr, "pos %d len %d n %d\n", pos, len, n);
error->all(FLERR,"Fragment_Memory: Incorrectly defined memory fragment");
}
for (i=pos; i<pos+len-min_sep; ++i) {
ilen_fm_map[i]++;
frag_mem_map[i] = (int *) memory->srealloc(frag_mem_map[i],ilen_fm_map[i]*sizeof(int),"modify:frag_mem_map");
frag_mem_map[i][ilen_fm_map[i]-1] = k;
}
}
}
// if the fragment frustratometer flag is on, perform appropriate initializations
if (frag_frust_flag) {
// open fragment frustration file for writing
fragment_frustration_file = fopen("fragment_frustration.dat","w");
fragment_frustration_gap_file = fopen("fragment_frustration_gap.dat","w");
fragment_frustration_variance_file = fopen("fragment_frustration_variance.dat","w");
fragment_frustration_decoy_data = fopen("fragment_frustration_decoy.dat","w");
fragment_frustration_native_data = fopen("fragment_frustration_native.dat","w");
if (comm->me==0) print_log("Reading decoy fragments...\n");
// create a decoy memory array by reading in the appropriate file
decoy_mems = read_mems(decoy_mems_file, n_decoy_mems); // n_decoy_mems is set equal to the number of decoys in the read_mems function
// because the number of decoy calculations is set by the size of the decoy list in "read" mode, we need to initialize the variable here
if (frag_frust_read_flag) {
num_decoy_calcs = n_decoy_mems+1; // add one so that the "native" energy can occupy the 0 index
}
// allocate decoy_mem_map and ilen_decoy_map
ilen_decoy_map = new int[n]; // Number of decoys for residue i
decoy_mem_map = new int*[n]; // decoy Memory Fragments map
for (i=0;i<n;++i) {
ilen_decoy_map[i] = 0;
decoy_mem_map[i] = NULL;
}
// Fill Decoy Memory map
int k, pos, len, min_sep;
min_sep = fm_gamma->minSep();
for (k=0;k<n_decoy_mems;++k) {
pos = decoy_mems[k]->pos;
len = decoy_mems[k]->len;
if (pos+len>n) {
fprintf(stderr, "pos %d len %d n %d\n", pos, len, n);
error->all(FLERR,"Fragment_Frustratometer: Incorrectly defined memory fragment");
}
for (i=pos; i<pos+len-min_sep; ++i) {
ilen_decoy_map[i]++;
decoy_mem_map[i] = (int *) memory->srealloc(decoy_mem_map[i],ilen_decoy_map[i]*sizeof(int),"modify:decoy_mem_map");
decoy_mem_map[i][ilen_decoy_map[i]-1] = k;
}
}
// Allocate decoy_energy array
decoy_energy = new double*[n];
for (i=0;i<n;i++)
{
decoy_energy[i] = new double[num_decoy_calcs];
for(int decoyindex=0; decoyindex<num_decoy_calcs; decoyindex++)
{
decoy_energy[i][decoyindex] = 0.0;
}
}
// if in "read" mode, allocate per residue mean and variance arrays and compute generated decoy energies
if (frag_frust_read_flag)
{
frag_frust_read_mean = new double[n];
frag_frust_read_variance = new double[n];
}
}
// if tert_frust_flag is on, perform appropriate initializations
if(tert_frust_flag) {
tert_frust_decoy_energies = new double[tert_frust_ndecoys];
decoy_ixn_stats = new double[2];
tert_frust_output_file = fopen("tertiary_frustration.dat","w");
tert_frust_vmd_script = fopen("tertiary_frustration.tcl","w");
if (strcmp(tert_frust_mode, "configurational")==0 || strcmp(tert_frust_mode, "mutational")==0) {
fprintf(tert_frust_output_file,"# i j i_chain j_chain xi yi zi xj yj zj r_ij rho_i rho_j a_i a_j native_energy <decoy_energies> std(decoy_energies) f_ij\n");
}
else if (strcmp(tert_frust_mode, "singleresidue")==0) {
fprintf(tert_frust_output_file,"# i i_chain xi yi zi rho_i a_i native_energy <decoy_energies> std(decoy_energies) f_i\n");
}
}
// if nmer_frust_flag is on, perform appropriate initializations
if(nmer_frust_flag) {
nmer_frust_decoy_energies = new double[nmer_frust_ndecoys];
nmer_decoy_ixn_stats = new double[2];
nmer_seq_i = new char[nmer_frust_size+1]; // extend the array
nmer_seq_i[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_seq_j = new char[nmer_frust_size+1]; // extend the array
nmer_seq_j[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_seq_k = new char[nmer_frust_size+1]; // extend the array
nmer_seq_k[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_ss_i = new char[nmer_frust_size+1]; // extend the array
nmer_ss_i[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_ss_j = new char[nmer_frust_size+1]; // extend the array
nmer_ss_j[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_ss_k = new char[nmer_frust_size+1]; // extend the array
nmer_ss_k[nmer_frust_size] = '\0'; // and null terminate it so that it can be printed properly
nmer_frust_output_file = fopen("nmer_frustration.dat","w");
nmer_frust_vmd_script = fopen("nmer_frustration.tcl","w");
if (strcmp(nmer_frust_mode, "pairwise")==0) {
fprintf(nmer_frust_output_file,"# i j ncontacts a_i a_j native_energy <decoy_energies> std(decoy_energies) f_ij\n");
}
else if (strcmp(nmer_frust_mode, "singlenmer")==0) {
fprintf(nmer_frust_output_file,"# i a_i native_energy <decoy_energies> std(decoy_energies) f_ij\n");
}
if(nmer_frust_trap_flag) {
nmer_frust_trap_file = fopen("nmer_traps.dat", "w");
fprintf(nmer_frust_trap_file,"# i a_i ss_i j a_j ss_j threshold_energy k a_k ss_k direction trap_energy\n");
}
}
// Selection temperature file
if (selection_temperature_flag) {
if (selection_temperature_output_interaction_energies_flag) {
selection_temperature_file = fopen(selection_temperature_file_name, "w");
}
if (selection_temperature_evaluate_sequence_energies_flag) {
selection_temperature_sequence_energies_output_file = fopen(selection_temperature_sequence_energies_output_file_name, "w");
fprintf(selection_temperature_file, "# i j a_i a_j rij rho_i rho_j water burial_i burial_j\n");
// read in sequences in selection temperature sequences file
char temp_sequence[1000];
ifstream selection_temperature_sequences_file(selection_temperature_sequences_file_name);
selection_temperature_sequences_file >> num_selection_temperature_sequences;
selection_temperature_sequences = new char*[num_selection_temperature_sequences];
for (int i=0;i<num_selection_temperature_sequences;i++) {
selection_temperature_sequences[i] = new char[n];
}
for(int i_sequence = 0; i_sequence < num_selection_temperature_sequences; i_sequence++) {
selection_temperature_sequences_file >> temp_sequence;
strcpy(selection_temperature_sequences[i_sequence],temp_sequence);
}
selection_temperature_sequences_file.close();
// read in residues in selection temperature residues file
int temp_res_index;
ifstream selection_temperature_residues_file(selection_temperature_residues_file_name);
selection_temperature_residues_file >> num_selection_temperature_residues;
selection_temperature_residues = new int[num_selection_temperature_residues];
for(int i=0; i<num_selection_temperature_residues;i++) {
selection_temperature_residues_file >> temp_res_index;
selection_temperature_residues[i] = temp_res_index;
}
selection_temperature_residues_file.close();
}
if (selection_temperature_output_contact_list_flag) {
selection_temperature_contact_list_file = fopen(selection_temperature_output_contact_list_file_name, "w");
}
}
if (monte_carlo_seq_opt_flag) {
mcso_seq_output_file = fopen(mcso_seq_output_file_name, "w");
mcso_energy_output_file = fopen(mcso_energy_output_file_name, "w");
}
// if optimization_flag is on, perform appropriate initializations
if(optimization_flag) {
optimization_file = fopen("optimization_energies.dat","w");
native_optimization_file = fopen("native_optimization_energies.dat","w");
optimization_norm_file = fopen("optimization_norms.dat","w");
native_optimization_norm_file = fopen("native_optimization_norms.dat","w");
}
if (burial_optimization_flag) {
burial_optimization_file = fopen("burial_optimization_energies.dat","w");
native_burial_optimization_file = fopen("native_burial_optimization_energies.dat","w");
burial_optimization_norm_file = fopen("burial_optimization_norm.dat","w");
}
if (debyehuckel_optimization_flag) {
debyehuckel_optimization_file = fopen("debyehuckel_optimization_energies.dat","w");
debyehuckel_native_optimization_file = fopen("debyehuckel_native_optimization_energies.dat","w");
debyehuckel_optimization_norm_file = fopen("debyehuckel_optimization_norm.dat","w");
debyehuckel_native_optimization_norm_file = fopen("debyehuckel_native_optimization_norm.dat","w");
}
// if optimization_flag is on, perform appropriate initializations
/* if(average_sequence_optimization_flag) {
average_sequence_optimization_file = fopen("average_sequence_optimization_energies.dat","w");
average_sequence_optimization_norm_file = fopen("average_sequence_optimization_norms.dat","w");
ifstream in_average_sequence(average_sequence_input_file_name);
for(i=0;i<n;i++) {
for(j=0;j<20;j++) {
in_average_sequence >> average_sequence[i][j];
}
}
in_average_sequence.close();
}*/
// if Mutate_Sequence flag is on, perform the appropriate initializations
if (mutate_sequence_flag) {
// read in sequences in selection temperature sequences file
char temp_sequence[1000];
ifstream mutate_sequence_sequences_file(mutate_sequence_sequences_file_name);
mutate_sequence_sequences_file >> mutate_sequence_number_of_sequences;
mutate_sequence_sequences = new char*[mutate_sequence_number_of_sequences];
for (int i=0;i<mutate_sequence_number_of_sequences;i++) {
mutate_sequence_sequences[i] = new char[n];
}
for(int i_sequence = 0; i_sequence < mutate_sequence_number_of_sequences; i_sequence++) {
mutate_sequence_sequences_file >> temp_sequence;
strcpy(mutate_sequence_sequences[i_sequence],temp_sequence);
}
mutate_sequence_sequences_file.close();
mutate_sequence_sequence_index = 0;
}
// Allocate FM the table
if (frag_mem_tb_flag) {
if (fm_gamma->maxSep()!=-1)
tb_nbrs = fm_gamma->maxSep()-fm_gamma->minSep()+1;
else
tb_nbrs = n - fm_gamma->minSep();
fm_table = new TBV*[4*n*tb_nbrs];
for (i=0; i<4*n*tb_nbrs; ++i) {
fm_table[i] = NULL;
}
if (comm->me==0) print_log("Computing FM table...\n");
compute_fragment_memory_table();
}
// If using Debye_Huckel potential, read charges from file
// Skip if DebyeHuckel optimization is on, because it uses a residue type based potential
// instead of residue index based potential (so that sequence shuffling can be used)
if (huckel_flag && !debyehuckel_optimization_flag) {
int residue_number, total_residues;
double charge_value;
double total_charge =0;
ifstream input_charge("charge_on_residues.dat");
if (!input_charge) error->all(FLERR,"File charge_on_residues.dat doesn't exist");
input_charge >> total_residues;
//fprintf(screen, "check charge data \n");
fprintf(screen, "Number of Charge input = %5d \n", total_residues);
for(int ires = 0; ires<total_residues; ires++)
{
input_charge >> residue_number >> charge_value;
int res_min_one = residue_number -1;
charge_on_residue[res_min_one] = charge_value;
total_charge = total_charge + charge_value;
//fprintf(screen, "residue=%5d, charge on residue =%8.6f\n", residue_number, charge_value);
//fprintf(screen, "residue=%5d, charge on residue =%8.6f\n", res_min_one, charge_on_residue[res_min_one]);
}
input_charge.close();
fprintf(screen, "Total Charge on the System = %8.4f\n", total_charge );
}
sStep=0, eStep=0;
ifstream in_rs("record_steps");
in_rs >> sStep >> eStep;
in_rs.close();
}
void FixBackbone::final_log_output()
{
double time, tmp;
char txt_timer[][11] = {"Chain", "Shake", "Chi", "Rama", "Vexcluded", "DSSP", "PAP", "Water", "Burial", "Helix", "AHM-Go", "Frag_Mem", "Vec_FM", "Membrane", "SSB", "DH"};
int me,nprocs;
MPI_Comm_rank(world,&me);
MPI_Comm_size(world,&nprocs);
fprintf(dout, "\n");
for (int i=0;i<TIME_N;++i) {
time = ctime[i];
MPI_Allreduce(&time,&tmp,1,MPI_DOUBLE,MPI_SUM,world);
time = tmp/nprocs;
if (me == 0) {
fprintf(dout, "%s time = %g\n", txt_timer[i], time);
}
}
fprintf(dout, "\n");
}
/* ---------------------------------------------------------------------- */
FixBackbone::~FixBackbone()
{
final_log_output();
if (allocated) {
for (int i=0;i<n;i++) {
delete [] xca[i];
delete [] xcb[i];
delete [] xo[i];
delete [] xn[i];
delete [] xcp[i];
delete [] xh[i];