-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKINRIBB.c
4257 lines (3846 loc) · 189 KB
/
PKINRIBB.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*/
/*PKINRIBB.c*/
/*(jEdit options) :folding=explicit:collapseFolds=1:*/
#include "PKIN.h"
#include "PKINCRTL.h" /*070801*/
#define PKINRIBB
#include "PKINRIBB.h"
#undef PKINRIBB
/*{{{--NOTE-- version, etc. */
/*051025 for now, just work with one model, and let prekin's levels==sections*/
/*PKINCRTL: define a new section each time prekin increments its level */
/* Lribbonnew is conditional for the new ribbon code */
/*need to PKININIT the globals this...ptr = NULL; structures are malloc-ed*/
/*}}}*/
/*{{{--NOTE-- number of strands: */
/*this routine always computes side guide points for 7 strands*/
/*middle: m0, flanking a1,a2, and b3,b4, and c5,c6 */
/*for stranded ribbons, 3 use middle plus b at full width */
/* while 5 use middle, a intermediate, b at full width */
/* this lets beta arrowheads work both for explict beta */
/* as well as stranded, e.g. for VRML 3D-printer ribbons */
/*for explicit ribbons, width for a: alpha, b: beta, c: coil */
/* except we've always used single fat strand for coil, not flat coil*/
/*Faced curvature dependent ribbons using c at calc width */
/* can exist along with explicit faced ribbons using a and b */
/*the widen-factor for each strand is calc from appropriate width */
/*The same curvature calc is used for both ribbon widen-factor and */
/* displacement factor radially out in tightly curled regions */
/* This confuses fudge for widen and fudge for displacement.*/
/* Curvature Dependent Variable Width, Radially Displaced Ribbons */
/*use "widen" for amount of width offset of coil toward alpha or beta*/
/*use "widthfactor" for the percent fudge */
/*for amount of radial offset of usual to curled guide point,*/
/*use "radialfactor" for that percent fudge */
/*Historically, prekin could do any number of strands up to 9 */
/* 9 stranded ribbons were very elegant on PS300 vector graphics */
/* but were probably never used later. Evens were very rare if ever */
/* 3 are goood for low-load kinemages, 5 make good VRML 3D-constructs */
/*}}}*/
/*{{{--CONTROLS-- types of ribbons: */
/*see PKINDLOG/EndRibbonDialog() */
/*Faced ribbons can be explicitly defined or have curvature-dependent-width*/
/*Lskeinedribbon controls stranded vs faced */
/*explicitribbontype is a residue's assigned secondary structure*/
/*explicitribbonidentity residue's sec. str. identity in a PDB SHEET record*/
/*stranded: nstrnd==3 and nstrnd==5 do curvature dependent variable width */
/* additional control for beta-like arrowheads */
/*faced: curvature dependent variable width always available, */
/* explicit alpha, beta (fake beta for nucleics) done when 2D regions given*/
/*20140520 redefined -spline vs -skeins, -spline now simple vector mid line*/
/*}}}*/
/*{{{****allocation of structures: model, section, frag, res, pnt ****/
/*{{{allocribmodelstructure()*************************************************/
ribmodelstruct* allocribmodelstructure(char* modnum)
{
struct ribmodelstruct *newribmodelptr;
int ireturn = 0; /*if successful, will be set == 1 */
newribmodelptr = (ribmodelstruct*)malloc(sizeof(struct ribmodelstruct));
if(newribmodelptr != NULL)
{/*successfull allocation*/
if(firstribmodelptr == NULL) /*initiate this set of structures*/
{
firstribmodelptr = newribmodelptr;
lastribmodelptr = newribmodelptr; /*new one is as-of-now the last one*/
firstribmodelptr->previousptr = NULL;
firstribmodelptr->nextptr = NULL;
}
else /*set references between last and new structures*/
{
lastribmodelptr->nextptr = newribmodelptr;
newribmodelptr->previousptr = lastribmodelptr; /*old last one*/
}
/*reset who is current global*/
/*thisribmodelptr = newribmodelptr;*/ /*identify as a global*/
newribmodelptr->nextptr = NULL; /*no others beyond this one*/
newribmodelptr->firstribsectionptr = NULL; /*initialize members*/
newribmodelptr->lastribsectionptr = NULL;
strcpy(newribmodelptr->modelstr,modnum); /*nmrmodel M###*/
ireturn = 1;
}
/*free(newribmodelptr);*/
/*newribmodelptr = NULL;*/
return(newribmodelptr);
}
/*___allocribmodelstructure()_____________________________________________}}}*/
/*{{{allocribsectionstructure()***********************************************/
ribsectionstruct* allocribsectionstructure(ribmodelstruct* thismodelptr )
{
struct ribsectionstruct *newribsectionptr;
int ireturn = 0; /*if successful, will be set == 1 */
newribsectionptr = (ribsectionstruct*)malloc(sizeof(struct ribsectionstruct));
if(newribsectionptr != NULL)
{/*successfull allocation*/
if(thismodelptr->firstribsectionptr == NULL)
{/*initiate this set of structures*/
thismodelptr->firstribsectionptr = newribsectionptr;
thismodelptr->lastribsectionptr = newribsectionptr;
newribsectionptr->previousptr = NULL; /*first of its peers*/
newribsectionptr->nextptr = NULL;
newribsectionptr->number = 0; /*090219*/
}
else /*set references between last and new structures*/
{
newribsectionptr->previousptr = thismodelptr->lastribsectionptr;
thismodelptr->lastribsectionptr->nextptr = newribsectionptr;
/*newribsectionptr->previousptr->nextptr = newribsectionptr;*/
/*link previous*/
newribsectionptr->nextptr = NULL;
thismodelptr->lastribsectionptr = newribsectionptr;
/*now last child of parent*/
}
/*reset who is current global, previous is known as previous*/
/*thisribsectionptr = newribsectionptr;*/ /*identify as this... global*/
/*reset current connections*/
newribsectionptr->ribmodelptr = thismodelptr; /*store parent*/
newribsectionptr->firstribfragptr = NULL; /*initialize members*/
newribsectionptr->lastribfragptr = NULL;
newribsectionptr->chainID[0] = ' '; /*2char 070926*/
newribsectionptr->chainID[1] = ' '; /*2char 070926*/
newribsectionptr->chainID[2] = '\0'; /*2char 070926*/
newribsectionptr->type = 'U'; /*Uknown,Protein,Nucl*/
newribsectionptr->kind = 'U'; /*Uknown,Dna,Rna*/
ireturn = 1;
}
/*free(newribsectionptr);*/
/*newribsectionptr = NULL;*/
return(newribsectionptr); /*NULL if alloc failed*/
}
/*___allocribsectionstructure()________________________________________}}}*/
/*{{{allocribfragstructure()***********************************************/
ribfragstruct* allocribfragstructure(ribsectionstruct* thissectionptr )
{
struct ribfragstruct *newribfragptr;
int ireturn = 0; /*if successful, will be set == 1 */
newribfragptr = (ribfragstruct*)malloc(sizeof(struct ribfragstruct));
if(newribfragptr != NULL)
{/*successfull allocation*/
if(thissectionptr->firstribfragptr == NULL)
{/*initiate this set of structures*/
/*register with parent*/
thissectionptr->firstribfragptr = newribfragptr;
thissectionptr->lastribfragptr = newribfragptr;
newribfragptr->previousptr = NULL; /*first of its peers*/
newribfragptr->nextptr = NULL;
}
else /*set references between last and new structures*/
{
newribfragptr->previousptr = thissectionptr->lastribfragptr;
newribfragptr->previousptr->nextptr = newribfragptr; /*link previous*/
newribfragptr->nextptr = NULL;
thissectionptr->lastribfragptr = newribfragptr;
/*now last child of parent*/
}
/*reset who is current global, previous is known as previous*/
/*thisribfragptr = newribfragptr; */ /*identify as this... global*/
/*reset current connections*/
newribfragptr->ribsectionptr = thissectionptr; /*store parent*/
newribfragptr->firstribresptr = NULL; /*initialize members*/
newribfragptr->lastribresptr = NULL;
/*initialize ribbon position number*/
newribfragptr->number = 0; /*number of ribresidues 051112*/
newribfragptr->splineset=NULL;
newribfragptr->guideset=NULL;
newribfragptr->residueset=NULL;
/*array of pointers to residues of this frag*/
ireturn = 1;
}
/*free(newribfragptr);*/
/*newribfragptr = NULL;*/
return(newribfragptr); /*NULL if alloc failed*/
}
/*___allocribfragstructure()___________________________________________}}}*/
/*{{{allocribresstructure()************************************************/
ribresstruct* allocribresstructure(ribfragstruct* thisfragptr )
{
struct ribresstruct *newribresptr;
int iok = 0; /*if successful, will be set == 1, and return ribresstruct*/
newribresptr = (ribresstruct*)malloc(sizeof(struct ribresstruct));
if(newribresptr != NULL)
{/*successfull allocation*/
if(thisfragptr->firstribresptr == NULL)/*initiate this set of structures*/
{
thisfragptr->firstribresptr = newribresptr;
thisfragptr->lastribresptr = newribresptr; /*register with parent*/
thisfragptr->number = 1; /*first position will be a dummy*/
newribresptr->previousptr = NULL; /*first of its peers*/
newribresptr->nextptr = NULL;
}
else
{
newribresptr->previousptr = thisfragptr->lastribresptr; /*set peers*/
newribresptr->previousptr->nextptr = newribresptr; /*link previous*/
newribresptr->nextptr = NULL;
thisfragptr->lastribresptr = newribresptr;/*now last child of parent*/
thisfragptr->number++; /*count of positions: dummy and real residues*/
}
newribresptr->ribfragptr = thisfragptr; /*store parent*/
(thisfragptr->ribsectionptr)->number++; /*090219 residues in section cnt*/
newribresptr->guideptr = NULL; /*initialize members*/
newribresptr->middlptr = NULL;
newribresptr->axialptr = NULL;
newribresptr->avecaptr = NULL;
newribresptr->cvecnptr = NULL;
newribresptr->dvecnptr = NULL;
newribresptr->npeptptr = NULL;
newribresptr->hnpepptr = NULL;
newribresptr->calphptr = NULL;
newribresptr->ccarbptr = NULL;
newribresptr->ocarbptr = NULL;
newribresptr->cbetaptr = NULL;
newribresptr->pnuclptr = NULL;
newribresptr->o5ribptr = NULL;
newribresptr->c1ribptr = NULL;
newribresptr->c3ribptr = NULL;
newribresptr->o3ribptr = NULL;
newribresptr->c4ribptr = NULL;
/*NOTE the above are NOT allocated, must be when atoms brought in */
newribresptr->widthpossible = 0;
newribresptr->width = 0;
newribresptr->number = thisfragptr->number;
/* # of residue along spline, incl padded ends*/
/* this number belongs to this residue*/
newribresptr->numrib = 0; /*residue number, as given in pdb file*/
newribresptr->resrib[0] = '\0';
newribresptr->subrib[0] = '\0';
newribresptr->subrib[1] = '\0';
newribresptr->subrib[2] = '\0';
newribresptr->rinsrib[0] = '\0';
newribresptr->Bvalrib = 0;
newribresptr->Lstub = 0;
newribresptr->explicit = 0;
newribresptr->extend = 0;
newribresptr->COside = 0;
newribresptr->azmangle = 0; /*for Calpha+COazmuthalangle 100322*/
/*alloc the vectors needed to define the splines*/
if(
(newribresptr->avecaptr=allocribpntstructure(newribresptr))!=NULL
&&(newribresptr->cvecnptr=allocribpntstructure(newribresptr))!=NULL
&&(newribresptr->dvecnptr=allocribpntstructure(newribresptr))!=NULL
&&(newribresptr->guideptr=allocribpntstructure(newribresptr))!=NULL
&&(newribresptr->middlptr=allocribpntstructure(newribresptr))!=NULL
&&(newribresptr->axialptr=allocribpntstructure(newribresptr))!=NULL
) {iok = 1;} /*still good*/
else{iok = 0;} /*fault*/
if(!iok){newribresptr=NULL;} /*ugh! garbage! should de-allocate*/
}
return(newribresptr); /*new ptr or NULL if any alloc failed*/
}
/*___allocribresstructure()_______________________________________________}}}*/
/*{{{allocribpntstructure()***************************************************/
ribpntstruct* allocribpntstructure(ribresstruct* thisresptr )
{
struct ribpntstruct *newribpntptr;
int ireturn = 0; /*if successful, will be set == 1 */
newribpntptr = (ribpntstruct*)malloc(sizeof(struct ribpntstruct));
if(newribpntptr != NULL)
{/*successfull allocation*/
/*parent takes care of assigning this point to the appropriate atom*/
newribpntptr->ribresptr = thisresptr; /*store parent*/
newribpntptr->name[0] = '\0'; /*initialize members*/
newribpntptr->x = 0;
newribpntptr->y = 0;
newribpntptr->z = 0;
}
return(newribpntptr); /*new ptr or NULL if alloc failed*/
}
/*___allocribpntstructure()_______________________________________________}}}*/
/*}}}****allocation of structures: model, section, frag, res, pnt ****/
/*{{{loadribbonatoms()********************************************************/
int loadribbonatoms() /*of current residue*/
{
/*{{{-- declarations and NOTES*/
/*loadribbonatoms() called once per residue during general input*/
/*loads specific atom info into ribres structures that are part of*/
/* ribfrag structures, which in turn are part of ribsection structures*/
/* prekin does a section of ribbon for each of its levels==chains*/
/* these are under ribmodel structures, the top of this hierarchy*/
/* after the residues of a level are in (prekin's idea of chains) */
/* then buildsectionguides(thisribsectionptr); */
int n=0; /* beware: n is a global counter for ranges*/
float distsq=0;
int Lgotatoms = 1; /*ireturn 010511, renamed Lgotatoms 090219*/
int discon=0;
ribfragstruct* trialribfragptr=NULL;
float wc=0;
float fx=0,fy=0,fz=0;
float factor=0;
int IOK=0; /*051214*/
int nitr=0,itr=0; /*070801*/
char Q=' '; /*070801 Q ...PQR...*/
/* B spline order==4 uses 4 intervals to calculate spline over mid-interval*/
/* nth spline calc using n-2,n-1,nth,n+1 guidepoints */
/*guide points between residues, named by the first */
/*construct 3 dummy residues to begin ribbon, then their guide points */
/*are used to construct spline for the first real interval == residue*/
/*similarly, at finish, a single dummy lets the nth be the last real one */
/*so the spline covers beginning and end residues */
/*}}}declarations and NOTES*/
if(LGFPchromophore && typechainfirstpass[level]=='P')
{nitr = 3;}
else
{nitr = 1;}
for(itr=1; itr<=nitr; itr++) /*070801 for GFPchromophore*/
{/*itr: iteration for multi-residue pseudo-hets like GFPchromophore*/
if(LGFPchromophore) /*070801*/
{
if (itr==1) {Q='1';}
else if(itr==2) {Q='2';}
else if(itr==3) {Q='3';}
}
/*{{{-- define and open a new ribresstruct for this residue*/
/*define a new global ribresstruct for this residue*/
thisribresptr = allocribresstructure(thisribfragptr);
if(thisribresptr != NULL && thisribresptr->number == 1 )/*start of fragment*/
{/*pad beginning with dummy residues so ribbon can tail off nicely*/
/*use original alloc above for 1st dummy residue*/
/*original becomes n-3, 3 dummies needed since */
/*spline uses n-3,n-2,n-1,nth to calc spline in interval n-1 */
/*SO WHY DID OLD PREKIN GET AWAY WITH ONLY 2 BEGINNING DUMMIES ???? */
/*thisribresptr->explicit == 0 unspecified, == 4 for coil */
thisribresptr->explicit = 0; /*number 1*/
thisribresptr = allocribresstructure(thisribfragptr);/*for 2nd dummy res*/
if(thisribresptr != NULL )
{
thisribresptr->explicit = 0; /*number 2*/
thisribresptr = allocribresstructure(thisribfragptr); /*3rd dummy*/
if(thisribresptr != NULL )
{
thisribresptr->explicit = 0; /*number 3*/
thisribresptr = allocribresstructure(thisribfragptr); /*1st real*/
if(thisribresptr != NULL )
{
thisribresptr->explicit = 0; /*number 4, might be reset below*/
}
}
}
Lnewribbonstart = 1; /*090219 to clear previousribbontype for ranges*/
previousribbontype = 0; /*090219 clear the d--m global */
}/*pad beginning with dummy residues so ribbon can tail off nicely*/
/*}}}define and open a new ribresstruct for this residue*/
if(thisribresptr != NULL) /*4 and greater are real residues, until last pad*/
{/*ribres allocated*/
/*{{{-- loop over all atoms of this residue */
for(n=1;n<=maxatm;n++)
{/*loop over all atoms*/
/*take first instance of an atom in the list*/
/*so SHOULD ONLY DO ALT A atoms if there are any */
/*{{{---- look for NUCLEIC atoms */
if( atom[n][1]=='p' && atom[n][2]==' '
&& thisribresptr->pnuclptr == NULL )
{/*P is usually the first atom of a nucleotide*/
thisribresptr->pnuclptr = allocribpntstructure(thisribresptr);
if(thisribresptr->pnuclptr != NULL)
{
(thisribresptr->pnuclptr)->x = x[n];
(thisribresptr->pnuclptr)->y = y[n];
(thisribresptr->pnuclptr)->z = z[n];
}
}
if( atom[n][1]=='o' && atom[n][2]=='5'
&& thisribresptr->o5ribptr == NULL )
{/*P is usually the first atom of a nucleotide, but sometimes missing*/
/*so pick up the O5' as possible replacement,*/
/*if never find a P, this will be used as beginning atom*/
if( (thisribresptr->o5ribptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->o5ribptr)->x = x[n];
(thisribresptr->o5ribptr)->y = y[n];
(thisribresptr->o5ribptr)->z = z[n];
}
}
if( atom[n][1]=='c' && atom[n][2]=='3'
&&(atom[n][3]=='*' || atom[n][3]=='\'')
&& thisribresptr->c3ribptr == NULL )
{
thisribresptr->c3ribptr = allocribpntstructure(thisribresptr);
if(thisribresptr->c3ribptr != NULL)
{
(thisribresptr->c3ribptr)->x = x[n];
(thisribresptr->c3ribptr)->y = y[n];
(thisribresptr->c3ribptr)->z = z[n];
}
}
if( atom[n][1]=='o' && atom[n][2]=='3'
&&(atom[n][3]=='*' || atom[n][3]=='\'')
&& thisribresptr->o3ribptr == NULL )
{/*hold O3' to use as an approximation to a next PO4 at chain breaks*/
thisribresptr->o3ribptr = allocribpntstructure(thisribresptr);
if(thisribresptr->o3ribptr != NULL)
{
(thisribresptr->o3ribptr)->x = x[n];
(thisribresptr->o3ribptr)->y = y[n];
(thisribresptr->o3ribptr)->z = z[n];
}
}
if( atom[n][1]=='c' && atom[n][2]=='4'
&&(atom[n][3]=='*' || atom[n][3]=='\'')
&& thisribresptr->c4ribptr == NULL )
{/*hold C4' to use as intermediate end point for doubled region ribbon*/
if( (thisribresptr->c4ribptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->c4ribptr)->x = x[n];
(thisribresptr->c4ribptr)->y = y[n];
(thisribresptr->c4ribptr)->z = z[n];
}
}
if( atom[n][1]=='c' && atom[n][2]=='1'
&&(atom[n][3]=='*' || atom[n][3]=='\'')
&& thisribresptr->c1ribptr == NULL )
{
if( (thisribresptr->c1ribptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->c1ribptr)->x = x[n];
(thisribresptr->c1ribptr)->y = y[n];
(thisribresptr->c1ribptr)->z = z[n];
/*set only on c1* atom for nucleic acid*/
thisribresptr->numrib = num[n];
strcpy(thisribresptr->resrib, res[n]);
strcpy(thisribresptr->subrib, sub[n]);
strcpy(thisribresptr->rinsrib, rins[n]);
thisribresptr->Bvalrib = B[n];
}
}
/*}}}---- look for NUCLEIC atoms */
/*{{{---- look for PROTEIN atoms*/
/*--atoms for fudged protein ribbons-- store all mc atoms for Hbonds*/
if( atom[n][1]=='c' && atom[n][2]=='a' && atom[n][3]==Q
&& thisribresptr->calphptr == NULL )
{
if( (thisribresptr->calphptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->calphptr)->x = x[n];
(thisribresptr->calphptr)->y = y[n];
(thisribresptr->calphptr)->z = z[n];
/*set only on ca atom for protein*/
thisribresptr->numrib = num[n];
strcpy(thisribresptr->resrib, res[n]);
strcpy(thisribresptr->subrib, sub[n]);
strcpy(thisribresptr->rinsrib, rins[n]);
thisribresptr->Bvalrib = B[n];
}
}
if( atom[n][1]=='n' && atom[n][2]==Q
&& thisribresptr->npeptptr == NULL )
{
if( (thisribresptr->npeptptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->npeptptr)->x = x[n];
(thisribresptr->npeptptr)->y = y[n];
(thisribresptr->npeptptr)->z = z[n];
}
}
if( atom[n][1]=='h' && atom[n][2]==Q
&& thisribresptr->hnpepptr == NULL )
{
if( (thisribresptr->hnpepptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->hnpepptr)->x = x[n];
(thisribresptr->hnpepptr)->y = y[n];
(thisribresptr->hnpepptr)->z = z[n];
}
}
if( atom[n][1]=='c' && atom[n][2]==Q
&& thisribresptr->ccarbptr == NULL )
{
if( (thisribresptr->ccarbptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->ccarbptr)->x = x[n];
(thisribresptr->ccarbptr)->y = y[n];
(thisribresptr->ccarbptr)->z = z[n];
}
}
if( atom[n][1]=='o' && atom[n][2]==Q
&& thisribresptr->ocarbptr == NULL )
{
if( (thisribresptr->ocarbptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->ocarbptr)->x = x[n];
(thisribresptr->ocarbptr)->y = y[n];
(thisribresptr->ocarbptr)->z = z[n];
}
}
if( atom[n][1]=='c' && atom[n][2]=='b' && atom[n][3]==Q
&& thisribresptr->cbetaptr == NULL )
{
if( (thisribresptr->cbetaptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->cbetaptr)->x = x[n];
(thisribresptr->cbetaptr)->y = y[n];
(thisribresptr->cbetaptr)->z = z[n];
if( (Lsite && siteoutl) || (Lsitefake && siteoutl) /*050928*/
|| (!Lsite && !Lsitefake) )
{
thisribresptr->Lstub = 1; /*050731*/
}
}
}
if( atom[n][1]=='c' && atom[n][2]!=' ' && atom[n][2]!='b'
&& atom[n][2]!='a'
&& thisribresptr->cunknptr == NULL )
{
if( (thisribresptr->cunknptr = allocribpntstructure(thisribresptr))
!= NULL)
{/*clunker carbon, e.g. acyl at Nterm,... 061011*/
(thisribresptr->cunknptr)->x = x[n];
(thisribresptr->cunknptr)->y = y[n];
(thisribresptr->cunknptr)->z = z[n];
}
}
/*}}}look for PROTEIN atoms*/
}/*loop over all atoms*/
if(Lribbonalso && !scoutl)
{/*override for only specified sc 050206*/
thisribresptr->Lstub = 0;
}
/*}}}loop over all atoms of this residue*/
/*{{{-- check completeness, do tricks for protein and nucleic acid*/
/*Protein vs Nucleic acid set by typechainfirstpass[level] for ribsection*/
if(thisribsectionptr->type == 'P')
/*{{{---- PROTEIN tricks*/
{/*PROTEIN tricks*/
if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr != NULL
&& thisribresptr->ocarbptr == NULL
&&(thisribresptr->previousptr)->ocarbptr != NULL )
{
/*special patch for green fluoresent protein 040406*/
/*interior of a continuous stretch, fake a carbonyl oxygen 040406*/
if( (thisribresptr->ocarbptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->ocarbptr)->x
= ((thisribresptr->previousptr)->ocarbptr)->x;
(thisribresptr->ocarbptr)->y
= ((thisribresptr->previousptr)->ocarbptr)->y;
(thisribresptr->ocarbptr)->z
= ((thisribresptr->previousptr)->ocarbptr)->z;
sprintf(temps,"fake a carbonyl oxygen at %s %d (O of res -1)"CRLF
,sub[n],num[n]);
pkintextinsert(temps);
adjusttext(1);
#ifdef UNIX_X11
if(!Lquiet)
{
fprintf(stderr,"fake a carbonyl oxygen at %s %d (O of res -1)\n"
,sub[n],num[n]);
}
#endif
Lgotatoms = 1;
}
}
else if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr != NULL
&& thisribresptr->ocarbptr == NULL )
{
/*maybe Calpha only file, fake oxygen 041105, can do a worm*/
if( (thisribresptr->ocarbptr = allocribpntstructure(thisribresptr))
!= NULL)
{
(thisribresptr->ocarbptr)->x = (thisribresptr->calphptr)->x;
(thisribresptr->ocarbptr)->y = (thisribresptr->calphptr)->y;
(thisribresptr->ocarbptr)->z = (thisribresptr->calphptr)->z;
Lgotatoms = 2;
}
}
else if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr == NULL
&& thisribresptr->ccarbptr != NULL) /*061011*/
{
/*No Calpha named, but have a carbonyl carbon atom 061011*/
if( (thisribresptr->calphptr = allocribpntstructure(thisribresptr))
!= NULL)
{/*fake a Calpha*/
(thisribresptr->calphptr)->x = (thisribresptr->ccarbptr)->x;
(thisribresptr->calphptr)->y = (thisribresptr->ccarbptr)->y;
(thisribresptr->calphptr)->z = (thisribresptr->ccarbptr)->z;
Lgotatoms = 3;
}
}
else if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr == NULL
&& thisribresptr->ccarbptr != NULL /*070801*/
&& thisribresptr->cunknptr != NULL) /*061011*/
{
/*No Calpha named, but have a clunker carbon atom 061011*/
if( (thisribresptr->calphptr = allocribpntstructure(thisribresptr))
!= NULL)
{/*fake a Calpha*/
(thisribresptr->calphptr)->x = (thisribresptr->cunknptr)->x;
(thisribresptr->calphptr)->y = (thisribresptr->cunknptr)->y;
(thisribresptr->calphptr)->z = (thisribresptr->cunknptr)->z;
Lgotatoms = 4;
}
}
else if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr == NULL
&& thisribresptr->ocarbptr != NULL) /*061011*/
{
/*No Calpha named, but have a carbonyl oxygen atom 061011*/
if( (thisribresptr->calphptr = allocribpntstructure(thisribresptr))
!= NULL)
{/*fake a Calpha, beware: ca--o now zero length vector...*/
(thisribresptr->calphptr)->x = (thisribresptr->ocarbptr)->x;
(thisribresptr->calphptr)->y = (thisribresptr->ocarbptr)->y;
(thisribresptr->calphptr)->z = (thisribresptr->ocarbptr)->z;
Lgotatoms = 5;
}
}
if( thisribsectionptr->type == 'P'
&& thisribresptr->calphptr != NULL
&& thisribresptr->ocarbptr != NULL )
{/*enough real atoms to do a ribbon properly*/
Lgotatoms = 6; /*enough to do a ribbon*/
/*EXTRA stuff for Protein Ribbons... */
if( (thisribresptr->hnpepptr == NULL) /*H of peptide NOT found*/
&& (thisribresptr->resrib[0] != 'p') ) /*not do pro */
{/*try to compute hnpep*/
if( thisribresptr->npeptptr != NULL
&& thisribresptr->calphptr != NULL
&& thisribresptr->previousptr->ccarbptr != NULL)
{/*the necessary atoms are present*/
/* calculate coords for the h (section from nhgen.f) */
/* .4775 jsr fudged "halfway" point: */
/* c-n-ca define a plane, */
/* a point xyz nearly halfway between c & ca */
/* is opposite the nh position. */
/*A normal vector in the xyz - n2xyz direction */
/* points one unit out from n toward the nh position.*/
/* Scale this and add to n2xyz to get nhxyz. */
/* (n-h ~ 1.0, so scale=1.0) */
fx = ( (thisribresptr->previousptr->ccarbptr->x)
+ (float)0.4775*( (thisribresptr->calphptr->x)
- (thisribresptr->previousptr->ccarbptr->x)));
fy = ( (thisribresptr->previousptr->ccarbptr->y)
+ (float)0.4775*( (thisribresptr->calphptr->y)
- (thisribresptr->previousptr->ccarbptr->y)));
fz = ( (thisribresptr->previousptr->ccarbptr->z)
+ (float)0.4775*( (thisribresptr->calphptr->z)
- (thisribresptr->previousptr->ccarbptr->z)));
factor = (float)(1.0
/(sqrt( ( (thisribresptr->npeptptr->x - fx)
* (thisribresptr->npeptptr->x - fx) )
+( (thisribresptr->npeptptr->y - fy)
* (thisribresptr->npeptptr->y - fy) )
+( (thisribresptr->npeptptr->z - fz)
* (thisribresptr->npeptptr->z - fz) ) ) ) );
if(thisribresptr->hnpepptr == NULL)
{thisribresptr->hnpepptr =
allocribpntstructure(thisribresptr);}
if(thisribresptr->hnpepptr != NULL)
{
thisribresptr->hnpepptr->x = thisribresptr->npeptptr->x
+ factor*(thisribresptr->npeptptr->x - fx);
thisribresptr->hnpepptr->y = thisribresptr->npeptptr->y
+ factor*(thisribresptr->npeptptr->y - fy);
thisribresptr->hnpepptr->z = thisribresptr->npeptptr->z
+ factor*(thisribresptr->npeptptr->z - fz);
}
}/*the necessary atoms are present*/
}/*try to compute hnpep*/
}/*enough to do a ribbon*/
else
{/*PROTEIN: partial or fully missing requisite atoms to make a ribbon*/
Lgotatoms = 0;
/*as of 051025 still no graceful way of dealing with imperfect data*/
/*130406 prune flawed segment end residue, avoid singleton N segfault*/
discon=1; /*force disconnection at this flawed, unuseable, residue*/
}
}/*PROTEIN tricks*/
/*}}}---- PROTEIN tricks*/
else if(thisribsectionptr->type == 'N')
/*{{{---- NUCLEIC tricks*/
{/*NUCLEIC tricks*/
if ( thisribsectionptr->type == 'N'
&& thisribresptr->pnuclptr != NULL
&& thisribresptr->c1ribptr != NULL
&& thisribresptr->c4ribptr != NULL )
{
Lgotatoms = 7;
}
/* dummy always starts so cannot use thisribresptr->previousptr == NULL*/
/* to know first real residue of frag*/
else if( thisribsectionptr->type == 'N'
&& thisribresptr->o5ribptr != NULL
&& thisribresptr->c1ribptr != NULL
&& thisribresptr->c4ribptr != NULL )
{ /* substitute o5 for missing first p */
thisribresptr->pnuclptr = allocribpntstructure(thisribresptr);
if(thisribresptr->pnuclptr != NULL) /*allocation succeeded*/
{
(thisribresptr->pnuclptr)->x = (thisribresptr->o5ribptr)->x;
(thisribresptr->pnuclptr)->y = (thisribresptr->o5ribptr)->y;
(thisribresptr->pnuclptr)->z = (thisribresptr->o5ribptr)->z;
Lgotatoms = 8;
}
else /*allocation failed*/
{
Lgotatoms = 0;
}
}
else
{/*partial or fully missing requisite atoms to make a ribbon*/
Lgotatoms = 0;
/*as of 051025 still no graceful way of dealing with imperfect data*/
/*090219 try to use discon for this*/
}
}/*NUCLEIC tricks*/
/*}}}---- NUCLEIC tricks*/
else /*neither P nor N, no notion of how to use this in a ribbon*/
{
Lgotatoms = 0;
}
/*}}}check completeness, do tricks for protein and nucleic acid*/
if(Lgotatoms) /*still good*/
{/*full number of atoms in to do a ribbon seqment*/
/*{{{-- if still good, try to define explicit sec str type from header*/
/* nucleic recognized by theribsectionptr->type */
/* and uses explicitribbontype == BETA2D ranges */
/* if(Lexplicitribbon && Lnucleicacid && !Lnucleicarrows) */
/* { */
/* explicitribbontype = NUCLEIC2D; */
/* } */
/*general range control: */
/* 0 Not explicit, 1 Alpha, 2 Beta, 4 Coil, 8 NUCLEIC, 16++ ARROW*/
thisribresptr->explicit = explicitribbontype; /*from PDB HEADER */
strcpy(thisribresptr->ribidentity,explicitribbonidentity);
explicitribbonidentity[0] = '\0'; /*forget so must be reset*/
/*explicitribbonidentity from SHEET record 060929*/
/*only need 1,2,3,4 for PKINRIBB code*/
/* ALPHA2D 1 */
/* BETA2D 2 */
/* COIL2D 4 */
/* NUCLEIC2D 8 */
/* ALL2D ALPHA2D | BETA2D | COIL2D */
/* ARROW2D 16 */
/* ALPHAARROW2D 17 */
/* BETAARROW2D 18 bit-wise logic imposed 061021*/
/* SEGMENTS 12 */ /*050204 for VRMLxSectionCircle */
/* bit-wise logic imposed 061021 keep explicit knowledge
if(thisribresptr->explicit == ALPHAARROW2D)
{thisribresptr->explicit = ALPHA2D;}
if(thisribresptr->explicit == BETAARROW2D)
{thisribresptr->explicit = BETA2D;}
if(thisribresptr->explicit == NUCLEIC2D)
{thisribresptr->explicit = BETA2D;}
*/
/*}}}-- if still good, try to define explicit sec str type from header*/
/*{{{-- check for disconnection because residues too far apart */
if(!LfakeCaCaspline) /*111106*/
{/*really do check*/
/*check for disconnected fragments at evey residue */
if(thisribresptr->previousptr != NULL)
{/*at least on 2nd residue of a fragment*/
if(thisribsectionptr->type == 'N')
{/*nucleic*/
if( thisribresptr->pnuclptr != NULL
&& (thisribresptr->previousptr)->pnuclptr != NULL )
{
distsq =
( (thisribresptr->pnuclptr)->x
- ((thisribresptr->previousptr)->pnuclptr)->x)
*( (thisribresptr->pnuclptr)->x
- ((thisribresptr->previousptr)->pnuclptr)->x)
+( (thisribresptr->pnuclptr)->y
- ((thisribresptr->previousptr)->pnuclptr)->y)
*( (thisribresptr->pnuclptr)->y
- ((thisribresptr->previousptr)->pnuclptr)->y)
+( (thisribresptr->pnuclptr)->z
- ((thisribresptr->previousptr)->pnuclptr)->z)
*( (thisribresptr->pnuclptr)->z
- ((thisribresptr->previousptr)->pnuclptr)->z);
if(distsq > 100.0) {discon=1;} /*10sq vs 7sq*/
}
}/*nucleic*/
else if(thisribsectionptr->type == 'P')
{/*protein*/
if( thisribresptr->calphptr != NULL
&& (thisribresptr->previousptr)->calphptr != NULL )
{
distsq =
( (thisribresptr->calphptr)->x
- ((thisribresptr->previousptr)->calphptr)->x)
*( (thisribresptr->calphptr)->x
- ((thisribresptr->previousptr)->calphptr)->x)
+( (thisribresptr->calphptr)->y
- ((thisribresptr->previousptr)->calphptr)->y)
*( (thisribresptr->calphptr)->y
- ((thisribresptr->previousptr)->calphptr)->y)
+( (thisribresptr->calphptr)->z
- ((thisribresptr->previousptr)->calphptr)->z)
*( (thisribresptr->calphptr)->z
- ((thisribresptr->previousptr)->calphptr)->z);
if(distsq > 36.0) {discon=1;} /*6sq vs 3.8 sq*/
}
}/*protein*/
}/*at least on 2nd residue of a fragment*/
}/*really do check*/
/*}}}-- check for disconnection because residues too far apart */
}/*full number of atoms in to do a ribbon seqment*/
/*{{{-- disconnection, alloc new fragment*/
if(discon || !Lgotatoms) /*090219, 130406 routine rearranged*/
{/*this residue disconnects from previous residue: backoff counters */
/*reset current global thisribfragptr->lastribresptr */
/* to the previous ribresptr */
thisribfragptr->lastribresptr = thisribresptr->previousptr;
thisribfragptr->lastribresptr->nextptr = NULL; /*an end*/
/*back-off residue count of working fragment*/
thisribfragptr->number--;
thisribsectionptr->number--;
thisribresptr = NULL;
previousribbontype = 4; /*090219 clear flag before next residue*/
explicitribbontype = 4; /*4==COIL*/
if(Lgotatoms)
{/*ribbon could continue in a new fragment with the current residue*/
/* Ribbon continues!? try to create new fragment...*/
/* alloc a new global thisribfragptr */
/* and start it with the current, disconnected ribresptr */
/* if this current residue has sufficient atoms, */
/* else skip and expect next residue to start new fragment */
thisribfragptr = allocribfragstructure(thisribsectionptr);
/* allocates global thisribfragptr 051214*/
if(thisribfragptr != NULL)
{
/*re-entrant to start another fragment with current residue*/
/*reloads a newly allocated ribresptr in this new fragment*/
/*thisribresptr->previousptr == NULL, cannot get here next time*/
loadribbonatoms(); /*works on current inputed residue*/
}
}/*ribbon could continue in a new fragment with the current residue*/
}/*this residue disconnected from previous residue*/
/*}}}-- disconnection, alloc new fragment*/
}/*ribres allocated*/
}/*itr: iteration for multi-residue pseudo-hets like GFPchromophore*/
return(Lgotatoms);
}
/*___loadribbonatoms()____________________________________________________}}}*/
/*{{{buildsectionguides()*****************************************************/
void buildsectionguides(ribsectionstruct* theribsectionptr)
{
/*{{{-- declarations--and definitions */
/*ribbon section structure has the specific residue atoms to specify the */
/*guide points for the splines of a section (prekin's notion of chains).*/
/*Loop through the ribbon residue structures of the*/
/*ribbon fragment structures of the*/
/*ribbon section structures of the current ribbon model structure.*/
/*Guide points and Spline points are stored back into the ribres structures*/
/* (with some extra dummy residues added as needed to the dummy residues */
/* that were anticipated early as the residues were loaded). */
ribfragstruct* theribfragptr=NULL;
ribresstruct* theribresptr=NULL;
ribresstruct* nthresptr=NULL;
ribresstruct* nm1resptr=NULL;
ribresstruct* nm2resptr=NULL;
ribresstruct* nm3resptr=NULL;
ribresstruct* nm4resptr=NULL;
ribresstruct* nm5resptr=NULL;
ribresstruct* nm6resptr=NULL;
ribresstruct* nm7resptr=NULL;
ribresstruct* nm8resptr=NULL;
/*nth is current residue under consideration (e.g. nm1==n-1)*/
/*four residues needed to define curvature, etc. nth,nm1,nm2,nm3 */
/*range of 3 fully defined needed to establish consistency: nm4,nm3,nm2 */
/*Simple array indexing would make this code easier to understand*/
/* rather than C type structures with internal pointer references*/
float thispnt[4]={0,0,0,0};
float nextpnt[4]={0,0,0,0};
float nearpnt[4]={0,0,0,0};
float distpnt[4]={0,0,0,0};
float midpnt[4]={0,0,0,0};
float avec[4]={0,0,0,0};
float bvec[4]={0,0,0,0};
float cvec[4]={0,0,0,0};
float dvec[4]={0,0,0,0};
float ppnt[4]={0,0,0,0};
float amag=0,bmag=0,cmag=0,dmag=0;
float wc=0;
float maxoff=0,minoff=0,maxoffset=0,dist1=0,dist2=0,distance=0,delta=0;
float fraction=0,widthfactor=0,radialfactor=0;
/*do not use fudge, old common percent offset, as a variable name*/
float minlimit=0,maxlimit=0; /*of extendedness 051211*/
float extended=0; /*curvature fractional extendedness 051211*/
float woffa=0,woffb=0;
int Lcurled=0,nuke=0;
float pmid[4]={0,0,0,0},direc[4]={0,0,0,0},center[4]={0,0,0,0};
int j=0;
int LOK = 0; /*070801*/
float azmangle=0; /*dihedral CA-1,CA,CA+1,O azmuthal to Carbonyl 100322*/
float prevpnt[4]={0,0,0,0}; /*for dihedral: CA-1 100322*/
/*wc--width in coil, no sec. structure */
wc = ribwidcoil;
/*woffa--width offset,up to this amount added when width fudged for alpha*/
woffa = ribwidalpha - ribwidcoil; /*old woff==1.1*/
/*woffb--width offset, up to this amount added when width fudged for beta*/
woffb = ribwidbeta - ribwidcoil; /*old woff==1.1*/