File: draw_venn.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (888 lines) | stat: -rw-r--r-- 29,410 bytes parent folder | download | duplicates (5)
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
/* Copyright (C) 2000-2004 Damir Zucic */

/*=============================================================================

				draw_venn.c

Purpose:
	Draw Venn diagram.  This function is used if the main win. drawing
	mode is equal to three. The sequence stored to the sequence buffer
	is used to prepare the Venn diagram.

Input:
	(1) Pointer to RuntimeS structure, with some runtime data.
	(2) Pointer to GUIS structure, with GUI data.
	(3) Pointer to NearestAtomS structure,  with information about the
	    atom occupying the given pixel.
	(4) The number of pixels in the main window free area.
	(5) The refreshI,  used to check the  NearestAtomS associated with
	    a given pixel. It is currently unused in this function.

Output:
	(1) Venn diagram drawn to the main window.
	(2) Return value.

Return value:
	(1) The number of residues used to prepare the Venn diagram.

Notes:
	(1) The initial drawing destination is the hidden pixmap,  and the
	    content of this pixmap is copied later to the main window.

	(2) Cysteine is treated  in a special way:  cysteine which  is not
	    involved in a disulfide bond should be treated as polar, while
	    cysteine which takes part  in disulfide bond  formation is not
	    polar.

========includes:============================================================*/

#include <stdio.h>

#include <string.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======function prototypes:=================================================*/

int		RefreshPixmap_ (Display *, Pixmap, GC,
				unsigned int, unsigned int, unsigned long);

/*======draw Venn diagram:===================================================*/

