-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKINCSBS.c
3350 lines (3120 loc) · 126 KB
/
PKINCSBS.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
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/* PKINCSBS.c */
#include "PKIN.h"
#include "PKINDLOG.h"
#include "PKINCRTL.h" /*070829 for LGFPchromophore*/
typedef struct resatomstruct {
char subc[3];
char resc[5];
char numc[6];
char rinsc[3];
char atomc[7];
}resatomstruct;
static struct resatomstruct* resatomptr;
static struct resatomstruct* resAtomOLDptr;
static struct resatomstruct* resAtomNEWptr;
/*prototypes used entirely within this source file*/
void writesctoscratch(int,char*);
void tesselatescrings(char*);
struct resatomstruct* allocresatomstruct(void); /*061202*/
void decoderesatom(resatomstruct*, char sub[3],char res[4],int num,char rins[2],char atom[6]); /*061202*/
/****distan()****************************************************************/
float distan(double xa,double ya,double za,double x1,double y1,double z1)
{
double x2,y2,z2;
float freturn;
x2 = ( xa - x1 )*( xa - x1 );
y2 = ( ya - y1 )*( ya - y1 );
z2 = ( za - z1 )*( za - z1 );
freturn = (float)sqrt( x2 + y2 + z2 );
return(freturn);
}
/*__distan()________________________________________________________________*/
/****distanfa4()***************************************************************/
float distanfa4(float xyza[4], float xyz1[4])
{
double xa=0,ya=0,za=0,x1=0,y1=0,z1=0,x2=0,y2=0,z2=0;
float freturn;
xa = (double)xyza[1];
ya = (double)xyza[2];
za = (double)xyza[3];
x1 = (double)xyz1[1];
y1 = (double)xyz1[2];
z1 = (double)xyz1[3];
x2 = ( xa - x1 )*( xa - x1 );
y2 = ( ya - y1 )*( ya - y1 );
z2 = ( za - z1 )*( za - z1 );
freturn = (float)sqrt( x2 + y2 + z2 );
return(freturn);
}
/*__distanfa4()_______________________________________________________________*/
/****uctolctexts()***********************************************************/
void uctolctexts(char texts[256])
{
int j,k,match;
static char uc[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static char lc[] = " abcdefghijklmnopqrstuvwxyz";
/*converts upper case alphabetic char to lower case */
for(k=0 ; k<80 ; k++) /*test everything for alphabetic character */
{
match = 0;
for(j=1 ; j<= 26 ; j++)
{
if(texts[k] == uc[j])
{
texts[k] = lc[j];
match = 1;
}
if(match==1) break;
}
}
return;
}
/*__uctolctexts()___________________________________________________________*/
/****lctouc()****************************************************************/
char lctouc(char charic)
{
int j,match;
static char uc[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static char lc[] = " abcdefghijklmnopqrstuvwxyz";
/*converts lower case alphabetic char to upper case */
match = 0;
for(j=1 ; j<= 26 ; j++)
{
if(charic == lc[j])
{
charic = uc[j];
match = 1;
}
if(match==1) break;
}
return(charic);
}
/*__lctouc()________________________________________________________________*/
/****uctolc()****************************************************************/
char uctolc(char charic)
{
int j,match;
static char uc[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static char lc[] = " abcdefghijklmnopqrstuvwxyz";
/*converts upper case alphabetic char to lower case */
match = 0;
for(j=1 ; j<= 26 ; j++)
{
if(charic == uc[j])
{
charic = lc[j];
match = 1;
}
if(match==1) break;
}
return(charic);
}
/*__uctolc()________________________________________________________________*/
/****allocresatomstruct()*****************************************************/
struct resatomstruct* allocresatomstruct(void)
{
struct resatomstruct* thereturnptr = NULL;
thereturnptr = (resatomstruct*)malloc(sizeof(resatomstruct));
if(thereturnptr != NULL)
{
thereturnptr->subc[0] = ' ';
thereturnptr->subc[1] = '\0';
thereturnptr->resc[0] = ' ';
thereturnptr->resc[1] = ' ';
thereturnptr->resc[2] = ' ';
thereturnptr->resc[3] = '\0';
thereturnptr->numc[0] = ' ';
thereturnptr->numc[1] = ' ';
thereturnptr->numc[2] = ' ';
thereturnptr->numc[3] = ' ';
thereturnptr->numc[4] = '\0';
thereturnptr->rinsc[0] = ' ';
thereturnptr->rinsc[1] = '\0';
thereturnptr->atomc[0] = ' ';
thereturnptr->atomc[1] = ' ';
thereturnptr->atomc[2] = ' ';
thereturnptr->atomc[3] = ' ';
thereturnptr->atomc[4] = ' ';
thereturnptr->atomc[5] = '\0';
}
return(thereturnptr);
}
/*___allocresatomstruct()____________________________________________________*/
/****decoderesatom()**********************************************************/
void decoderesatom(resatomstruct* resatomptr, char sub[3],char res[4],int num,char rins[2],char atom[6]) /*061202*/ /*071222*/
{
int j=0;
if(resatomptr != NULL)
{
/*convert to 2char subunit==chainID 071222*/
if( (sub[0] == '\0' || sub[0] == ' ')
&&(sub[1] == '\0' || sub[1] == ' ') )
{
resatomptr->subc[0] = ' ';
resatomptr->subc[1] = '_';
resatomptr->subc[2] = '\0';
}
else
{
resatomptr->subc[0] = lctouc(sub[0]);
resatomptr->subc[1] = lctouc(sub[1]);
resatomptr->subc[2] = '\0';
}
sprintf(resatomptr->resc,"%s",res);
for(j=0; j<3; j++){if(resatomptr->resc[j] == ' '){resatomptr->resc[j] = '_';}
else{resatomptr->resc[j] = lctouc(resatomptr->resc[j]);} }
resatomptr->resc[3] = '\0';
sprintf(resatomptr->numc,"%4d",num);
for(j=0; j<4; j++){if(resatomptr->numc[j] ==' '){resatomptr->numc[j] ='_';} }
resatomptr->numc[4] = '\0';
if(rins[0] == '\0' || rins[0] == ' ')
{resatomptr->rinsc[0] = '_'; resatomptr->rinsc[1] = '\0';}
else {resatomptr->rinsc[0] = lctouc(rins[0]); resatomptr->rinsc[1] = '\0';}
sprintf(resatomptr->atomc,"%s",atom);
for(j=0; j<5; j++) {if(resatomptr->atomc[j] ==' '){resatomptr->atomc[j] ='_';}
else{resatomptr->atomc[j] = lctouc(resatomptr->atomc[j]);} }
resatomptr->atomc[5] = '\0';
}
}
/*___decoderesatom()_________________________________________________________*/
/*connect current residue back to previous residue*/
/****oldcon()****************************************************************/
void oldcon(int jatom, float setdst, int ica)
{
int didit,noldat,k,ny;
float dist = -1; /*negative if not calculated*/
char YN[2][2]={ {'X','\0'},{'-','\0'},};
char subc[2],resc[4],numc[5],rinsc[2],atomc[6];
int j=0;
int Lstderr = 0;
int jconn = 0; /*atom for which base[jconn] = noldat*/
static int Lneedconnectheader=1; /*need header even when first residue wierd*/
/* set offset for mainchain or ca-ca connection */
k = 0; /*mainchain*/
if( ica != 0 ) {k = 4;} /*ca-ca*/
base[jatom] = jatom; /*default to a dot */
discon = TRUE; /* default discon...nected flag */
/*--check to see if alternate conf flags set */
/*--atom[jatom][4] holds the alt conf character for atom jatom*/
jconn = jatom; /*default*/
if(atom[jatom][4] == ' ')
{
if(oldatm[ica])
{
noldat = lastat - k;
dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst && icountres[level] > 0) /*061202*/
{
base[jatom] = noldat;
jconn = jatom;
}
/*limited logic: connect ' ' with ' ', ... or */
}
else if(oldata[ica] && !altcfa[ica])
{
noldat = lastat - k - 1;
dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
/*--connect ' ' to 'b' only if this residue doesn't have 'b' conf */
if(oldatb[ica] && !altcfb[ica])
{
noldat = lastat - k - 2;
/*--create extra atom, connect it to 'b', then ...*/
/*.*/ didit = creatm(natom);
if(didit)
{
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[maxatm] = noldat;
jconn = maxatm;
}
}
}
if(oldatc[ica] && !altcfc[ica])
{
noldat = lastat - k - 3;
/*--create extra atom, connect it to 'c', then ...*/
/*.*/ didit = creatm(natom);
if(didit)
{
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[maxatm] = noldat;
jconn = maxatm;
}
}
}
}
else if(atom[jatom][4] == 'a')
{
if(oldata[ica])
{
noldat = lastat - k - 1;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
else if(oldatm[ica])
{
/*-- use lastat unless previous mainchain had an alt conf */
noldat = lastat - k;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
}
else if(atom[jatom][4] == 'b')
{
if(oldatb[ica])
{
noldat = lastat - k - 2;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
else if(oldatm[ica])
{
/*-- use lastat unless previous mainchain had an alt conf */
noldat = lastat - k;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
}
else if(atom[jatom][4] == 'c')
{
if(oldatc[ica])
{
noldat = lastat - k - 3;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
else if(oldatm[ica])
{
/*-- use lastat unless previous mainchain had an alt conf */
noldat = lastat - k;
/*.*/ dist = (float)distan(x[jatom],y[jatom],z[jatom]
,x[noldat],y[noldat],z[noldat]);
if(dist <= setdst)
{
base[jatom] = noldat;
jconn = jatom;
}
}
}
/*--defaults had been set so: base(jatom) = jatom & discon = TRUE */
if(base[jatom] != jatom) discon = FALSE;
/*--i.e., something got connected! */
if(Lconnectresiduesdump) /* 061202 in oldcon() */
{/*Lconnectresiduesdump*/
if(icountres[level] == 0 || Lneedconnectheader)
{
if(level == 1) /*header for dump...*/
{
if(Lstderr)
{
fprintf(stderr,"typechainfirstpass[level]== %c\n",typechainfirstpass[level]);
fprintf(stderr,"dump:%s: connect distance <= %.3f\n"
,NameStr,setdst);
}
sprintf(temps,"dump:%s: connect distance <= %.3f:"EOLO
,NameStr,setdst);
putonetextblockline(&mainscratch,temps);
Lneedconnectheader = 0;
}
if(resAtomNEWptr == NULL) {resAtomNEWptr = allocresatomstruct();}
if(resAtomNEWptr != NULL)
{
decoderesatom(resAtomNEWptr,sub[jconn],res[jconn],num[jconn],rins[jconn],atom[jconn]);
if(Lstderr)
{
fprintf(stderr,"%2d # %5d back :%s:%s:%s%s:%s:<E-:\n"
,level,icountres[level]
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
}
sprintf(temps,"dump:%s:%s:%s%s:%s:<E-:"EOLO
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
putonetextblockline(&mainscratch,temps);
}
}
else
{/*in chain...*/
if(dist >= 0)
{/*distance was calculated, so noldat exists for this residue and atom*/
if(base[jconn] == noldat) {ny = 1;} else {ny = 0;}
if(resAtomOLDptr == NULL) {resAtomOLDptr = allocresatomstruct();}
if(resAtomOLDptr != NULL)
{
decoderesatom(resAtomOLDptr,sub[noldat],res[noldat],num[noldat],rins[noldat],atom[noldat]);
}
if(resAtomNEWptr == NULL) {resAtomNEWptr = allocresatomstruct();}
if(resAtomNEWptr != NULL)
{
decoderesatom(resAtomNEWptr,sub[jconn],res[jconn],num[jconn],rins[jconn],atom[jconn]);
}
if(resAtomNEWptr != NULL && resAtomOLDptr != NULL )
{
if(Lstderr)
{
fprintf(stderr,"%2d # %5d fore :%s:%s:%s%s:%s:-%s>:%.3f"
,level, icountres[level]-1
,resAtomOLDptr->subc,resAtomOLDptr->resc,resAtomOLDptr->numc
,resAtomOLDptr->rinsc,resAtomOLDptr->atomc
,YN[ny],dist
);
fprintf(stderr, ":%s:%s:%s%s:%s:\n\n"
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
fprintf(stderr,"%2d # %5d back :%s:%s:%s%s:%s:<%s-:%.3f"
,level, icountres[level]
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
,YN[ny],dist
);
fprintf(stderr, ":%s:%s:%s%s:%s:\n"
,resAtomOLDptr->subc,resAtomOLDptr->resc,resAtomOLDptr->numc
,resAtomOLDptr->rinsc,resAtomOLDptr->atomc
);
}
sprintf(temps,"dump:%s:%s:%s%s:%s:-%s>:%.3f:%s:%s:%s%s:%s:"EOLO
,resAtomOLDptr->subc,resAtomOLDptr->resc,resAtomOLDptr->numc
,resAtomOLDptr->rinsc,resAtomOLDptr->atomc
,YN[ny],dist
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
putonetextblockline(&mainscratch,temps);
sprintf(temps,"dump:%s:%s:%s%s:%s:<%s-:%.3f:%s:%s:%s%s:%s:"EOLO
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
,YN[ny],dist
,resAtomOLDptr->subc,resAtomOLDptr->resc,resAtomOLDptr->numc
,resAtomOLDptr->rinsc,resAtomOLDptr->atomc
);
putonetextblockline(&mainscratch,temps);
}
}/*distance was calculated, so noldat exists for this residue*/
else
{/*nothing known about connecting this residue*/
if(resAtomNEWptr == NULL) {resAtomNEWptr = allocresatomstruct();}
if(resAtomNEWptr != NULL)
{
decoderesatom(resAtomNEWptr,sub[jconn],res[jconn],num[jconn],rins[jconn],atom[jconn]);
if(Lstderr)
{
fprintf(stderr, "%2d # %5d fore "
":_:___:_____:_____:-X>:_:%s:%s:%s%s:%s:\n\n"
,level, icountres[level]-1
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
fprintf(stderr,"%2d # %5d back :%s:%s:%s%s:%s:<X-:\n"
,level, icountres[level]
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
}
sprintf(temps, "dump:_:___:_____:_____:-X>:_:%s:%s:%s%s:%s:"EOLO
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
putonetextblockline(&mainscratch,temps);
sprintf(temps,"dump:%s:%s:%s%s:%s:<X-:"EOLO
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc,resAtomNEWptr->atomc
);
putonetextblockline(&mainscratch,temps);
}
}/*nothing known about connecting this residue*/
if(endchn)
{
if(resAtomNEWptr == NULL) {resAtomNEWptr = allocresatomstruct();}
if(resAtomNEWptr != NULL)
{
decoderesatom(resAtomNEWptr,sub[jconn],res[jconn],num[jconn],rins[jconn],atom[jconn]);
if(Lstderr)
{
fprintf(stderr,"%2d # %5d fore :%s:%s:%s%s:_____:-E>:\n\n"
,level,icountres[level]
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc
);
}
sprintf(temps,"dump:%s:%s:%s%s:_____:-E>:"EOLO
,resAtomNEWptr->subc,resAtomNEWptr->resc,resAtomNEWptr->numc
,resAtomNEWptr->rinsc
);
putonetextblockline(&mainscratch,temps);
}
}
}/*in chain...*/
}/*Lconnectresiduesdump*/
return;
}
/*__oldcon()________________________________________________________________*/
/****tacker()****************************************************************/
void tacker(int nput,int nget)
{
int j;
x[nput] = x[nget];
y[nput] = y[nget];
z[nput] = z[nget];
o[nput] = o[nget];
B[nput] = B[nget];
Uval[nput] = Uval[nget];
strcpy(Anum[nput],Anum[nget]); /*hybrid36 071001 ncnt[nput] = ncnt[nget] */
num[nput] = num[nget];
for(j=0; j<= 5; j++){atom[nput][j] = atom[nget][j];}
for(j=0; j<= 3; j++){res[nput][j] = res[nget][j];}
for(j=0; j<= 6; j++){name[nput][j] = name[nget][j];}
for(j=0; j<= 2; j++){sub[nput][j] = sub[nget][j];} /*2char 071222*/
for(j=0; j<= 1; j++){rins[nput][j] = rins[nget][j];}
for(j=0; j<= 2; j++){element[nput][j] = element[nget][j];} /*070520*/
for(j=0; j< MAXmodchr; j++){mod[nput][j] = mod[nget][j];}
/*residue's atom records inc mod[][MAXmodchr] for nmrmodel number str 0-99 */
for(j=0; j< MAXaspectchars+3; j++){aspectstr[nput][j] = aspectstr[nget][j];}
atstyle[nput] = atstyle[nget]; /*030920*/
return;
}
/*__tacker()________________________________________________________________*/
/****muttacker()*************************************************************/
void muttacker(int nput,int nget)
{
int j;
mutx[nput] = mutx[nget];
muty[nput] = muty[nget];
mutz[nput] = mutz[nget];
strcpy(mutAnum[nput],mutAnum[nget]); /*071001 mutncnt[nput] = mutncnt[nget] */
mutnum[nput] = mutnum[nget];
for(j=0; j<= 5; j++){mutatom[nput][j] = mutatom[nget][j];}
for(j=0; j<= 3; j++){mutres[nput][j] = mutres[nget][j];}
for(j=0; j<= 6; j++){mutname[nput][j] = mutname[nget][j];}
for(j=0; j<= 2; j++){mutsub[nput][j] = mutsub[nget][j];} /*2char 071222*/
for(j=0; j<= 1; j++){mutrins[nput][j] = mutrins[nget][j];}
for(j=0; j< MAXmodchr; j++){mutmod[nput][j] = mutmod[nget][j];}
return;
}
/*__muttacker()_____________________________________________________________*/
/****sstapler()**************************************************************/
void sstapler(int nput,int nget)
{
int j;
ssx[nput] = x[nget];
ssy[nput] = y[nget];
ssz[nput] = z[nget];
strcpy(ssAnum[nput],ssAnum[nget]); /* 071001 ssncnt[nput] = ssncnt[nget] */
ssnum[nput] = num[nget];
for(j=0; j<= 5; j++){ssatom[nput][j] = atom[nget][j];}
for(j=0; j<= 3; j++){ssres[nput][j] = res[nget][j];}
for(j=0; j<= 6; j++){ssname[nput][j] = name[nget][j];}
for(j=0; j<= 2; j++){sssub[nput][j] = sub[nget][j];} /*2char 071222*/
for(j=0; j<= 1; j++){ssrins[nput][j] = rins[nget][j];}
for(j=0; j< MAXmodchr; j++){ssmod[nput][j] = mod[nget][j];}
for(j=0; j< MAXaspectchars+3; j++){ssaspectstr[nput][j]=aspectstr[nget][j];}
/*also store Bvalue...*/
if(Ncolorscalebasis==3)
ssBval[nput] = Uval[nget]; /*Unusual field in PDB format: col 67...72*/
else if(Ncolorscalebasis==2)
ssBval[nput] = o[nget]; /*occupancy factor, or PDB field: col 55...60*/
else
ssBval[nput] = B[nget]; /*temperature factor in PDB field: col 61...66*/
return;
}
/*__sstapler()______________________________________________________________*/
/****creatm()****************************************************************/
int creatm(int j)
{
int didit;
/*--make sure there is room in the atom array for another vector */
if(maxatm+1 >= lastat-8)
{
/*--no more room*/
/*c*/ sprintf(temps,"array exceeded, atom not duplicated: "
"%s %s %d %f %f %f"CRLF
,atom[j],res[j],num[j],x[j],y[j],z[j]);
pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/
adjusttext(1); /*PKMCTEXT.C PKPCTEXT.C*/
didit = 0;
/*c*/ sprintf(alertstr,"array exceeded, atom not duplicated: "
CRLF"%s %s %d %f %f %f"
,atom[j],res[j],num[j],x[j],y[j],z[j]);
/*Ms*/ DoReportDialog();
}
else
{
maxatm = maxatm + 1;
/*.*/ tacker(maxatm,j);
/*-- nput nget */
didit = TRUE;
}
return(didit);
}
/*___creatm()_______________________________________________________________*/
/****mutadder()****************************************************************/
void mutadder(int nput,int nget)
{
int j;
/*coords, atom name, residue name, atom number get replaced*/
x[nput] = mutx[nget];
y[nput] = muty[nget];
z[nput] = mutz[nget];
o[nput] = 1.0; /*occupancy artifcially set*/
B[nput] = (float)99.99; /*Temperature parameter artifcially set*/
strcpy(Anum[nput],mutAnum[nget]); /*hybrid36 071001 ncnt[nput]=mutncnt[nget]*/
for(j=0 ; j<= 5 ; j++) atom[nput][j] = mutatom[nget][j];
for(j=0 ; j<= 3 ; j++) res[nput][j] = mutres[nget][j];
/*record name, residue number, subunit indicator, insertion indicator kept*/
for(j=0 ; j<= 6 ; j++) name[nput][j] = name[maxatm][j];
for(j=0 ; j<= 2 ; j++) sub[nput][j] = sub[maxatm][j]; /*2char 071222*/
num[nput] = num[maxatm];
for(j=0 ; j<= 1 ; j++) rins[nput][j] = rins[maxatm][j];
for(j=0 ; j< MAXmodchr ; j++) mod[nput][j] = mod[maxatm][j];
/*nmr model # */
for(j=0 ; j< MAXaspectchars+3 ; j++) aspectstr[nput][j] = aspectstr[nget][j];
for(j=0 ; j<= 2 ; j++) element[nput][j] = mutelement[nget][j]; /*071222*/
return;
}
/*name[n],Anum[n],atom[n],res[n],sub[n],&num[n],rins[n],&x[n],&y[n],&z[n]*/
/*
atom 2 ca arg a 1 25.497 26.862 -1.573 1.00 17.63 4pti 90
*/
/*__mutadder()________________________________________________________________*/
/****screenatompair()********************************************************/
int screenatompair(int j)
{
int itype;
itype = 1; /*presume ok then test for exceptions */
/* any pair in this direction will show up in the other direction */
/* so can safely not connect in a particular direction */
if( atom[natom][1] == 'c' && atom[natom][2] == 'a'
&& atom[j][1] == 'c' && atom[j][2] == 'b') itype = 0;
/*don't base ca on cb */
if( atom[natom][1] == 'c' && atom[natom][2] == ' '
&& atom[j][1] == 'o' && atom[j][2] == ' ') itype = 0;
/*don't base c on o */
if( atom[natom][1] == 'c' && atom[natom][2] == 'a'
&& atom[j][1] == 'c' && atom[j][2] == ' ') itype = 0;
/*don't base ca on c */
if( atom[natom][1] == 'n' && atom[natom][2] == ' '
&& atom[j][1] == 'c' && atom[j][2] == 'a') itype = 0;
/*don't base n on ca */
if( atom[natom][2] == 'b' && atom[j][2] == 'g') itype = 0;
/*don't base _b on _g */
if( atom[natom][2] == 'g' && atom[j][2] == 'd') itype = 0;
/*don't base _g on _d */
if( atom[natom][2] == 'd' && atom[j][2] == 'e') itype = 0;
/*don't base _d on _e */
if( atom[natom][2] == 'e' && atom[j][2] == 'z') itype = 0;
/*don't base _e on _z */
if( atom[natom][2] == 'z' && atom[j][2] == 'h') itype = 0;
/*don't base _z on _h */
if( atom[natom][2] == 'a' && atom[j][2] == 'e') itype = 0;
/*don't base _a on _e proline with ne at position of n*/
if( atom[natom][2] == 'e' && atom[j][2] == 'a') itype = 0;
/*don't base _e on _a proline with ne at position of n*/
return(itype);
}
/*___screenatompair()_______________________________________________________*/
/****screenhetpairs()********************************************************/
int screenhetpairs(int j)
{
int itype,k;
itype = 1; /*presume ok then test for exceptions */
/* any pair in this direction will show up in the other direction */
/* so can safely not connect in a particular direction */
/*Question being asked is j atom a base for natom atom?*/
/* Is natom connected to j anywhere else? */
/* for (1 -> maxatom) = k */
/* look for other instances of j which may have been connected to natom */
/* if( atom[k] == atom[j] */
/* does base[natom] == k ? */
/* does base[k] == natom ? */
for( k=1 ; k <= maxatm ; k++ )
{
if( atom[k][0] == atom[j][0] &&
atom[k][1] == atom[j][1] &&
atom[k][2] == atom[j][2] &&
atom[k][3] == atom[j][3] &&
atom[k][4] == atom[j][4] )
{
if(base[natom] == k) itype = 0;
if(base[k] == natom) itype = 0;
}
}
return(itype);
}
/*___screenhetpairs()_______________________________________________________*/
/****decidemainside()********************************************************/
int decidemainside(int j)
{
int Lncacos;
Lncacos = FALSE;
if( atom[j][1] == 'n' && atom[j][2] == ' ' ) Lncacos = TRUE;
else if( atom[j][1] == 'n' && atom[j][2] == 't' ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == 'a' ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == ' ' ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == ' ' ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == 'x' && atom[j][3] == 't')
Lncacos = TRUE;
#ifdef GFPchromophore /*070731 this part works, BUT see PKINCSUB code... */
/*070731 code for GFP chromophore: flagged 070829*/
else if( LGFPchromophore
&&( (atom[j][1]=='n'||atom[j][1]=='c'||atom[j][1]=='o')
&&(atom[j][2]=='1'||atom[j][2]=='2'||atom[j][2]=='3')))Lncacos=TRUE;
else if( LGFPchromophore
&&( (atom[j][1]=='c'&&atom[j][2]=='a')
&&(atom[j][3]=='1'||atom[j][3]=='2'||atom[j][3]=='3')))Lncacos=TRUE;
#endif /*GFPchromophore 070731*/
#ifdef OLDCODE /*pre 070728*/
/*070520 this still may be OK even with new hydrogen names ????*/
else if( ( atom[j][1] == 'h' || atom[j][1] == 'd' || atom[j][1] == 'q') )
if( ( atom[j][2] == 'a' || atom[j][2] == ' ' )
&&( atom[j][3] == ' ' && atom[j][0] != '2' ) ) Lncacos = TRUE;/*mc h*/
if( ( atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
#endif
/*new code 070728...*/
else if(isahydrogen(name[j],atom[j],element[j]))
{
if( ( atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;/*nucleic*/
else if( (atom[j][2] == 'a' || atom[j][2] == ' ')
&&(atom[j][3] == ' ' ) ) Lncacos = TRUE;/*mc h on ca and n*/
else if( (atom[j][2] == 'a' && atom[j][3] == ' ')
&&(atom[j][0] == '1' || atom[j][0] == '2')) Lncacos = TRUE;/*oldgly*/
else if( (atom[j][2] == 'a' && atom[j][0] == ' ')
&&(atom[j][3] == '3' || atom[j][3] == '2')) Lncacos = TRUE;/*newgly*/
else if( (atom[j][0] == ' ' && atom[j][3] == ' ')
&&(isdigit(atom[j][2]))) Lncacos = TRUE; /*old&new Nterm*/
}
else if( atom[j][1] == 'p' && atom[j][2] == ' ' && atom[j][3] == ' ')
Lncacos = TRUE;
/*pre 200707:*/
else if( atom[j][1] == 'o' && atom[j][2] == '1' && atom[j][3] == 'p')
Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '2' && atom[j][3] == 'p')
Lncacos = TRUE;
/*post 200707: Nucleic Mainchain OP1 and OP2 070726 */
else if( atom[j][1] == 'o' && atom[j][2] == 'p' && atom[j][3] == '1')
Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == 'p' && atom[j][3] == '2')
Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '5' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == '5' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '4' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == '4' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == '3' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '3' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == '2' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '2' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'o' && atom[j][2] == '1' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
else if( atom[j][1] == 'c' && atom[j][2] == '1' &&
(atom[j][3] == '*' || atom[j][3] == '\'') ) Lncacos = TRUE;
return(Lncacos);
}
/*___decidemainside()_______________________________________________________*/
/****decidemutmainside()*****************************************************/
int decidemutmainside(int j)
{
int Lncacos;
Lncacos = FALSE;
if( mutatom[j][1] == 'n' && mutatom[j][2] == ' ' ) Lncacos = TRUE;
else if( mutatom[j][1] == 'n' && mutatom[j][2] == 't' ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == 'a' ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == ' ' ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == ' ' ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == 'x' && mutatom[j][3] == 't')
Lncacos = TRUE;
#ifdef OLDCODE
/*070520 this still may be OK even with new hydrogen names ????*/
/*no, gly was HA1 HA2 now HA2 HA3 071222 */
else if( ( mutatom[j][1]== 'h' || mutatom[j][1]== 'd' || mutatom[j][1]== 'q')
&&( mutatom[j][2]== 'a' || mutatom[j][2]== ' ') /*mainchain hydrogen*/
&&( mutatom[j][3]== ' ' && mutatom[j][0]!= '2') ) Lncacos = TRUE;
#endif
else if(isahydrogenname(mutatom[j]))
{
if( ( mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;/*nucleic*/
else if( (mutatom[j][2] == 'a' || mutatom[j][2] == ' ')
&&(mutatom[j][3] == ' ' ) ) Lncacos = TRUE;/*mc h on ca and n*/
else if( (mutatom[j][2] == 'a' && mutatom[j][3] == ' ')
&&(mutatom[j][0] == '1' || mutatom[j][0] == '2')) Lncacos = TRUE;/*oldgly*/
else if( (mutatom[j][2] == 'a' && mutatom[j][0] == ' ')
&&(mutatom[j][3] == '3' || mutatom[j][3] == '2')) Lncacos = TRUE;/*newgly*/
else if( (mutatom[j][0] == ' ' && mutatom[j][3] == ' ')
&&(isdigit(mutatom[j][2]))) Lncacos = TRUE; /*old&new Nterm*/
}
else if( mutatom[j][1] == 'p' && mutatom[j][2] == ' ' && mutatom[j][3] == ' ')
Lncacos = TRUE;
/*pre 200707:*/
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '1' && mutatom[j][3] == 'p')
Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '2' && mutatom[j][3] == 'p')
Lncacos = TRUE;
/*post 200707: Nucleic Mainchain OP1 and OP2 070726 */
else if( mutatom[j][1] == 'o' && mutatom[j][2] == 'p' && mutatom[j][3] == '1')
Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == 'p' && mutatom[j][3] == '2')
Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '5' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == '5' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '4' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == '4' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == '3' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '3' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == '2' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '2' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'o' && mutatom[j][2] == '1' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
else if( mutatom[j][1] == 'c' && mutatom[j][2] == '1' &&
(mutatom[j][3] == '*' || mutatom[j][3] == '\'') ) Lncacos = TRUE;
return(Lncacos);
}
/*___decidemutmainside()____________________________________________________*/
/*
sprintf(temps,CRLF"writesctoscratch(%d,%s) k==%d, xth:%c:"CRLF,j,cntl,k,xth);
pkintextinsert(temps);
adjusttext(1);
*/
/****writesctoscratch()******************************************************/
void writesctoscratch(int j,char* cntl)
{
char colr[32];
char colr1[32],colr2[32];
int k,Lprint1,Lprint2,kj;
float Avalue;
char extra[16],extra1[20],extra2[20];
char ballstr[32],hydrgstr[16];
static char xth = ' '; /*991128*/
char rds[16],sty[16]; /*030920*/
float radius=0; /*050211 VRML*/
char whostr[32]; /*050211 VRML*/
char cs[MAXNAMECHAR+2]; /*051102*/
k = base[j];
/*
sprintf(temps,CRLF"sca %d: %s %s %s %d , isc== %d"
,j,atom[j],res[j],sub[j],num[j],isc[j]);
pkintextinsert(temps);
adjusttext(1);
*/
if(lastsc == -1) /*true only on first call for this sidechain*/
{
if(Leachsclist) /*991128*/
{/*toggle output indicator for changed sidechain*/
if(xth == '1') xth = '2';
else xth = '1';
}
else xth = ' '; /*for completeness*/
}
hydrgstr[0] = '\0';
if(isc[j]==2) /*hydrogen got through to here*/
{
if(Leachsclist)
{/*include hydrogens in sc list*/
cntl[0]='s';cntl[1]='c';cntl[2]='v';cntl[3]=xth;
Listhy = TRUE;Listsc = TRUE;typenow=typehy;
sprintf(hydrgstr," gray! 'H'");
}
else
{
cntl[0]='h';cntl[1]='y';cntl[2]='s';cntl[3]='c';
Listhy = TRUE;typenow=typehy;
}
}
else
{
cntl[0]='s';cntl[1]='c';cntl[2]=' ';cntl[3]=xth;
Listsc=TRUE;typenow=typesc;
}
if(Lalts) /*altstr is the pointmaster designator*/
{
altstr[0] = ' '; /*leading blank*/
altstr[2] = atom[j][4];
}
Lprint1 = TRUE; /*print the base as P */
Lprint2 = TRUE; /*print the atom as L */
if( (!(Lcbstubsrib && atom[k][1]=='c' && atom[k][2]=='b')) /*050206*/
&& (lastsc == k) )
/*cbstubsrib---CB vector, need explicitly both ends of CB---CG vector */
{/*polyline*/
Lprint1 = FALSE;
if(Lalts && altstr[2]==' ')
{/*may be join to primary conf, avoid line jumping previous atom*/
altstr[2] = atom[k][4];
}
}
if(Lalts && altstr[2]==' ')
{/*try NO pointmaster for ' ' case*/
altstr[0] = '\0';
}
lastsc = j;
if( !scCPKoutl && !rotoutl)
{
Listscv = 1;
if(isc[j]!=2)
{
cntl[0]='s';cntl[1]='c';cntl[2]='v';cntl[3] = xth;cntl[4] = '\0';
}
}
else if(scCPKoutl)
{
/*else if(hyoutl && (atom[j][1] == 'h' || atom[j][1] == 'd'))*/
if(hyoutl && isahydrogen(name[j],atom[j],element[j]) ) /*070520*/
{
Listsckh = 1;cntl[2] = 'k';cntl[3] = 'h';cntl[4] = '\0';
}
else if(atom[j][1] == 'c')
{