forked from rlabduke/mage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAGEOUT.c
3156 lines (2937 loc) · 125 KB
/
MAGEOUT.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*/
/* MAGEOUT.C MAGE general calls mostly doing writeouts */
#include "MAGE.h"
#include "MAGELIST.h"
#include "MAGEPOST.h"
#include "MAGEFLAG.h"
#include "MAGEANGL.h"
#include "MAGEBBOX.h"
#include "MAGETABL.h"
#include "MAGECOLR.h"
#include "MAGESCRT.h"
#include "MAGEOUTR.h"
#define MAXFILESTR 128
void writeindividuallist(void);
void writeindividualpoint(int);
void writepointID(void);
void writefullrgbpalette(void);
void accumsums(void);
void getmeans(void);
void accumdevi(void);
void getsigmas(void);
void meansigmasout(void);
static int Lbeginselectionout=0; /*beginselectionpointptr */
static int ipass=0, npass=0;
static int LemphasisOUT=0;
static int LNOditto=1; /*writerotated needs all full pointIDs 051120*/
/****commandfrompointID()*****************************************************/
void commandfrompointID(void)
{
char command[256];
getptIDstring(word, pickedpointptr);
sprintf(command,"echo \"@start\" >>simout.kin\n");
system(command);
sprintf(command,"echo \"@nowfind {%s}\" >>simout.kin\n",word);
system(command);
sprintf(command,"echo \"@finish\" >>simout.kin\n");
system(command);
}
/*___commandfrompointID()____________________________________________________*/
/****writefullrgbpalette()****************************************************/
void writefullrgbpalette()
{
int j=0, k=0, level=0;
char bkg = ' ';
fprintf(fpout,"@fullrgbpalette\n");
for(j=0; j<MageRGBtableSIZE; j++)
{
k = j;
level = 0;
while(k > 50) /*change to 50 when black-->deadblack*/
{
k = k - 50;
level++;
}
if(k > 25) /*change to 25 when black-->deadblack*/
{/*white background*/
bkg = 'W';
k = k - 25;
}
else
{/*black background*/
bkg = 'B';
}
/*now k is the index of the color*/
interpretcolor(k); /*which puts color name into global word*/
if(level >= 5)
{/*ran off end of actual used palette cells*/
if(j == 255)
{
sprintf(word,"deadwhite index==");
level = 255;
}
else
{
sprintf(word,"unused index==");
}
level = j;
bkg = ' ';
}
else if(j == 0)
{
sprintf(word,"deadblack index==");
bkg = ' ';
}
if(Lshiftkey)
{
fprintf(fpout,"{%3d} %5d, %5d, %5d, {%-10s %d %c}\n"
,j
,(257*(myfullpalette[j][0]))
,(257*(myfullpalette[j][1]))
,(257*(myfullpalette[j][2]))
,word,level,bkg);
}
else
{ /*divide down by 256, multiply back up by 257*/
fprintf(fpout,"{%3d} %3d, %3d, %3d, {%-10s %d %c}\n"
,j
,((myfullpalette[j][0]))
,((myfullpalette[j][1]))
,((myfullpalette[j][2]))
,word,level,bkg);
}
/* and the {...} can be edited to be comments*/
}
fclose(fpout);
fpout = NULL;
}
/*___writefullrgbpalette()___________________________________________________*/
/****writepointID()***********************************************************/
void writepointID()
{
fprintf(fpout,"@start\n"); /*c*/
getptIDstring(word, pickedpointptr);
fprintf(fpout,"@nowfind {%s}\n",word); /*c*/
fprintf(fpout,"@finish\n"); /*c*/
fclose(fpout);
fpout = NULL;
}
/*___writepointID()__________________________________________________________*/
/****writematrix()************************************************************/
void writematrix() /*write current view*/
{
int iout=0,i=0;
float span=0;
fprintf(fpout,"@%dviewid {%s}\n",iviewset,viewcom[iviewset]);
if(Lspanfromzoom)
{
span = oldmaxwide/(Scale * zoom);
fprintf(fpout,"@%dspan %.2f \n",iviewset,span);
}
else
{
fprintf(fpout,"@%dzoom %.2f \n",iviewset,zoom);
}
iout = izclipold[0];/*970915*/
fprintf(fpout,"@%dzslab %d\n",iviewset,iout);
iout = iztranold[0];/*970915*/
fprintf(fpout,"@%dztran %d\n",iviewset,iout); /*970909*/
fprintf(fpout,"@%dcenter %.3f %.3f %.3f\n"
,iviewset,fxcenternew,fycenternew,fzcenternew);
if(gwidthview[iviewset] > 0 && gheightview[iviewset] > 0) /*041031*/
{
fprintf(fpout,"@%dsize %d %d\n"
,iviewset,gwidthview[iviewset],gheightview[iviewset]);
}
if(Laxischoice[iviewset]) /*060613 save as, 061123 here, iviewset 061125*/
{ /*axes array indexed from 0, count axes from 1 */
fprintf(fpout,"@%daxischoice %d %d %d\n"
,iviewset,1+axischoice[iviewset][0],1+axischoice[iviewset][1]
,1+axischoice[iviewset][2]);
}
fprintf(fpout,"@%dmatrix\n",iviewset);
fprintf(fpout,"%8.5f ",a11);
fprintf(fpout,"%8.5f ",-a12); /* 1 2 3 1 0 0 */
fprintf(fpout,"%8.5f ",a13); /* 7 8 9 0 0 1 */
fprintf(fpout,"%8.5f ",a21); /* 4 5 6 X 0 -1 0 */
fprintf(fpout,"%8.5f ",-a22);
fprintf(fpout,"%8.5f ",a23); /* screen handedness correction: */
fprintf(fpout,"%8.5f ",a31); /* back correct so written matrix*/
fprintf(fpout,"%8.5f ",-a32); /* is correct for input to this, */
fprintf(fpout,"%8.5f\n",a33); /* or any program */
fclose(fpout);
fpout = NULL;
}
/*___writematrix()___________________________________________________________*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****writefocus()*************************************************************/
void writefocus()
{
recondition(focusxyzstr);
fprintf(fpout,"%s\n",focusxyzstr); /*c*/
condition(focusxyzstr);
fclose(fpout);
fpout = NULL;
}
/*___writefocus()____________________________________________________________*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****writerotated()***********************************************************/
void writerotated()
{/*this only works if the rotated groups/sections are still active*/
if(beginselectionpointptr != NULL)
{/*expect selection from begin and end selection*/
Lbeginselectionout = 1; /*flag to write @beginselect*/
}
Lnewstuffactive = 0;
if(Lkinformat)
{
fprintf(fpout,"@text rotated stuff\n"
"@kinemage 1\n"
"@caption MAGE rotated and outputted\n");
}
else if(Lrotangleout) /*070706,071215*/
{
fprintf(fpout,"@text rotation angles \n"); /*hypertext*/
if(conformerstr[0] != '\0') fprintf(fpout,"*{%s\n",conformerstr); /* } */
else fprintf(fpout,"*{\n"); /*balance} hypertext start*/
}
else /*!Lrotangleout and NOT Lkinformat*/ /*071215*/
{/*PDB format: */
if(conformerstr[0] != '\0') /*071215*/
{
fprintf(fpout,"REMARK *{%s}*\n",conformerstr);
}
if(ribose3hyperstr[0] != '\0')
{
fprintf(fpout,"REMARK *{%s}*\n",ribose3hyperstr);
}
if(ribose5hyperstr[0] != '\0')
{
fprintf(fpout,"REMARK *{%s}*\n",ribose5hyperstr);
}
}
thisgrupptr = firstgrupptr;
while(thisgrupptr != NULL)
{/*loop-over-groups*/
if(thisgrupptr->bondrot != 0) /*inc thisgrupptr->bondrot==DOCKSET */
{/*rotated-group*/
if( (Lprobeactive && !thisgrupptr->on) /*NO Probe if NOT ON 041109*/
||(!Lkinformat && !thisgrupptr->on && Lvisibleout) ) /*070702*/
{;} /*NOP*/
else
{/*group outputable*/
if(Lkinformat)
{/*Lkinformat*/
fprintf(fpout,"@group {%s}\n",thisgrupptr->name);
if(thisgrupptr->pdbfilestr[0] != '\0')
{
fprintf(fpout,"@grouppdbfile {%s}\n",thisgrupptr->pdbfilestr);
}
if( ( thisgrupptr->pointx[0] > (float)1.0001
||thisgrupptr->pointx[0] < (float)0.9999)
||( thisgrupptr->pointx[1] > (float)0.0001
||thisgrupptr->pointx[1] < -(float)0.0001)
||( thisgrupptr->pointx[2] > (float)0.0001
||thisgrupptr->pointx[2] < -(float)0.0001)
||( thisgrupptr->pointy[0] > (float)0.0001
||thisgrupptr->pointy[0] < -(float)0.0001)
||( thisgrupptr->pointy[1] > (float)1.0001
||thisgrupptr->pointy[1] < (float)0.9999)
||( thisgrupptr->pointy[2] > (float)0.0001
||thisgrupptr->pointy[2] < -(float)0.0001)
||( thisgrupptr->pointz[0] > (float)0.0001
||thisgrupptr->pointz[0] < -(float)0.0001)
||( thisgrupptr->pointz[1] > (float)0.0001
||thisgrupptr->pointz[1] < -(float)0.0001)
||( thisgrupptr->pointz[2] > (float)1.0001
||thisgrupptr->pointz[2] < (float)0.9999)
||( thisgrupptr->position[0] > (float)0.0001
||thisgrupptr->position[0] < -(float)0.0001)
||( thisgrupptr->position[1] > (float)0.0001
||thisgrupptr->position[1] < -(float)0.0001)
||( thisgrupptr->position[2] > (float)0.0001
||thisgrupptr->position[2] < -(float)0.0001) )
{/*initial values: 1,0,0 0,1,0 0,0,1 0,0,0 */
fprintf(fpout,"@gnomon\n"
" %.3f %.3f %.3f\n"
" %.3f %.3f %.3f\n"
" %.3f %.3f %.3f\n"
" %.3f %.3f %.3f\n"
,thisgrupptr->pointx[0]
,thisgrupptr->pointx[1]
,thisgrupptr->pointx[2]
,thisgrupptr->pointy[0]
,thisgrupptr->pointy[1]
,thisgrupptr->pointy[2]
,thisgrupptr->pointz[0]
,thisgrupptr->pointz[1]
,thisgrupptr->pointz[2]
,thisgrupptr->position[0]
,thisgrupptr->position[1]
,thisgrupptr->position[2]
);
}
npass = 1;
}/*Lkinformat*/
else if(!Lrotangleout) /*and NOT Lkinformat*/ /*070705*/
{/*PDB format: 2 passes in group: 1st heavy atoms: 2nd hydrogens*/
if(Lhydrogensout && LhydrogensSep) /*070829*/
{/*double pass to separate hydrogens only works for 1 residue/group*/
npass = 2;
}
else {npass = 1;}
if(update_res_model >= 0)
{/*model record needed by probe if model is specified*/
fprintf(fpout,"MODEL %3d\n",update_res_model); /*050121*/
/*ignore this possibility for LrotoutSORTED as of 070901*/
}
}
else {npass = 1;} /*070705*/
for(ipass = 1; ipass<=npass; ipass++)
{/*passes over each group*/
thissgrpptr = thisgrupptr->firstsgrpptr;
while(thissgrpptr != NULL)
{/*loop-over-subgroups*/
if( (Lprobeactive && !thissgrpptr->on) /*NO Probe if NOT ON 041109*/
||(!Lkinformat && !thissgrpptr->on && Lvisibleout) ) /*070702*/
{;} /*NOP*/
else
{/*subgroup outputable*/
if( (thissgrpptr->bondrot != 0)
||( ((thisgrupptr->bondrot)&DOCKSET)==DOCKSET) ) /*050123*/
{/*rotated-subgroup*/ /*inc thisgrupptr->bondrot==DOCKSET*/
if(Lkinformat)
{
fprintf(fpout,"@subgroup {%s}\n",thissgrpptr->name);
}
thislistptr = thissgrpptr->firstlistptr;
while(thislistptr != NULL)
{/*loop-over-lists*/
if( (Lprobeactive && !thislistptr->on)/*NO Probe if OFF 041109*/
||(!Lkinformat && !thislistptr->on && Lvisibleout) ) /*070702*/
{;} /*NOP*/
else
{/*list outputable*/
if( (thislistptr->bondrot != 0)
||( ((thisgrupptr->bondrot)&DOCKSET)==DOCKSET) ) /*050123*/
{/*rotated-list*/ /*Sheep from Goats criteria*/
/*inc thisgrupptr->bondrot==DOCKSET*/
if(Lrotangleout) /*070705*/
{
if( ( (thislistptr->bondrot >0 && thislistptr->bondrot<100)
&&(bondrotptr[thislistptr->bondrot])->slider != 0 )
&&( (bondrotptr[thislistptr->bondrot])->select != 0
||(bondrotptr[thislistptr->bondrot])->changed != 0 ) )
{
fprintf(fpout,"rot={%s} %.3f\n"
,thislistptr->name
,bondrotptr[thislistptr->bondrot]->angle);
}
}
else
{
writeindividuallist(); /*MAGEOUT.c*/
}
}/*rotated-list*/
}/*list outputable*/
if(thislistptr == thissgrpptr->lastlistptr) thislistptr = NULL;
else thislistptr = thislistptr->nextptr;
}/*loop-over-lists*/
}/*rotated-subgroup*/
}/*subgroup outputable*/
if(thissgrpptr == thisgrupptr->lastsgrpptr) thissgrpptr = NULL;
else thissgrpptr = thissgrpptr->nextptr;
}/*loop-over-subgroups*/
}/*passes over each group*/
}/*group outputable*/
}/*rotated-group*/
thisgrupptr = thisgrupptr->nextptr;
}/*loop-over-groups*/
if(Lrotangleout) /*070706*/
{
/*{balance*/ fprintf(fpout,"}*"); /* hypertext end*/
}
if(LrotoutSORTED)
{
writeOUTRotordered();
}
Lhydrogensout = 1; /*reset so probe will get hydrogens 070829*/
LhydrogensSep = 0;
LrotoutSORTED = 0; /*reset so probe will get its usual atoms 070901*/
fprintf(fpout,"\n");
if(fpout != stdout && fpout != stderr)
{
fclose(fpout);
fpout = NULL;
}
}
/*___writerotated()__________________________________________________________*/
/*name[n],&ncnt[n],atom[n],res[n],sub[n],&num[n],rins[n],&x[n],&y[n],&z[n]*/
/*format(a6,i5,1x,a5,a3,1x,a1,i4,a1,3x,3&8.3)*/
/* these next lines are 84 char long, they contain 80 char templates */
/*0123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789*/
/*123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_*/
/*atom 1 n arg a 1 26.465 27.452 -2.490 1.00 25.18 4pti 89*/
/*atom 2 ca arg a 1 25.497 26.862 -1.573 1.00 17.63 4pti 90*/
/* --name*6 record designator: atom or hetatom recognized */
/* --ncnt:i5 atom number: moved blindly to output file */
/* --atom*5 includes atomname*4 and alt-conformation-indicator*1, */
/* --res*3 residue name */
/* --sub*1 chain ID: subunit designator */
/* --num:i4 residue number */
/* --rins*1 inserted residue indicator */
/* --x,y,z coord of the atom */
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****writedrawnew()**********************************************************/
int writedrawnew()
{
int ireturn;
char dname[26],hold[256],colorstr[32],buttonstr[32],masterstr[256];
int hasvectorlist,hasdotlist,haslabellist,hasarrowlist,haswierdlist;
int hasballlist;
unsigned long long mask; /*081120 long long*/
char hiliteness[32],staticness[26],onoffstr[16],tempstr[32];
/*in any case, this attempt to write a file with the drawnew */
/*stuff relieves MAGE of worrying about saving drawnew stuff*/
Ldrawactive = 0; /*worry flag*/
hasvectorlist = 0;
hasdotlist = 0;
haslabellist = 0;
hasarrowlist = 0;
hasballlist = 0;
haswierdlist = 0;
/*scan to see what type of lists are present */
thispointptr = drawnewlistptr->firstpointptr;
while(thispointptr != NULL)
{/*scan all points in drawnew list*/
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( ( (thispointptr->type) & VECTOR )
&&( (thispointptr->type) & VARIANT1) == 0
&&( (thispointptr->type) & VARIANT2) == 0
&&( (thispointptr->type) & VARIANT3) == 0 )
/*plain vector*/
hasvectorlist = 1;
else if( ( (thispointptr->type) & DOT ) ) /*dot*/
hasdotlist = 1;
else if( ( (thispointptr->type) & LABEL ) ) /*label*/
haslabellist = 1;
else if( ( (thispointptr->type) & ARROW ) ) /*arrow*/
hasarrowlist = 1;
else if( ( (thispointptr->type) & BALL ) ) /*ball*/
hasballlist = 1;
else if( ( (thispointptr->type) & STORED ) )
haswierdlist = 1;
else haswierdlist = 1;
}/*survived pruning*/
/*NOTE: ARROW == (VECTOR | VARIANT3) see MAGEFLAG.h*/
if(thispointptr == drawnewlistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}/*scan all points in drawnew list*/
if(haswierdlist)
{
sprintf(alertstr,"something besides vectors, labels, dots, balls"
" in draw new stuff!");
dosinglealert(0); /*____DLOG.C*/
}
if(hasvectorlist||haslabellist||hasdotlist||hasarrowlist||hasballlist)
{/*has vectors or labels or dots or arrows or balls*/
thislistptr = drawnewsgrpptr->firstlistptr;
/*NOTE: only one list of draw stuff*/
interpretcolor(thislistptr->color);
/*color name string put into global "word[]"*/
sprintf(temps," color= %s",word);
sprintf(colorstr,"%s",temps);
if(thislistptr->STATUS & NOBUTTON) sprintf(buttonstr," nobutton");
else buttonstr[0]='\0';
masterstr[0]='\0'; /*clear str to hold place for masters*/
if(thislistptr->master > 0) /*master button for this one*/
{
thismasterptr = firstmasterptr;
while(thismasterptr != NULL)
{
mask = thismasterptr->mask;
/*mask = 1<<(i-1);*/ /*see ajustmaster() in MAGEBBOX.c*/
if((thislistptr->master)&mask)
{
sprintf(hold,"%s master= {%s}"
,masterstr,thismasterptr->name);
sprintf(masterstr,"%s",hold); /*combined->masterstr*/
}
thismasterptr = thismasterptr->nextptr;
}
}
if(thislistptr->on == 0) sprintf(onoffstr," off ");
else onoffstr[0]='\0';
if(thislistptr->radius > 0.001)
/*only allow positive values now*/
{
sprintf(dname," radius= %.3f ",thislistptr->radius);
}
else dname[0]='\0';
if( (thislistptr->STATUS & STATICFLAG) == STATICFLAG)
{
sprintf(staticness," static");
}
if( (thislistptr->STATUS & SCREENFLAG) == SCREENFLAG)
{
sprintf(staticness," screen");
}
else staticness[0]='\0';
/*Thus screen is a more rigorous form of static */
/*but in any case, they are incompatible types */
hiliteness[0] = '\0'; /*clear*/
if( (thislistptr->STATUS & NOHILITEFLAG) == NOHILITEFLAG)
{
sprintf(tempstr," nohilite");
}
else tempstr[0]='\0';
if( (thislistptr->STATUS & NOBLKRIMFLAG) == NOBLKRIMFLAG) /*040925*/
{
strcat(tempstr," noblkrim");
}
sprintf(hiliteness,"%s",tempstr);
if(hasballlist)
{/*ball output*/
fprintf(fpout,"@balllist {balls}%s%s%s%s%s%s%s\n"
,colorstr,buttonstr,masterstr,onoffstr
,dname,hiliteness,staticness); /*invent list name*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( (thispointptr->type) & BALL ) /*ball*/
{/*write ball point*/
writeindividualpoint(0); /*iPointFlag==0*/ /*writedrawnew()*/
}/*write ball point*/
}/*survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}
}/*ball output*/
if(hasvectorlist)
{/*vector output*/
fprintf(fpout,"@vectorlist {%s}%s%s%s%s%s%s%s\n"
,thislistptr->name,colorstr,buttonstr,masterstr,onoffstr
,dname,hiliteness,staticness); /*using the one list name is*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( ( (thispointptr->type) & VECTOR )
&&( (thispointptr->type) & VARIANT1) == 0
&&( (thispointptr->type) & VARIANT2) == 0
&&( (thispointptr->type) & VARIANT3) == 0 )
{/*write plain vector point*/
writeindividualpoint(0); /*iPointFlag==0*/ /*writedrawnew()*/
}/*write plain vector point*/
}/*survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}
}/*vector output*/
if(haslabellist)
{/*label output*/
fprintf(fpout,"@labellist {labels}%s%s%s%s%s%s%s\n"
,colorstr,buttonstr,masterstr,onoffstr
,dname,hiliteness,staticness); /*invent list name*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( (thispointptr->type) & LABEL ) /*label*/
{/*write label point*/
writeindividualpoint(0); /*iPointFlag==0*/ /*writedrawnew()*/
}/*write label point*/
}/*survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}
}/*label output*/
if(hasdotlist)
{/*dot output*/
fprintf(fpout,"@dotlist {dots}%s%s%s%s%s%s%s\n"
,colorstr,buttonstr,masterstr,onoffstr
,dname,hiliteness,staticness); /*invent list name*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( (thispointptr->type) & DOT ) /*dot*/
{/*write dot point*/
writeindividualpoint(0); /*iPointFlag==0*/ /*writedrawnew()*/
}/*write dot point*/
}/*survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}
}/*dot output*/
if(hasarrowlist)
{/*arrow output*/
sprintf(dname," radius= %.3f angle= %.3f ",distarrow,anglearrow);
/*globals: length of tine, angle of tine,*/
/*implicit: dihedralarrow==90: 4 tines*/
fprintf(fpout,"@arrowlist {arrows}%s%s%s%s%s%s%s\n"
,colorstr,buttonstr,masterstr,onoffstr
,dname,hiliteness,staticness); /*invent list name*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
&&!((thispointptr->STATUS) & GHOST) ) /*not a ghost*/
{/*survived pruning*/
if( (thispointptr->type) & ARROW ) /*arrow*/
{/*write dot point*/
writeindividualpoint(0); /*iPointFlag==0*/ /*writedrawnew()*/
}/*write dot point*/
}/*survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}
}/*arrow output*/
fprintf(fpout,"\n");
ireturn = 1;
}/*has vectors or labels or dots or arrows or balls*/
else
{
ireturn = 0;
}
/*fclose(fpout);fpout = NULL;*/
/*Don't close here, writedrawnew can be part of output*/
return(ireturn);
}
/*___writedrawnew()_________________________________________________________*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
/****writepruned()***********************************************************/
int writepruned() /*960316 viewout stuff*/
{/*output (modified) current kinemage*/
/*kinescopeout() calls this as part of writing all kins in its file*/
int ireturn,i,j,isurvived;
char aname[MAXNAMECHAR+1],bname[MAXNAMECHAR+1];
char cname[MAXNAMECHAR+1],extraname[MAXNAMECHAR+1];
char dname[256]; /*060525 for dimension=7 etc...*/
char dname1[16],dname2[16],dname3[16],dname4[16],dname5[16];
char dNnames[256]; /*060525 for dimension=7 etc...*/
char onename[256],newname[256]; /*060726 for dimension=7 etc...*/
char hold[256];
unsigned long long mask; /*081120 long long*/
float mx[10];
int Lfirsttablegroup = 1; /*until encounter a first table group*/
int IONlimit; /*060604 for Lononlyout*/
int Lononlyout=0; /*made local to writepruned() as of 061123*/
if(LPDBformat) /*040208,rev 070829*/
{
Lkinformat = 0;
}
else
{
Lkinformat = 1; /*kinemage rather than PDB format*/
}
if(Lvisibleout || Laverageout) /*060604*/
{
Lononlyout = 1;
IONlimit = 0; /*survive for output only if really visibly ON */
}
else /*revert Lononlyout 061124*/
{
IONlimit = -50;/*survived pickshow deletion, either ON or OFF*/ /*060604*/
Lononlyout = 0;
}
Lpruneactive = 0; /* worry flags*/
Ldrawactive = 0;
Lnewviewactive = 0;
Lnewstuffactive = 0;
LemphasisOUT = 0; /*031127*/
if(Lkinformat && !Laverageout) /*040208, 060604*/
{/*output header stuff*/
if(beginselectionpointptr != NULL)
{/*expect selection from begin and end selection*/
Lbeginselectionout = 1; /*flag to write @beginselect*/
}
fprintf(fpout,"@kinemage %d\n",thiskinenum);
writecaption(); /*MACOUT.C MPCOUT.C*/
/*fprintf(fpout,"\n");*/ /*ensure next keyword on a new line*/
/*990124 remove, writetext and writecaption should ensure final EOL char*/
if(Lkintitle) {fprintf(fpout,"@title {%s}\n",kintitlestr);} /*030605*/
if(Lkinpdbfile) {fprintf(fpout,"@pdbfile {%s}\n",kinpdbfilestr);} /*011010*/
if(Lkinmapfile) {fprintf(fpout,"@mapfile {%s}\n",kinmapfilestr);} /*030312*/
/*if(Lspanofview) fprintf(fpout,"@xxxx %.2f\n",spanofview);*/ /*980920*/
if(LLensflagset){fprintf(fpout,"@lens %.2f\n",lensFactor);} /*970917*/
if(Listcolordominant) {fprintf(fpout,"@listcolordominant\n");} /*970917*/
if(update_command_line[0] != '\0')
{
fprintf(fpout,"@command {%s}\n",update_command_line);
}
else if(input_command_line[0] != '\0')
{
fprintf(fpout,"@command {%s}\n",input_command_line);
}
if(Lcommentinput) /*020917*/
{
fprintf(fpout,"@comment {%s}\n",commentinputstr);
}
if(Ldrawnewinput) {fprintf(fpout,"@drawnew\n");}
if(Ldrawlineinput) {fprintf(fpout,"@drawline\n");}
if(Ldrawlabelinput) {fprintf(fpout,"@drawlabel\n");}
if(Ldrawballinput) {fprintf(fpout,"@drawball\n");}
if(Lbigfontsinput) {fprintf(fpout,"@bigfonts\n");}
if(Lnosavealertinput) {fprintf(fpout,"@nosavealert\n");}
if(Lshortlineinput) {fprintf(fpout,"@shortline\n");}
if(Lonewidth) {fprintf(fpout,"@onewidth\n");}
if(Lthin) {fprintf(fpout,"@thinline\n");}
if(Lperspec) {fprintf(fpout,"@perspective\n");}
if(Lwhitebkg) {fprintf(fpout,"@whitebackground\n");} /*990125*/
if(LNdimnames) /*060726*/
{ /*construct keyword and its set of dimensions*/
/*names*/
dNnames[0] = '\0'; /*trouble with first field 061124,26,...*/
sprintf(dNnames,"@dimension"); /*to be continued...*/
for(j=0; j<NDIM; j++)
{
sprintf(onename," {%s}",dimensionptr[j].name);
/*if(sizeof(onename) + sizeof(dNnames) < 255) both 256 */
{/*character string still in bounds one hopes since sizeof not work*/
sprintf(newname,"%s%s",dNnames,onename);
strcpy(dNnames,newname);
}
}
sprintf(newname,"%s\n",dNnames); /*tack on LF*/
strcpy(dNnames,newname); /*bounds above allow LF character*/
fprintf(fpout,"%s",dNnames); /*actual output line 061113*/
/*min max pairs*/
dNnames[0] = '\0'; /*trouble with first field 061124,26,...*/
sprintf(dNnames,"@dimension"); /*to be continued...*/
for(j=0; j<NDIM; j++)
{
sprintf(onename," {%s}",dimensionptr[j].name);
/*if(sizeof(onename) + sizeof(dNnames) < 255) both 256 */
{/*character string still in bounds one hopes since sizeof not work*/
sprintf(newname,"%s%s",dNnames,onename);
strcpy(dNnames,newname);
}
}
sprintf(dNnames,"@dimminmax"); /*to be continued...*/
for(j=0; j<NDIM; j++)
{
sprintf(onename," %.3f %.3f",dimensionptr[j].min,dimensionptr[j].max);
/*if(sizeof(onename) + sizeof(dNnames) < 255) both 256 */
{/*character string still in bounds one hopes since sizeof not work*/
sprintf(newname,"%s%s",dNnames,onename);
strcpy(dNnames,newname);
}
}
sprintf(newname,"%s\n",dNnames); /*tack on LF*/
strcpy(dNnames,newname); /*bounds above allow LF character*/
fprintf(fpout,"%s",dNnames); /*actual output line*/
}
for(i=1; i< MAXRESETS ;i++)
{
if(Lview[i])
{/*Lview*/
/*---------------------------------*/
if(viewcom[i][0] != '\0') /*not null string*/
{
if(i==1) fprintf(fpout,"@viewid {%s}\n",viewcom[i]);
else if(i<10) fprintf(fpout,"@%1dviewid {%s}\n",i,viewcom[i]);
else fprintf(fpout,"@%2dviewid {%s}\n",i,viewcom[i]);
}
if(Lzoomer[i]!=0)/*980929*/
{
if(Lzoomer[i]>0)/*980929*/
{
if(i==1) fprintf(fpout,"@zoom %.2f\n",zoomold[i]);
else if(i<10) fprintf(fpout,"@%1dzoom %.2f\n",i,zoomold[i]);
else fprintf(fpout,"@%2dzoom %.2f\n",i,zoomold[i]);
}
else
{/* span of screen from which to calc zoom*/
if(i==1) fprintf(fpout,"@span %.2f\n",zoomold[i]);
else if(i<10) fprintf(fpout,"@%1dspan %.2f\n",i,zoomold[i]);
else fprintf(fpout,"@%2dspan %.2f\n",i,zoomold[i]);
}/*980929*/
}
/*---------------------------------*/
if(Lzcliper[i])
{
if(i==1) fprintf(fpout,"@zslab %d\n",izclipold[i]);
else if(i<10) fprintf(fpout,"@%1dzslab %d\n"
,i,izclipold[i]);
else fprintf(fpout,"@%2dzslab %d\n",i,izclipold[i]);
}
/*----------------------------------*/
if(Lztraner[i]) /*970909*/
{
if(i==1) fprintf(fpout,"@ztran %d\n",iztranold[i]);
else if(i<10) fprintf(fpout,"@%1dztran %d\n"
,i,iztranold[i]);
else fprintf(fpout,"@%2dztran %d\n",i,iztranold[i]);
}
/*----------------------------------*/
if(Lcenter[i])
{
if(i==1) fprintf(fpout,"@center %.3f %.3f %.3f\n"
,fxcenterold[i],fycenterold[i],fzcenterold[i]);
else if(i<10) fprintf(fpout,"@%1dcenter %.3f %.3f %.3f\n"
,i,fxcenterold[i],fycenterold[i],fzcenterold[i]);
else fprintf(fpout,"@%2dcenter %.3f %.3f %.3f\n"
,i,fxcenterold[i],fycenterold[i],fzcenterold[i]);
}
/*----------------------------------*/
if( Lgwidthheightview[i] >0 /*060613*/
&& gwidthview[i] >0 && gheightview[i] >0) /*041031*/
{/*041031 060613*/
if(i==1) fprintf(fpout,"@size %d %d\n"
,gwidthview[i],gheightview[i]);
else if(i<10) fprintf(fpout,"@%1dsize %d %d\n"
,i,gwidthview[i],gheightview[i]);
else fprintf(fpout,"@%2dsize %d %d\n"
,i,gwidthview[i],gheightview[i]);
}
/*----------------------------------*/
if(Laxischoice[i]) /*060613*/
{ /*axes array indexed from 0, count axes from 1 */
if(i==1)
{
fprintf(fpout,"@axischoice %d %d %d\n"
,1+axischoice[i][0],1+axischoice[i][1],1+axischoice[i][2]);
}
else if(i<10)
{
fprintf(fpout,"@%1daxischoice %d %d %d\n"
,i,1+axischoice[i][0],1+axischoice[i][1],1+axischoice[i][2]);
}
else
{
fprintf(fpout,"@%2daxischoice %d %d %d\n"
,i,1+axischoice[i][0],1+axischoice[i][1],1+axischoice[i][2]);
}
}
/*----------------------------------*/
if(Lreset[i])
{
j = i;
mx[1] = (float)ma[j][1];
mx[2] = -(float)ma[j][2]; /* 1 2 3 1 0 0 */
mx[3] = (float)ma[j][3]; /* 4 5 6 X 0 -1 0 */
mx[4] = (float)ma[j][4]; /* 7 8 9 0 0 1 */
mx[5] = -(float)ma[j][5];
mx[6] = (float)ma[j][6]; /* Mac handedness correction : */
mx[7] = (float)ma[j][7]; /* back correct so written matrix*/
mx[8] = -(float)ma[j][8]; /* is correct for input to this, */
mx[9] = (float)ma[j][9]; /* or any program */
if(i==1) fprintf(fpout,"@matrix\n");
else if(i<10)fprintf(fpout,"@%1dmatrix\n",i);
else fprintf(fpout,"@%2dmatrix\n",i);
fprintf(fpout,"%f %f %f %f %f %f %f %f %f\n",
mx[1],mx[2],mx[3],mx[4],mx[5],mx[6],mx[7],mx[8],mx[9]);
}
/*---------------------------------*/
}/*Lview*/
}
if(firstmasterptr != NULL) /*there are masters*/ /*970513*/
{
thismasterptr = firstmasterptr;
while(thismasterptr != NULL)
{
fprintf(fpout,"@master {%s}\n",thismasterptr->name);
thismasterptr = thismasterptr->nextptr;
}
/*scan through again looking for pointmasters*/ /*991210*/
thismasterptr = firstmasterptr;
while(thismasterptr != NULL)
{
if(thismasterptr->masterchar != '\0')
{
if(thismasterptr->on) {sprintf(word," on");} /*030425*/
else {sprintf(word," off");} /*030425*/
fprintf(fpout,"@pointmaster '%c' {%s}%s\n"
,thismasterptr->masterchar,thismasterptr->name,word);
}
thismasterptr = thismasterptr->nextptr;
}
}
if(firstcolorsetptr != NULL) /*there are colorsets*/ /*991104*/
{
thiscolorsetptr = firstcolorsetptr;
while(thiscolorsetptr != NULL)
{
interpretcolor(thiscolorsetptr->color); /*returns in word*/
fprintf(fpout,"@colorset {%s} %s\n",thiscolorsetptr->name,word);
thiscolorsetptr = thiscolorsetptr->nextptr;
}
}
if(naspectsthiskinemage > 0) /*there are aspects*/ /*031227*/
{
for(i=1; i<naspectsthiskinemage+1; i++)
{
fprintf(fpout,"@%daspect {%s}\n",i,aspect[i]);
}
}
}/*output header stuff*/
thisgrupptr = firstgrupptr;
while(thisgrupptr != NULL)
{/*BIG loop-over-groups*/
isurvived = 0; /*set to NOT survive, must be persuaded to live*/
/*check for survival of self and at least one child*/
if(thisgrupptr->on > IONlimit) /*0606040*/
{/*for this group: group survived pickshow*/
thissgrpptr = thisgrupptr->firstsgrpptr;
while(thissgrpptr != NULL)
{/*for this group: test for subgroup survival*/
if(thissgrpptr->on > IONlimit) /*060604*/
{/*for this group: subgroup survived pickshow*/
thislistptr = thissgrpptr->firstlistptr;
while(thislistptr != NULL)
{/*for this group: test for list survival*/
if(thislistptr->on > IONlimit) /*060604*/
{/*for this group: list survived pickshow*/
thispointptr = thislistptr->firstpointptr;
while(thispointptr != NULL)
{/*for this group: test for point survival*/
/*since a surviving point is the ultimate and only true*/
/*survival test, check for bond rotation lists here*/
/*some of them have no points but all must be kept*/
if( !((thispointptr->type) & PRUNED) /*survived pruning*/
|| (thislistptr->bondrot != 0) )/*bondrot list pt*/
{/*for this group: point survived pruning, etc.*/
if( !Lononlyout
|| (Lononlyout && thispointptr->STATUS & ON) )
{
isurvived = 1;
}
}/*for this group: point survived pruning*/
if(thispointptr == thislistptr->lastpointptr)
thispointptr = NULL;
else thispointptr = thispointptr->nextptr;
}/*for this group: test for point survival*/
}/*for this group: list survived pickshow*/
if(thislistptr == thissgrpptr->lastlistptr) thislistptr = NULL;
else thislistptr = thislistptr->nextptr;
}/*for this group: test for list survival*/
}/*for this group: subgroup survived pickshow*/
if(thissgrpptr == thisgrupptr->lastsgrpptr) thissgrpptr = NULL;
else thissgrpptr = thissgrpptr->nextptr;
}/*for this group: test for subgroup survival*/
/*for this group: check for groups not to be included in a kinemage*/
if(thisgrupptr==markergrupptr ||thisgrupptr==measuregrupptr)isurvived =0;
if(Lononlyout && thisgrupptr->on == 0) isurvived = 0;
/*off: don't output*/
}/*for this group: group survived pickshow*/
if(isurvived)
{/*BIG this group survived*/
if(Lkinformat && !Laverageout) /*040208,060604*/
{/*this group: output first line*/
/*actually, before the first line of the first table group*/
if( (thisgrupptr->type & TABLEFLAG) == TABLEFLAG)
{/*table group*/
if(Lfirsttablegroup)
{
fprintf(fpout,"@tablewrap %d\n",tablewrapcol);
fprintf(fpout,"@tablecolscale %.2f\n",tablecolscale);
fprintf(fpout,"@tablefontsize %d\n",tablefontsize);