1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Parse the sequence string.
11
(1) Pointer to RuntimeS structure.
12
(2) Pointer to the string which contains the sequence.
15
(1) Sequence stored to the sequence buffer.
19
(1) Positive on success.
20
(2) Negative on failure.
23
(1) The sequence is expected in three letters code. One letter
24
code may be missinterpreted as valid three letters code.
26
(2) Space, comma, tab and semicolon may be used as separators.
28
========includes:============================================================*/
35
#include <X11/Xutil.h>
37
#include <X11/Xatom.h>
43
/*======function prototypes:=================================================*/
45
char *ExtractToken_ (char *, int, char *, char *);
46
void InitHyphob_ (RuntimeS *);
48
/*======parse sequence string:===============================================*/
50
int ParseSequence_ (RuntimeS *runtimeSP, char *stringP)
54
char tokenA[SHORTSTRINGSIZE];
58
/* The maximal residue name length: */
59
max_length = RESNAMESIZE - 1;
61
/* Zero initialize the sequence buffer: */
62
runtimeSP->residuesN = 0;
63
for (i = 0; i < runtimeSP->sequence_buffer_size; i++)
65
*(runtimeSP->sequenceP + i) = '\0';
68
/* Parse the string: */
70
while ((remainderP = ExtractToken_ (tokenA, SHORTSTRINGSIZE,
71
remainderP, " ,;\t\n")) != NULL)
73
/* Check the residue name size: */
74
if (strlen (tokenA) > max_length)
76
sprintf (runtimeSP->messageA,
77
"Residue name %s too long!",
79
runtimeSP->message_length = strlen (runtimeSP->messageA);
83
/* Copy the residue name to the sequence buffer: */
84
P = runtimeSP->sequenceP + max_length * residueI;
87
/* Update the residue index: */
91
/* Store the number of residues: */
92
runtimeSP->residuesN = residueI;
94
/* Reinitialize serial numbers: */
95
for (residueI = 0; residueI < runtimeSP->residuesN; residueI++)
97
*(runtimeSP->serialIP + residueI) = residueI + 1;
100
/* Reinitialize disulfide flags: */
101
for (residueI = 0; residueI < runtimeSP->residuesN; residueI++)
103
*(runtimeSP->disulfideFP + residueI) = 0;
106
/* Initialize hydrophobicity values: */
107
InitHyphob_ (runtimeSP);
109
/* Return positive value on success: */
113
/*===========================================================================*/