-
Notifications
You must be signed in to change notification settings - Fork 8
/
probe.c
executable file
·2255 lines (1978 loc) · 84.1 KB
/
probe.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
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
/*
** These routines calculate and print important polypeptide characteristics.
**
** Copyright (c) 2004 - 2010 Alexei Podtelezhnikov
** Copyright (c) 2007 - 2013 Nikolas Burkoff, Csilla Varnai and David Wild
*/
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include"error.h"
#include"params.h"
#include"aadict.h"
#include"vector.h"
#include"rotation.h"
#include"peptide.h"
#include"vdw.h"
#include"energy.h"
#include"metropolis.h"
#include"probe.h"
#include"flex.h"
#ifdef PARALLEL
#include<mpi.h>
#endif
#include"checkpoint_io.h"
#define Distb(I,J) biasmap->distb[(I) * biasmap->NAA + (J)]
/* test registry */
struct TEST {
void (*func) (Chain *chain,Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm);
char *name;
int init_mask;
};
/* number of tests should not exceed the integer bits (32) */
struct TEST test[] = {
{rgyr, "Centroid and radius of gyration (default)", 0x01 }, /* before init */
{pdbout, "Snapshots in PDB format (default)", 0x11 }, /* ((before and)) after init */
{phipsi, "Ramachandran dihedral angles and backbone angle and side chain dihedral angles", 0x10 }, /* before and after init */
{sstructure, "Secondary structure assignment from dihedral angles", 0x10 }, /* after init */
{n_contacts, "Total number of contacts", 0x1 }, /* before init */
{cm_txt, "Text contact map !FOR SIMULATION INPUT GENERATION USE cm_ideal INSTEAD!", 0x1 }, /* before init */
{cm_pbm, "Contact map image in PBM format", 0x1 }, /* before init */
{hbtot, "Total number of hydrogen bonds", 0x1 }, /* before init */
{hpattern, "Local binary H-bonding donor and acceptor patterns", 0x1 }, /* before init */
{hbss, "DSSP-like secondary structure assignment", 0x1 }, /* before init */
{writhe, "Writhe of alpha-carbon trace", 0x1 }, /* before init */
{ergtot, "Total and local energy (default only for NS)", 0x10 }, /* after init */
{stepsize, "Crankshaft amplitude, acceptance rate, other diagnostics", 0x10 }, /* after init */
{energy_gradient_wrt_parameters, "The gradient of the energy with respect to its parameters, calculated by finite differences", 0x10 }, /* only after init */
{n_native_contacts, "Number of native contacts", 0x10 },
{evidence,"log(Evidence) estimate (only NS, default)", 0x11 },
{information,"Information estimate (only NS, default)", 0x11 },
{cm_ideal, "Ideal contact map", 0x11 },
//{cm_ideal_4, "Ideal contact map including i,i+4 alpha contacts", 0x11 },
//{cm_native_go, "Native contact map including all Cbeta-Cbeta contacts (useful for the calculation of the number of native contacts).", 0x01 },
{test_flex,"Test Flex",0x10 }, /* only after init */
{energy_contributions, "Energy contributions of all different terms", 0x10 }, /* only after init */
{exclude_energy_contributions, "Exclude energy of amino acid pairs", 0x10 }, /* only after init */
{cos_dihedral_naac, "cos of N(i)-CA(i)-CA(i+1)-C(i+1) dihedral angle", 0x11 }, /* before and after init */
{strand_bias_distances, "CB-CB and CA-CA distances of beta contacts", 0x11 }, /* before and after init */
{hydrophobic_distances, "CB-CB and CA-CA distances of HH and HP contacts", 0x10 }, /* after init */
{number_of_contacts, "Number of contacts", 0x11 },
{initialize_displacement, "The displacement of atoms and generated clashes during initialization", 0x1 }, /* only before init */
{hydrophobic_rgyr, "Centroid and radius of gyration of only the hydrophobic residues", 0x01 }, /* before init */
{CA_geometry, "Various geometrical parameters using CA atoms (atomic distances, angles, dihedrals)", 0x01 }, /* before init */
{atomic_distances,"List all atomic distances, useful for LJ testing",0x10 },
{hbond_geometry, "All geometrical parameters of Hbonds: d(O,H), <(C,O,H), <(O,H,N)",0x10 },
{vdw_max_gamma, "Calculate vdW max gamma-(non)gamma tables for the given vdW parameters. Use peptide ABCDEFGHIGKLMNGPQRSTGVWGYZ, and do not forget to specify the VDW parameters.",0x10 },
// {vdw_contributions, "Calculate vdW contributions between all atoms.",0x10 },
//{hbond_pattern, "Calculate H-bond pattern.",0x01 },
{checkpoint_out, "Snapshots in CHK format", 0x11 }, /* ((before and)) after init */
// {cm_alpha_8, "Contact map with contacts where d(CA-CA) < 8 Angstroms.", 0x01 },
//{fasta, "Print fasta sequence.", 0x01 },
{NULL, NULL, 0x0 }
};
/* helper buffers */
//char *ss = NULL;
int *hbm = NULL;
//char *map = NULL;
#define Hbm(I,J) hbm[(I) * chain->NAA + (J)]
#define Map(I,J) map[(I) * chain->NAA + (J)]
void evidence(Chain *chain, Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm){
; //see nested.c
}
void information(Chain *chain,Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm){
; //see nested.c
}
void tests(Chain *chain, Biasmap *biasmap, unsigned int t, simulation_params *sim_params, int init_mask, void *mpi_comm)
{
int i;
for (i = 0; test[i].func != NULL && t; i++, t >>= 1)
//do test if its mask is given and if it is meant to be calculated (some are only valid before/after initialization)
if ((t & 0x1) && (init_mask & test[i].init_mask))
(test[i].func) (chain,biasmap,sim_params, mpi_comm);
}
void helps(void)
{
int i;
unsigned int t = 0x1;
fprintf(stderr, "TestMASK Index:\n");
for (i = 0; test[i].func != NULL && t; i++, t <<= 1)
fprintf(stderr, "%8x %s\n", t, test[i].name);
}
void test_flex(Chain *chain, Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm){
if(sim_params->flex_params.number_of_processors > 0){
Chain *input_chains;
double *rmsd;
initialize_flex(chain,&input_chains,biasmap,sim_params,&rmsd);
output_and_run_flex(chain,biasmap,input_chains,sim_params,rmsd);
finalize_flex(chain,&input_chains,sim_params,&rmsd);
}
}
/* various geometrical parameters using CA atoms*/
void CA_geometry(Chain *chain, Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm) {
// for (i=0; i<sim_params->geometry.nbonds; i++) {
// int aa1 = sim_params->geometry.bond1[i];
// int aa2 = sim_params->geometry.bond2[i];
// fprintf(sim_params->outfile,"distance %d %d %g", sqrt(distance(chain->aa[aa1].ca,chain->aa[aa2].ca)));
// }
fprintf(sim_params->outfile,"distance 1 16 %g", sqrt(distance(chain->aa[1].ca,chain->aa[16].ca)));
fprintf(sim_params->outfile,"distance 3 14 %g", sqrt(distance(chain->aa[3].ca,chain->aa[14].ca)));
fprintf(sim_params->outfile,"distance 5 12 %g", sqrt(distance(chain->aa[5].ca,chain->aa[12].ca)));
fprintf(sim_params->outfile,"distance 7 10 %g", sqrt(distance(chain->aa[7].ca,chain->aa[10].ca)));
if (chain->NAA>17) {
fprintf(sim_params->outfile,"distance 18 15 %g", sqrt(distance(chain->aa[18].ca,chain->aa[15].ca)));
fprintf(sim_params->outfile,"distance 20 13 %g", sqrt(distance(chain->aa[20].ca,chain->aa[13].ca)));
fprintf(sim_params->outfile,"distance 22 11 %g", sqrt(distance(chain->aa[22].ca,chain->aa[11].ca)));
fprintf(sim_params->outfile,"distance 24 9 %g", sqrt(distance(chain->aa[24].ca,chain->aa[9].ca)));
}
}
/* various geometrical parameters using CA atoms*/
void vdw_contributions(Chain *chain, Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm) {
model_params *mod_params = &sim_params->protein_model;
//Assign function pointer to the vdW model
double (*vdw_fn) (vector r1, vector r2, double Rmin, double depth, double vdw_rel_cutoff, double energy_shift, double clash_at_vdw_cutoff) = NULL;
if (mod_params->vdw_potential == HARD_CUTOFF_VDW_POTENTIAL) {
vdw_fn = vdw_hard_cutoff;
} else if (mod_params->vdw_potential == LJ_VDW_POTENTIAL) {
vdw_fn = vdw_lj;
} else {
stop("Clash cannot be calculated without a valid vdW potential.");
}
for (int i=1; i<chain->NAA; i++) {
for (int j=i; j<chain->NAA; j++) {
fprintf(sim_params->outfile,"%d %d interactions:",i,j);
AA *a = &(chain->aa[i]);
AA *b = &(chain->aa[j]);
fprintf(sim_params->outfile,"CA_ CA_ %g\n",vdw_fn(a->ca, b->ca, mod_params->rca + mod_params->rca,mod_params->vdw_depth_ca_ca, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_ca, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CA_ CB_ %g\n",vdw_fn(a->ca, b->cb, mod_params->rca + mod_params->rcb,mod_params->vdw_depth_ca_cb, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_cb, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CA_ C__ %g\n",vdw_fn(a->ca, b->c, mod_params->rca + mod_params->rc,mod_params->vdw_depth_ca_c, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_c, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CA_ N__ %g\n",vdw_fn(a->ca, b->n, mod_params->rca + mod_params->rn,mod_params->vdw_depth_ca_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CA_ O__ %g\n",vdw_fn(a->ca, b->o, mod_params->rca + mod_params->ro,mod_params->vdw_depth_ca_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CB_ CA_ %g\n",vdw_fn(a->cb, b->ca, mod_params->rca + mod_params->rca,mod_params->vdw_depth_ca_cb, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_cb, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CB_ CB_ %g\n",vdw_fn(a->cb, b->cb, mod_params->rcb + mod_params->rcb,mod_params->vdw_depth_cb_cb, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_cb, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CB_ C__ %g\n",vdw_fn(a->cb, b->c, mod_params->rcb + mod_params->rc,mod_params->vdw_depth_cb_c, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_c, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CB_ N__ %g\n",vdw_fn(a->cb, b->n, mod_params->rcb + mod_params->rn,mod_params->vdw_depth_cb_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"CB_ O__ %g\n",vdw_fn(a->cb, b->o, mod_params->rcb + mod_params->ro,mod_params->vdw_depth_cb_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"C__ CA_ %g\n",vdw_fn(a->c, b->ca, mod_params->rcb + mod_params->rca,mod_params->vdw_depth_ca_c, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_c, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"C__ CB_ %g\n",vdw_fn(a->c, b->cb, mod_params->rc + mod_params->rcb,mod_params->vdw_depth_cb_c, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_c, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"C__ C__ %g\n",vdw_fn(a->c, b->c, mod_params->rc + mod_params->rc,mod_params->vdw_depth_c_c, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_c_c, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"C__ N__ %g\n",vdw_fn(a->c, b->n, mod_params->rc + mod_params->rn,mod_params->vdw_depth_c_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_c_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"C__ O__ %g\n",vdw_fn(a->c, b->o, mod_params->rc + mod_params->ro,mod_params->vdw_depth_c_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_c_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"N__ CA_ %g\n",vdw_fn(a->n, b->ca, mod_params->rn + mod_params->rca,mod_params->vdw_depth_ca_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"N__ CB_ %g\n",vdw_fn(a->n, b->cb, mod_params->rn + mod_params->rcb,mod_params->vdw_depth_cb_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"N__ C__ %g\n",vdw_fn(a->n, b->c, mod_params->rn + mod_params->rc,mod_params->vdw_depth_c_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_c_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"N__ N__ %g\n",vdw_fn(a->n, b->n, mod_params->rn + mod_params->rn,mod_params->vdw_depth_n_n, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_n_n, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"N__ O__ %g\n",vdw_fn(a->n, b->o, mod_params->rn + mod_params->ro,mod_params->vdw_depth_n_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_n_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"O__ CA_ %g\n",vdw_fn(a->o, b->ca, mod_params->ro + mod_params->rca,mod_params->vdw_depth_ca_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_ca_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"O__ CB_ %g\n",vdw_fn(a->o, b->cb, mod_params->ro + mod_params->rcb,mod_params->vdw_depth_cb_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_cb_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"O__ C__ %g\n",vdw_fn(a->o, b->c, mod_params->ro + mod_params->rc,mod_params->vdw_depth_c_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_c_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"O__ N__ %g\n",vdw_fn(a->o, b->n, mod_params->ro + mod_params->rn,mod_params->vdw_depth_n_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_n_o, mod_params->vdw_clash_energy_at_hard_cutoff));
fprintf(sim_params->outfile,"O__ O__ %g\n",vdw_fn(a->o, b->o, mod_params->ro + mod_params->ro,mod_params->vdw_depth_o_o, mod_params->rel_vdw_cutoff, mod_params->vdw_Eshift_o_o, mod_params->vdw_clash_energy_at_hard_cutoff));
}
}
}
/* the displacement of atoms and generated clashes during initialization */
void initialize_displacement(Chain *chain, Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm) {
Chain chain_init;
chain_init.NAA = 0;
chain_init.aa = NULL; chain_init.xaa = NULL; chain_init.erg = NULL; chain_init.xaa_prev = NULL;
allocmem_chain(&chain_init,chain->NAA,chain->Nchains);
Chaint chaint;
chaint.aat = NULL; chaint.xaat = NULL; chaint.ergt = NULL; chaint.xaat_prev = NULL;
Chain displacements;
displacements.NAA = 0;
displacements.aa = NULL; displacements.xaa = NULL; displacements.erg = NULL; displacements.xaa_prev = NULL;
allocmem_chain(&displacements,chain->NAA,chain->Nchains);
/* calculate initialized distances */
copybetween(&chain_init,chain);
// fprintf(sim_params->outfile,"before init chain_init\n");
chkpeptide(chain_init.aa, chain_init.NAA, &(sim_params->protein_model));
// pdbprint(chain_init.aa, chain_init.NAA, &(sim_params->protein_model), sim_params->outfile, NULL);
//// energy_init(&chain_init,biasmap,&(sim_params->protein_model));
initialize(&chain_init,&chaint,sim_params); // PEPTIDE MODIFICATION!!
//// energy_matrix_init(chain,biasmap,&(sim_params->protein_model));
// fprintf(sim_params->outfile,"after init chain_init\n");
// pdbprint(chain_init.aa, chain_init.NAA, &(sim_params->protein_model), sim_params->outfile, NULL);
double threshold = 0.5;
double dist;
fprintf(stderr,"Listing displacements larger than %g Angstroms (not listing G__ atoms):\n",threshold);
/* calculate displacements of all atoms */
for (int i=1; i<chain_init.NAA; i++) {
if (chain_init.aa[i].etc & CA_) { /* CA_ */
dist = sqrt(distance(chain_init.aa[i].ca, chain->aa[i].ca));
displacements.aa[i].ca[0] = dist;
if (dist > threshold) fprintf(stderr,"Big displacement of %c%d CA_: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
if (chain_init.aa[i].etc & C__) { /* C__ */
dist = sqrt(distance(chain_init.aa[i].c, chain->aa[i].c));
displacements.aa[i].c[0] = dist;
if (dist > threshold) fprintf(stderr,"Big displacement of %c%d C__: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
if (chain_init.aa[i].etc & N__) { /* N_ */
dist = sqrt(distance(chain_init.aa[i].n, chain->aa[i].n));
displacements.aa[i].n[0] = dist;
if (dist > threshold) fprintf(stderr,"Big displacement of %c%d N__: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
if (chain_init.aa[i].etc & O__) { /* O__ */
dist = sqrt(distance(chain_init.aa[i].o, chain->aa[i].o));
displacements.aa[i].o[0] = dist;
if (dist > threshold) fprintf(stderr,"Big displacement of %c%d O__: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
if (chain_init.aa[i].etc & CB_) { /* CB_ */
dist = sqrt(distance(chain_init.aa[i].cb, chain->aa[i].cb));
displacements.aa[i].cb[0] = dist;
if (dist > threshold) {
fprintf(stderr,"Big displacement of %c%d CB_: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
//fprintf(stderr," old %g %g %g and new %g %g %g\n",chain->aa[i].cb[0],chain->aa[i].cb[1],chain->aa[i].cb[2],chain_init.aa[i].cb[0],chain_init.aa[i].cb[1],chain_init.aa[i].cb[2]);
}
}
/* gamma atoms will always move a lot -- don't list them */
if (chain_init.aa[i].etc & G__) { /* G__ */
dist = sqrt(distance(chain_init.aa[i].g, chain->aa[i].g));
displacements.aa[i].g[0] = dist;
// if (dist > threshold) fprintf(stderr,"Big displacement of %c%d G__: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
if (chain_init.aa[i].etc & G2_) { /* G2_ */
dist = sqrt(distance(chain_init.aa[i].g2, chain->aa[i].g2));
displacements.aa[i].g2[0] = dist;
// if (dist > threshold) fprintf(stderr,"Big displacement of %c%d G2_: %g\n",chain_init.aa[i].id,chain_init.aa[i].num,dist);
}
}
int *G_to_delete = malloc(chain_init.NAA * sizeof(int));
int *G2_to_delete = malloc(chain_init.NAA * sizeof(int));
for (int i=0; i<chain_init.NAA; i++) {
G_to_delete[i] = 0;
G2_to_delete[i] = 0;
//fprintf(sim_params->outfile,"%x ",chain_init.aa[i].etc);
}
//fprintf(sim_params->outfile,"\n");
/* calculate exclude energies with and without each gamma atom */
for (int i=1; i<chain_init.NAA; i++) {
/* G__ */
if (chain_init.aa[i].etc & G__) {
/* exclude */
double exclude_with = 0;
for (int j=1; j<chain_init.NAA; j++) {
if (abs(i-j)<2) continue;
exclude_with += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
}
double exclude_without = 0;
chain_init.aa[i].etc &= ~G__;
for (int j=1; j<chain_init.NAA; j++) {
if (abs(i-j)<2) continue;
exclude_without += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
}
chain_init.aa[i].etc |= G__;
if (exclude_with > exclude_without + 5.0) {
// fprintf(stderr,"XXX ");
G_to_delete[i] = 1;
}
// fprintf(stderr,"The clash energy of %c%d with and without G__ atom is %g and %g\n",
// chain_init.aa[i].id, chain_init.aa[i].num,
// exclude_with, exclude_without);
/* clash */
double clash_with = clash(&(chain_init.aa[i]), &(sim_params->protein_model));
chain_init.aa[i].etc &= ~G__;
double clash_without = clash(&(chain_init.aa[i]), &(sim_params->protein_model));
chain_init.aa[i].etc |= G__;
if (clash_with > clash_without + 5.0) {
G_to_delete[i] = 1;
fprintf(stderr,"The clash energy of %c%d with and without G__ atom is %g and %g\n",
chain_init.aa[i].id, chain_init.aa[i].num,
clash_with, clash_without);
}
}
/* G2_ */
if (chain_init.aa[i].etc & G2_) {
/* exclude */
double exclude_with = 0;
for (int j=1; j<chain_init.NAA; j++) {
if (abs(i-j)<2) continue;
exclude_with += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
}
double exclude_without = 0;
chain_init.aa[i].etc &= ~G2_;
for (int j=1; j<chain_init.NAA; j++) {
if (abs(i-j)<2) continue;
exclude_without += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
}
chain_init.aa[i].etc |= G2_;
if (exclude_with > exclude_without + 5.0) {
// fprintf(stderr,"XXX ");
G2_to_delete[i] = 1;
}
// fprintf(stderr,"The clash energy of %c%d with and without G2_ atom is %g and %g\n",
// chain_init.aa[i].id, chain_init.aa[i].num,
// exclude_with, exclude_without);
/* clash */
double clash_with = clash(&(chain_init.aa[i]), &(sim_params->protein_model));
chain_init.aa[i].etc &= ~G2_;
double clash_without = clash(&(chain_init.aa[i]), &(sim_params->protein_model));
chain_init.aa[i].etc |= G2_;
if (clash_with > clash_without + 5.0) {
G_to_delete[i] = 1;
fprintf(stderr,"The clash energy of %c%d with and without G2_ atom is %g and %g\n",
chain_init.aa[i].id, chain_init.aa[i].num,
clash_with, clash_without);
}
}
}
/* remove clashing gamma atoms */
fprintf(sim_params->outfile,"Removed clashing gamma atoms: ");
for (int i=1; i<chain_init.NAA; i++) {
if (G_to_delete[i]) {
fprintf(sim_params->outfile,"%c%d-G ",chain_init.aa[i].id,i);
chain_init.aa[i].etc &= ~G__;
}
if (G2_to_delete[i]) {
fprintf(sim_params->outfile,"%c%d-G2 ",chain_init.aa[i].id,i);
chain_init.aa[i].etc &= ~G2_;
}
//fprintf(sim_params->outfile,"%x ",chain_init.aa[i].etc);
}
fprintf(sim_params->outfile,"\n");
/* check that there are no more clashes */
for (int i=1; i<chain_init.NAA; i++) {
double exclude_all = 0;
for (int j=1; j<chain_init.NAA; j++) {
if (abs(i-j)<2) continue;
exclude_all += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
}
if (exclude_all > 5.0)
fprintf(stderr,"WARNING! The clash energy of %c%dafter removing clashing gamma atoms is %g\n",
chain_init.aa[i].id, chain_init.aa[i].num, exclude_all);
}
/* print PDB */
fprintf(sim_params->outfile,"--+ PDB without clashing gamma atoms +--\n");
fprintf(stderr,"Outputting initialized PDB?\n");
pdbprint(chain_init.aa, chain_init.NAA, &(sim_params->protein_model), sim_params->outfile, NULL);
// /* calculate clashes and print displacements and vdW energy of clashing atoms */
// for (int i=1; i<chain_init.NAA; i++) {
// for (int j=i+1; j<chain_init.NAA; j++) {
// double vdw_energy;
// /* CA_ - CA_ */
// if (j!=i+1){
// vdw_energy = vdw(chain_init.aa[i].ca,chain_init.aa[j].ca,sim_params->protein_model.rca+sim_params->protein_model.rca,sim_params->protein_model.vdw_depth_ca_ca,sim_params->protein_model.rel_vdw_cutoff,sim_params->protein_model.vdw_Eshift_ca_ca)>0.0;
// if (vdw_energy > 0.0) {
// fprintf(stderr,"Clash %c%d CA_ and %c%d CA_ with displacements %g and %g and distance %g and energy %g, \n",
// chain_init.aa[i].id,chain_init.aa[i].num,
// chain_init.aa[j].id,chain_init.aa[j].num,
// displacements.aa[i].ca[0],displacements.aa[j].ca[0],
// sqrt(distance(chain_init.aa[i].ca,chain_init.aa[j].ca)), vdw_energy);
// }
// /* all */
// vdw_energy += exclude(&(chain_init.aa[i]), &(chain_init.aa[j]), 0.0, &(sim_params->protein_model));
// if (vdw_energy > 0.0) {
// fprintf(stderr,"Clash %c%d and %c%d with energy %g, \n",
// chain_init.aa[i].id,chain_init.aa[i].num,
// chain_init.aa[j].id,chain_init.aa[j].num,
// vdw_energy);
// }
// if (vdw_energy > 5.0) {
// fprintf(stderr,"Clash %c%d and %c%d with energy %g",
// chain_init.aa[i].id,chain_init.aa[i].num,
// chain_init.aa[j].id,chain_init.aa[j].num,
// vdw_energy);
// if (chain_init.aa[i].etc & G__) fprintf(stderr,", 1st G__ displacement %g",displacements.aa[i].g[0]);
// if (chain_init.aa[i].etc & G2_) fprintf(stderr,", 1st G2_ displacement %g",displacements.aa[i].g2[0]);
// if (chain_init.aa[j].etc & G__) fprintf(stderr,", 2nd G__ displacement %g",displacements.aa[j].g[0]);
// if (chain_init.aa[j].etc & G2_) fprintf(stderr,", 2nd G2_ displacement %g\n",displacements.aa[j].g2[0]);
// }
// }
// }
// }
//
freemem_chain(&chain_init);
}
void torsion(Chain *chain, Biasmap *biasmap,double *phi, double *psi, int i)
{
vector nca, cac; /* N-Ca and Ca-C bonds */
subtract(nca, chain->aa[i].ca, chain->aa[i].n);
subtract(cac, chain->aa[i].c, chain->aa[i].ca);
if (chain->aa[i].chainid != chain->aa[i-1].chainid) {
*phi = M_180_PI * dihedral(chain->xaa_prev[chain->aa[i].chainid][1], nca, cac);
} else {
*phi = M_180_PI * dihedral(chain->xaa[i - 1][1], nca, cac);
}
*psi = M_180_PI * dihedral(nca, cac, chain->xaa[i][1]);
}
void all_torsions(Chain *chain,Biasmap *biasmap, double *phi, double *psi, double *chi1, double *chi2, int i)
{
vector nca, cacb, cbg, cbg2; /* N-Ca, Ca-Cb, Cb-G, Cb-G2 bonds */
vector cbca;
double NaN;
NaN = strtod("NaN", NULL);
/* phi, psi */
torsion(chain,biasmap,phi, psi, i);
/* chi1, chi2 */
*chi1 = NaN;
*chi2 = NaN;
if ( chain->aa[i].etc & G__ ) { /* at least one gamma atom */
subtract(nca, chain->aa[i].ca, chain->aa[i].n);
subtract(cacb, chain->aa[i].cb, chain->aa[i].ca);
subtract(cbca, chain->aa[i].ca, chain->aa[i].cb);
subtract(cbg, chain->aa[i].g, chain->aa[i].cb);
*chi1 = M_180_PI * dihedral(nca,cacb,cbg);
if ( chain->aa[i].etc & G2_ ) { /* two gamma atoms */
subtract(cbg2, chain->aa[i].g2, chain->aa[i].cb);
*chi2 = M_180_PI * dihedral(nca,cacb,cbg2);
}
} else { /* first gamma atom is not present */
if ( chain->aa[i].etc & G2_ ) { /* only second gamma atoms */
fprintf(stderr,"WARNING: amino acid %c%d has the second gamma atom, but not the first one!",chain->aa[i].id,i);
subtract(cbg2, chain->aa[i].g2, chain->aa[i].cb);
*chi2 = M_180_PI * dihedral(nca,cacb,cbg2);
}
}
}
void sstructure(Chain *chain,Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm)
{
int i, ch;
double phi, psi;
for (i = 1; i < chain->NAA; i++) {
torsion(chain,biasmap,&phi, &psi, i);
if (!(0. < phi && phi < 120.) && (-120. < psi && psi < 60.))
ch = 'H';
else
ch = 'C';
fputc(ch,sim_params->outfile);
}
fputc('\n',sim_params->outfile);
}
/* the N(i)-CA(i)-CA(i+1)-C(i+1) dihedral angles which constraints psi(i)+phi(i+1) together via the bias eta parameters (to determine their distributions) */
void cos_dihedral_naac(Chain *chain,Biasmap *biasmap, simulation_params *sim_params, void *mpi_comm)
{
//TODO invalidate at chain breaks
int i, ch;
for (i = 1; i < chain->NAA-1; i++) {
if (Distb(i, i) > 0. && Distb(i+1, i+1) > 0.){ /* alpha helix */
ch = 'H';
} else if (Distb(i, i) < 0. && Distb(i+1, i+1) < 0.){ /* beta strand */
ch = 'E';
} else {
ch = 'C';
}
// naac dihedral angle's cosine
vector x, y, z;
subtract(x, chain->aa[i].ca, chain->aa[i].n);
subtract(y, chain->aa[i+1].ca, chain->aa[i].ca);
subtract(z, chain->aa[i+1].c, chain->aa[i+1].ca);
fprintf(sim_params->outfile,"%c %g\n", ch, -cosdihedral(x, y, z));
}
}
/* number of contacts between two amino acids */
void n_cont_aa( AA a, AA b, int *n_i_bb, int *n_i_sch, int *n_j_bb, int *n_j_sch, simulation_params *sim_params, int print_distances, int filter_out_14, int hbond_contact)
{
/* exclude all 1-4 interactions */
/* exclude interactions due to hydrogen bonding proximity */
if (hbond_contact) return;
*n_i_bb = 0;
*n_i_sch = 0;
*n_j_bb = 0;
*n_j_sch = 0;
//directed sequence distance, if on the same chain
int seqdist;
if (a.chainid != b.chainid)
seqdist = 1000 * abs(b.chainid - a.chainid);
else
seqdist = b.num - a.num;
char label1[4];
char label2[4];
if (a.etc & CA_) {
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--CA_ %g\n",sqrt(distance(a.ca,b.ca)));
*n_i_bb += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--N__ %g\n",sqrt(distance(a.ca,b.n)));
*n_i_bb += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--C__ %g\n",sqrt(distance(a.ca,b.c)));
*n_i_bb += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--O_ %g\n",sqrt(distance(a.ca,b.o)));
*n_i_bb += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--CB_ %g\n",sqrt(distance(a.ca,b.cb)));
*n_i_bb += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist CA_--%3s_ %g\n",label1,sqrt(distance(a.ca,b.g)));
}
*n_i_bb += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.ca,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist CA_--CB_ %g\n",sqrt(distance(a.ca,b.g2)));
*n_i_bb += 1;
*n_j_sch += 1;
}
}
}
/*a->N*/
if (a.etc & N__) {
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--CA_ %g\n",sqrt(distance(a.n,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--N__ %g\n",sqrt(distance(a.n,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--C__ %g\n",sqrt(distance(a.n,b.c)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--O__ %g\n",sqrt(distance(a.n,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.n,b.cb));
if (sim_params->protein_model.touch2 > distance(a.n,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--CB_ %g\n",sqrt(distance(a.n,b.cb)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist N__--%3s_ %g\n",label1,sqrt(distance(a.n,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.n,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist N__--CB_ %g\n",sqrt(distance(a.n,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}
/*a->C*/
if (a.etc & C__) {
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--CA_ %g\n",sqrt(distance(a.c,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--N__ %g\n",sqrt(distance(a.c,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--C__ %g\n",sqrt(distance(a.c,b.c)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--O__ %g\n",sqrt(distance(a.c,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.c,b.cb));
if (sim_params->protein_model.touch2 > distance(a.c,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--CB_ %g\n",sqrt(distance(a.c,b.cb)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist C__--%3s_ %g\n",label1,sqrt(distance(a.c,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.c,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist C__--G2_ %g\n",sqrt(distance(a.c,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}
/*a->O*/
if (a.etc & O__) {
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.o,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist O__--CA_ %g\n",sqrt(distance(a.o,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.o,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist O__--N__ %g\n",sqrt(distance(a.o,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.o,b.c)) {
if (print_distances) {
if ((b.num-a.num)==1) {
fprintf(sim_params->outfile,"dist O__--C__ %g Y\n",sqrt(distance(a.o,b.c)));
} else {
fprintf(sim_params->outfile,"dist O__--C__ %g\n",sqrt(distance(a.o,b.c)));
}
}
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.o,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist O__--O__ %g\n",sqrt(distance(a.o,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.o,b.cb));
if (sim_params->protein_model.touch2 > distance(a.o,b.cb)) {
if (print_distances) {
if ((b.num-a.num)==1) {
fprintf(sim_params->outfile,"dist O__--CB_ %g X\n",sqrt(distance(a.o,b.cb)));
} else {
fprintf(sim_params->outfile,"dist O__--CB_ %g\n",sqrt(distance(a.o,b.cb)));
}
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__) {
if (sim_params->protein_model.touch2 > distance(a.o,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist O__--%3s_ %g\n",label1,sqrt(distance(a.o,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_) {
if (sim_params->protein_model.touch2 > distance(a.o,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist O__--CB_ %g\n",sqrt(distance(a.o,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}
/*a->CB*/
if (a.etc & CB_) {
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CA_ %g\n",sqrt(distance(a.cb,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && seqdist!=1 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--N__ %g\n",sqrt(distance(a.cb,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--C__ %g\n",sqrt(distance(a.cb,b.c)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--O__ %g\n",sqrt(distance(a.cb,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.cb,b.cb));
if (sim_params->protein_model.touch2 > distance(a.cb,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CB_ %g\n",sqrt(distance(a.cb,b.cb)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist CB_--%3s_ %g\n",label1,sqrt(distance(a.cb,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.cb,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CB_ %g\n",sqrt(distance(a.cb,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}
/*a->G*/
if (a.etc & G__) {
if (print_distances) {
if (a.id=='C') {
sprintf(label1,"S__");
} else if (a.id=='S' || a.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
}
if (b.etc & CA_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--CA_ %g\n",label1,sqrt(distance(a.g,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--N__ %g\n",label1,sqrt(distance(a.g,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--C__ %g\n",label1,sqrt(distance(a.g,b.c)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) { //we've already included it once
if (sim_params->protein_model.touch2 > distance(a.g,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--O__ %g\n",label1,sqrt(distance(a.g,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.g,b.cb));
if (sim_params->protein_model.touch2 > distance(a.g,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--CB_ %g\n",label1,sqrt(distance(a.g,b.cb)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label2,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label2,"O__");
} else {
sprintf(label2,"CB_");
}
fprintf(sim_params->outfile,"dist %3s--%3s_ %g\n",label1,label2,sqrt(distance(a.cb,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist %3s--G2_ %g\n",label1,sqrt(distance(a.g,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}
/*a->G2*/
if (a.etc & G2_) {
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g2,b.ca)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CA_ %g\n",sqrt(distance(a.g2,b.ca)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & N__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g2,b.n)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--N__ %g\n",sqrt(distance(a.g2,b.n)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & C__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g2,b.c)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--C__ %g\n",sqrt(distance(a.g2,b.c)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & O__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) { //we've already included it once
if (sim_params->protein_model.touch2 > distance(a.g2,b.o)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--O__ %g\n",sqrt(distance(a.g2,b.o)));
*n_i_sch += 1;
*n_j_bb += 1;
}
}
if (b.etc & CB_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
// fprintf(stderr,"comparing %g > %g ?\n",sim_params->protein_model.touch2,distance(a.g2,b.cb));
if (sim_params->protein_model.touch2 > distance(a.g2,b.cb)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CB_ %g\n",sqrt(distance(a.g2,b.cb)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G__ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g2,b.g)) {
if (print_distances) {
if (b.id=='C') {
sprintf(label1,"S__");
} else if (b.id=='S' || b.id=='T') {
sprintf(label1,"O__");
} else {
sprintf(label1,"CB_");
}
fprintf(sim_params->outfile,"dist CB_--%3s_ %g\n",label1,sqrt(distance(a.g2,b.g)));
}
*n_i_sch += 1;
*n_j_sch += 1;
}
}
if (b.etc & G2_ && ( !filter_out_14 || (filter_out_14 && a.num!=b.num) )) {
if (sim_params->protein_model.touch2 > distance(a.g2,b.g2)) {
if (print_distances) fprintf(sim_params->outfile,"dist CB_--CB_ %g\n",sqrt(distance(a.g2,b.g2)));
*n_i_sch += 1;
*n_j_sch += 1;
}
}
}