-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKINCSUB.c
4994 lines (4680 loc) · 196 KB
/
PKINCSUB.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*/
/* PKINCSUB.c */
/*****************************************************************/
/* NOTICE: This is free software and the source code is freely */
/* available. You are free to redistribute or modify under the */
/* conditions that (1) this notice is not removed or modified */
/* in any way and (2) any modified versions of the program are */
/* also available for free. */
/* ** Absolutely no Warranty ** */
/* Copyright (C) 2000 David C. Richardson */
/*****************************************************************/
#include "PKIN.h"
#include "PKINDLOG.h"
#include "PKINCRTL.h"
#include "PKINRIBB.h" /*090219*/
static double anglerot1=0,anglerot2=0,cbcbaxis[3]={0,0,0},cacbcalc[3]={0,0,0};
static double caxyz[3]={0,0,0};
/*to superimpose PDB records*/
int NA_BaseCategory(char[4]);
int threepointimpose(float[3],float[3],float[3],char);
int imposeontoideal(float[3]);
int midanglepoint(float[3],float[3],float[3],float[3]);
/****NA_BaseCategory()********************************************************/
int NA_BaseCategory(char resname[4]) /*resname expected to be uppercase*/
{/* hacked from Mike's naBaseCategory()*/
ResidueAndAtomPair *pair;
for (pair = NAbaseGrouping; pair->rlist; pair++)
{
/*char *strstr(cs,ct) return pointer to first occurrence of */
/*string ct in cs, or NULL if not present*/
if(strstr(pair->rlist, resname))
{
return pair->bits; /* bits contain the atom type */
}
}
return baseOther; /* not in table */
}
/*___NA_BaseCategory()_______________________________________________________*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****setsubunitconditions()**************************************************/
void setsubunitconditions(void)
{
int j;
/*--set conditions for beginning of each subunit loop */
first1 = 1; endsub = 0; endchn = 0; endres = 0;
/*note that stonex may = 1 : valid atom still held in brk buffer (texts)*/
/*but oldatm stored from last residue is meaningless at subunit start*/
/*oldatm signels a stored possible atom to connect to next residue */
/*and 3 possible alternate conformations, mainchain and ca-ca */
/* j == 0 for mainchain, j == 1 for ca-ca connection and virtual nucl bb*/
for(j=0 ; j<=1 ; j++)
{
oldatm[j] = 0; oldata[j] = 0; oldatb[j] = 0; oldatc[j] = 0;
}
/*--logicals for hbond: all set false, no atoms yet encountered */
tfc1 = 0; tfn2 = 0; tfca2 = 0; tfc2 = 0; tfo2 = 0; tfnh2 = 0;
/*--initialize counters */
/*counters for number of main chain and side chain vectors, labels, etc.*/
mccnt = 0; sccnt = 0; sscnt = 0; ssknt = 0;
hcount = 0; hetcnt = 0; metcnt = 0; hetknt = 0;
lbacnt = 0; lbncnt = 0; lbzcnt = 0;
atmcnt = 0; atncnt = 0; atocnt = 0; atscnt = 0; atwcnt = 0; atccnt = 0;
ribcnt = 0; nrib = 0; npept = 0; mutcnt = 0;
for(j=0; j<MAXTYPES; j++) pointcnt[j] = 0;
ntypes = 0; /*countpoints() will reload cntp and cntn as it goes 011202*/
/*--hbond counters */
cocnt = 0; nhcnt = 0;
/*--sonofchaos & oup-msb vector counter */
vccnt = 0;
/*__open scratch "tapes" */
inittextblock(&mainscratch);
inittextblock(&hbnscratch);
inittextblock(&hboscratch);
if(Lhetconnect)
{
inittextblock(&hetscratch);
}
/*--rewind scratch "tapes", inplicit with inittextblock() */
/*--allocation of space automatic when attempting write*/
/*initial conditions for range control runs */
/*------output control logicals, one for each type of output */
/* in effect if (mrange > 0), initialized by rangecontrol() */
caonly = 0; /*ca only*/
caoutl = 0; /*ca-ca bonds */
/*output list controls*/
Listmc = FALSE;Listmcn = FALSE;Listmco = FALSE;Listmcs = FALSE;
Listsc = FALSE;Listscn = FALSE;Listsco = FALSE;Listscs = FALSE;
Listca = FALSE;
Listlb = FALSE;Listlbn = FALSE;
Listhb = FALSE;
Listhy = FALSE;
Listss = FALSE;
Listht = FALSE;Listhtn = FALSE;Listhto = FALSE;Listhts = FALSE;
Listwa = FALSE; Listwao = FALSE;
Listat = FALSE;
Listmut = FALSE;
Listrot = FALSE;
Listrot2 = FALSE;
Listnum = FALSE;
Listrib = FALSE;
Listtaudev = FALSE;
Listcbdev = FALSE; /*Listtaudev,Listcbdev set in PKINANGL/constructbeta()*/
/*called from mutateresidue() when Lcbetadev==1 */
Listsuppos = FALSE;
Ldump = FALSE; /*011027*/
/*Listext = FALSE;*/ /*extra output*/
/*DO NOT DEFAULT HERE: contol with kludges on an individual pass basis*/
Listmcc = FALSE;Listscc = FALSE;Listhtc = FALSE;/*960809*/
Listmcv=0;Listmck=0;Listscv=0;Listsck=0;Listhtv=0;Listhtk=0; /*960815*/
Listmckc=0;Listmcko=0;Listmckn=0;Listmcks=0;Listmckh=0; /*960815*/
Listsckc=0;Listscko=0;Listsckn=0;Listscks=0;Listsckh=0; /*960815*/
Listhtkc=0;Listhtko=0;Listhtkn=0;Listhtks=0;Listhtkh=0; /*960815*/
Listtabl=0;/*991122*/
Listscring=0;/*991128*/
Nprotein = 0;
Nnucleic = 0;
Nwater = 0;
Nhetgroup = 0;
NDNA = 0; /*counts accum for a subunit*/
NRNA = 0;
LRNA = 0; /*flag could be set for each residue*/
residuetype = ' '; /*best guess at P vs N, etc. type 061006*/
previousresiduetype = ' '; /*061006*/
/*auto ribbon setup moved to after first atom record of this subunit*/
/*so the actual chain ID character will be known. */
}
/*__setsubunitconditions()__________________________________________________*/
#ifdef PRINTOUTL
printf("rangel %d, mcoutl %d, scoutl %d, lboutl %d, croutl %d, htoutl %d, hyoutl %d, hboutl %d, caoutl %d, waoutl %d, atoutl %d, mcaoutl %d, htaoutl %d, scaoutl %d, waaoutl %d, ssscoutl %d, rotoutl %d, mutoutl %d, riboutl %d, extoutl %d, mccoutl %d, sccoutl %d, htcoutl %d, mcCPKoutl %d,scCPKoutl %d,htCPKoutl %d, Bcoloutl %d, Bvaloutl %d\n"
,rangel, mcoutl, scoutl, lboutl, croutl,
htoutl, hyoutl, hboutl, caoutl, waoutl,
atoutl, mcaoutl, htaoutl, scaoutl, waaoutl,
ssscoutl, rotoutl, mutoutl, riboutl, extoutl,
mccoutl, sccoutl, htcoutl,
mcCPKoutl,scCPKoutl,htCPKoutl,
Bcoloutl, Bvaloutl);
#endif /*PRINTOUTL*/
/***rangecontrol()***********************************************************/
void rangecontrol(void)
{
int j,Lgood,Lbreak,LresOK,k,m,i;
int Lnosidechain;
static int oldnumber = -999;
/*static int previousribbontype = 0; to PKINRIBB.h 090219*/
int Lcoilregion = 0;
int Lcoilend = 0;
int LAlpharegion = 0;
int LAlphaend = 0;
int LBetaregion = 0;
int LBetaend = 0;
char resname[4];
char Cabc=' ',Cnc=' ';
int Newaspects=0;
char thischain[3] = {' ',' ','\0'}; /*2char sub== chainID 070926 */
/*sub[maxatm] defaults to \0 to take no space*/
/*so need to match blank chain with blank, not NULL 050925*/
/*but it looks as if sub[][0] can be read in as a space character!*/
/*2007 preserve pdb format spacing in output, 2char chainID 070926*/
if(Lnewribbonstart)
{previousribbontype=0; explicitribbontype=0; Lnewribbonstart=0;} /*090219*/
if(mrange == 0)
{/*no range controls*/
/*allow everything, except atom markers, labels, and h-bonds */
rangel = 1; mcoutl = 1; scoutl = 1; lboutl = 0; croutl = 1;
htoutl = 1; hyoutl = 1; hboutl = 0; caoutl = 1; waoutl = 1;
atoutl = 0; mcaoutl = 0; htaoutl = 0; scaoutl = 0; waaoutl = 0;
ssscoutl = 0; /*all cys sc atoms along with -ss- */
rotoutl = 0; mutoutl = 0;
/*mutations && rotations not standard things*/
riboutl = 0; /*ribbons not quite in CHAOS form*/
extoutl = 0; /* extra stuff*/
mccoutl = 0; sccoutl = 0; htcoutl = 0; /*960815*/
mcCPKoutl = 0;scCPKoutl = 0;htCPKoutl = 0; /*960815*/
Bcoloutl = 0; Bvaloutl = 0; /*971213*/
tabloutl = 0; /*991122*/
supoutl = 0; /*020227*/
siteoutl = 0; /*050731*/
}/*no range controls*/
else
{/*mrange!=0:expect range controls*/
/*first prohibit everything, with exceptions... 090219 */
rangel = 0; mcoutl = 0; scoutl = 0; lboutl = 0; croutl = 0;
htoutl = 0; hyoutl = 0; hboutl = 0; caoutl = 0; waoutl = 0;
atoutl = 0; mcaoutl = 0; htaoutl = 0; scaoutl = 0; waaoutl = 0;
ssscoutl = 0; rotoutl = 0; mutoutl = 0; extoutl = 0;
mccoutl = 0; sccoutl = 0; htcoutl = 0; /*960815*/
mcCPKoutl = 0;scCPKoutl = 0;htCPKoutl = 0; /*960815*/
Bcoloutl = 0; Bvaloutl = 0; /*971213*/
tabloutl = 0; /*991122*/
supoutl = 0; /*020227*/
siteoutl = 0; /*050731*/
/*do not reset riboutl : signals ribbon after all residues, if any need it*/
/*then scan all ranges to see if this residue is included*/
/* finds range by inclusive residue number */
/* exclusive mode has two sub modes*/
Lbreak = 0; /*lets exclusion jump out once occurred*/
Lcoilregion = 0;
Lcoilend = 0;
LAlpharegion = 0;
LAlphaend = 0;
LBetaregion = 0;
LBetaend = 0;
Lendribbon = 0; /*global*/
/*working on a residue....*/
/* identifiers of residue taken as identifiers on the last atom*/
if(sub[maxatm][0] == '\0') /*070926 legacy code...*/
{
thischain[0] = ' '; thischain[1] = ' '; /* 2char chainID 070926*/
thischain[2] = '\0';
/*sub[maxatm] used to default to \0 to take no space*/
/*so need to match blank chain with blank, not NULL 050925*/
/*but now preserve pdb format in pointID and 2char chainID 070926*/
}
else
{
thischain[0] = sub[maxatm][0]; /*070926*/
thischain[1] = sub[maxatm][1]; /*070926*/
thischain[2] = '\0';
}
/*selections.........*/
/*special selections......*/
if(Lallaminoacids) /*special selections */
{
if(iresiduecnt == 2) ssscoutl = 1; /*all cys sc atoms with -ss- */
if(iresiduecnt == 4) lboutl = 1; /* glycine labels */
}
/*general selections... working in rangecontrol()...*/
Lnosidechain = 0; /*flag to exclude by res name*/
Lgood = 1; /*flag to still consider this residue*/
/*first check for possible NMR models*/
/*NMR models can contain multiple chains, so models take precedence*/
/*NOTE: to use same commandline for both NMR and XL files */
/*include "_" as a possible model code and "_" as a possible chain ID*/
if(Nmodelcharcode > 0)
{/*commandline has specified model ID as a selection criterion*/
Lgood = 0; /*must match model ID to be selected*/
for(j=0; j<Nmodelcharcode; j++)
{/*check against all permitted model codes*/
/*use: mod[maxatm] for the current residue */
/*instead of: nmrmodel which changes at ends before this test */
if( (toupper(modelcharcode[j][0])==toupper(mod[maxatm][2]))
&&(toupper(modelcharcode[j][1])==toupper(mod[maxatm][3]))
&&(toupper(modelcharcode[j][2])==toupper(mod[maxatm][4])) )
{/*Match of model IDs allowed to present model ID*/
Lgood = 1;
break; /*any one match allows this model*/
}
}/*check against all permitted model codes*/
}/*commandline has specified model ID as a selection criterion*/
if(Lgood)
{/*passed model filter, check for chain ID*/
if(Nchaincharcode > 0)
{/*commandline has specified chain ID as a selection criterion*/
Lgood = 0; /*must match chain ID to be selected*/
for(j=0; j<Nchaincharcode; j++)
{ /*chainID case sensitive pdb v3.0 070926*/
if( (chaincharcode[j][0]==thischain[0]) /*2char 070926*/
&&(chaincharcode[j][1]==thischain[1])) /*2char 070926*/
{/*Match of chain IDs allowed to present chain ID*/
Lgood = 1;
break; /*any one match allows this chain*/
}
}
}
}/*passed model filter, check for chain ID*/
if(Laspectabc) /*search actual ranges 050924*/
{/*aspect by any inputed ALPHA or BETA HEADER records 010920*/
/*050924 ???? FLAG NEEDED FOR EXISTANCE OF HELIX,SHEET RECORDS? */
/*search through the separate rib ranges for sec str designation 050928*/
Cabc = 'I'; /*sky default coil*/
for(j=1; j<=Nribs; j++)
{
if( ribBeta[j]
&& thischain[0] == ribchain[j][0] /*sub[maxatm][0] 2char 070926*/
&& thischain[1] == ribchain[j][1] /*sub[maxatm][1] 2char 070926*/
&& num[maxatm] >= ribresnu1[j]
&& num[maxatm] <= ribresnu2[j]
)
{/*residue is in Beta SHEET*/
Cabc = 'F'; /*green*/
break; /*on first instance of matching Beta range*/
}
else if( ribAlpha[j]
&& thischain[0] == ribchain[j][0] /*sub[maxatm][0] 2char 070926*/
&& thischain[1] == ribchain[j][1] /*sub[maxatm][1] 2char 070926*/
&& num[maxatm] >= ribresnu1[j]
&& num[maxatm] <= ribresnu2[j]
)
{/*residue is in Alpha HELIX*/
Cabc = 'A'; /*red*/
break; /*on first instance of matching Alpha range*/
}
}
}/*aspect by any inputed ALPHA or BETA HEADER records */
if(LcolorbyNtoC && icountresfirstpass[level] != 0)
{/*011109 commandline request for pointcolor colorNtoC*/
if(icountres[level] < icountresfirstpass[level]/10)
sprintf(colorbyNtoC," blue");
else if(icountres[level] < 2*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," sky");
else if(icountres[level] < 3*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," cyan");
else if(icountres[level] < 4*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," sea");
else if(icountres[level] < 5*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," green");
else if(icountres[level] < 6*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," lime");
else if(icountres[level] < 7*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," yellow");
else if(icountres[level] < 8*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," gold");
else if(icountres[level] < 9*(icountresfirstpass[level]/10))
sprintf(colorbyNtoC," orange");
else
sprintf(colorbyNtoC," red");
}/*011109 commandline request for pointcolor colorNtoC*/
else
{
colorbyNtoC[0] = '\0'; /*null string*/
}/*011109 NOT commandline request for pointcolor colorNtoC*/
if(Laspectnc && icountresfirstpass[level] != 0)
{/*010920 aspect by N-->C proportion*/
Newaspects++;
if(icountres[level] < icountresfirstpass[level]/10)
Cnc = 'J'; /*blue*/
else if(icountres[level] < 2*(icountresfirstpass[level]/10))
Cnc = 'I'; /*sky*/
else if(icountres[level] < 3*(icountresfirstpass[level]/10))
Cnc = 'H'; /*cyan*/
else if(icountres[level] < 4*(icountresfirstpass[level]/10))
Cnc = 'G'; /*sea*/
else if(icountres[level] < 5*(icountresfirstpass[level]/10))
Cnc = 'F'; /*green*/
else if(icountres[level] < 6*(icountresfirstpass[level]/10))
Cnc = 'E'; /*lime*/
else if(icountres[level] < 7*(icountresfirstpass[level]/10))
Cnc = 'D'; /*yellow*/
else if(icountres[level] < 8*(icountresfirstpass[level]/10))
Cnc = 'C'; /*gold*/
else if(icountres[level] < 9*(icountresfirstpass[level]/10))
Cnc = 'B'; /*orange*/
else
Cnc = 'A'; /*red*/
}/*010920 aspect by N-->C proportion*/
if(MAXaspectcode > Naspectcode) /*Naspectcode: # inputted*/
{/*add these new aspects to any inputed on PDB ATOM records*/
for(j=1 ; j<=maxatm; j++)
{/*scan over all atoms of this residue*/
/*if(aspectstr[j][Naspectcode]=='\0') */
/*{*/ /*need to initialize this string, Naspectcode should==0*/
/* aspectstr[j][Naspectcode]='(';*/ /*necessary starting char*/
/* aspectstr[j][Naspectcode+1]=')';*/ /*for completeness*/
/* aspectstr[j][Naspectcode+2]='\0';*/ /*for completeness*/
/*}*/
if(aspectstr[j][0]=='\0')
{/*need to initialize this string, Naspectcode should==0*/
aspectstr[j][0]='('; /*necessary starting char*/
aspectstr[j][1]=')'; /*for completeness*/
aspectstr[j][2]='\0'; /*for completeness*/
}
/*with some presumption that aspect index numbers are correct*/
/* and that aspects input in header records are already in the str*/
/* so add on to end, over-writing the trailing end-paren */
if(Laspectnc) {aspectstr[j][Naspectnc] =Cnc;}
if(Laspectabc) {aspectstr[j][Naspectabc]=Cabc;}
aspectstr[j][MAXaspectcode+1]=')'; /*necessary ending char*/
aspectstr[j][MAXaspectcode+2]='\0'; /*regular str ending*/
}
}/*add these new aspects to any inputed on PDB ATOM records*/
if(Lgood)
{/*acceptable chain: check each range for this residue*/
for(j=1 ; j<=mrange ; j++)
{/*check each jth range*/
Lgood = 0; /*controls for each range*/
/*rejects unless accepted*/
if(Linclusive)
{
if((num[maxatm] >= resnu1[j]) && (num[maxatm] <= resnu2[j]) )
{
Lgood=1;
}
}
else
{
Lgood = 1; /*accepts unless excluded*/
if(Loverlap) /*lap into ranges, this gives extra at ends*/
{
if( (num[maxatm] > resnu1[j]) && (num[maxatm] < resnu2[j]) )
{ /*exclude this residue*/
Lgood = 0;
rangel = 0;
Lbreak = 1;
}
}
else /*don't lap into ranges, this gives spaces on ca-ca*/
{
if( (num[maxatm] >= resnu1[j]) && (num[maxatm] <= resnu2[j]) )
{ /*exclude this residue*/
Lgood = 0;
rangel = 0;
Lbreak = 1;
}
}
}
if(Lbreak) break;
if(Lgood)
{/*Lgood range*/
/*Now must see if this residue should have conditions checked*/
LresOK = 1; /*presume acceptable and needing extra conditions*/
/*Now do tests on this residue which can modify this presumption*/
/*if Ldotlist has set coordinate triples for this range, */
/* an atom of this residue must have this coord to allow output*/
if(xyzl[j])
{/*using coord to identify residues for output*/
LresOK = 0; /*not expected to match*/
for(k=1;k<=maxatm;k++)
{
if( (x[k]>=fxyz[j][0]-.002 && x[k]<=fxyz[j][0]+.002)
&& (y[k]>=fxyz[j][1]-.002 && y[k]<=fxyz[j][1]+.002)
&& (z[k]>=fxyz[j][2]-.002 && z[k]<=fxyz[j][2]+.002) )
LresOK = 1; /*accepted, need conditions*/
}
}
/* resl[]: if invoked, there is exclusive choice by residue type */
/* if residue name is not specified for this range, then it is a */
/* valid range for any residue, but if the residue name is given,*/
/* it must match the current residue for this range to be considered*/
/*970419: resl[] now a positive number for inclusions by res name, */
/*a negative number for exclusions by name, resid[][012,345,678,...]*/
/*holds the sequence of characters of these names */
/*Negative resl[] not only blocks this jth range from having a*/
/*contribution from this residue, it sets a flag so the sidechain*/
/*of this residue will not be shown */
/*if mutl[j] set then resl[j] will have been set as well */
/* if no residue name given, then sc rotations are set up*/
/* if residue named, then this residue is to be mutated */
/* to the given one, then sc rotations set up */
/*NOT HERE 051213 ???? SITE by number, not name, as well 050917*/
/*maybe needed for fakesite from GUI ???? */
if(resl[j]==0)
{/*unnamed residue*/
if(rotl[j]==1)
{/*unnamed residue at this location is to have rotations*/
resid[j][0] = res[maxatm][0];
resid[j][1] = res[maxatm][1];
resid[j][2] = res[maxatm][2];
resl[j] = 1; /*now set to just do rotations*/
rotoutl = j; /*set up rotations*/
rangel = 1; /* accept this residue as rotatable*/
scoutl = 1; /*set to get sidechain*/
numrotsc = num[maxatm];
/*NOT named, do rotations for whatever residue is here*/
LresOK = 1; /*rotation can have specifications*/
/*modelnumber==this chain's model, nmrmodel== MODEL record*/
/*[0]=='\0' no modelnumber else: [0]==' ',[1]=='M',[2]=='#'...*/
if(modelnumber[0] == ' ') /*leading space to print nicely 050121*/
{ /*bondrotation label has spaces for readability */
sprintf(rotatorname,"%s %s %d %s"
,resid[j],sub[maxatm],num[maxatm],modelnumber);
}
else
{
sprintf(rotatorname,"%s %s %d",resid[j],sub[maxatm],num[maxatm]);
}
/*rotatorname incl sub 030925*/
}
}/*unnamed residue*/
else /*(resl[j] != 0)*/
{/*residue by name*/ /*PREKIN IS SCHIZOPHRENIC WITH REGARD TO CASE*/
/*MOST INPUT FILES, INC PDB, USE UPPER CASE */
/*PREKIN CONVERTS ATOM RECORD STUFF INTO LOWER CASE*/
/*PROBLEM IS MATCHING USER INPUT OF THINGS LIKE RESIDUE NAMES*/
LresOK = 0; /*presume no match*/
/*check for mutant ninja rotations, only possible for resl==1*/
if(resl[j] ==1 && mutl[j] && name[maxatm][0]=='a') /*ATOM records*/
{/*mutation and/or rotation*/
rotoutl = j; /*set up rotations*/
rangel = 1; /* accept this residue to be mutated*/
scoutl = 1; /*set to get sidechain*/
numrotsc = num[maxatm];
resid[j][0] = tolower(resid[j][0]); /*011202*/
resid[j][1] = tolower(resid[j][1]);
resid[j][2] = tolower(resid[j][2]);
mutoutl = j;
/*Residue named: mutate to this resid[j] residue*/
/*or rebuild the same one from a library residue*/
LresOK = 1; /*rotation can have specifications*/
/*modelnumber==this chain's model, nmrmodel== MODEL record*/
/*[0]=='\0' no modelnumber else: [0]==' ',[1]=='M',[2]=='#'...*/
if(modelnumber[0] == ' ') /*leading space to print nicely 050121*/
{ /*bondrotation label has spaces for readability */
sprintf(rotatorname,"%s %s %d %s"
,resid[j],sub[maxatm],num[maxatm],modelnumber);
}
else
{
sprintf(rotatorname,"%s %s %d",resid[j],sub[maxatm],num[maxatm]);
}
/*rotatorname incl sub 030925*/
}/*mutation and/or rotation*/
else
{/*look for residue name match*/
if(resl[j]<0)
{
m = -resl[j];
}
else
{
m = resl[j];
}
for(k=1; k<=m; k++)
{/* look for one or more residue name matches*/
i = 3*(k-1);
if( res[maxatm][0] == tolower(resid[j][0+i])
&& res[maxatm][1] == tolower(resid[j][1+i])
&& res[maxatm][2] == tolower(resid[j][2+i]) )/*011202*/
{
LresOK = 1;
if(Lsite)
{
Lsitefake = 1; /*add this named res along with site res*/
siteoutl = 1; /*051213*/
}
}
else if(Lallbases)
{
resname[0] = toupper(res[maxatm][0]);
resname[1] = toupper(res[maxatm][1]);
resname[2] = toupper(res[maxatm][2]);
resname[3] = '\0';
if(strstr(NAList, resname))
{/*recognized as a Nucleic Acid*/
if(NA_BaseCategory(resname) == iresiduecnt)
{/*name matches cycle counter*/
LresOK = 1;
}
else
{
LresOK = 0;
}
}
else
{/*NOT recognized as a Nucleic Acid*/
LresOK = 0;
}
}
}/* look for one or more residue name matches*/
if(resl[j]<0)
{
if(LresOK==1 && resl[j]<0)
{/*exclude this sidechain*/
Lnosidechain = 1;
}/*exclude this sidechain*/
LresOK = 1; /*since only excluding sidechain anyway*/
}
}/*look for residue name match*/
}/*residue by name*/
if(LresOK)
{/*LresOK: get conditions*/
rangel = 1; /* turn on this residue for general use*/
if(supl[j])
{
supoutl = 1; /*superposition of aa type onto ideal std*/
}
/*set logicals for only what is allowed as output in this range */
/*these accummulate for this residue for all ranges that have this*/
/* residue*/
/* logicals act at the write-scratch-file place */
if (mcxl[j]) mcoutl = 1; /* mainchain */
if(Lallbases && iresiduecnt>1) mcoutl = 0; /*override*/
if (scxl[j]) scoutl = 1; /* sidechain */
if(Lallbases && iresiduecnt==1) scoutl = 0; /*override*/
if (hbxl[j]) hboutl = 1; /* mc h-bonds */
if (hyxl[j]) hyoutl = 1; /* hydrogens */
if (caxl[j])
{
if(Ltable) tabloutl = 1; /*991122*/
else caoutl = 1; /* ca-ca */
}
if (htxl[j]) htoutl = 1; /* hetatms */
if( (mcxl[j]) && mcCPKl[j]) mcCPKoutl = 1; /*960815*/
if( (scxl[j]) && scCPKl[j]) scCPKoutl = 1; /*960815*/
if( (htxl[j]) && htCPKl[j]) htCPKoutl = 1; /*960815*/
if (atxl[j]) atoutl = 1; /* some atom markers */
if (mcal[j]) mcaoutl = 1; /* mainchain atom markers*/
if(mcal[j] && ctxl[j]) mccoutl = 1; /*carbon atoms also 960815+*/
if (scal[j]) scaoutl = 1; /* sidechain atom markers*/
if(scal[j] && ctxl[j]) sccoutl = 1; /*carbon atoms also 960815+*/
if (htal[j]) htaoutl = 1; /* het group atom markers*/
if(htal[j] && ctxl[j]) htcoutl = 1; /*carbon atoms also 960815+*/
if (Bcol[j]) Bcoloutl = 1; /* color by B-values */ /*971213*/
if (Bval[j]) Bvaloutl = 1; /* pointID B-values & occupancies*/
if (lbxl[j]) lboutl = 1; /* residue labels */
if (cssl[j]) ssscoutl = 1; /*all cys sc atoms with -ss- */
if (waxl[j]) waoutl = 1;
if(waoutl) if (waal[j]) waaoutl = 1; /* water atom markers*/
if(sitel[j]) /*broken after 050925 to 051212, Nsite not implemented*/
{/*051213 fix the 050731 site residue, e.g. for rib stud*/
/*char sitechain[MAXR][3],siteinsert[MAXR]; int siteresnum[MAXR];*/
for(k=1; k <= Nsite; k++) /*check residue against SITE records*/
{/*search in separate site ranges*/
if( (num[maxatm] == siteresnum[k])
&& (rins[maxatm][0] == siteinsert[k]) /* char comparison*/
&& (thischain[0] == sitechain[k][0]) /* 2char 070926*/
&& (thischain[1] == sitechain[k][1]) ) /* 2char 070926*/
{
siteoutl = 1; /*this residue is a valid site residue*/
scoutl = 1; /*051213*/
}
}
}
/*050928 ribl[j] is part of general ranges, flags search for */
/* Alpha, Beta, Coil in separate ribbon sec str ranges */
/*if( (ribl[j] || Coil[j] || Alpha[j] || Beta[j])*/
if( ((ribl[j])||(Best[j])) &&( (char)name[maxatm][0] != 'h') )
{/*ribbon controls NOT applied to hets, e.g. HOH of 1BOV.pdb 041106*/
riboutl = 1;
/*090219 this would fail if MSE or other het as last res of atoms*/
/* so riboutl should be a set-once per level logical*/
/*setsubunitconditions() does reset riboutl, */
/* so rangecontrols should NOT clear riboutl when called 090219*/
/*always look for secondary structure records HELIX, SHEET 051208*/
for(k=1; k <= Nribs; k++)
{/*search in separate ribbon sec str ranges 1--k--Nribs*/
/*THIS ROUTINE REQUIRES CORRECT FILL OF THESE RANGES*/
if( (num[maxatm] >= ribresnu1[k])
&& (num[maxatm] <= ribresnu2[k])
&& ((thischain[0] == ribchain[k][0])||(ribchain[k][0]=='+'))
&& ((thischain[1] == ribchain[k][1])||(ribchain[k][1]=='+')))
{/*appropriate range where + is GUI selected range*/
/*prekin not dealing with residue insertion codes*/
/* ribbons: Alpha & Beta can overlap */
if((ribAlpha[k])||(ribBeta[k]))
{
if(ribAlpha[k])
{
LAlpharegion = 1;
Lcoilregion = 0;
if(num[maxatm] == ribresnu2[k])
{
if(num[maxatm] != oldnumber)
{
LAlphaend = 1;
}
else
{/*ribbon region ends on first of set of insertions*/
LAlpharegion = 0;
}
}
}
else
{
LAlpharegion = 0;
}
if(ribBeta[k])
{
LBetaregion = 1;
Lcoilregion = 0;
if(num[maxatm] == ribresnu2[k])
{
if(num[maxatm] != oldnumber)
{
LBetaend = 1;
}
else
{/*ribbon region ends on first of set of insertions*/
LBetaregion = 0;
}
}
/*just doing beta for nucleics now, 060929*/
strcpy(explicitribbonidentity,ribidentity[k]);
/*explicitribbonidentity,ribidentity SHEET 060929*/
Lribidentity = 1; /*define rib sec str colorsets*/
}
else
{
LBetaregion = 0;
}
}
/*if(ribCoil[k])*/ /*050928 default to coil*/
else
{
Lcoilregion = 1;
LAlpharegion = 0;
LBetaregion = 0;
if(num[maxatm] == ribresnu2[k])
{
if(num[maxatm] != oldnumber)
{
Lcoilend = 1;
}
else
{
Lcoilregion = 0;
}
}
}
}/*appropriate range*/
else
{/*not in a defined range, default to coil*/
Lcoilregion = 1;
}
}/*search in separate ribbon sec str ranges 1--k--Nribs*/
}/*ribbon controls*/
if(Lnosidechain) scoutl = 0; /*override by res name exclusion*/
}/*LresOK: get conditions*/
}/*Lgood range*/
}/*check each jth range*/
if(Lcoilregion || LAlpharegion || LBetaregion)
{/*explicit ribbon under construction*/
if(LAlpharegion && LBetaregion)
{/*double listed, try to decide between Alpha and Beta*/
if(previousribbontype==BETA2D)
{/*continuing Beta takes precedence over Alpha*/
if(LBetaend) explicitribbontype = BETAARROW2D;
else explicitribbontype = BETA2D;
}
else if(previousribbontype==ALPHA2D)
{
if(LAlphaend) explicitribbontype = ALPHAARROW2D;
else explicitribbontype = ALPHA2D;
}
else
{/*Beta takes precedence over Alpha*/
if(LBetaend) explicitribbontype = BETAARROW2D;
else explicitribbontype = BETA2D;
}
}/*double listed, try to decide between Alpha and Beta*/
else if(LBetaregion)
{
{/*Beta takes precedence over Alpha*/
if(LBetaend) explicitribbontype = BETAARROW2D;
else explicitribbontype = BETA2D;
}
}
else if(LAlpharegion)
{
if(LAlphaend) explicitribbontype = ALPHAARROW2D;
else explicitribbontype = ALPHA2D;
}
else
{/*claims to be just coil, see if Alpha or Beta needs end arrow*/
if(previousribbontype==BETA2D) /*ended would be BETAARROW2D*/
{/*ending Beta takes precedence over ending Alpha*/
explicitribbontype = BETAARROW2D;
}
else if(previousribbontype==ALPHA2D) /*ended would be ALPHAARROW2D*/
{
explicitribbontype = ALPHAARROW2D;
}
else
{
explicitribbontype = COIL2D;
}
}/*claims to be just coil, see if Alpha or Beta needs end arrow*/
if(Lcoilend) Lendribbon = 1;
}/*explicit ribbon under construction*/
previousribbontype = explicitribbontype;
oldnumber = num[maxatm];
}/*acceptable chain: check each range for this residue*/
if(Lribbonalso){rangel=1; riboutl=1; /*050206 continuous ribbon*/ }
}/*mrange!=0:expect range controls*/
/*keep this as a horrible example of hets (HOH) being included in ribbon calc
if(explicitribbontype!=savedvalue)fprintf(stderr,"level==%d, nrib==%d: res: %s %s %d: rangecontrol explicitribbontype: %d-->%d\n",level,nrib,name[maxatm],res[maxatm],num[maxatm],savedvalue,explicitribbontype);
*/
}
/*__rangecontrol()__________________________________________________________*/
/***checkline()**************************************************************/
int checkline(char texts[256])
{ /* check of a line to see if it is a valid coord record */
static int Lcompnd = 0;
int ignore,j,k;
char chainID[3] = {' ',' ','\0'}; /*2char 070926*/
int ireturn = 0;
int naspect=0,Lnew=0;
int Lnumber = 1, nc=0;
char cnumber[256];
int ith=0,LOK=0,ithnum=0,ithnumr,ithnum0=0,ithnum1=0,ithnumt;
int identity=0; /*060929*/
/* need to check for atom or hetatm key word */
/* keyword must be contiguous characters as a single word */
/* this routine looks for atom and hetatm */
ireturn = 0; /* presume not a coordinate record line until proven */
/* try ATOM or HETATM, CompArgStr iqnores case*/
if( CompArgStr(texts,"ATOM",4) /*PUXMINIT*/
|| CompArgStr(texts,"HETATM",6) )
{
if(Lthispass==1 && inputflag == 0 && Nsite > 0 && CompArgStr(texts,"ATOM",4) )
{
/*
fprintf(stderr,"checkline finds ATOM record: Nsite== %d\n",Nsite);
fprintf(stderr,"%s\n",texts);
*/
/*050928 keep site ranges stored separately*/
/* computesiteranges();*/ /*050731*/
/* Nsite = 0;*/ /*050731 site info now stored in range info*/
}
ireturn = 1; /* set flag for a coordinate record line */
}
else if(CompArgStr(texts,"TER",3) ) /*PUXMINIT*/
{
ireturn = 2;
}
else if(CompArgStr(texts,"END",3) ) /*PUXMINIT*/
{
ireturn = 3;
if(CompArgStr(texts,"ENDMDL",6) ) /*PUXMINIT*/
Ngroups = 0; /*Number of groups outputed reset for this MODEL*/
}
else if(CompArgStr(texts,"MOD",3) ) /*PUXMINIT*/
{
/*
01234567890123... index of texts[]
123456789_1234... columns
MODEL 20 2CBH9610
*/
if(CompArgStr(texts,"MODEL",5) )
{/*really is a MODEL record, remember putative MODEL # chars*/
/*
But, as one might expect, this number is not always placed in strict pdb format
so for robustness, try to find it... 030111
*/
/*set off model# by "M" to distinguish from residue number*/
/*this will be in addition to chain ID Alphabetic character*/
nmrmodel[0] = ' '; /*leading blank for spacing on output line*/
nmrmodel[1] = 'M'; /*000418*/
nmrmodel[2] = '1'; /* 1's digit default*/
nmrmodel[3] = '\0';
nmrmodel[4] = '\0';
nmrmodel[5] = '\0';
j = strlen(texts); /*length exclusive of EOL, so EOL is indexed as j*/
if( j>=14 && isdigit(texts[13]) )
{/*most likely this is actually standard pdb format*/
if(texts[11] != ' ')
{/*hundreds*/
nmrmodel[2] = texts[11];/*possible 100's digit*/
nmrmodel[3] = texts[12]; /*possible 10's digit*/
nmrmodel[4] = texts[13]; /*expected 1's digit*/
}
else if(texts[12] != ' ')
{/*tens*/
nmrmodel[2] = texts[12]; /*possible 10's digit*/
nmrmodel[3] = texts[13]; /*expected 1's digit*/
}
else
{/*only units*/
nmrmodel[2] = texts[13]; /* 1's digit*/
}
}/*most likely this is actually standard pdb format*/
else
{/*NOT standard pdb format, try to find a model number*/
/*take intact set of digits nearest MODEL*/
Lnumber = 0;
nc = -1; /*augment before storage, end digit indexed by nc*/
for(k=5; k<j; k++)
{
if(isdigit(texts[k]))
{
Lnumber = 1;
cnumber[++nc] = texts[k];
}
else
{
if(Lnumber) {break;}
}
}
if(Lnumber)
{/*found something*/
if(nc>=2)
{/*at least 3 digit number, take 3 digits*/
nmrmodel[2] = cnumber[nc-2]; /*possible 100's digit*/
nmrmodel[3] = cnumber[nc-1]; /*possible 10's digit*/
nmrmodel[4] = cnumber[nc]; /*expected 1's digit*/
}
else if(nc==1)
{/*tens*/
nmrmodel[2] = cnumber[nc-1]; /*possible 10's digit*/
nmrmodel[3] = cnumber[nc]; /*expected 1's digit*/
}
else
{/*only units*/
nmrmodel[2] = cnumber[nc]; /* 1's digit*/
}
}
}/*NOT standard pdb format, try to find a model number*/
Nmodels = Nmodels + 1;
Lonegroup = 1; /*once encounter MODEL, then mode set*/
Lnosubgroupmasters = 0; /*050925*/
Ngroups = 0; /*Number of groups outputed reset for this MODEL*/
ireturn = 4;/*moved to here 040406, distinguish MOD MODEL MODRES etc.*/
/*NOTE: nmrmodel now set to NEXT MODEL # of the input file! */
Lmodel = 1; /*at least one MODEL record exists 050922*/
if(Lthispass > 1)
{
if(FirstModel[0]=='\0') {strcpy(FirstModel,nmrmodel);} /*initiate*/
if( !strcmp(FirstModel,nmrmodel) )
{
Nthmodel = 1; /*still on first model*/
}
else
{
Nthmodel++; /*augment counter for MODEL records 050922*/
}
}
}/*really is a MODEL record, remember putative MODEL # chars*/
}
if(Lnewpassflow) /* try HEADER stuff*/
{/*Lnewpassflow*/
if(Lthispass==1)
{/*Lthispass==1*/
if( Lallowaspectsin > 0
&& CompArgStr(texts,"USER",4)
&& CompArgStr(&texts[6],"ASPECT",6)
&& CompArgStr(&texts[13],"CODE",4)
)
{/*USER ASPECT CODE # {label} # */
/*012345678901234567890*/
/*parse for aspect-number, {aspect label}, col-of-char-code*/
j = 18; /*position in pdb record*/
naspect = -1;
Lnew = 1;
while(!getinteger(texts[j],Lnew,&naspect) )
{
j++;
Lnew = 0;
if(j>253){break;}
}
if(naspect >= 0 && naspect <= MAXaspects)
{/*try to get an aspect identifier*/
aspectid[naspect][0] = '\0';
aspectcodecol[naspect] = -1;
Lnew = 1;
while(!getbracketed(texts[j],Lnew,MAXaspectchars,aspectid[naspect]) )
{