File: scale.c

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

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

				scale.c

Purpose:
	Execute scale command: change the hydrophobicity scale. This scale
	will be assigned to all caught macromolecular complexes and to the
	sequence stored in the sequence buffer.

Input:
	(1) Pointer to MolComplexS structure.
	(2) The number of macromolecular complexes.
	(3) Pointer to RuntimeS structure.
	(4) Pointer to the remainder of the command string.  The remainder
	    should contain the hydrophobicity scale name. The keywords are
	    EIS (EISENBERG), INT (INTERFACE), IN2, KD (KYTE-DOOLITLE), OCT  
	    (OCTANOL) and DIF (DIFFERENTIAL, octanol minus interface).

Output:
	(1) Hydrophobicity scale changed  for each caught complex  and for
	    the sequence stored in the sequence buffer.
	(2) Return value.

Return value:
	(1) Positive (command) code on success.
	(2) Negative (error) code on failure.

Notes:
	(1) The main window content will not be refreshed.

	(2) Check init_runtime.c for default hydrophobicity scale!

========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 "commands.h"
#include "typedefs.h"

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

char		*ExtractToken_ (char *, int, char *, char *);
int		AssignHydrophobicity_ (MolComplexS *, int);
void		InitHyphob_ (RuntimeS *);

/*======execute scale command:===============================================*/

int Scale_ (MolComplexS *mol_complexSP, int mol_complexesN,
	    RuntimeS *runtimeSP, char *stringP)
{
char		*remainderP;
char		tokenA[STRINGSIZE];
int		scaleI = 2;
int		mol_complexI;
MolComplexS	*curr_mol_complexSP;

/* Extract the first token, if present: */
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");

/* If there are no tokens in the remainder of the */
/* command  string,  the  scale name  is missing: */
if (!remainderP)
	{
	strcpy (runtimeSP->messageA, "Scale name missing!");
	runtimeSP->message_length = strlen (runtimeSP->messageA);
	return ERROR_SCALE;
	}

/* OCT (OCTANOL); before it was WHI (WHITE): */
else if (strstr (tokenA, "OCT") == tokenA) scaleI = 0;

/* For compatibility reasons, check for the old */
/* (obsolete) keyword for  White octanol scale: */
else if (strstr (tokenA, "WHI") == tokenA)
	{
	strcpy (runtimeSP->messageA, 
		"Keyword WHITE (WHI) is obsolete, please use OCTANOL (OCT)!");
	runtimeSP->message_length = strlen (runtimeSP->messageA);
	scaleI = 0;
	}

/* KD (KYTE-DOOLITLE): */
else if (strstr (tokenA, "KD")  == tokenA) scaleI = 1;

/* EIS (EISENBERG): */
else if (strstr (tokenA, "EIS") == tokenA) scaleI = 2;

/* INT (INTERFACE): */
else if (strstr (tokenA, "INT") == tokenA) scaleI = 3;

/* IN2 (modified interface scale): */
else if (strstr (tokenA, "IN2") == tokenA) scaleI = 4;

/* DIF (differential, octanol-interface): */
else if (strstr (tokenA, "DIF") == tokenA) scaleI = 5;

/* Keyword not recognized: */
else
	{
	strcpy (runtimeSP->messageA, "Keyword not recognized!");
	runtimeSP->message_length = strlen (runtimeSP->messageA);
	return ERROR_SCALE;
	}

/* For each caught macromolecular complex, change the scale: */
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
	{
	/* Pointer to the current macromolecular complex: */
	curr_mol_complexSP = mol_complexSP + mol_complexI;

	/* Check is the current macromolecular complex caught: */
	if (curr_mol_complexSP->catchF == 0) continue;

	/* Change hydrophobicity scale: */
	AssignHydrophobicity_ (curr_mol_complexSP, scaleI);
	}

/* Update the hydrophobicity scale index in RuntimeS structure: */
runtimeSP->hydrophobicity_scaleI = scaleI;

/* Update hydrophobicity values assigned to residues in the sequence buffer: */
InitHyphob_ (runtimeSP);

/* Return the command code: */
return COMMAND_SCALE;
}

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