size_t DrawVenn_ (RuntimeS *runtimeSP, GUIS *guiSP,
		  NearestAtomS *nearest_atomSP, size_t pixelsN,
		  unsigned int refreshI)
{
int		max_length;
size_t		residuesN, residueI;
char		*residue_nameP;
char		residue_nameA[RESNAMESIZE];
int		range_startI, range_endI, residues_in_vennN = 0;
size_t		vennI = 0;
int		alaN = 0, argN = 0, asnN = 0, aspN = 0, cysN = 0;
int		glnN = 0, gluN = 0, glyN = 0, hisN = 0, ileN = 0;
int		leuN = 0, lysN = 0, metN = 0, pheN = 0, proN = 0;
int		serN = 0, thrN = 0, trpN = 0, tyrN = 0, valN = 0;
int		unkN = 0;
int		S_S_cysN = 0, S_H_cysN = 0;
int		hydrophobicN, polarN, smallN;
int		aromaticN, aliphaticN, tinyN, chargedN;
int		positiveN, negativeN;
int		screen_margin_x, screen_margin_y;
int		screen_delta_x, screen_delta_y;
int		screen_x0, screen_y0, screen_x;
unsigned int	screen_width, screen_height;
double		d;
int		text_width, text_height;
char		stringA[SHORTSTRINGSIZE];

/* The number of residues in sequence buffer: */
residuesN = runtimeSP->residuesN;
if (residuesN == 0)
	{
	strcpy (runtimeSP->messageA, "The sequence buffer is empty!");
	runtimeSP->message_length = strlen (runtimeSP->messageA);
	return 0;
	}

/* The maximal residue name length: */
max_length = RESNAMESIZE - 1;

/* Residue array index range: */
range_startI = runtimeSP->range_startI;
range_endI   = runtimeSP->range_endI;

/* Count the number of residues in the specified range: */
for (residueI = 0; residueI < residuesN; residueI++)
	{
	/* Check is the residue array index inside the range: */
	if (((int) residueI < range_startI) || ((int) residueI > range_endI))
		{
		continue;
		}

	/* Increase the count of residues if current */
	/* residue  belongs to  the specified range: */
	residues_in_vennN++;
	}

/* Check the number of residues in Venn diagram: */
if (residues_in_vennN == 0)
	{
	strcpy (runtimeSP->messageA, "The specified range is empty!");
	runtimeSP->message_length = strlen (runtimeSP->messageA);
	return 0;
	}

/* Refresh the hidden pixmap, where drawing will be done: */
RefreshPixmap_ (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		guiSP->control_winS.x0, guiSP->input_winS.y0,
		guiSP->main_winS.bg_colorID);

/*------auxilliary parameters:-----------------------------------------------*/

/* Text line height: */
text_height = guiSP->main_winS.font_height;

/* Prepare margins and useful area width and height: */
screen_margin_x = guiSP->main_win_free_area_width / 20;
if (screen_margin_x < 2) screen_margin_x = 2;
screen_margin_y = guiSP->main_win_free_area_height / 20;
if (screen_margin_y < 2) screen_margin_y = 2;
screen_delta_x = guiSP->main_win_free_area_width  - 2 * screen_margin_x;
if (screen_delta_x < 0) screen_delta_x = 0;
screen_delta_y = guiSP->main_win_free_area_height - 2 * screen_margin_y;
if (screen_delta_y < 0) screen_delta_y = 0;

/*------scan the sequence and count residues by type:------------------------*/

/* Count residues by type: */
for (residueI = 0; residueI < residuesN; residueI++)
	{
	/* Check is the residue array index inside the range: */
	if (((int) residueI < range_startI) || ((int) residueI > range_endI))
		{
		continue;
		}

	/* Pointer to the current residue name: */
	residue_nameP = runtimeSP->sequenceP + residueI * max_length;

	/* Copy the residue name: */
	strncpy (residue_nameA, residue_nameP, max_length);
	residue_nameA[max_length] = '\0';

	/* Check the residue name: */
	if      (strcmp (residue_nameA, "ALA") == 0) alaN++;
	else if (strcmp (residue_nameA, "ARG") == 0) argN++;
	else if (strcmp (residue_nameA, "ASN") == 0) asnN++;
	else if (strcmp (residue_nameA, "ASP") == 0) aspN++;
	else if (strcmp (residue_nameA, "CYS") == 0)
		{
		/* Update the total number of cysteines: */
		cysN++;

		/* Check disulfide flag: */
		if (*(runtimeSP->disulfideFP + residueI)) S_S_cysN++;
		else S_H_cysN++;
		}
	else if (strcmp (residue_nameA, "GLN") == 0) glnN++;
	else if (strcmp (residue_nameA, "GLU") == 0) gluN++;
	else if (strcmp (residue_nameA, "GLY") == 0) glyN++;
	else if (strcmp (residue_nameA, "HIS") == 0) hisN++;
	else if (strcmp (residue_nameA, "ILE") == 0) ileN++;
	else if (strcmp (residue_nameA, "LEU") == 0) leuN++;
	else if (strcmp (residue_nameA, "LYS") == 0) lysN++;
	else if (strcmp (residue_nameA, "MET") == 0) metN++;
	else if (strcmp (residue_nameA, "PHE") == 0) pheN++;
	else if (strcmp (residue_nameA, "PRO") == 0) proN++;
	else if (strcmp (residue_nameA, "SER") == 0) serN++;
	else if (strcmp (residue_nameA, "THR") == 0) thrN++;
	else if (strcmp (residue_nameA, "TRP") == 0) trpN++;
	else if (strcmp (residue_nameA, "TYR") == 0) tyrN++;
	else if (strcmp (residue_nameA, "VAL") == 0) valN++;
	else unkN++;

	/* Update the Venn diagram index: */
	vennI++;
	}

/* Prepare the combined counts: */
hydrophobicN = pheN + tyrN + trpN + hisN + metN +
	       ileN + leuN + valN + alaN + glyN +
	       cysN;
polarN = tyrN + trpN + hisN + lysN + argN + gluN +
	 glnN + aspN + asnN + thrN + serN + S_H_cysN;
smallN = glyN + alaN + serN + proN + valN + thrN + aspN + asnN + cysN;
chargedN = argN + lysN + hisN + gluN + aspN;
aromaticN = trpN + tyrN + pheN + hisN;
aliphaticN = valN + leuN + ileN;
tinyN = glyN + alaN + serN + S_H_cysN;
positiveN = argN + lysN + hisN;
negativeN = gluN + aspN;

/*------draw polar, hydrophobic and small rectangle:-------------------------*/

/* Polar rectangle: */
screen_x0 = screen_margin_x;
d = 0.075 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.666 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.765 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->blue_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 3, screen_y0 - 3,
		screen_width + 6, screen_height + 6);

