~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to color_hyphob.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                color_hyphob.c
 
6
 
 
7
Purpose:
 
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
 
11
        blue.
 
12
 
 
13
Input:
 
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.
 
18
 
 
19
Output:
 
20
        (1) Return value.
 
21
 
 
22
Return value:
 
23
        (1) Positive always.
 
24
 
 
25
=============================================================================*/
 
26
 
 
27
#include <stdio.h>
 
28
 
 
29
#include <string.h>
 
30
 
 
31
#include <X11/Xlib.h>
 
32
#include <X11/Xutil.h>
 
33
#include <X11/Xos.h>
 
34
#include <X11/Xatom.h>
 
35
 
 
36
#include "defines.h"
 
37
#include "typedefs.h"
 
38
 
 
39
/*======function prototypes:=================================================*/
 
40
 
 
41
int             MixColors_ (AtomS *, ColorSchemeS *, ColorSchemeS *,
 
42
                            double, GUIS *);
 
43
 
 
44
/*======hyphob color scheme:=================================================*/
 
45
 
 
46
int ColorHyphob_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
47
                  GUIS *guiSP, ColorSchemeS *color_schemeSP)
 
48
{
 
49
int                     mol_complexI;
 
50
MolComplexS             *curr_mol_complexSP;
 
51
size_t                  atomsN, atomI;
 
52
AtomS                   *curr_atomSP;
 
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;
 
58
double                  hyphob;
 
59
double                  scale_factor;
 
60
 
 
61
/* The size of RGBS structure: */
 
62
rgb_struct_size = sizeof (RGBS);
 
63
 
 
64
/* Red scheme pointer: */
 
65
red_schemeSP = color_schemeSP + 0;
 
66
 
 
67
/* Yellow scheme pointer: */
 
68
white_schemeSP = color_schemeSP + 6;
 
69
 
 
70
/* Blue scheme pointer: */
 
71
blue_schemeSP = color_schemeSP + 2;
 
72
 
 
73
/* Scan every macromolecular complex: */
 
74
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
 
75
        {
 
76
        /* Pointer to the current macromolecular complex: */
 
77
        curr_mol_complexSP = mol_complexSP + mol_complexI;
 
78
 
 
79
        /* Check is the current macromolecular complex caught: */
 
80
        if (curr_mol_complexSP->catchF == 0) continue;
 
81
 
 
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;
 
85
        threshold_hyphob =
 
86
                     (double) curr_mol_complexSP->threshold_hydrophobicity;
 
87
 
 
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;
 
95
 
 
96
        /* Number of atoms in a macromolecular complex: */
 
97
        atomsN = curr_mol_complexSP->atomsN;
 
98
 
 
99
        /* Scan all atoms in the current complex: */
 
100
        for (atomI = 0; atomI < atomsN; atomI++)
 
101
                {
 
102
                /* Pointer to the current atom: */
 
103
                curr_atomSP = curr_mol_complexSP->atomSP + atomI;
 
104
 
 
105
                /* Check is atom selected: */
 
106
                if (curr_atomSP->selectedF == 0) continue;
 
107
 
 
108
                /* Set the number of color surfaces: */
 
109
                curr_atomSP->surfacesN = 2;
 
110
 
 
111
                /* Hydrophobicity of the current atom: */
 
112
                hyphob = (double) curr_atomSP->raw_atomS.hydrophobicity;
 
113
 
 
114
                /* If hydrophobicity is below threshold value: */
 
115
                if (hyphob <= threshold_hyphob)
 
116
                        {
 
117
                        scale_factor = (threshold_hyphob - hyphob) *
 
118
                                        inverse_range2;
 
119
                        MixColors_ (curr_atomSP,
 
120
                                    white_schemeSP, blue_schemeSP,
 
121
                                    scale_factor, guiSP);
 
122
                        }
 
123
 
 
124
                /* If hydrophobicity is above threshold value: */
 
125
                else
 
126
                        {
 
127
                        scale_factor = (hyphob - threshold_hyphob) *
 
128
                                        inverse_range1;
 
129
                        MixColors_ (curr_atomSP,
 
130
                                    white_schemeSP, red_schemeSP,
 
131
                                    scale_factor, guiSP);
 
132
                        }
 
133
                }
 
134
 
 
135
        /* Reset the position_changedF: */
 
136
        curr_mol_complexSP->position_changedF = 1;
 
137
        }
 
138
 
 
139
/* Return positive value: */
 
140
return 1;
 
141
}
 
142
 
 
143
/*===========================================================================*/
 
144
 
 
145