-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKINCRTL.c
1820 lines (1638 loc) · 71.3 KB
/
PKINCRTL.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
/*23456789_123456789_123456789_123456789_123456789_123456789_123456789_1234567*/
/* PKINCRTL.c */
#include "PKIN.h"
#define PKINCRTL
#include "PKINCRTL.h"
#undef PKINCRTL
#include "PKINDLOG.h"
#include "PKINRIBB.h"
int queercompare(const void * astr, const void * bstr); /*050925*/
/***flowControl()**********************************************************/
void flowControl()
{
/*enters here for each pass, aka Lthispass, so any globals that must */
/*presist from the first pass, must not be reset here without protection*/
int i,j,k,maxcounter,iskip,inputline,iscan,Lperiod,LOK=1;
static int Loutput,Lallrescycle,Numberresiduetypes,LLfpoutput;
static char oldmaxatmnamechar;
static char residuereport[3][MAXlevels]; /*up from 128 040324,040504*/
static int realresiduereport[MAXlevels]; /*up from 128 040324,040504*/
static int iresiduereport,iteststring;
static long ncountticks, accumticks[11],OldTickCounts[11];
char resname[4],secstrcstr[256];
static int nlevel=0;
long previousconect=0; /*050409*/
int IOK = 0,nN=0,nP=0; /*061001,061006*/
#ifdef GFPchromophore /*070801*/ /*Perhaps do this as Lspecialresidue ???? */
int LCA1=0,LCA2=0,LCA3=0,LNN1=0,LNN2=0,LNN3=0; /*070801*/
int LCC1=0,LCC2=0,LCC3=0,LCO1=0,LCO2=0,LCO3=0; /*070801*/
#endif
accumticks[0] = 0;
accumticks[1] = 0;
accumticks[2] = 0;
accumticks[3] = 0;
accumticks[4] = 0;
accumticks[5] = 0;
accumticks[6] = 0;
accumticks[7] = 0;
accumticks[8] = 0;
accumticks[9] = 0;
accumticks[10] = 0;
OldTickCounts[0] = 0;
OldTickCounts[1] = 0;
OldTickCounts[2] = 0;
OldTickCounts[3] = 0;
OldTickCounts[4] = 0;
OldTickCounts[5] = 0;
OldTickCounts[6] = 0;
OldTickCounts[7] = 0;
OldTickCounts[8] = 0;
OldTickCounts[9] = 0;
OldTickCounts[10] = 0;
OldTickCounts[0] = TickCount();
/*#define PRINTINFORMATION*/ /*080915*/
#ifdef PRINTINFORMATION
fprintf(stderr,"mrange== %d\n",mrange);
fprintf(stderr,"j:mcxl,scxl,hbxl,hyxl,caxl,htxl,mcCPKl,scCPKl,htCPKl,atxl,ctxl,lbxl,cssl,waxl,waal\n");
for(j=1 ; j<=mrange ; j++)
{/*check each range*/
fprintf(stderr,"%d: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, resnu1[%d]== %d, resnu2[%d]== %d\n"
,j,mcxl[j],scxl[j],hbxl[j],hyxl[j],caxl[j],htxl[j]
,mcCPKl[j],scCPKl[j],htCPKl[j],atxl[j],ctxl[j],lbxl[j],cssl[j],waxl[j],waal[j]
,j,resnu1[j],j,resnu2[j]);
}
fprintf(stderr,"FOVEA %d, xyz %.3f, %.3f, %.3f"
", focussc %.2f, focusmc %.2f, focusca %.2f, focuswa %.2f, focusht %.2f\n"
,FOVEA,focus[1],focus[2],focus[3],focussc,focusmc,focusca,focuswa,focusht);
#endif
/*#define PRINTRANGES*/
#ifdef PRINTRANGES
printf("code r=1 2 3 4 5 6 7 8 9\n");
printf("mcxl %d %d %d %d %d %d %d %d %d\n"
,mcxl[1],mcxl[2],mcxl[3],mcxl[4],mcxl[5],mcxl[6],mcxl[7],mcxl[8],mcxl[9]);
printf("scxl %d %d %d %d %d %d %d %d %d\n"
,scxl[1],scxl[2],scxl[3],scxl[4],scxl[5],scxl[6],scxl[7],scxl[8],scxl[9]);
printf("hbxl %d %d %d %d %d %d %d %d %d\n"
,hbxl[1],hbxl[2],hbxl[3],hbxl[4],hbxl[5],hbxl[6],hbxl[7],hbxl[8],hbxl[9]);
printf("hyxl %d %d %d %d %d %d %d %d %d\n"
,hyxl[1],hyxl[2],hyxl[3],hyxl[4],hyxl[5],hyxl[6],hyxl[7],hyxl[8],hyxl[9]);
printf("caxl %d %d %d %d %d %d %d %d %d\n"
,caxl[1],caxl[2],caxl[3],caxl[4],caxl[5],caxl[6],caxl[7],caxl[8],caxl[9]);
printf("htxl %d %d %d %d %d %d %d %d %d\n"
,htxl[1],htxl[2],htxl[3],htxl[4],htxl[5],htxl[6],htxl[7],htxl[8],htxl[9]);
printf("waxl %d %d %d %d %d %d %d %d %d\n"
,waxl[1],waxl[2],waxl[3],waxl[4],waxl[5],waxl[6],waxl[7],waxl[8],waxl[9]);
printf("atxl %d %d %d %d %d %d %d %d %d\n"
,atxl[1],atxl[2],atxl[3],atxl[4],atxl[5],atxl[6],atxl[7],atxl[8],atxl[9]);
printf("lbxl %d %d %d %d %d %d %d %d %d\n"
,lbxl[1],lbxl[2],lbxl[3],lbxl[4],lbxl[5],lbxl[6],lbxl[7],lbxl[8],lbxl[9]);
printf("ctxl %d %d %d %d %d %d %d %d %d\n"
,ctxl[1],ctxl[2],ctxl[3],ctxl[4],ctxl[5],ctxl[6],ctxl[7],ctxl[8],ctxl[9]);
printf("mcal %d %d %d %d %d %d %d %d %d\n"
,mcal[1],mcal[2],mcal[3],mcal[4],mcal[5],mcal[6],mcal[7],mcal[8],mcal[9]);
printf("scal %d %d %d %d %d %d %d %d %d\n"
,scal[1],scal[2],scal[3],scal[4],scal[5],scal[6],scal[7],scal[8],scal[9]);
printf("htal %d %d %d %d %d %d %d %d %d\n"
,htal[1],htal[2],htal[3],htal[4],htal[5],htal[6],htal[7],htal[8],htal[9]);
printf("waal %d %d %d %d %d %d %d %d %d\n"
,waal[1],waal[2],waal[3],waal[4],waal[5],waal[6],waal[7],waal[8],waal[9]);
#endif /*PRINTRANGES*/
numrotsc = -999;
iresiduereport = 0;
for(j=0;j<256;j++){realresiduereport[j]=0;}
iteststring = 0;
Lperiod = 0; /*allows keyboard . interrupt*/
countxyz = 0; /* number of xyz written to .kin */
oldmaxatmnamechar = 'a'; /*presume start with ATOM records*/
/*--define constants: array sizes and distance checks */
lastat = (MAXARR - 1);
ssmax = (MAXARR - 1);
hetmax = 1000;
/* --allowed connection distances for s-s, hetatom hookups, and mainchain*/
ssdist = 2.5;
bondst = 2.5;
/*--mainchain allowed sloppy for poorly determined structures */
/*ca-ca distance allowance: */
cadist = 5.0;
iresiduecnt = 0; /* for special cycles through all aminoacids */
/*------define starting values of control flags */
/*-- endfil: signels end of input file */
endfil = 0;
/* -- endsub: signels end of a subunit and another to come */
endsub = 0;
/* -- endchn: signals break in continuity */
endchn = 0;
/* -- discon: set when current residue is disconnected from previous one */
discon = 0;
/* -- endres: signels end of a residue, implies continuity if possible */
endres = 0;
/* -- first one shot declaration of very first piece of data on infile */
first1 = 1;
/* -- level relates to putting different subunits in different groups */
level = 0;
nlevel = 0;
/* -- icountres[level] number of . showing number of residues processed */
for(j=0;j<MAXlevels;j++)
{
icountres[j] = 0; /*number of . showing number of residues processed*/
ChainID[j][0] = '\0'; /*2char 070926*/
ChainID[j][1] = '\0'; /*2char 070926*/
ChainID[j][2] = '\0'; /*2char 070926*/
}
if(Lthispass==1)
{/*initialize residue counter, values will NOT be recreated in later passes*/
for(j=0;j<MAXlevels;j++)
{
icountresfirstpass[j] = 0;
}
LtypeP = 0; /*051201*/
LtypeN = 0;
LtypeH = 0;
LtypeW = 0;
LtypeU = 0;
}
/* -- irpass serves as the level indicator when level starts .gt. 0 */
irpass = 0;
/* -- 910131 ksave defines which character of subnam changed for multi- */
/* -- subunit names, ksave=0 is illegal, so forces subroutine subals to */
/* -- construct a unique name, at whatever level subals is first called!*/
ksave = 0;
/* -- levmsg if 0 when morsub .true. will print message about other levels*/
levmsg = 0;
/* -- morsub: signels that there may be multiple subunits, */
morsub = 1; /* set 0 when done last or only subunit*/
/* -- Ngroups: counts Number of groups outputed this PASS or this MODEL */
Ngroups = 0;
/* -- Ltopout: flags when masters, etc. written at top of kinemage*/
Ltopout = 0;
/* -- Nmodels: 0 for regular complex, ==1 for 1st member of nmr ensemble*/
/* unfortunately, rolls over at end of each MODEL before*/
/* processing of earlier one because prekin always reads*/
/* into next valid coordinate record as its fool-proof way*/
/* of really knowing where boundarys are. */
/* This is a pre-PDB uniformity sanity check.*/
Nmodels = 0;
/* -- Nresiduesin: counts number of residues in each chain as they come in*/
Nresiduesin = 0;
stonex = 0;
/*stonex signels that the 'texts' buffer has stored a possible next atom */
icount = 0; /*icount is total of individual residue sidechains read out */
delnum = 0;
delres = 0;
delnam = 0;
delsub = 0;
oldsub[0] = ' ';
oldsub[1] = ' ';
oldsub[2] = '\0';
nexsub[0] = ' ';
nexsub[1] = ' ';
nexsub[2] = '\0';
oldmod[0] = '\0';
nexmod[0] = '\0';
atomin = 0;
/*atomin set by a valid atom/hetatm read, so if 0: still in headers */
atpdbEOF = FALSE;
Lfoundresnum = 0; /*for fovea by residue number */
ihitend = 0; /*stores EOF info, used if EOF ends valid line*/
ihitaalibend = 0;
nmrmodel[0] = '\0'; /*reset NULL, set to char str of MODEL # */
/*this has to be before PDB MODEL record encountered*/
Nusermod = 0; /*020514 for pdbinfostuff in Lthispass==1 */
Lpointmasteralta = 0; /*030503*/
Lpointmasteraltb = 0;
Lpointmasteraltc = 0;
Lribidentity = 0; /*default, no colorsets defined yet 060929*/
if(Lthispass==1)
{/*initialize ribidentity's, values will NOT be recreated in later passes*/
for(j=0; j<MAXR; j++) {ribidentity[j][0] = '\0';} /*060929*/
}
/*------------------------------------------------------------------------*/
sprintf(temps,CRLF CRLF"...program running... this pass == %d",Lthispass);
pkintextinsert(temps); /*____TEXT.C*/
adjusttext(0); /* 0: force text liines onto screen ____TEXT.C*/
/*------------------------------------------------------------------------*/
inputflag = 0;
while(inputflag !=1)/*eventually inputflag==1 when 1st ATOM record reached*/
{/*read HEADER */
inputline = Getoneinputline(); /*PKININPT*/
if(atpdbEOF) inputflag = 1;
else if(inputline == 1) /* new input may be in buffer */
{/*checkline for atom record, interpret HEADER records*/
if(LpdbIO) /*040304*/
{/*just doing straight dump of pdb header to output*/
/*and transform of coords then dump of modified ATOM, HETATM records*/
inputflag = pdbInOutprocessing(texts); /*PKININPT*/ /*LpdbIO 040304*/
}
else
{/*checkline for doing pre-kinemage work*/
inputflag = checkline(texts); /*PKINCSUB*/
}
}
}
/*evidentually, 1st ATOM record has been reached...*/
Lnewpassflow = 0; /* now do work for this pass*/
if(!Lin_stdin) rewind(fpinput);
/*HEADER stuff has been examined for this pass*/
MAXaspectcode = Naspectcode; /*aspects inputted*/
Naspectnc = 0;
Naspectabc = 0;
if(Laspectnc || Laspectabc)
{/*add internal aspects to any HEADER inputted ones*/
/*HEADER inputted Naspectcode aspects*/
if(Laspectnc)
{
MAXaspectcode++;
Naspectnc = MAXaspectcode;
sprintf(aspectid[MAXaspectcode],"N-->C");
}
if(Laspectabc)
{
MAXaspectcode++;
Naspectabc = MAXaspectcode;
sprintf(aspectid[MAXaspectcode],"Sec Str");
}
}
if(Lplotpperptobase){Lkinmasters = 1;ballradius=(float)0.05;} /*030519*/
if(LpdbIO) /*040304*/
{
Lallrescycle = 0; /*no further work for LpdbIO processing of pdb file*/
}
else
{
Lallrescycle = 1; /*need at least one cycle for pre-kinemage work*/
}
if(Lallaminoacids) Numberresiduetypes = 21;
/*21 since 1st pass does all ca-ca */
if(Lallbases) Numberresiduetypes = 6;
/*(naba) 6 since 1st pass does backbone, 4 types, plus 1 misc category*/
OldTickCounts[1] = TickCount();
while(Lallrescycle)
{/*Lallrescycle*/
/*each cycle rewinds input file and goes through everything*/
sprintf(temps,CRLF); /*c*/ /*extra carriage return between cycles*/
pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/
adjusttext(1); /*PKMCTEXT.C PKPCTEXT.C*/
level = 0;
nlevel = 0;
atomin = 0; /*040406*/
/*atomin set by a valid atom/hetatm read, so if 0: still in headers */
if( (Lallaminoacids||Lallbases)
&& (iresiduecnt < Numberresiduetypes)
&& (Lthispass>1) ) /*040406 Lthispass criterion*/
{
/*find special residue name for this cycle*/
getresiduename();/*augments iresiduecnt, 1 for backbone/pseudobackbone*/
sprintf(temps,"now look for: %s"CRLF
,resid[1]);
pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/
adjusttext(1); /*PKMCTEXT.C PKPCTEXT.C*/
Lallrescycle = 1;
}
else if(Lresnumfovea)
{
Lallrescycle = 1; /*need 2nd cycle to apply distance to found residue*/
}
else
{
Lallrescycle = 0; /*on last cycle of Lthispass*/
}
OldTickCounts[2] = TickCount();
/************************************************************/
/*---loop all subunits; while input file has data: */
/*** cycle to here after process each subunit */
while( morsub == 1 && endfil == 0) /*100 continue*/
{/*within molecular coordinates: morsub == 1 && endfil == 0 */
if(level < MAXlevels-1) /*040406*/
{
level = level + 1;
nlevel++;
} /*040406*/
else
{
nlevel++;
sprintf(temps,"level would be %d, stuff now into max level %d"CRLF,nlevel,level); /*040504*/
pkintextinsert(temps);
adjusttext(1);
#ifdef UNIX_X11
fprintf(stderr,"level would be %d, stuff now into max level %d"CRLF,nlevel,level); /*040504*/
#endif
}
icountres[level] = 0;
Nresiduesin = 0;
/* this defines level == subunit or molecule number */
if(Lthispass>1)
{
Loutput = TRUE;
if(Lribbon && Lribbonnew) /*051025 new ribbon code*/
{/*Lribbonnew*/
if(typechainfirstpass[level]=='P'||typechainfirstpass[level]=='N')
{/*could have ribbon for this level*/
/*define a new section for this level */
if(thisribmodelptr == NULL) /*probably 1st time through...*/
{
thisribmodelptr = allocribmodelstructure(nmrmodel); /* global*/
/*nmrmodel safe for incoming atoms, but not for output of a model*/
/*
fprintf(stderr,"PKINCRTL level:%d, ribl[n==%d]==%d alloc thisribmodelptr == %ld\n",level,n,ribl[n],thisribmodelptr);
*/
}
/*global thisribmodelptr set here or by MODEL record in PKINCSUB*/
/*NOTE: as of 051025 PKINCSUB DOES NOT alloc ribmodelstruct */
if(thisribmodelptr != NULL)
{
trialribsectionptr = allocribsectionstructure(thisribmodelptr);
if(trialribsectionptr != NULL)
{
Lnewribbonstart = 1; /*090219 clear previousribbontype*/
thisribsectionptr = trialribsectionptr;
/*
fprintf(stderr,"PKINCRTL level:%d, ribl[%d]==%d alloc thisribsectionptr == %ld\n",level,n,ribl[n],thisribsectionptr);
*/
thisribsectionptr->type = typechainfirstpass[level];
thisribsectionptr->kind = kindchainfirstpass[level]; /*060114*/
thisribfragptr = allocribfragstructure(thisribsectionptr);
/*first fragment of this section*/
/*
fprintf(stderr,"PKINCRTL level:%d, ribl[%d]==%d alloc thisribfragptr == %ld\n",level,n,ribl[n],thisribfragptr);
*/
}
}
}/*could have ribbon for this level*/
if(thisribfragptr == NULL)
{
Lribbonnew = 0; /*cannot do newribbon code */
/*all hetatms, or not enough Prot or Nuc to do ribbon 090219*/
#ifdef UNIX_X11
fprintf(stderr,"CANNOT do a ribbon for this file"CRLF);/*090219*/
if(Lribnhet) {Lribbon = 0;} /*FAIL for RCSB PDB ribbon command*/
/*so failure will be evident in batch processing mode! */
#endif
}
}/*Lribbonnew*/
if(Lbestribbon) /*011030*/
{
/*BEWARE: PREKIN confusion between chain and coordinate block 050923*/
/*e.g. subunits vs models and mixtures of the two */
if(Lexplicitribbonpossible[level] || Lmodel) /*Lmodel 050923*/
{/*Lmodel flag is stupid patch to get ribbon ranges for all models*/
/* this may cause problems with nmr struct with big hetatm molecs */
Lexplicitribbon = 1;
explicitribbontype = 3; /*COIL*/
explicitribbonidentity[0] = '\0'; /*default: no ID 060929*/
Lonestrandcoil = 1;
Lfudgedwidth = 0;
Lbetaarrows = 1;
Lautoribbon = 1;
Ledgedribbon = 1;
Lcrosstie = 0;
Lskeinedribbon = 0;
ribwidcoil = 1;/*explicit range ribbon with beta arrows:*/
/* before 050206 was coil==0*/
}
else
{
Lexplicitribbon = 0;
Lonestrandcoil = 0;
Lfudgedwidth = 1;
Lbetaarrows = 0;
Lautoribbon = 0;
Ledgedribbon = 1;
Lcrosstie = 0;
Lskeinedribbon = 0;
ribwidcoil = 1.0;
}
}
}
else /*Lthispass==1*/
{
if(Nmodels < 3)
{/*first pass Nmodels==0 for multi-subunit complex*/
/* and Nmodels never incremented*/
/*first pass Nmodels==1 for 1st nmr MODEL ensemble member*/
/* incremented at end of 1st nmr MODEL when run into 2nd*/
/* but this is before prekin is allowed to process first member*/
Nchainfirstpass = Nchainfirstpass + 1;
}
Loutput = FALSE;
}
/*
sprintf(temps,CRLF"PKINCRTL Lthispass %d, Nmodels %d, Nchainfirstpass %d, ichainthispass %d"
,Lthispass,Nmodels,Nchainfirstpass,ichainthispass);
pkintextinsert(temps);
adjusttext(1);
*/
if(gflag[0] == ' ' || gflag[0] == '0' ) /*gflag[0]==1 means do all chains*/
{/* not necessarily doing all subunits*/
/*chains done as marked in the order as recognized by PREKIN*/
/*This is set in subunit choice dialog box of GUI*/
/*Different control than commandline: -chain A, handled by rangecontrol*/
if(gflag[level] == '_') /* simulate end of data */
{
morsub = 0;
endfil = 1;
/*---------------------------------------------------------------*/
sprintf(temps,"simulate data end at subunit or molecule %d"CRLF,level);
pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/
adjusttext(1); /*PKMCTEXT.C PKPCTEXT.C*/
/*---------------------------------------------------------------*/
goto loopend; /* with morsub and endfil set to break out of loop */
}
if(gflag[level] == ' ' || gflag[level] == '0' )
/* not doing this subunit*/
{
Loutput = FALSE;
/*---------------------------------------------------------------*/
sprintf(temps,"scanning but not outputting subunit or molecule %d"CRLF,level);
pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/
adjusttext(1); /*PKMCTEXT.C PKPCTEXT.C*/
/*---------------------------------------------------------------*/
}
}/* not necessarily doing all subunits*/
/*--------------within a subunit----------------------------------------*/
/*--while within a subunit, cycle this while loop */
/*set conditions for beginning of each real subunit loop */
setsubunitconditions();/*CSUB this resets most counters for virtual subunit*/
Lfirstrecordinlevel = 1; /*lurks for that first atom record*/
/*--------------------WORKING ON CHAIN PRINT STATEMENT-----------------------*/
sprintf(temps,CRLF"working on coordinates for coordinate block %d %s "
,level,nmrmodel);
pkintextinsert(temps); /*____TEXT.C*/
adjusttext(0); /* 0: force text lines onto screen ____TEXT.C*/
/*---------------------------------------------------------------------------*/
OldTickCounts[3] = TickCount();
/****************** while(endsub == 0) ***********************/
while(endsub == 0) /* 130 continue */
{ /* within a subunit: endsub == 0 */
/*loop all residues/blocks of atoms of current subunit */
OldTickCounts[4] = TickCount();
Latomnext = 0; /*030515*/
endres = 0;
discon = 0;
/* discon...nected residue, default is 0, connected to previous */
if (endchn == 1)
/*this residue flagged as discontinuous with previous one */
{
discon = 1;
endchn = 0;
}
iskip = 0;
n = 0; /*atom counter started afresh for this next residue */
atarraymax = 0; /* limited number of atoms in a residue */
resinloop = 0; /*separate loop control so can look ahead in input file*/
/*read through until hit a valid atom/hetatm or EOF past each residue*/
/*set the vector tail(==base) to each atom to be itself*/
/*avoid past historical values for the atom base[] if not set currently*/
for(j=0; j<= lastat-8; j++) {base[j] = j;} /*061001*/
/*logicals concerned with ca-ca only */
catrue = 0; /*set catrue = TRUE when encounter a ca (or c4',or p 061001)*/
if(LpdbCACOpdb) {caonly = 0;} /*doing Calphas--> all mainchain 030202*/
else {caonly = 1;}
/*set caonly = FALSE when encounter something besides a ca*/
/*note: caoutl controls whether only ca will be connected in mc output*/
while( (resinloop == 0) && (atarraymax == 0) )
{/*residue input, while resinloop == 0 */
/*--------within a residue-----------------------------------------*/
OldTickCounts[7] = TickCount(); /*input record*/
n = n + 1; /* atoms of this residue counter */
/*lastat reserved for possible connection atom in previous residue */
/* lastat-1,lastat-2,lastat-3 for possible alternate conf: a,b,c */
/* lastat-4,lastat-5,lastat-6 lastat-7 for ca - ca connections */
if(n == (lastat-8) ) atarraymax = 1;
/*array size limit to match expected max residue/group size ; */
nnow = n; /*nnow keeps value of n for use after do loop finished */
delnum = 0; /* residue ends at residue number change */
/*delnum flagged normally by evalatomrecord(), */
/*non-PDB char in number flagged by readbrkatmrecord()*/
delres = 0; /* residue ends at residue name change BUT */
/*011208 sequence heterogeneity sc res change but same num*/
/*so delres NOT robust*/
/* not really needed anyway if number or insertion indicator changes*/
/*check if texts buffer holds the next atom, i.e. the to be n==1 atom */
/*when starting a new residue. */
if ( n > 1 || stonex == 0)
/*if valid atom being held in texts buffer, don't do this read section*/
{/*input a record into texts buffer*/
/*here there is no stored atom in texts, */
/*so have to beware of changes */
/*in name of record or name of subunit that will affect processing*/
/*read in record as character string into 'texts' buffer */
/*this is the only place where the input file is read! */
inputline = Getoneinputline(); /*PKININPT*/
if(atpdbEOF)
{/*EOF*/
endfil = 1; /*end of the file*/
morsub = 0; /*no more subunits expected*/
endchn = 1;
endres = 1;
endsub = 1;
/*note that endsub means multiple subunits, */
/*which may not be true here */
resinloop = 1; /* declare at end of a residue */
}/*EOF*/
if(inputline == 1) /* new input may be in buffer */
{/*checkline for atom record*/
inputflag = checkline(texts); /*PKINCSUB*/
if( inputflag != 1) /* return != 1 if not atom, not hetatm*/
{/*check out line without coord info, allow upper or lower case*/
evalnonatmrecord(); /*PKINCSUB*/
/*uses inputflag as returned from checkline*/
iskip = 1;
/*prekin historically just keeps reading until new residue*/
/*at which time it closes and processes the previous residue*/
/*Then, if has flags set, it goes on to process the chain*/
/*or, of course, if it hits an EOF*/
}
else /* checkline returned == 1 */
{/* valid atom or hetatm record */
atomin = 1;
iskip = 0;
/*for ease and consistency upper case converted to lower*/
/*convertcase(texts);*/ /*PKINCSUB*/
/*do this inside of readbrkatmrecord()*/
}/* valid atom or hetatm record */
}/*checkline for atom record*/
else /* Getoneinputline returned 0 */
{/*no current line*/
resinloop = 1; /*declare at end of a residue*/
iskip = 1; /* no coordinate line to process */
n = n - 1; /* back off the counter so could keep reading */
/*with return of 1, evalnonatmrecord() does n=n-1 */
}/*no current line*/
}/*input a record into texts buffer*/
ncountticks = TickCount();
accumticks[7] = accumticks[7] + (ncountticks - OldTickCounts[7]);
OldTickCounts[8] = ncountticks; /*valid record*/
if(resinloop == 0 && iskip == 0)
{/* valid record */
/*now do a formated reread of the line in texts */
readbrkatmrecord(); /*PKINCSUB.c*/
/*valid read now means inside a chain, */
/*with this atom also held in texts */
stonex = 1; /*so stonex is indeed true */
evalatomrecord(); /*PKINCSUB.c*/
if(resinloop == 1) break; /* break from readinloop */
/*within a residue or block of atoms, */
/* PREKIN: treat hetatm sets as residues */
/* waters are individual residues */
/* Metals(?): hetatm residue with one atom that is not a water */
/* is given a 3-D Unpickable cross as well as a center dot */
/*ca logicals */ /*munged in honor of GFPchromophore 070801*/
if( atom[n][1] =='c'&&atom[n][2] =='a'
&&(atom[n][3] ==' '||isdigit(atom[n][3]))) catrue = 1; /*070801*/
else caonly = 0;
if( atom[n][1] =='c'&&atom[n][2] =='4'
&&(atom[n][3] =='*'||atom[n][3] =='\'')) catrue = 1;
if( atom[n][1] =='p'&&atom[n][2] ==' '
&&(atom[n][3] ==' '||atom[n][3] =='\'')) catrue = 1; /*061001*/
}/* valid record*/ /* n is atom counter: */
if (iskip == 1 && atpdbEOF == 0 )
{
resinloop = 0;
/* skip useless record, e.g. HEADER */
}
ncountticks = TickCount();
accumticks[8] = accumticks[8] + (ncountticks - OldTickCounts[8]);
}/* end-of residue input, while resinloop ==0 controlled */ /*goto 132*/
ncountticks = TickCount();
accumticks[4] = accumticks[4] + (ncountticks - OldTickCounts[4]);
OldTickCounts[5] = ncountticks;
OldTickCounts[9] = ncountticks;
/*--------------------------------------------------------------------*/
if( (resinloop == 0) && (atarraymax == 1) )
{
/*150 continue*/
/*only get in here if at limit of atoms/residue, */
/*and not hit an end to the residue */
/*c*/ sprintf(alertstr," %s %s %d has at least %d atoms, the array limit"
,res[n],sub[n],num[n],n);
/*m*/ DoReportDialog();
/*c*/ sprintf(alertstr," processing will continue, "
"but results may be wierd");
/*m*/ DoReportDialog();
}
/*--------------------------------------------------------------------*/
/*brought in current residue*/
Nresiduesin++;
/*maxatm keeps track of how many atoms belong in this residue */
maxatm = nnow - 1;
/*920512 let evalatomrecord() treat EOF at end of valid line as a */
/* TER on a phantom next line */
/*it is n-1 since reads one atom into next residue each time! */
/*nnow holds the last value of n of the above loop, last atom inputed */
/*or 1 past last atom if hit a 'ter', and */
/* 'texts' holds last record as char string */
/*NB 070801 if NOT at end of chain, evalatomrecord() stored nnow th */
/* as atomnext, xnext, ynext, znext, etcnext... */
finishres = 0;
/* set flag to process residue, reset later when finish this residue */
/*maxatm = 0 means passing through here with no stored residue so */
/* skip any attempt to connect atoms in the stored residue! */
if(maxatm == 0) finishres = 1;
/*----------------------------------------------------------------------------*/
residuetype = ' '; /*not even a guess */
if(maxatm > 0) /*guess residuetype: P,N,H,W,U, , 061006*/
{
#ifdef GFPchromophore /*070801*/ /*Perhaps do this as Lspecialresidue ???? */
LGFPchromophore = 0; /* unset the flag */
Lunknownresidue = 0;
Lunuseableresidue = 0;
#endif /*GFPchromophore 070801*/
nP = 0;
nN = 0;
if(maxatm == 1)
{
if(isawater()) {residuetype = 'W';}
else if( atom[1][1] == 'o' && atom[1][2] == '3'
&&(atom[1][3] == '*' || atom[1][3] == '\'') )
{residuetype = 'N';} /*lone previous nucl O3* 070512*/
else {residuetype = 'H';}
}
else
{
if(strstr(aaList, res[maxatm]) ) {residuetype = 'P';}
else if(strstr(naList, res[maxatm]) ) {residuetype = 'N';}
else if(atom[maxatm][0] == 'a')
{/*atom record but residue name not in our lists, try to guess*/
for(j=1; j<=maxatm; j++)
{/*look for a subset of Protein and Nucleic type atom names*/
if ( atom[j][1] == 'c' && atom[j][2] == 'a') {nP++;}
else if( atom[j][1] == 'c' && atom[j][2] == ' ') {nP++;}
else if( atom[j][1] == 'n' && atom[j][2] == ' ') {nP++;}
else if( atom[j][1] == 'p' && atom[j][2] == ' ') {nN++;}
else if( atom[j][1] == 'c' && atom[j][3] == '\'') {nN++;}
}
if (nP > nN) {residuetype = 'P';}
else if(nP < nN) {residuetype = 'N';}
else {residuetype = 'U';}
}
#ifdef GFPchromophore /*070801*/ /*Perhaps do this as Lspecialresidue ????*/
else if(Lthispass > 1) /*guess if this hetatm a GFPchromophore*/
{
if(typechainfirstpass[level]=='P')
{
LCA1=0;LCA2=0;LCA3=0;LNN1=0;LNN2=0;LNN3=0;
LCC1=0;LCC2=0;LCC3=0;LCO1=0;LCO2=0;LCO3=0; /*070801*/
for(j=1; j<=maxatm; j++)
{/*look for GFPchromophore type atom names*/
/*unfortunately, other hets, e.g. 2INZ/NAP match... */
/*so have to be very detailed*/
if(atom[j][1]=='c' && atom[j][2]=='a')
{
if(atom[j][3]=='1') {LCA1=1;}
if(atom[j][3]=='2') {LCA2=1;}
if(atom[j][3]=='3') {LCA3=1;}
}
if(atom[j][1]=='n' && atom[j][3]==' ')
{
if(atom[j][2]=='1') {LNN1=1;}
if(atom[j][2]=='2') {LNN2=1;}
if(atom[j][2]=='3') {LNN3=1;}
}
if(atom[j][1]=='c' && atom[j][3]==' ')
{
if(atom[j][2]=='1') {LCC1=1;}
if(atom[j][2]=='2') {LCC2=1;}
if(atom[j][2]=='3') {LCC3=1;}
}
if(atom[j][1]=='o' && atom[j][3]==' ')
{
/*if(atom[j][2]=='1') {LCO1=1;} missing==link*/
if(atom[j][2]=='2') {LCO2=1;}
if(atom[j][2]=='3') {LCO3=1;}
}
}
if( LCA1&&LCA2&&LCA3&&LNN1&&LNN2&&LNN3
&&LCC1&&LCC2&&LCC3 &&LCO2&&LCO3)
{ /*very likely to be GFPchromophore embedded in Protein*/
/*alternate atoms can increase number of hits */
LGFPchromophore = 1; /*070801*/
residuetype = 'H';/*otherwise not set, use for ribnhet*/
}
if(LGFPchromophore) /*reset the hetatm to be atom records*/
{
for(j=1; j<=maxatm; j++)
{
sprintf(name[j],"atom ");
}
}
}
}
#endif /*GFPchromophore 070801*/
else
{/*hetatm record, punt...*/
residuetype = 'H';
}
}
}
if(Nresiduesin == 1)
{/*first residue of chain: invent chain name*/
/*sub[]: blank or 1 char chain identifier and/or nmrmodel(#) <=5 char*/
if(sub[maxatm][1] == ' '){ChainID[level][1] = 'A';}/*right justified*/
else {ChainID[level][0] = sub[maxatm][0]; /*case sensitive pdb v3.0*/
ChainID[level][1] = sub[maxatm][1];} /*070926*/
if(sub[maxatm][1] == ' ' && mod[maxatm][0]=='\0')
{/*nothing to use, topID == null*/
topID[0] = '\0';
modelnumber[0] = '\0'; /*050121 model associated with this chain*/
}
else if(mod[maxatm][0]!='\0')
{/*there is a model number available*/
/*use: mod[maxatm] for the current residue */
/*instead of: nmrmodel which changes when MODEL delinates end of res */
/*strcpy(modelnumber,nmrmodel);*/ /*050121*/
strcpy(modelnumber,mod[maxatm]); /*051128*/
/*050121 model associated with this chain == most recent MODEL*/
if(sub[maxatm][1] != ' ')
{/*non-blank chain identifier, topID == chainID & model# */
topID[0] = sub[maxatm][0];
topID[1] = '_'; /*spacer*/
for(j=1; j<MAXmodchr; j++) /*start at 1 to*/
{/*drop leading blank of mod, 050121 keep char 0,1 of topID*/
topID[j+1] = mod[maxatm][j];/*top group indicator for output*/
}
}/*non-blank chain identifier*/
else
{/*no one letter chainID in sub[][], topID == the model number*/
for(j=1; j<MAXmodchr; j++) /*start at 1 to*/
{/*drop leading blank of mod*/
topID[j-1] = mod[maxatm][j]; /*top group indicator for output*/
}
}/*no one letter chainID in sub[][], topID == the model number*/
}/*there is a model number available*/
else if(sub[maxatm][0] != ' ')
{/*there is only a chain identifier, topID == chain identifier*/
topID[0] = sub[maxatm][1]; /*top group indicator for output*/
topID[1] = '\0';
modelnumber[0] = '\0'; /*050121 model associated with this chain*/
}/*there is only a chain identifier, topID == chain identifier*/
/*-----------ADD ON TO WORKING ON CHAIN PRINT STATEMENT-----------------------*/
sprintf(temps," ,chain code|%s|%s| ",sub[maxatm],mod[maxatm]);
pkintextinsert(temps);
adjusttext(1);
/*----------------------------------------------------------------------------*/
}/*first residue of chain: invent chain name*/
if(Lthispass>1 && Loutput)
{/*Loutput*/
while(finishres == 0)
{/*working on a residue: finishres == 0 */
/*in a residue: see if we want it if we are in range control */
/*fprintf(stderr,"PKINCRTL level==%d calls rangecontrol() riboutl==%d, %s %s %s\n",level,riboutl,atom[maxatm],res[maxatm],sub[maxatm]); */ /*KEEP STDERR*/
rangecontrol(); /*PKINCSUB*/
/*
fprintf(stderr,"PKINCRTL level==%d return rangecontrol() riboutl==%d\n",level,riboutl);
*/
if( (mutoutl != 0 || supoutl != 0)
||( (Lcbetadev||Ltaudev)&&typechainfirstpass[level]=='P'
&& CompArgStr(name[maxatm],"atom",4)
) /*011029 check for P & atom*/
/* NB maxatm last of current residue, n is first of next residue*/
)
{/*011029 check for P protein*/
mutateresidue(); /*PKINCSUB*/
}
/* FOVEA adds to rangecontrols, sets rangel and other logicals */
if(FOVEA) checkfocus(); /*PKINCSUB*/
if( rangel == 0 ) finishres = 1;
if(finishres == 1) break; /*----skip this residue*/
/*PREKIN uses distances within a residue for connectivity, */
/* not library connections */
/*continuing with this residue---*/
/*keep track of encounters of all ribbon guide atoms in this residue*/
o3snew = 0; /*040229 for nucleic ribbon extention*/
c1snew = 0;
c3snew = 0;
nupnew = 0;
canew = 0;
cbnew = 0; /*041205*/
onew = 0;
Lalts = 0; /*flag for alt conf in this residue*/
altstd = 0; /*standard conformation flag*/
/*reset alternate conformation flags */
/* these are only used to connect back to a previous residue*/
altcfa[0] = 0;
altcfb[0] = 0;
altcfc[0] = 0;
altcfa[1] = 0;
altcfb[1] = 0;
altcfc[1] = 0;
/* reset mc h-bond flags for this residue */
tfn2 = FALSE;tfca2 = FALSE;tfc2 = FALSE;tfo2 = FALSE;tfnh2 = FALSE;
/* if h-bonds not being done, carbonyl not stored for next either*/
if( !hboutl) tfc1 = FALSE;
/*do all original atoms, */
/* don't do created ones for ring closure, etc, on second pass*/
maxcounter = maxatm;
for(natom=1 ; natom <= maxcounter ; natom++) idupl[natom] = natom;
/*set each atom duplicated flag to the atom itself */
/* as atoms are duplicated at the end of the list, their */
/* idupl flag is set to the original atom number so sorting*/
/* can know who each duplicated atom really is. */
ncountticks = TickCount();
accumticks[9] = accumticks[9] + (ncountticks - OldTickCounts[9]);
OldTickCounts[6] = ncountticks;
/*putative slow step**********************************************************/
/*
fprintf(stderr,"putative: mcoutl %d, scoutl %d, waoutl %d, (htoutl %d, %c),(ssscoutl %d, %c%c%c)\n"
,mcoutl,scoutl,waoutl,htoutl,name[maxatm][0]
,ssscoutl,res[maxatm][0],res[maxatm][1],res[maxatm][2]);
*/
if( mcoutl
|| scoutl
|| waoutl /*971031*/
|| (htoutl && (name[maxatm][0]=='h' || residuetype=='H')) /*070801*/
|| (ssscoutl &&
res[maxatm][0]=='c'&&res[maxatm][1]=='y'&&res[maxatm][2]=='s') )
{/*speed filter*/
if(htoutl && name[maxatm][0]=='a' && residuetype=='H') /*070801*/
{ /*special case, eg GFPchromophore, converted to atom but still het*/
mcoutl = 1;
scoutl = 1; /*070801 output residue as if it were still a het*/
}
for(iscan = 1; iscan <= 2 ; iscan++) /*double pass*/
{/*make connections for this residue, */
/* 2 passes helps some non-standard order problems */
/*
sprintf(alertstr,"make base connection for natom= %d"
CRLF"%s|%s|%s|%s|%s|%d|%s|%f %f %f",natom,name[natom],Anum[natom],atom[natom]
,res[natom],sub[natom],num[natom],rins[natom],x[natom],y[natom],z[natom]);
DoReportDialog();
*/
/*
printf("make base connection for natom= %d\n",natom);
printf("%s|%|%s|%s|%s|%d|%s|\n"
,name[natom],Anum[natom],atom[natom] Anum hybrid36 071001
,res[natom],sub[natom],num[natom],rins[natom]);
printf(" %f %f %f\n" ,x[natom] ,y[natom] ,z[natom]);
*/
for(natom=1 ; natom <= maxcounter ; natom++)
{/*current atom: sequentially looked at in this residue */
if(iscan == 1) {base[natom] = 0;}
/* initially set as NO vector drawn to this atom */
/*make atmcpy, so can rearrange and */
/*play with atom name character str. */
for(j=0 ; j<=5 ; j++) {atmcpy[j] = atom[natom][j];}
#ifdef OLDCODE
/*070520 unclear that this is needed, would need work for new names*/
/*since now using isahydrogen() */
/*if atom is labeled as a deuterium, rename the copy to be an h:*/
if(atmcpy[1] == 'd' ) {atmcpy[1] = 'h';}
/*if atom is labeled as a NMR pseudo atom, */
/*rename the copy to be an h:*/
if(atmcpy[1] == 'q' ) {atmcpy[1] = 'h';}
#endif
/*screen for alternate conformation letters at end of atoms: */
/*s*/ screenaltconf();
/*residue-by-residue storage of mc h-bond calculating info */
/*H*/ if( hboutl )
{
if(iscan == 1)
{
if( name[natom][0] == 'a' )
{
/*ss*/ if( decidemainside(natom) )
{