/* Hydrophobic rectangle: */
d = 0.333 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
screen_y0 = screen_margin_y;
d = 0.666 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.824 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[1], guiSP->red_colorID);
XDrawRectangle (guiSP->displaySP,
                guiSP->main_hidden_pixmapID,
                guiSP->theGCA[1],
                screen_x0, screen_y0,
                screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 3, screen_y0 - 3,
		screen_width + 6, screen_height + 6);

/* Small rectangle (small refers to small residues, not to the rectangle): */
d = 0.012 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.534 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.967 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.470 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[2], guiSP->green_colorID);
XDrawRectangle (guiSP->displaySP,
                guiSP->main_hidden_pixmapID,
                guiSP->theGCA[2],
                screen_x0, screen_y0,
                screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0 - 3, screen_y0 - 3,
		screen_width + 6, screen_height + 6);

/*------draw charged, aromatic, aliphatic and tiny rectangle:----------------*/

/* Charged rectangle: */
d = 0.023 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.200 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.635 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.430 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->blue_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);

/* Aromatic rectangle: */
d = 0.342 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.088 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.648 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.255 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[1], guiSP->red_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);

/* Aliphatic rectangle: */
d = 0.679 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.372 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.311 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.257 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[1], guiSP->red_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[1],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);

/* Tiny rectangle: */
d = 0.023 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.730 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.948 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.190 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[2], guiSP->green_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[2],
		screen_x0 - 2, screen_y0 - 2,
		screen_width + 4, screen_height + 4);

/*------positive and negative rectangle:-------------------------------------*/

/* Positive rectangle: */
d = 0.030 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.270 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.618 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.150 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->blue_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);

/* Negative rectangle: */
d = 0.030 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (unsigned int) d;
d = 0.430 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d;
d = 0.292 * (double) screen_delta_x;
if (d < 1.0) d = 1.0;
screen_width = (unsigned int) d;
d = 0.190 * (double) screen_delta_y;
if (d < 1.0) d = 1.0;
screen_height = (unsigned int) d;
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], guiSP->blue_colorID);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0, screen_y0,
		screen_width, screen_height);
XDrawRectangle (guiSP->displaySP,
		guiSP->main_hidden_pixmapID,
		guiSP->theGCA[0],
		screen_x0 - 1, screen_y0 - 1,
		screen_width + 2, screen_height + 2);

/*------draw text:-----------------------------------------------------------*/

XSetForeground (guiSP->displaySP, guiSP->theGCA[0],
		guiSP->main_winS.fg_colorID);

