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

« back to all changes in this revision

Viewing changes to scale.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
                                scale.c
 
6
 
 
7
Purpose:
 
8
        Execute scale command: change the hydrophobicity scale. This scale
 
9
        will be assigned to all caught macromolecular complexes and to the
 
10
        sequence stored in the sequence buffer.
 
11
 
 
12
Input:
 
13
        (1) Pointer to MolComplexS structure.
 
14
        (2) The number of macromolecular complexes.
 
15
        (3) Pointer to RuntimeS structure.
 
16
        (4) Pointer to the remainder of the command string.  The remainder
 
17
            should  contain  the hydrophobicity scale  name.  The keywords
 
18
            are: EIS (EISENBERG), KD (KYTE-DOOLITLE) and WHI (WHITE).
 
19
 
 
20
Output:
 
21
        (1) Hydrophobicity scale changed  for each caught complex  and for
 
22
            the sequence stored in the sequence buffer.
 
23
        (2) Return value.
 
24
 
 
25
Return value:
 
26
        (1) Positive (command) code on success.
 
27
        (2) Negative (error) code on failure.
 
28
 
 
29
Notes:
 
30
        (1) The main window content will not be refreshed.
 
31
 
 
32
========includes:============================================================*/
 
33
 
 
34
#include <stdio.h>
 
35
 
 
36
#include <string.h>
 
37
 
 
38
#include <X11/Xlib.h>
 
39
#include <X11/Xutil.h>
 
40
#include <X11/Xos.h>
 
41
#include <X11/Xatom.h>
 
42
 
 
43
#include "defines.h"
 
44
#include "commands.h"
 
45
#include "typedefs.h"
 
46
 
 
47
/*======function prototypes:=================================================*/
 
48
 
 
49
char            *ExtractToken_ (char *, int, char *, char *);
 
50
int             AssignHydrophobicity_ (MolComplexS *, int);
 
51
void            InitHyphob_ (RuntimeS *);
 
52
 
 
53
/*======execute scale command:===============================================*/
 
54
 
 
55
int Scale_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
56
            RuntimeS *runtimeSP, char *stringP)
 
57
{
 
58
char            *remainderP;
 
59
char            tokenA[STRINGSIZE];
 
60
int             scaleI = 2;
 
61
int             mol_complexI;
 
62
MolComplexS     *curr_mol_complexSP;
 
63
 
 
64
/* Extract the first token, if present: */
 
65
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
 
66
 
 
67
/* If there are no tokens in the remainder of the */
 
68
/* command  string,  the  scale name  is missing: */
 
69
if (!remainderP)
 
70
        {
 
71
        strcpy (runtimeSP->messageA, "Scale name missing!");
 
72
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
73
        return ERROR_SCALE;
 
74
        }
 
75
 
 
76
/* WHI (WHITE): */
 
77
else if (strstr (tokenA, "WHI") == tokenA) scaleI = 0;
 
78
 
 
79
/* KD (KYTE-DOOLITLE): */
 
80
else if (strstr (tokenA, "KD")  == tokenA) scaleI = 1;
 
81
 
 
82
/* EIS (EISENBERG): */
 
83
else if (strstr (tokenA, "EIS") == tokenA) scaleI = 2;
 
84
 
 
85
/* Keyword not recognized: */
 
86
else
 
87
        {
 
88
        strcpy (runtimeSP->messageA, "Keyword not recognized!");
 
89
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
90
        return ERROR_SCALE;
 
91
        }
 
92
 
 
93
/* For each caught macromolecular complex, change the scale: */
 
94
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
 
95
        {
 
96
        /* Pointer to the current macromolecular complex: */
 
97
        curr_mol_complexSP = mol_complexSP + mol_complexI;
 
98
 
 
99
        /* Check is the current macromolecular complex caught: */
 
100
        if (curr_mol_complexSP->catchF == 0) continue;
 
101
 
 
102
        /* Change hydrophobicity scale: */
 
103
        AssignHydrophobicity_ (curr_mol_complexSP, scaleI);
 
104
        }
 
105
 
 
106
/* Update the hydrophobicity scale index in RuntimeS structure: */
 
107
runtimeSP->hydrophobicity_scaleI = scaleI;
 
108
 
 
109
/* Update hydrophobicity values assigned to residues in the sequence buffer: */
 
110
InitHyphob_ (runtimeSP);
 
111
 
 
112
/* Return the command code: */
 
113
return COMMAND_SCALE;
 
114
}
 
115
 
 
116
/*===========================================================================*/
 
117
 
 
118