1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Hyphob color scheme: colors are assigned according to hydrophobicity.
9
Residues with hydrophobicity close to threshold value will be white,
10
hydrophobic residues will be red and hydrophilic residues will be
14
(1) Pointer to MolComplexS structure, with macromol. complexes.
15
(2) Number of macromolecular complexes.
16
(3) Pointer to GUIS structure, with GUI data.
17
(4) Pointer to ColorSchemeS structure.
25
=============================================================================*/
32
#include <X11/Xutil.h>
34
#include <X11/Xatom.h>
39
/*======function prototypes:=================================================*/
41
int MixColors_ (AtomS *, ColorSchemeS *, ColorSchemeS *,
44
/*======hyphob color scheme:=================================================*/
46
int ColorHyphob_ (MolComplexS *mol_complexSP, int mol_complexesN,
47
GUIS *guiSP, ColorSchemeS *color_schemeSP)
50
MolComplexS *curr_mol_complexSP;
53
size_t rgb_struct_size;
54
ColorSchemeS *blue_schemeSP, *white_schemeSP, *red_schemeSP;
55
double min_hyphob, threshold_hyphob, max_hyphob;
56
double delta_hyphob1, delta_hyphob2;
57
double inverse_range1, inverse_range2;
61
/* The size of RGBS structure: */
62
rgb_struct_size = sizeof (RGBS);
64
/* Red scheme pointer: */
65
red_schemeSP = color_schemeSP + 0;
67
/* Yellow scheme pointer: */
68
white_schemeSP = color_schemeSP + 6;
70
/* Blue scheme pointer: */
71
blue_schemeSP = color_schemeSP + 2;
73
/* Scan every macromolecular complex: */
74
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
76
/* Pointer to the current macromolecular complex: */
77
curr_mol_complexSP = mol_complexSP + mol_complexI;
79
/* Check is the current macromolecular complex caught: */
80
if (curr_mol_complexSP->catchF == 0) continue;
82
/* Minimal, maximal and threshold hydrophob. for current complex: */
83
min_hyphob = (double) curr_mol_complexSP->min_hydrophobicity;
84
max_hyphob = (double) curr_mol_complexSP->max_hydrophobicity;
86
(double) curr_mol_complexSP->threshold_hydrophobicity;
88
/* Inverse hydrophobicity ranges: */
89
delta_hyphob1 = max_hyphob - threshold_hyphob;
90
if (delta_hyphob1 != 0.0) inverse_range1 = 1.0 / delta_hyphob1;
91
else inverse_range1 = 0.0;
92
delta_hyphob2 = threshold_hyphob - min_hyphob;
93
if (delta_hyphob2 != 0.0) inverse_range2 = 1.0 / delta_hyphob2;
94
else inverse_range2 = 0.0;
96
/* Number of atoms in a macromolecular complex: */
97
atomsN = curr_mol_complexSP->atomsN;
99
/* Scan all atoms in the current complex: */
100
for (atomI = 0; atomI < atomsN; atomI++)
102
/* Pointer to the current atom: */
103
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
105
/* Check is atom selected: */
106
if (curr_atomSP->selectedF == 0) continue;
108
/* Set the number of color surfaces: */
109
curr_atomSP->surfacesN = 2;
111
/* Hydrophobicity of the current atom: */
112
hyphob = (double) curr_atomSP->raw_atomS.hydrophobicity;
114
/* If hydrophobicity is below threshold value: */
115
if (hyphob <= threshold_hyphob)
117
scale_factor = (threshold_hyphob - hyphob) *
119
MixColors_ (curr_atomSP,
120
white_schemeSP, blue_schemeSP,
121
scale_factor, guiSP);
124
/* If hydrophobicity is above threshold value: */
127
scale_factor = (hyphob - threshold_hyphob) *
129
MixColors_ (curr_atomSP,
130
white_schemeSP, red_schemeSP,
131
scale_factor, guiSP);
135
/* Reset the position_changedF: */
136
curr_mol_complexSP->position_changedF = 1;
139
/* Return positive value: */
143
/*===========================================================================*/