/* TOTAL NUMBER OF RESIDUES: */
screen_x0 = screen_margin_x;
screen_y0 = screen_margin_y + text_height - 1;
sprintf (stringA, "TOTAL: %d", residuesN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* POLAR: */
screen_x0 = screen_margin_x + 5;
d = 0.075 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height - 1;
sprintf (stringA, "POLAR: %d", polarN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
             screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* HYDROPHOBIC: */
d = 0.333 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
screen_y0 = screen_margin_y + text_height - 1;
sprintf (stringA, "HYDROPHOBIC: %d", hydrophobicN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* SMALL: */
d = 0.012 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.985 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + guiSP->main_winS.fontSP->descent + 1;
sprintf (stringA, "SMALL: %d", smallN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* CHARGED: */
d = 0.023 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.200 * (double) screen_delta_y + text_height;
screen_y0 = screen_margin_y + (int) d - 1;
sprintf (stringA, "CHARGED: %d", chargedN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* AROMATIC: */
d = 0.670 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.088 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height - 1;
sprintf (stringA, "AROMATIC: %d", aromaticN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* ALIPHATIC: */
d = 0.679 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.372 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height - 1;
sprintf (stringA, "ALIPHATIC: %d", aliphaticN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* TINY: */
d = 0.023 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.905 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (unsigned int) d +
	    guiSP->main_winS.fontSP->descent + 1;
sprintf (stringA, "TINY: %d", tinyN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* POSITIVE: */
d = 0.030 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.270 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height - 1;
sprintf (stringA, "POSITIVE: %d", positiveN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* NEGATIVE: */
d = 0.030 * (double) screen_delta_x;
screen_x0 = screen_margin_x + (int) d + 5;
d = 0.428 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height - 1;
sprintf (stringA, "NEGATIVE: %d", negativeN);
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The first five strings will be placed at the same screen_x: */
d = 0.167 * screen_delta_x;
screen_x = screen_margin_x + (int) d;

/* GLN: */
sprintf (stringA, "GLN: %d", glnN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.138 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* ARG: */
sprintf (stringA, "ARG: %d", argN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.340 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* LYS: */
sprintf (stringA, "LYS: %d", lysN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.380 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* GLU: */
sprintf (stringA, "GLU: %d", gluN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.515 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* ASP: */
sprintf (stringA, "ASP: %d", aspN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.570 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* SER: */
sprintf (stringA, "SER: %d", serN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.780 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The next two strings are not aligned vertically with the previous five: */

/* ASN: */
sprintf (stringA, "ASN: %d", asnN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.092 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.675 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* THR: */
sprintf (stringA, "THR: %d", thrN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.253 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.675 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The next five strings are placed at the same screen_x: */
d = 0.500 * screen_delta_x;
screen_x = screen_margin_x + (int) d;

/* HIS: */
sprintf (stringA, "HIS: %d", hisN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.307 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* CYS (S-S): */
sprintf (stringA, "CYS (S-S): %d", S_S_cysN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.675 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* CYS (S-H): */
sprintf (stringA, "CYS (S-H): %d", S_H_cysN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.780 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* PRO: */
sprintf (stringA, "PRO: %d", proN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.960 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The next two strings are not aligned vertically with the previous five: */

/* TYR: */
sprintf (stringA, "TYR: %d", tyrN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.423 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.138 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* TRP: */
sprintf (stringA, "TRP: %d", trpN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.585 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.138 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The next three strings are placed at the same screen_x: */
d = 0.825 * screen_delta_x;
screen_x = screen_margin_x + (int) d;

/* MET: */
sprintf (stringA, "MET: %d", metN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.044 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* PHE: */
sprintf (stringA, "PHE: %d", pheN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x0 = screen_x - text_width / 2;
d = 0.216 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* VAL: */
sprintf (stringA, "VAL: %d", valN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
screen_x = screen_x0 - text_width / 2;
d = 0.570 * (double) screen_delta_y;
screen_y0 = screen_margin_y + (int) d + text_height / 2;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* The next four strings are not aligned with the previous three: */

/* LEU: */
sprintf (stringA, "LEU: %d", leuN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.757 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.470 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* ILE: */
sprintf (stringA, "ILE: %d", ileN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.912 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.470 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* ALA: */
sprintf (stringA, "ALA: %d", alaN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.745 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.780 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/* GLY: */
sprintf (stringA, "GLY: %d", glyN);
text_width = XTextWidth (guiSP->main_winS.fontSP, stringA, strlen (stringA));
d = 0.890 * screen_delta_x;
screen_x0 = screen_margin_x + (int) d - text_width / 2;
d = 0.780 * screen_delta_y;
screen_y0 = screen_margin_y + (int) d;
XDrawString (guiSP->displaySP,
	     guiSP->main_hidden_pixmapID,
	     guiSP->theGCA[0],
	     screen_x0, screen_y0,
	     stringA, strlen (stringA));

/*------copy the prepared image to the main window:--------------------------*/

/* Copy hidden pixmap to the main window: */
XCopyArea (guiSP->displaySP,
	   guiSP->main_hidden_pixmapID, guiSP->main_winS.ID,
	   guiSP->theGCA[0],
	   0, 0,
	   guiSP->main_win_free_area_width, guiSP->main_win_free_area_height,
	   0, 0);

return residuesN;
}

/*===========================================================================*/