QPromaQ commited on
Commit
a9ea236
·
verified ·
1 Parent(s): 87469d3

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .venv_haddock/include/site/python3.12/freesasa/classifier.c +1256 -0
  2. .venv_haddock/include/site/python3.12/freesasa/classifier.h +117 -0
  3. .venv_haddock/include/site/python3.12/freesasa/classifier_naccess.c +434 -0
  4. .venv_haddock/include/site/python3.12/freesasa/classifier_oons.c +350 -0
  5. .venv_haddock/include/site/python3.12/freesasa/classifier_protor.c +494 -0
  6. .venv_haddock/include/site/python3.12/freesasa/coord.c +342 -0
  7. .venv_haddock/include/site/python3.12/freesasa/coord.h +340 -0
  8. .venv_haddock/include/site/python3.12/freesasa/freesasa.c +266 -0
  9. .venv_haddock/include/site/python3.12/freesasa/freesasa_internal.h +461 -0
  10. .venv_haddock/include/site/python3.12/freesasa/lexer.c +2129 -0
  11. .venv_haddock/include/site/python3.12/freesasa/lexer.h +336 -0
  12. .venv_haddock/include/site/python3.12/freesasa/log.c +270 -0
  13. .venv_haddock/include/site/python3.12/freesasa/nb.c +642 -0
  14. .venv_haddock/include/site/python3.12/freesasa/nb.h +67 -0
  15. .venv_haddock/include/site/python3.12/freesasa/parser.c +1639 -0
  16. .venv_haddock/include/site/python3.12/freesasa/parser.h +97 -0
  17. .venv_haddock/include/site/python3.12/freesasa/pdb.c +432 -0
  18. .venv_haddock/include/site/python3.12/freesasa/pdb.h +187 -0
  19. .venv_haddock/include/site/python3.12/freesasa/rsa.c +174 -0
  20. .venv_haddock/include/site/python3.12/freesasa/sasa_lr.c +487 -0
  21. .venv_haddock/include/site/python3.12/freesasa/sasa_sr.c +338 -0
  22. .venv_haddock/include/site/python3.12/freesasa/selection.c +1003 -0
  23. .venv_haddock/include/site/python3.12/freesasa/selection.h +49 -0
  24. .venv_haddock/include/site/python3.12/freesasa/structure.c +1243 -0
  25. .venv_haddock/include/site/python3.12/freesasa/util.c +141 -0
  26. .venv_haddock/lib/python3.12/site-packages/Bio/Affy/CelFile.py +577 -0
  27. .venv_haddock/lib/python3.12/site-packages/Bio/Affy/__init__.py +6 -0
  28. .venv_haddock/lib/python3.12/site-packages/Bio/Affy/__pycache__/CelFile.cpython-312.pyc +0 -0
  29. .venv_haddock/lib/python3.12/site-packages/Bio/Affy/__pycache__/__init__.cpython-312.pyc +0 -0
  30. .venv_haddock/lib/python3.12/site-packages/Bio/Align/AlignInfo.py +54 -0
  31. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__init__.py +0 -0
  32. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/AlignInfo.cpython-312.pyc +0 -0
  33. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/a2m.cpython-312.pyc +0 -0
  34. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/analysis.cpython-312.pyc +0 -0
  35. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bed.cpython-312.pyc +0 -0
  36. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigbed.cpython-312.pyc +0 -0
  37. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigmaf.cpython-312.pyc +0 -0
  38. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigpsl.cpython-312.pyc +0 -0
  39. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/chain.cpython-312.pyc +0 -0
  40. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/clustal.cpython-312.pyc +0 -0
  41. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/emboss.cpython-312.pyc +0 -0
  42. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/exonerate.cpython-312.pyc +0 -0
  43. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/fasta.cpython-312.pyc +0 -0
  44. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/hhr.cpython-312.pyc +0 -0
  45. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/interfaces.cpython-312.pyc +0 -0
  46. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/maf.cpython-312.pyc +0 -0
  47. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/mauve.cpython-312.pyc +0 -0
  48. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/msf.cpython-312.pyc +0 -0
  49. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/nexus.cpython-312.pyc +0 -0
  50. .venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/phylip.cpython-312.pyc +0 -0
.venv_haddock/include/site/python3.12/freesasa/classifier.c ADDED
@@ -0,0 +1,1256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <stdlib.h>
7
+ #if HAVE_STRINGS_H
8
+ #include <strings.h>
9
+ #endif
10
+ #include <errno.h>
11
+
12
+ #include "classifier.h"
13
+ #include "freesasa_internal.h"
14
+ #include "pdb.h"
15
+
16
+ #define STD_CLASSIFIER_NAME "no-name-given"
17
+
18
+ #define MAX_LINE_LEN 256
19
+
20
+ /**
21
+ In this file the concept class refers to polar/apolar and type to
22
+ aliphatic/aromatic/etc. See the example configurations in share/.
23
+ */
24
+
25
+ static const struct classifier_types empty_types = {0, NULL, NULL, NULL};
26
+
27
+ static const struct classifier_residue empty_residue = {0, NULL, NULL, NULL, NULL, {NULL, 0, 0, 0, 0, 0}};
28
+
29
+ static const struct freesasa_classifier empty_config = {0, NULL, NULL, NULL};
30
+
31
+ struct classifier_types *
32
+ freesasa_classifier_types_new(void)
33
+ {
34
+ struct classifier_types *t = malloc(sizeof(struct classifier_types));
35
+ if (t == NULL)
36
+ mem_fail();
37
+ else
38
+ *t = empty_types;
39
+ return t;
40
+ }
41
+
42
+ void freesasa_classifier_types_free(struct classifier_types *t)
43
+ {
44
+ int i;
45
+
46
+ if (t != NULL) {
47
+ free(t->type_radius);
48
+ free(t->type_class);
49
+ if (t->name)
50
+ for (i = 0; i < t->n_types; ++i)
51
+ free(t->name[i]);
52
+ free(t->name);
53
+
54
+ free(t);
55
+ }
56
+ }
57
+
58
+ struct classifier_residue *
59
+ freesasa_classifier_residue_new(const char *name)
60
+ {
61
+ struct classifier_residue *res;
62
+ assert(strlen(name) > 0);
63
+
64
+ res = malloc(sizeof(struct classifier_residue));
65
+
66
+ if (res == NULL)
67
+ mem_fail();
68
+ else {
69
+ *res = empty_residue;
70
+ res->name = strdup(name);
71
+ if (res->name == NULL) {
72
+ mem_fail();
73
+ free(res);
74
+ res = NULL;
75
+ }
76
+ }
77
+ return res;
78
+ }
79
+
80
+ void freesasa_classifier_residue_free(struct classifier_residue *res)
81
+ {
82
+ int i;
83
+ if (res != NULL) {
84
+ free(res->name);
85
+
86
+ if (res->atom_name)
87
+ for (i = 0; i < res->n_atoms; ++i)
88
+ free(res->atom_name[i]);
89
+ free(res->atom_name);
90
+
91
+ free(res->atom_radius);
92
+ free(res->atom_class);
93
+
94
+ free(res);
95
+ }
96
+ }
97
+
98
+ freesasa_classifier *
99
+ freesasa_classifier_new()
100
+ {
101
+ struct freesasa_classifier *cfg = malloc(sizeof(struct freesasa_classifier));
102
+ if (cfg == NULL)
103
+ mem_fail();
104
+ else
105
+ *cfg = empty_config;
106
+ return cfg;
107
+ }
108
+
109
+ void freesasa_classifier_free(freesasa_classifier *c)
110
+ {
111
+ int i;
112
+ if (c != NULL) {
113
+ if (c->residue)
114
+ for (i = 0; i < c->n_residues; ++i)
115
+ freesasa_classifier_residue_free(c->residue[i]);
116
+ free(c->residue);
117
+ free(c->residue_name);
118
+ free(c->name);
119
+ free(c);
120
+ }
121
+ }
122
+
123
+ /* check if array of strings has a string that matches key,
124
+ ignores trailing and leading whitespace */
125
+ static int
126
+ find_string(char **array,
127
+ const char *key,
128
+ int array_size)
129
+ {
130
+ int n, i, found = 0;
131
+ char *key_trimmed;
132
+
133
+ if (array == NULL || array_size == 0) return -1;
134
+
135
+ n = strlen(key);
136
+ key_trimmed = malloc(n + 1);
137
+
138
+ if (key_trimmed == NULL) return mem_fail();
139
+
140
+ /* remove trailing and leading whitespace */
141
+ sscanf(key, "%s", key_trimmed);
142
+
143
+ for (i = 0; i < array_size; ++i) {
144
+ assert(array[i]);
145
+ if (strcmp(array[i], key_trimmed) == 0) {
146
+ found = 1;
147
+ break;
148
+ }
149
+ }
150
+
151
+ free(key_trimmed);
152
+
153
+ if (found) return i;
154
+ return FREESASA_FAIL;
155
+ }
156
+
157
+ /**
158
+ Removes comments and strips leading and trailing
159
+ whitespace. Returns the length of the stripped line on success,
160
+ FREESASA_FAIL if malloc/realloc fails. Result will be stored in
161
+ the string line, which is assumed to have size MAX_LINE_LEN + 1.
162
+ */
163
+ static int
164
+ strip_line(char *line,
165
+ const char *input)
166
+ {
167
+ char *comment, *first, *last;
168
+ char linebuf[MAX_LINE_LEN + 1];
169
+
170
+ assert(strlen(input) <= MAX_LINE_LEN);
171
+
172
+ strcpy(linebuf, input);
173
+ comment = strchr(linebuf, '#');
174
+ if (comment) *comment = '\0'; /* skip comments */
175
+
176
+ first = linebuf;
177
+ last = linebuf + strlen(linebuf) - 1;
178
+ while (*first == ' ' || *first == '\t')
179
+ ++first;
180
+
181
+ if (last > first)
182
+ while (*last == ' ' || *last == '\t' || *last == '\n')
183
+ --last;
184
+
185
+ if (first >= last) {
186
+ line[0] = '\0';
187
+ return 0;
188
+ }
189
+
190
+ *(last + 1) = '\0';
191
+ strncpy(line, first, MAX_LINE_LEN);
192
+
193
+ return strlen(line);
194
+ }
195
+
196
+ /**
197
+ Essentially a safer fscanf(input, "%s", str) limited to the
198
+ current line in input. Stores the result in 'str' (which should
199
+ be able to store a string of length MAX_LINE_LEN)
200
+ */
201
+ static int
202
+ get_next_string(FILE *input, char *str)
203
+ {
204
+ char line[MAX_LINE_LEN + 1];
205
+ long pos = ftell(input);
206
+
207
+ if (fgets(line, MAX_LINE_LEN + 1, input) == NULL) {
208
+ if (ferror(input)) {
209
+ return freesasa_fail(strerror(errno));
210
+ }
211
+ return 0;
212
+ }
213
+
214
+ str[0] = '\0';
215
+
216
+ sscanf(line, "%s", str);
217
+
218
+ fseek(input, pos + strlen(str), SEEK_SET);
219
+ return strlen(str);
220
+ }
221
+
222
+ /**
223
+ Allocates space and stores a line stripped of comments in the line
224
+ pointer. Returns the length of the line on success, FREESASA_FAIL
225
+ for I/O errors.
226
+ */
227
+ static int
228
+ next_line(char *line,
229
+ FILE *fp)
230
+ {
231
+ char linebuf[MAX_LINE_LEN + 1];
232
+
233
+ if (fgets(linebuf, MAX_LINE_LEN + 1, fp) == NULL) {
234
+ if (ferror(fp)) {
235
+ return fail_msg(strerror(errno));
236
+ }
237
+
238
+ if (feof(fp)) {
239
+ line[0] = '\0';
240
+ return 0;
241
+ }
242
+ }
243
+
244
+ return strip_line(line, linebuf);
245
+ }
246
+
247
+ /**
248
+ Find offset of str in line, returns -1 if not found
249
+ Ignores comments
250
+ */
251
+ static inline int
252
+ locate_string(const char *line,
253
+ const char *str)
254
+ {
255
+ int NOT_FOUND = -1;
256
+ char *loc, buf[MAX_LINE_LEN + 1];
257
+
258
+ assert(line);
259
+ assert(strlen(line) <= MAX_LINE_LEN);
260
+ assert(str);
261
+
262
+ if (strlen(line) == 0) {
263
+ return NOT_FOUND;
264
+ }
265
+
266
+ strcpy(buf, line);
267
+
268
+ /* skip comments */
269
+ loc = strstr(buf, "#");
270
+ if (loc == buf) {
271
+ return NOT_FOUND;
272
+ } else if (loc != NULL) {
273
+ *loc = '\0';
274
+ }
275
+
276
+ loc = strstr(buf, str);
277
+ if (loc != NULL) {
278
+ return loc - buf;
279
+ }
280
+
281
+ return NOT_FOUND;
282
+ }
283
+
284
+ /**
285
+ If string exists on line its location is stored in this_range, and
286
+ if prev_range is non-null it is set to end at the same location.
287
+ */
288
+ static inline int
289
+ try_register_stringloc(const char *line,
290
+ const char *str,
291
+ long last_tell,
292
+ struct file_range *this_range,
293
+ struct file_range **prev_range)
294
+ {
295
+ int pos, NOT_FOUND = -1;
296
+
297
+ if (strlen(line) == 0) return NOT_FOUND;
298
+
299
+ pos = locate_string(line, str);
300
+ if (pos >= 0) {
301
+ this_range->begin = last_tell + pos;
302
+ if (*prev_range) (*prev_range)->end = last_tell + pos;
303
+ (*prev_range) = this_range;
304
+ return last_tell + pos;
305
+ }
306
+ return NOT_FOUND;
307
+ }
308
+
309
+ /**
310
+ Checks that input file has the required fields and locates the
311
+ 'types' and 'atoms' sections. No syntax checking. Return
312
+ FREESASA_SUCCESS if file seems ok, FREESASA_FAIL if either/both of
313
+ the sections are missing, or file invalid in some other way, or there was an error reading the file.
314
+ */
315
+ static int
316
+ check_file(FILE *input,
317
+ struct file_range *types,
318
+ struct file_range *atoms,
319
+ struct file_range *name)
320
+ {
321
+ long last_tell;
322
+ char line[MAX_LINE_LEN + 1];
323
+ struct file_range *last_range = NULL;
324
+
325
+ assert(input);
326
+ assert(types);
327
+ assert(atoms);
328
+
329
+ last_tell = ftell(input);
330
+
331
+ /* this allows us to detect wether a section wasn't found later */
332
+ types->begin = atoms->begin = name->begin = -1;
333
+
334
+ while (fgets(line, MAX_LINE_LEN + 1, input)) {
335
+ try_register_stringloc(line, "types:", last_tell, types, &last_range);
336
+ try_register_stringloc(line, "atoms:", last_tell, atoms, &last_range);
337
+ try_register_stringloc(line, "name:", last_tell, name, &last_range);
338
+ last_tell = ftell(input);
339
+
340
+ if (strlen(line) == MAX_LINE_LEN &&
341
+ line[MAX_LINE_LEN - 1] != '\n') {
342
+ return fail_msg("Lines in classifier files can only be %d characters or less",
343
+ MAX_LINE_LEN);
344
+ }
345
+ }
346
+
347
+ if (ferror(input)) {
348
+ return fail_msg(strerror(errno));
349
+ }
350
+
351
+ if (last_range != NULL) {
352
+ last_range->end = last_tell;
353
+ }
354
+ rewind(input);
355
+
356
+ if (name->begin == -1) {
357
+ freesasa_warn("input configuration lacks the entry 'name:', "
358
+ "will use '" STD_CLASSIFIER_NAME "'");
359
+ }
360
+
361
+ if ((types->begin == -1) ||
362
+ (atoms->begin == -1)) {
363
+ return fail_msg("input configuration lacks (at least) one of "
364
+ "the entries 'types:' or 'atoms:'");
365
+ }
366
+
367
+ return FREESASA_SUCCESS;
368
+ }
369
+
370
+ int freesasa_classifier_parse_class(const char *name)
371
+ {
372
+ #if HAVE_STRNCASECMP
373
+ if (strncasecmp(name, "apolar", 6) == 0) {
374
+ return FREESASA_ATOM_APOLAR;
375
+ } else if (strncasecmp(name, "polar", 5) == 0) {
376
+ return FREESASA_ATOM_POLAR;
377
+ } else {
378
+ return fail_msg("only atom classes allowed are 'polar' and 'apolar'"
379
+ " (case insensitive)");
380
+ }
381
+ #else
382
+ if (strncmp(name, "apolar", 6) == 0) {
383
+ return FREESASA_ATOM_APOLAR;
384
+ } else if (strncmp(name, "polar", 5) == 0) {
385
+ return FREESASA_ATOM_POLAR;
386
+ } else {
387
+ return fail_msg("only atom classes allowed are 'polar' and 'apolar'");
388
+ }
389
+ #endif
390
+ }
391
+
392
+ /**
393
+ Add type. Returns the index of the new type on success,
394
+ FREESASA_FAIL if realloc/strdup fails, FREESASA_WARN if type
395
+ already known (ignore duplicates).
396
+ */
397
+ int freesasa_classifier_add_type(struct classifier_types *types,
398
+ const char *type_name,
399
+ const char *class_name,
400
+ double r)
401
+ {
402
+ int the_class;
403
+ int n = types->n_types + 1;
404
+ char **tn = types->name;
405
+ double *tr = types->type_radius;
406
+ freesasa_atom_class *tc = types->type_class;
407
+
408
+ if (find_string(types->name, type_name, types->n_types) >= 0)
409
+ return freesasa_warn("ignoring duplicate configuration entry for '%s'", type_name);
410
+
411
+ the_class = freesasa_classifier_parse_class(class_name);
412
+ if (the_class == FREESASA_FAIL) return fail_msg("");
413
+
414
+ if ((types->name = realloc(tn, sizeof(char *) * n)) == NULL) {
415
+ types->name = tn;
416
+ return mem_fail();
417
+ }
418
+
419
+ if ((types->type_radius = realloc(tr, sizeof(double) * n)) == NULL) {
420
+ types->type_radius = tr;
421
+ return mem_fail();
422
+ }
423
+
424
+ if ((types->type_class = realloc(tc, sizeof(int) * n)) == NULL) {
425
+ types->type_class = tc;
426
+ return mem_fail();
427
+ }
428
+
429
+ if ((types->name[n - 1] = strdup(type_name)) == NULL) {
430
+ return mem_fail();
431
+ }
432
+
433
+ types->n_types++;
434
+ types->type_radius[types->n_types - 1] = r;
435
+ types->type_class[types->n_types - 1] = the_class;
436
+
437
+ return types->n_types - 1;
438
+ }
439
+
440
+ /**
441
+ Read a line specifying a type, store it in the config. Returns
442
+ warning for duplicates, failures for syntax errors or memory
443
+ allocation errors.
444
+ */
445
+ static int
446
+ read_types_line(struct classifier_types *types,
447
+ const char *line)
448
+ {
449
+ int the_type, ret = FREESASA_SUCCESS;
450
+ double r;
451
+ char buf1[MAX_LINE_LEN + 1], buf2[MAX_LINE_LEN + 1];
452
+
453
+ assert(strlen(line) <= MAX_LINE_LEN);
454
+
455
+ if (sscanf(line, "%s %lf %s", buf1, &r, buf2) == 3) {
456
+ the_type = freesasa_classifier_add_type(types, buf1, buf2, r);
457
+ if (the_type == FREESASA_FAIL) ret = fail_msg("");
458
+ if (the_type == FREESASA_WARN) ret = FREESASA_WARN;
459
+ } else {
460
+ ret = fail_msg("could not parse line '%s' in configuration, "
461
+ "expecting triplet of type 'TYPE [RADIUS] CLASS' for "
462
+ "example 'C_ALI 2.00 apolar'",
463
+ line);
464
+ }
465
+
466
+ return ret;
467
+ }
468
+
469
+ /**
470
+ Reads info about types from the user config. Associates each type
471
+ with a class and a radius in the config struct. Returns
472
+ FREESASA_SUCCESS on success, FREESASA_FAIL on syntax or memory
473
+ allocation errors.
474
+ */
475
+ static int
476
+ read_types(struct classifier_types *types,
477
+ FILE *input,
478
+ struct file_range fi)
479
+ {
480
+ char line[MAX_LINE_LEN + 1];
481
+ int ret = FREESASA_SUCCESS, nl;
482
+
483
+ fseek(input, fi.begin, SEEK_SET);
484
+
485
+ /* read command (and discard) */
486
+ if (next_line(line, input) > 0) {
487
+ char buf[7]; /* we should not get here if the line isn't "types:" (plus whitespace) */
488
+ if (sscanf(line, "%6s", buf) == 0) return FREESASA_FAIL;
489
+ assert(strcmp(buf, "types:") == 0);
490
+ } else {
491
+ return FREESASA_FAIL;
492
+ }
493
+
494
+ while (ftell(input) < fi.end) {
495
+ nl = next_line(line, input);
496
+ if (nl == 0) continue;
497
+ if (nl == FREESASA_FAIL) {
498
+ ret = nl;
499
+ break;
500
+ };
501
+ ret = read_types_line(types, line);
502
+ if (ret == FREESASA_FAIL) break;
503
+ }
504
+
505
+ return ret;
506
+ }
507
+
508
+ /**
509
+ Add atom to residue. Returns index of the new atom on
510
+ success. FREESASA_FAIL if memory allocation fails. FREESASA_WARN
511
+ if the atom has already been added.
512
+ */
513
+ int freesasa_classifier_add_atom(struct classifier_residue *res,
514
+ const char *name,
515
+ double radius,
516
+ int the_class)
517
+ {
518
+ int n;
519
+ char **an = res->atom_name;
520
+ double *ar = res->atom_radius;
521
+ freesasa_atom_class *ac = res->atom_class;
522
+
523
+ if (find_string(res->atom_name, name, res->n_atoms) >= 0)
524
+ return freesasa_warn("ignoring duplicate configuration entry for atom '%s %s'",
525
+ res->name, name);
526
+ n = res->n_atoms + 1;
527
+
528
+ if ((res->atom_name = realloc(res->atom_name, sizeof(char *) * n)) == NULL) {
529
+ res->atom_name = an;
530
+ return mem_fail();
531
+ }
532
+ if ((res->atom_radius = realloc(res->atom_radius, sizeof(double) * n)) == NULL) {
533
+ res->atom_radius = ar;
534
+ return mem_fail();
535
+ }
536
+ if ((res->atom_class = realloc(res->atom_class, sizeof(int) * n)) == NULL) {
537
+ res->atom_class = ac;
538
+ return mem_fail();
539
+ }
540
+ if ((res->atom_name[n - 1] = strdup(name)) == NULL)
541
+ return mem_fail();
542
+
543
+ ++res->n_atoms;
544
+ res->atom_radius[n - 1] = radius;
545
+ res->atom_class[n - 1] = the_class;
546
+
547
+ return n - 1;
548
+ }
549
+
550
+ /**
551
+ Add residue to config. If the residue already exists, it returns
552
+ the index of that residue, else it returns the index of the new
553
+ residue. Returns FREESASA_FAILURE if realloc/strdup fails.
554
+ */
555
+ int freesasa_classifier_add_residue(struct freesasa_classifier *c,
556
+ const char *name)
557
+ {
558
+ char **rn = c->residue_name;
559
+ struct classifier_residue **cr = c->residue;
560
+ int res = find_string(c->residue_name, name, c->n_residues);
561
+
562
+ if (res >= 0) return res;
563
+
564
+ res = c->n_residues + 1;
565
+
566
+ if ((c->residue_name = realloc(rn, sizeof(char *) * res)) == NULL) {
567
+ c->residue_name = rn;
568
+ return mem_fail();
569
+ }
570
+
571
+ if ((c->residue = realloc(cr, sizeof(struct classifier_residue *) * res)) == NULL) {
572
+ c->residue = cr;
573
+ return mem_fail();
574
+ }
575
+
576
+ if ((c->residue[res - 1] = freesasa_classifier_residue_new(name)) == NULL) {
577
+ return mem_fail();
578
+ }
579
+
580
+ ++c->n_residues;
581
+ c->residue_name[res - 1] = c->residue[res - 1]->name;
582
+ return res - 1;
583
+ }
584
+
585
+ /**
586
+ Read a line specifying an atom, store it in the config. Use
587
+ supplied types to add assign radius and class. Returns
588
+ FREESASA_WARN for duplicates. Returns FREESASA_FAIL for syntax
589
+ errors or memory allocation errors. FREESASA_SUCCESS else.
590
+ */
591
+ static int
592
+ read_atoms_line(struct freesasa_classifier *c,
593
+ const struct classifier_types *types,
594
+ const char *line)
595
+ {
596
+ char buf1[MAX_LINE_LEN + 1], buf2[MAX_LINE_LEN + 1], buf3[MAX_LINE_LEN + 1];
597
+ int res, type, atom;
598
+
599
+ assert(strlen(line) <= MAX_LINE_LEN);
600
+
601
+ if (sscanf(line, "%s %s %s", buf1, buf2, buf3) == 3) {
602
+ if (strlen(buf1) > PDB_ATOM_RES_NAME_STRL) {
603
+ return fail_msg("residue name %s is too long in classifier file", buf1);
604
+ }
605
+
606
+ if (strlen(buf2) > PDB_ATOM_NAME_STRL) {
607
+ return fail_msg("atom name %s is too long in classifier file", buf2);
608
+ }
609
+
610
+ type = find_string(types->name, buf3, types->n_types);
611
+
612
+ if (type < 0) {
613
+ return fail_msg("unknown atom type '%s' in configuration, line '%s'",
614
+ buf3, line);
615
+ }
616
+
617
+ res = freesasa_classifier_add_residue(c, buf1);
618
+
619
+ if (res == FREESASA_FAIL) return fail_msg("");
620
+
621
+ atom = freesasa_classifier_add_atom(c->residue[res],
622
+ buf2,
623
+ types->type_radius[type],
624
+ types->type_class[type]);
625
+
626
+ if (atom == FREESASA_FAIL) return fail_msg("");
627
+ if (atom == FREESASA_WARN) return FREESASA_WARN;
628
+
629
+ } else {
630
+ return fail_msg("could not parse configuration, line '%s', "
631
+ "expecting triplet of type "
632
+ "'RESIDUE ATOM CLASS', for example 'ALA CB C_ALI'",
633
+ line);
634
+ }
635
+ return FREESASA_SUCCESS;
636
+ }
637
+
638
+ /**
639
+ Reads atom configurations from config-file. Associates each atom
640
+ with a radius and class using the types that should already have
641
+ been stored in the config struct.
642
+ */
643
+ static int
644
+ read_atoms(struct freesasa_classifier *c,
645
+ struct classifier_types *types,
646
+ FILE *input,
647
+ struct file_range fi)
648
+ {
649
+ char line[MAX_LINE_LEN + 1], buf[MAX_LINE_LEN + 1];
650
+ int ret = FREESASA_SUCCESS, nl;
651
+
652
+ fseek(input, fi.begin, SEEK_SET);
653
+
654
+ /* read command (and discard) */
655
+ if (next_line(line, input) > 0) {
656
+ assert(strlen(line) <= MAX_LINE_LEN);
657
+ if (sscanf(line, "%s", buf) == 0) return FREESASA_FAIL;
658
+ assert(strcmp(buf, "atoms:") == 0);
659
+ } else {
660
+ return FREESASA_FAIL;
661
+ }
662
+
663
+ while (ftell(input) < fi.end) {
664
+ nl = next_line(line, input);
665
+ if (nl == 0) continue;
666
+ if (nl == FREESASA_FAIL) return fail_msg("");
667
+ ret = read_atoms_line(c, types, line);
668
+ if (ret == FREESASA_FAIL) break;
669
+ }
670
+
671
+ return ret;
672
+ }
673
+
674
+ static int
675
+ read_name(struct freesasa_classifier *classifier,
676
+ FILE *input,
677
+ struct file_range fi)
678
+ {
679
+ char buf[MAX_LINE_LEN + 1];
680
+
681
+ if (fi.begin < 0)
682
+ return FREESASA_SUCCESS; /* name not set? */
683
+
684
+ fseek(input, fi.begin, SEEK_SET);
685
+ if (get_next_string(input, buf) <= 0)
686
+ return fail_msg("");
687
+
688
+ assert(strcmp(buf, "name:") == 0);
689
+
690
+ if (get_next_string(input, buf) <= 0) {
691
+ return fail_msg("empty name for configuration?");
692
+ }
693
+
694
+ classifier->name = strdup(buf);
695
+ if (classifier->name == NULL) {
696
+ return mem_fail();
697
+ }
698
+
699
+ return FREESASA_SUCCESS;
700
+ }
701
+
702
+ static struct freesasa_classifier *
703
+ read_config(FILE *input)
704
+ {
705
+ struct file_range types_section, atoms_section, name_section;
706
+ struct freesasa_classifier *classifier = NULL;
707
+ struct classifier_types *types = NULL;
708
+
709
+ assert(input);
710
+
711
+ if (!(types = freesasa_classifier_types_new()))
712
+ goto cleanup;
713
+ if (!(classifier = freesasa_classifier_new()))
714
+ goto cleanup;
715
+ if (check_file(input, &types_section, &atoms_section, &name_section))
716
+ goto cleanup;
717
+ if (read_name(classifier, input, name_section))
718
+ goto cleanup;
719
+ if (read_types(types, input, types_section))
720
+ goto cleanup;
721
+ if (read_atoms(classifier, types, input, atoms_section))
722
+ goto cleanup;
723
+
724
+ freesasa_classifier_types_free(types);
725
+
726
+ return classifier;
727
+
728
+ cleanup:
729
+ freesasa_classifier_free(classifier);
730
+ freesasa_classifier_types_free(types);
731
+ return NULL;
732
+ }
733
+
734
+ /**
735
+ See if an atom_name has been defined for the residue ANY (writes
736
+ indices to the provided pointers).
737
+ */
738
+ static void
739
+ find_any(const struct freesasa_classifier *c,
740
+ const char *atom_name,
741
+ int *res, int *atom)
742
+ {
743
+ *res = find_string(c->residue_name, "ANY", c->n_residues);
744
+ if (*res >= 0) {
745
+ *atom = find_string(c->residue[*res]->atom_name,
746
+ atom_name,
747
+ c->residue[*res]->n_atoms);
748
+ }
749
+ }
750
+ /**
751
+ Find the residue and atom index of an atom in the supplied
752
+ configuration. Prints error and returns FREESASA_WARN if not
753
+ found.
754
+ */
755
+ static int
756
+ find_atom(const struct freesasa_classifier *c,
757
+ const char *res_name,
758
+ const char *atom_name,
759
+ int *res,
760
+ int *atom)
761
+ {
762
+ const struct classifier_residue *residue;
763
+ *atom = -1;
764
+ *res = find_string(c->residue_name, res_name, c->n_residues);
765
+ if (*res < 0) {
766
+ find_any(c, atom_name, res, atom);
767
+ } else {
768
+ residue = c->residue[*res];
769
+ *atom = find_string(residue->atom_name, atom_name, residue->n_atoms);
770
+ if (*atom < 0) {
771
+ find_any(c, atom_name, res, atom);
772
+ }
773
+ }
774
+ if (*atom < 0) {
775
+ return FREESASA_WARN;
776
+ }
777
+ return FREESASA_SUCCESS;
778
+ }
779
+
780
+ double
781
+ freesasa_classifier_radius(const freesasa_classifier *classifier,
782
+ const char *res_name,
783
+ const char *atom_name)
784
+ {
785
+ int res, atom, status;
786
+
787
+ assert(classifier);
788
+ assert(res_name);
789
+ assert(atom_name);
790
+
791
+ status = find_atom(classifier, res_name, atom_name, &res, &atom);
792
+ if (status == FREESASA_SUCCESS)
793
+ return classifier->residue[res]->atom_radius[atom];
794
+ return -1.0;
795
+ }
796
+
797
+ freesasa_atom_class
798
+ freesasa_classifier_class(const freesasa_classifier *classifier,
799
+ const char *res_name,
800
+ const char *atom_name)
801
+ {
802
+ int res, atom, status;
803
+
804
+ assert(classifier);
805
+ assert(res_name);
806
+ assert(atom_name);
807
+
808
+ status = find_atom(classifier, res_name, atom_name, &res, &atom);
809
+ if (status == FREESASA_SUCCESS)
810
+ return classifier->residue[res]->atom_class[atom];
811
+ return FREESASA_ATOM_UNKNOWN;
812
+ }
813
+
814
+ const char *
815
+ freesasa_classifier_class2str(freesasa_atom_class atom_class)
816
+ {
817
+ switch (atom_class) {
818
+ case FREESASA_ATOM_APOLAR:
819
+ return "Apolar";
820
+ case FREESASA_ATOM_POLAR:
821
+ return "Polar";
822
+ case FREESASA_ATOM_UNKNOWN:
823
+ return "Unknown";
824
+ }
825
+ fail_msg("invalid atom class");
826
+ return NULL;
827
+ }
828
+
829
+ freesasa_nodearea
830
+ freesasa_result_classes(const freesasa_structure *structure,
831
+ const freesasa_result *result)
832
+ {
833
+ freesasa_nodearea area = {"whole-structure", 0, 0, 0, 0, 0};
834
+ freesasa_range_nodearea(&area, structure, result,
835
+ 0, freesasa_structure_n(structure) - 1);
836
+ return area;
837
+ }
838
+
839
+ freesasa_classifier *
840
+ freesasa_classifier_from_file(FILE *file)
841
+ {
842
+ struct freesasa_classifier *classifier = read_config(file);
843
+
844
+ if (classifier == NULL) {
845
+ fail_msg("");
846
+ return NULL;
847
+ }
848
+
849
+ return classifier;
850
+ }
851
+
852
+ const freesasa_nodearea *
853
+ freesasa_classifier_residue_reference(const freesasa_classifier *classifier,
854
+ const char *res_name)
855
+ {
856
+ int res = find_string(classifier->residue_name, res_name, classifier->n_residues);
857
+
858
+ if (res < 0) return NULL;
859
+
860
+ return &classifier->residue[res]->max_area;
861
+ }
862
+
863
+ const char *
864
+ freesasa_classifier_name(const freesasa_classifier *classifier)
865
+ {
866
+ return classifier->name;
867
+ }
868
+
869
+ struct symbol_radius {
870
+ const char symbol[3];
871
+ double radius;
872
+ };
873
+
874
+ /* Taken from:
875
+
876
+ Mantina et al. "Consistent van der Waals Radii for
877
+ the Whole Main Group". J. Phys. Chem. A, 2009, 113 (19), pp
878
+ 5806–5812.
879
+
880
+ Many of these elements, if they occur in a PDB file, should
881
+ probably rather be skipped than used in a SASA calculation, and
882
+ ionization will change the effective radius.
883
+
884
+ */
885
+ static const struct symbol_radius symbol_radius[] = {
886
+ /* elements that actually occur in the regular amino acids and nucleotides */
887
+ {" H", 1.10},
888
+ {" C", 1.70},
889
+ {" N", 1.55},
890
+ {" O", 1.52},
891
+ {" P", 1.80},
892
+ {" S", 1.80},
893
+ {"SE", 1.90},
894
+ /* some others, values pulled from gemmi elem.hpp */
895
+ /* Halogens */
896
+ {" F", 1.47},
897
+ {"CL", 1.75},
898
+ {"BR", 1.83},
899
+ {" I", 1.98},
900
+ /* Alkali and Alkali Earth metals */
901
+ {"LI", 1.81},
902
+ {"BE", 1.53},
903
+ {"NA", 2.27},
904
+ {"MG", 1.73},
905
+ {" K", 2.75},
906
+ {"CA", 2.31},
907
+ {"RB", 3.03},
908
+ {"SR", 2.49},
909
+ {"CS", 3.43},
910
+ {"BA", 2.68},
911
+ {"FR", 3.48},
912
+ {"RA", 2.83},
913
+ /* Transition metals */
914
+ {"SC", 2.11},
915
+ {"TI", 1.95},
916
+ {" V", 1.06},
917
+ {"CR", 1.13},
918
+ {"MN", 1.19},
919
+ {"FE", 1.26},
920
+ {"CO", 1.13},
921
+ {"NI", 1.63},
922
+ {"CU", 1.40},
923
+ {"ZN", 1.39},
924
+ {" Y", 1.61},
925
+ {"ZR", 1.42},
926
+ {"NB", 1.33},
927
+ {"MO", 1.75},
928
+ {"TC", 2.00},
929
+ {"RU", 1.20},
930
+ {"RH", 1.22},
931
+ {"PD", 1.63},
932
+ {"AG", 1.72},
933
+ {"CD", 1.58},
934
+ {"HF", 1.40},
935
+ {"TA", 1.22},
936
+ {" W", 1.26},
937
+ {"RE", 1.30},
938
+ {"OS", 1.58},
939
+ {"IR", 1.22},
940
+ {"PT", 1.75},
941
+ {"AU", 1.66},
942
+ {"HG", 1.55},
943
+ /* Post-Transition metals */
944
+ {"AL", 1.84},
945
+ {"GA", 1.87},
946
+ {"IN", 1.93},
947
+ {"SN", 2.17},
948
+ {"TL", 1.96},
949
+ {"PB", 2.02},
950
+ {"BI", 2.07},
951
+ {"PO", 1.97},
952
+ /* Metalloid */
953
+ {" B", 1.92},
954
+ {"SI", 2.10},
955
+ {"GE", 2.11},
956
+ {"AS", 1.85},
957
+ {"SB", 2.06},
958
+ {"TE", 2.06},
959
+ {"AT", 2.02},
960
+ /* Noble gases */
961
+ {"HE", 1.40},
962
+ {"NE", 1.54},
963
+ {"AR", 1.88},
964
+ {"KR", 2.02},
965
+ {"XE", 2.16},
966
+ {"RN", 2.20},
967
+ /* Lanthanoids */
968
+ {"LA", 1.83},
969
+ {"CE", 1.86},
970
+ {"PR", 1.62},
971
+ {"ND", 1.79},
972
+ {"PM", 1.76},
973
+ {"SM", 1.74},
974
+ {"EU", 1.96},
975
+ {"GD", 1.69},
976
+ {"TB", 1.66},
977
+ {"DY", 1.63},
978
+ {"HO", 1.61},
979
+ {"ER", 1.59},
980
+ {"TM", 1.57},
981
+ {"YB", 1.54},
982
+ {"LU", 1.53},
983
+ /* Actinoids */
984
+ {"AC", 2.12},
985
+ {"TH", 1.84},
986
+ {"PA", 1.60},
987
+ {" U", 1.86},
988
+ {"NP", 1.71},
989
+ {"PU", 1.67},
990
+ {"AM", 1.66},
991
+ {"CM", 1.65},
992
+ {"BK", 1.64},
993
+ {"CF", 1.63},
994
+ {"ES", 1.62},
995
+ {"FM", 1.61},
996
+ {"MD", 1.60},
997
+ {"NO", 1.59},
998
+ {"LR", 1.58},
999
+ };
1000
+
1001
+ double
1002
+ freesasa_guess_radius(const char *input_symbol)
1003
+ {
1004
+ int n_symbol, i;
1005
+ char symbol[3];
1006
+
1007
+ assert(input_symbol);
1008
+ snprintf(symbol, 3, "%2s", input_symbol);
1009
+
1010
+ n_symbol = sizeof(symbol_radius) / sizeof(struct symbol_radius);
1011
+
1012
+ for (i = 0; i < n_symbol; ++i) {
1013
+ if (strcmp(symbol, symbol_radius[i].symbol) == 0)
1014
+ return symbol_radius[i].radius;
1015
+ }
1016
+ return -1.0;
1017
+ }
1018
+
1019
+ // clang-format off
1020
+ /* The residue types that are returned by freesasa_classify_residue() */
1021
+ enum residue {
1022
+ /* Regular amino acids */
1023
+ ALA = 0, ARG, ASN, ASP,
1024
+ CYS, GLN, GLU, GLY,
1025
+ HIS, ILE, LEU, LYS,
1026
+ MET, PHE, PRO, SER,
1027
+ THR, TRP, TYR, VAL,
1028
+ /* some non-standard ones */
1029
+ CSE, SEC, PYL, PYH, ASX, GLX,
1030
+ /* residue unknown */
1031
+ RES_UNK,
1032
+ /* capping N- and C-terminal groups (usually HETATM) */
1033
+ ACE, NH2,
1034
+ /* DNA */
1035
+ DA, DC, DG, DT, DU, DI,
1036
+ /* RNA (avoid one-letter enums) */
1037
+ RA, RC, RG, RU, RI, RT,
1038
+ /* generic nucleotide */
1039
+ NN
1040
+ };
1041
+
1042
+ /* Residue types, make sure this always matches the corresponding enum. */
1043
+ static const char *residue_names[] = {
1044
+ /* amino acids */
1045
+ "ALA", "ARG", "ASN", "ASP",
1046
+ "CYS", "GLN", "GLU", "GLY",
1047
+ "HIS", "ILE", "LEU", "LYS",
1048
+ "MET", "PHE", "PRO", "SER",
1049
+ "THR", "TRP", "TYR", "VAL",
1050
+ /* non-standard amino acids */
1051
+ "CSE", "SEC", "PYL", "PYH", /* SEC and PYL are standard names, CSE and PYH are found in some early files */
1052
+ "ASX", "GLX",
1053
+ "UNK",
1054
+ /* capping groups */
1055
+ "ACE", "NH2",
1056
+ /* DNA */
1057
+ "DA", "DC", "DG", "DT", "DU", "DI",
1058
+ /* RNA */
1059
+ "A", "C", "G", "U", "I", "T",
1060
+ /* General nucleotide */
1061
+ "N"};
1062
+ // clang-format on
1063
+
1064
+ int freesasa_classify_n_residue_types()
1065
+ {
1066
+ return NN + 1;
1067
+ }
1068
+
1069
+ int freesasa_classify_residue(const char *res_name)
1070
+ {
1071
+ int i;
1072
+ char cpy[PDB_ATOM_RES_NAME_STRL + 1];
1073
+
1074
+ sscanf(res_name, "%s", cpy);
1075
+
1076
+ for (i = ALA; i < freesasa_classify_n_residue_types(); ++i) {
1077
+ if (strcmp(cpy, residue_names[i]) == 0) return i;
1078
+ }
1079
+
1080
+ return RES_UNK;
1081
+ }
1082
+
1083
+ const char *
1084
+ freesasa_classify_residue_name(int residue_type)
1085
+ {
1086
+ assert(residue_type >= 0 && residue_type <= NN);
1087
+ return residue_names[residue_type];
1088
+ }
1089
+
1090
+ int freesasa_atom_is_backbone(const char *atom_name)
1091
+ {
1092
+ const char *bb[] = {"CA", "N", "O", "C", "OXT",
1093
+ "P", "OP1", "OP2", "O5'", "C5'", "C4'",
1094
+ "O4'", "C3'", "O3'", "C2'", "C1'"};
1095
+ char name[PDB_ATOM_NAME_STRL + 1];
1096
+ int i;
1097
+
1098
+ name[0] = '\0';
1099
+ sscanf(atom_name, "%s", name); /* trim whitespace */
1100
+
1101
+ if (strlen(name) == 0) return 0;
1102
+ for (i = 0; i < sizeof(bb) / sizeof(const char *); ++i) {
1103
+ if (strcmp(name, bb[i]) == 0) {
1104
+ return 1;
1105
+ }
1106
+ }
1107
+ return 0;
1108
+ }
1109
+
1110
+ #if USE_CHECK
1111
+ #include <check.h>
1112
+ #include <math.h>
1113
+
1114
+ START_TEST(test_classifier)
1115
+ {
1116
+ struct classifier_types *types = freesasa_classifier_types_new();
1117
+ struct classifier_residue *residue_cfg = freesasa_classifier_residue_new("ALA");
1118
+ struct freesasa_classifier *clf = freesasa_classifier_new();
1119
+
1120
+ freesasa_set_verbosity(FREESASA_V_SILENT);
1121
+
1122
+ ck_assert_int_eq(freesasa_classifier_parse_class("A"), FREESASA_FAIL);
1123
+ #if HAVE_STRNCASECMP
1124
+ ck_assert_int_eq(freesasa_classifier_parse_class("POLAR"), FREESASA_ATOM_POLAR);
1125
+ ck_assert_int_eq(freesasa_classifier_parse_class("APOLAR"), FREESASA_ATOM_APOLAR);
1126
+ #endif
1127
+ ck_assert_int_eq(freesasa_classifier_parse_class("polar"), FREESASA_ATOM_POLAR);
1128
+ ck_assert_int_eq(freesasa_classifier_parse_class("apolar"), FREESASA_ATOM_APOLAR);
1129
+
1130
+ ck_assert_int_eq(types->n_types, 0);
1131
+ ck_assert_int_eq(freesasa_classifier_add_type(types, "a", "A", 1.0), FREESASA_FAIL);
1132
+ ck_assert_int_eq(freesasa_classifier_add_type(types, "a", "polar", 1.0), 0);
1133
+ ck_assert_int_eq(freesasa_classifier_add_type(types, "b", "apolar", 2.0), 1);
1134
+ ck_assert_int_eq(freesasa_classifier_add_type(types, "b", "polar", 1.0), FREESASA_WARN);
1135
+ ck_assert_int_eq(freesasa_classifier_add_type(types, "c", "apolar", 3.0), 2);
1136
+ ck_assert_int_eq(types->n_types, 3);
1137
+ ck_assert_str_eq(types->name[0], "a");
1138
+ ck_assert_str_eq(types->name[1], "b");
1139
+ ck_assert_str_eq(types->name[2], "c");
1140
+ ck_assert(fabs(types->type_radius[0] - 1.0) < 1e-10);
1141
+ ck_assert(fabs(types->type_radius[1] - 2.0) < 1e-10);
1142
+ ck_assert(fabs(types->type_radius[2] - 3.0) < 1e-10);
1143
+
1144
+ freesasa_classifier_types_free(types);
1145
+ types = freesasa_classifier_types_new();
1146
+
1147
+ ck_assert_int_eq(read_types_line(types, ""), FREESASA_FAIL);
1148
+ ck_assert_int_eq(read_types_line(types, "a"), FREESASA_FAIL);
1149
+ ck_assert_int_eq(read_types_line(types, "a 1.0"), FREESASA_FAIL);
1150
+ ck_assert_int_eq(read_types_line(types, "a b C"), FREESASA_FAIL);
1151
+ ck_assert_int_eq(read_types_line(types, "a 1.0 C"), FREESASA_FAIL);
1152
+ ck_assert_int_eq(read_types_line(types, "a 1.0 apolar"), FREESASA_SUCCESS);
1153
+ ck_assert_int_eq(read_types_line(types, "b 2.0 polar"), FREESASA_SUCCESS);
1154
+ ck_assert_int_eq(types->n_types, 2);
1155
+ ck_assert_str_eq(types->name[0], "a");
1156
+ ck_assert_str_eq(types->name[1], "b");
1157
+ ck_assert(fabs(types->type_radius[0] - 1.0) < 1e-10);
1158
+ ck_assert(fabs(types->type_radius[1] - 2.0) < 1e-10);
1159
+
1160
+ ck_assert_int_eq(freesasa_classifier_add_atom(residue_cfg, "C", 1.0, 0), 0);
1161
+ ck_assert_int_eq(freesasa_classifier_add_atom(residue_cfg, "CB", 2.0, 0), 1);
1162
+ ck_assert_int_eq(freesasa_classifier_add_atom(residue_cfg, "CB", 2.0, 0), FREESASA_WARN);
1163
+ ck_assert_str_eq(residue_cfg->atom_name[0], "C");
1164
+ ck_assert_str_eq(residue_cfg->atom_name[1], "CB");
1165
+ ck_assert(fabs(residue_cfg->atom_radius[0] - 1.0) < 1e-10);
1166
+ ck_assert(fabs(residue_cfg->atom_radius[1] - 2.0) < 1e-10);
1167
+ freesasa_classifier_residue_free(residue_cfg);
1168
+
1169
+ ck_assert_int_eq(freesasa_classifier_add_residue(clf, "A"), 0);
1170
+ ck_assert_int_eq(freesasa_classifier_add_residue(clf, "B"), 1);
1171
+ ck_assert_int_eq(freesasa_classifier_add_residue(clf, "B"), 1);
1172
+ ck_assert_int_eq(clf->n_residues, 2);
1173
+ ck_assert_str_eq(clf->residue_name[0], "A");
1174
+ ck_assert_str_eq(clf->residue_name[1], "B");
1175
+ ck_assert_str_eq(clf->residue[0]->name, "A");
1176
+
1177
+ freesasa_classifier_free(clf);
1178
+ clf = freesasa_classifier_new();
1179
+
1180
+ ck_assert_int_eq(read_atoms_line(clf, types, "A A"), FREESASA_FAIL);
1181
+ ck_assert_int_eq(read_atoms_line(clf, types, "A A bla"), FREESASA_FAIL);
1182
+ ck_assert_int_eq(read_atoms_line(clf, types, "ALA CA a"), FREESASA_SUCCESS);
1183
+ ck_assert_int_eq(read_atoms_line(clf, types, "ALA CB b"), FREESASA_SUCCESS);
1184
+ ck_assert_int_eq(read_atoms_line(clf, types, "ARG CA a"), FREESASA_SUCCESS);
1185
+ ck_assert_int_eq(read_atoms_line(clf, types, "ARG CB b"), FREESASA_SUCCESS);
1186
+ ck_assert_int_eq(read_atoms_line(clf, types, "ARG CG b"), FREESASA_SUCCESS);
1187
+ ck_assert_int_eq(read_atoms_line(clf, types, "TOOLONGRESNAME CG b"), FREESASA_FAIL);
1188
+ ck_assert_int_eq(read_atoms_line(clf, types, "ARG TOOLONGATOMNAME b"), FREESASA_FAIL);
1189
+ ck_assert_int_eq(clf->n_residues, 2);
1190
+ ck_assert_str_eq(clf->residue_name[0], "ALA");
1191
+ ck_assert_str_eq(clf->residue_name[1], "ARG");
1192
+ ck_assert_int_eq(clf->residue[0]->n_atoms, 2);
1193
+ ck_assert_str_eq(clf->residue[0]->atom_name[0], "CA");
1194
+ ck_assert_str_eq(clf->residue[0]->atom_name[1], "CB");
1195
+ ck_assert(fabs(clf->residue[0]->atom_radius[0] - 1.0) < 1e-5);
1196
+ ck_assert(fabs(clf->residue[0]->atom_radius[1] - 2.0) < 1e-5);
1197
+
1198
+ freesasa_classifier_free(clf);
1199
+ freesasa_classifier_types_free(types);
1200
+
1201
+ freesasa_set_verbosity(FREESASA_V_NORMAL);
1202
+ }
1203
+ END_TEST
1204
+
1205
+ START_TEST(test_classifier_utils)
1206
+ {
1207
+ const char *strarr[] = {"A", "B", "C"};
1208
+ const char *line[] = {"# Bla", " # Bla", "Bla # Bla", " Bla # Bla", "#Bla #Alb"};
1209
+
1210
+ char dummy_str[MAX_LINE_LEN + 1];
1211
+ ck_assert_int_eq(find_string((char **)strarr, "A", 3), 0);
1212
+ ck_assert_int_eq(find_string((char **)strarr, "B", 3), 1);
1213
+ ck_assert_int_eq(find_string((char **)strarr, "C", 3), 2);
1214
+ ck_assert_int_eq(find_string((char **)strarr, "D", 3), -1);
1215
+ ck_assert_int_eq(find_string((char **)strarr, " C ", 3), 2);
1216
+ ck_assert_int_eq(find_string((char **)strarr, "CC", 3), -1);
1217
+
1218
+ ck_assert_int_eq(strip_line(dummy_str, line[0]), 0);
1219
+ ck_assert_int_eq(strip_line(dummy_str, line[1]), 0);
1220
+ ck_assert_int_eq(strip_line(dummy_str, line[2]), 3);
1221
+ ck_assert_str_eq(dummy_str, "Bla");
1222
+
1223
+ ck_assert_int_eq(strip_line(dummy_str, line[3]), 3);
1224
+ ck_assert_str_eq(dummy_str, "Bla");
1225
+
1226
+ ck_assert_int_eq(strip_line(dummy_str, line[4]), 0);
1227
+
1228
+ const char *str = "foo bar # baz";
1229
+ ck_assert_int_eq(locate_string(str, "Foo"), -1);
1230
+ ck_assert_int_eq(locate_string(str, "foo"), 0);
1231
+ ck_assert_int_eq(locate_string(str, "bar"), 4);
1232
+ ck_assert_int_eq(locate_string(str, "baz"), -1);
1233
+ ck_assert_int_eq(locate_string(str, "ar"), 5);
1234
+
1235
+ struct file_range this_range, *last_range = NULL;
1236
+ ck_assert_int_eq(try_register_stringloc(str, "foo", 0, &this_range, &last_range), 0);
1237
+ ck_assert_int_eq(this_range.begin, 0);
1238
+ ck_assert_ptr_eq(last_range, &this_range);
1239
+ ck_assert_int_eq(try_register_stringloc(str, "bar", 0, &this_range, &last_range), 4);
1240
+ ck_assert_ptr_eq(last_range, &this_range);
1241
+ ck_assert_int_eq(last_range->end, 4);
1242
+ ck_assert_int_eq(try_register_stringloc(str, "baz", 0, &this_range, &last_range), -1);
1243
+ }
1244
+ END_TEST
1245
+
1246
+ TCase *
1247
+ test_classifier_static()
1248
+ {
1249
+ TCase *tc = tcase_create("classifier.c static");
1250
+ tcase_add_test(tc, test_classifier);
1251
+ tcase_add_test(tc, test_classifier_utils);
1252
+
1253
+ return tc;
1254
+ }
1255
+
1256
+ #endif /** USE_CHECK */
.venv_haddock/include/site/python3.12/freesasa/classifier.h ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef CLASSIFIER_H
2
+ #define CLASSIFIER_H
3
+
4
+ #include "freesasa_internal.h"
5
+
6
+ /**
7
+ This classifier only has the sasa_class() and class2str()
8
+ functions, which returns 1 for protein backbone atoms, and 0
9
+ else. Backbone atoms are CA, N, C and O.
10
+ */
11
+ extern const freesasa_classifier freesasa_backbone_classifier;
12
+
13
+ /** Classifier that classifies each atom according to residue */
14
+ extern const freesasa_classifier freesasa_residue_classifier;
15
+
16
+ /**
17
+ The following three structs and the following functions are only
18
+ exposed in a header because the autogenerated static classifiers
19
+ need to see them, they are not intended for use outside of this
20
+ context. Therefore the functions to modify the structs are hidden
21
+ inside classifier.c.
22
+
23
+ Names of classes, types, etc are stored in arrays to simplify
24
+ generic searching.
25
+ */
26
+
27
+ /**
28
+ Struct to store information about the types-section in a user-config.
29
+ */
30
+ struct classifier_types {
31
+ int n_types; /**< number of types */
32
+ char **name; /**< names of types */
33
+ double *type_radius; /**< radius of type */
34
+ freesasa_atom_class *type_class; /**< class of each type */
35
+ };
36
+
37
+ /**
38
+ Configuration info for each residue type.
39
+ */
40
+ struct classifier_residue {
41
+ int n_atoms; /**< Number of atoms */
42
+ char *name; /**< Name of residue */
43
+ char **atom_name; /**< Names of atoms */
44
+ double *atom_radius; /**< Atomic radii */
45
+ freesasa_atom_class *atom_class; /**< Classes of atoms */
46
+ freesasa_nodearea max_area; /**< Maximum area (for RSA) */
47
+ };
48
+
49
+ /**
50
+ Stores a user-configuration as extracted from a configuration
51
+ file. No info about types, since those are only a tool used
52
+ intermediately in assigment of radii and classes.
53
+
54
+ An array of the names of residues is stored directly in the struct
55
+ to facilitate searching for residues. The class_name array should
56
+ be a clone of that found in struct types (can be done bye
57
+ config_copy_classes()).
58
+
59
+ Only for internal use.
60
+ */
61
+ struct freesasa_classifier {
62
+ int n_residues; /**< Number of residues */
63
+ char **residue_name; /**< Names of residues */
64
+ char *name;
65
+ struct classifier_residue **residue;
66
+ };
67
+
68
+ /**
69
+ Get the VdW radius of an element
70
+ */
71
+ double
72
+ freesasa_guess_radius(const char *symbol);
73
+
74
+ const freesasa_nodearea *
75
+ freesasa_classifier_residue_reference(const freesasa_classifier *classifier,
76
+ const char *res_name);
77
+
78
+ /* The functions below are only exposed to allow testing */
79
+ freesasa_classifier *
80
+ freesasa_classifier_new(void);
81
+
82
+ struct classifier_types *
83
+ freesasa_classifier_types_new(void);
84
+
85
+ void freesasa_classifier_types_free(struct classifier_types *t);
86
+
87
+ struct classifier_residue *
88
+ freesasa_classifier_residue_new(const char *name);
89
+
90
+ void freesasa_classifier_residue_free(struct classifier_residue *res);
91
+
92
+ int freesasa_classifier_add_residue(struct freesasa_classifier *c,
93
+ const char *name);
94
+
95
+ int freesasa_classifier_add_atom(struct classifier_residue *res,
96
+ const char *name,
97
+ double radius,
98
+ int the_class);
99
+
100
+ int freesasa_classifier_add_type(struct classifier_types *types,
101
+ const char *type_name,
102
+ const char *class_name,
103
+ double r);
104
+
105
+ int freesasa_classifier_add_class(struct classifier_types *types,
106
+ const char *name);
107
+
108
+ /* These three are used to calculate residue type areas */
109
+
110
+ int freesasa_classify_n_residue_types(void);
111
+
112
+ int freesasa_classify_residue(const char *res_name);
113
+
114
+ const char *
115
+ freesasa_classify_residue_name(int residue_type);
116
+
117
+ #endif /* CLASSIFIER_H */
.venv_haddock/include/site/python3.12/freesasa/classifier_naccess.c ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "classifier.h"
2
+
3
+ /* Autogenerated code from the script config2c.pl */
4
+
5
+ static const char *naccess_residue_name[] = {"A", "ALA", "ANY", "ARG", "ASN", "ASP", "C", "CYS", "DA", "DC", "DG", "DI", "DT", "DU", "G", "GLN", "GLU", "GLY", "HIS", "I", "ILE", "LEU", "LYS", "MET", "MSE", "PHE", "PRO", "SEC", "SER", "T", "THR", "TRP", "TYR", "U", "VAL", };
6
+ static const char *naccess_A_atom_name[] = {"C2", "C6", "C4", "N7", "N9", "C5", "C8", "N3", "N6", "N1", };
7
+ static double naccess_A_atom_radius[] = {1.80, 1.80, 1.80, 1.60, 1.60, 1.80, 1.80, 1.60, 1.60, 1.60, };
8
+ static int naccess_A_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
9
+ static struct classifier_residue naccess_A_cfg = {
10
+ 10,
11
+ "A",
12
+ (char**) naccess_A_atom_name,
13
+ (double*) naccess_A_atom_radius,
14
+ (freesasa_atom_class*) naccess_A_atom_class,
15
+ {NULL, 0, 0, 0, 0, 0},
16
+ };
17
+
18
+ static const char *naccess_ALA_atom_name[] = {"CB", };
19
+ static double naccess_ALA_atom_radius[] = {1.87, };
20
+ static int naccess_ALA_atom_class[] = {FREESASA_ATOM_APOLAR, };
21
+ static struct classifier_residue naccess_ALA_cfg = {
22
+ 1,
23
+ "ALA",
24
+ (char**) naccess_ALA_atom_name,
25
+ (double*) naccess_ALA_atom_radius,
26
+ (freesasa_atom_class*) naccess_ALA_atom_class,
27
+ {"ALA", 107.89, 43.94, 63.94, 36.71, 71.17, 0},
28
+ };
29
+
30
+ static const char *naccess_ANY_atom_name[] = {"C3'", "OP1", "C", "O5'", "OXT", "C1'", "CA", "C5'", "C4'", "O2'", "O", "OP2", "CB", "N", "P", "O4'", "OP3", "C2'", "O3'", };
31
+ static double naccess_ANY_atom_radius[] = {1.80, 1.40, 1.76, 1.40, 1.40, 1.80, 1.87, 1.80, 1.80, 1.40, 1.40, 1.40, 1.87, 1.65, 1.90, 1.40, 1.40, 1.80, 1.40, };
32
+ static int naccess_ANY_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
33
+ static struct classifier_residue naccess_ANY_cfg = {
34
+ 19,
35
+ "ANY",
36
+ (char**) naccess_ANY_atom_name,
37
+ (double*) naccess_ANY_atom_radius,
38
+ (freesasa_atom_class*) naccess_ANY_atom_class,
39
+ {NULL, 0, 0, 0, 0, 0},
40
+ };
41
+
42
+ static const char *naccess_ARG_atom_name[] = {"CG", "CD", "NH1", "NE", "NH2", "CZ", };
43
+ static double naccess_ARG_atom_radius[] = {1.87, 1.87, 1.65, 1.65, 1.65, 1.76, };
44
+ static int naccess_ARG_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
45
+ static struct classifier_residue naccess_ARG_cfg = {
46
+ 6,
47
+ "ARG",
48
+ (char**) naccess_ARG_atom_name,
49
+ (double*) naccess_ARG_atom_radius,
50
+ (freesasa_atom_class*) naccess_ARG_atom_class,
51
+ {"ARG", 238.33, 41.72, 196.61, 161.10, 77.23, 0},
52
+ };
53
+
54
+ static const char *naccess_ASN_atom_name[] = {"OD1", "CG", "ND2", };
55
+ static double naccess_ASN_atom_radius[] = {1.40, 1.76, 1.65, };
56
+ static int naccess_ASN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
57
+ static struct classifier_residue naccess_ASN_cfg = {
58
+ 3,
59
+ "ASN",
60
+ (char**) naccess_ASN_atom_name,
61
+ (double*) naccess_ASN_atom_radius,
62
+ (freesasa_atom_class*) naccess_ASN_atom_class,
63
+ {"ASN", 143.97, 41.03, 102.94, 97.83, 46.14, 0},
64
+ };
65
+
66
+ static const char *naccess_ASP_atom_name[] = {"OD1", "CG", "OD2", };
67
+ static double naccess_ASP_atom_radius[] = {1.40, 1.76, 1.40, };
68
+ static int naccess_ASP_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
69
+ static struct classifier_residue naccess_ASP_cfg = {
70
+ 3,
71
+ "ASP",
72
+ (char**) naccess_ASP_atom_name,
73
+ (double*) naccess_ASP_atom_radius,
74
+ (freesasa_atom_class*) naccess_ASP_atom_class,
75
+ {"ASP", 140.48, 41.76, 98.72, 91.19, 49.29, 0},
76
+ };
77
+
78
+ static const char *naccess_C_atom_name[] = {"C5", "C6", "C4", "C2", "N1", "N4", "O2", "N3", };
79
+ static double naccess_C_atom_radius[] = {1.80, 1.80, 1.80, 1.80, 1.60, 1.60, 1.40, 1.60, };
80
+ static int naccess_C_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
81
+ static struct classifier_residue naccess_C_cfg = {
82
+ 8,
83
+ "C",
84
+ (char**) naccess_C_atom_name,
85
+ (double*) naccess_C_atom_radius,
86
+ (freesasa_atom_class*) naccess_C_atom_class,
87
+ {NULL, 0, 0, 0, 0, 0},
88
+ };
89
+
90
+ static const char *naccess_CYS_atom_name[] = {"SG", };
91
+ static double naccess_CYS_atom_radius[] = {1.85, };
92
+ static int naccess_CYS_atom_class[] = {FREESASA_ATOM_APOLAR, };
93
+ static struct classifier_residue naccess_CYS_cfg = {
94
+ 1,
95
+ "CYS",
96
+ (char**) naccess_CYS_atom_name,
97
+ (double*) naccess_CYS_atom_radius,
98
+ (freesasa_atom_class*) naccess_CYS_atom_class,
99
+ {"CYS", 134.24, 41.92, 92.33, 36.49, 97.75, 0},
100
+ };
101
+
102
+ static const char *naccess_DA_atom_name[] = {"N6", "N1", "C8", "N3", "N9", "N7", "C5", "C2", "C6", "C4", };
103
+ static double naccess_DA_atom_radius[] = {1.60, 1.60, 1.80, 1.60, 1.60, 1.60, 1.80, 1.80, 1.80, 1.80, };
104
+ static int naccess_DA_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
105
+ static struct classifier_residue naccess_DA_cfg = {
106
+ 10,
107
+ "DA",
108
+ (char**) naccess_DA_atom_name,
109
+ (double*) naccess_DA_atom_radius,
110
+ (freesasa_atom_class*) naccess_DA_atom_class,
111
+ {NULL, 0, 0, 0, 0, 0},
112
+ };
113
+
114
+ static const char *naccess_DC_atom_name[] = {"C2", "C4", "C6", "C5", "O2", "N3", "N4", "N1", };
115
+ static double naccess_DC_atom_radius[] = {1.80, 1.80, 1.80, 1.80, 1.40, 1.60, 1.60, 1.60, };
116
+ static int naccess_DC_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
117
+ static struct classifier_residue naccess_DC_cfg = {
118
+ 8,
119
+ "DC",
120
+ (char**) naccess_DC_atom_name,
121
+ (double*) naccess_DC_atom_radius,
122
+ (freesasa_atom_class*) naccess_DC_atom_class,
123
+ {NULL, 0, 0, 0, 0, 0},
124
+ };
125
+
126
+ static const char *naccess_DG_atom_name[] = {"C8", "N3", "N1", "N2", "C2", "C6", "C4", "C5", "N9", "N7", "O6", };
127
+ static double naccess_DG_atom_radius[] = {1.80, 1.60, 1.60, 1.60, 1.80, 1.80, 1.80, 1.80, 1.60, 1.60, 1.40, };
128
+ static int naccess_DG_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
129
+ static struct classifier_residue naccess_DG_cfg = {
130
+ 11,
131
+ "DG",
132
+ (char**) naccess_DG_atom_name,
133
+ (double*) naccess_DG_atom_radius,
134
+ (freesasa_atom_class*) naccess_DG_atom_class,
135
+ {NULL, 0, 0, 0, 0, 0},
136
+ };
137
+
138
+ static const char *naccess_DI_atom_name[] = {"N7", "N9", "C5", "O6", "C2", "C4", "C6", "N1", "C8", "N3", };
139
+ static double naccess_DI_atom_radius[] = {1.60, 1.60, 1.80, 1.40, 1.80, 1.80, 1.80, 1.60, 1.80, 1.60, };
140
+ static int naccess_DI_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
141
+ static struct classifier_residue naccess_DI_cfg = {
142
+ 10,
143
+ "DI",
144
+ (char**) naccess_DI_atom_name,
145
+ (double*) naccess_DI_atom_radius,
146
+ (freesasa_atom_class*) naccess_DI_atom_class,
147
+ {NULL, 0, 0, 0, 0, 0},
148
+ };
149
+
150
+ static const char *naccess_DT_atom_name[] = {"C7", "N3", "O2", "N1", "C2", "O4", "C6", "C4", "C5", };
151
+ static double naccess_DT_atom_radius[] = {1.80, 1.60, 1.40, 1.60, 1.80, 1.40, 1.80, 1.80, 1.80, };
152
+ static int naccess_DT_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
153
+ static struct classifier_residue naccess_DT_cfg = {
154
+ 9,
155
+ "DT",
156
+ (char**) naccess_DT_atom_name,
157
+ (double*) naccess_DT_atom_radius,
158
+ (freesasa_atom_class*) naccess_DT_atom_class,
159
+ {NULL, 0, 0, 0, 0, 0},
160
+ };
161
+
162
+ static const char *naccess_DU_atom_name[] = {"N3", "O2", "N1", "C6", "C4", "O4", "C2", "C5", };
163
+ static double naccess_DU_atom_radius[] = {1.60, 1.40, 1.60, 1.80, 1.80, 1.40, 1.80, 1.80, };
164
+ static int naccess_DU_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
165
+ static struct classifier_residue naccess_DU_cfg = {
166
+ 8,
167
+ "DU",
168
+ (char**) naccess_DU_atom_name,
169
+ (double*) naccess_DU_atom_radius,
170
+ (freesasa_atom_class*) naccess_DU_atom_class,
171
+ {NULL, 0, 0, 0, 0, 0},
172
+ };
173
+
174
+ static const char *naccess_G_atom_name[] = {"N2", "C2", "C6", "C4", "N9", "N7", "C5", "O6", "C8", "N3", "N1", };
175
+ static double naccess_G_atom_radius[] = {1.60, 1.80, 1.80, 1.80, 1.60, 1.60, 1.80, 1.40, 1.80, 1.60, 1.60, };
176
+ static int naccess_G_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
177
+ static struct classifier_residue naccess_G_cfg = {
178
+ 11,
179
+ "G",
180
+ (char**) naccess_G_atom_name,
181
+ (double*) naccess_G_atom_radius,
182
+ (freesasa_atom_class*) naccess_G_atom_class,
183
+ {NULL, 0, 0, 0, 0, 0},
184
+ };
185
+
186
+ static const char *naccess_GLN_atom_name[] = {"NE2", "OE1", "CD", "CG", };
187
+ static double naccess_GLN_atom_radius[] = {1.65, 1.40, 1.76, 1.87, };
188
+ static int naccess_GLN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
189
+ static struct classifier_residue naccess_GLN_cfg = {
190
+ 4,
191
+ "GLN",
192
+ (char**) naccess_GLN_atom_name,
193
+ (double*) naccess_GLN_atom_radius,
194
+ (freesasa_atom_class*) naccess_GLN_atom_class,
195
+ {"GLN", 178.24, 41.72, 136.52, 126.35, 51.89, 0},
196
+ };
197
+
198
+ static const char *naccess_GLU_atom_name[] = {"OE2", "OE1", "CD", "CG", };
199
+ static double naccess_GLU_atom_radius[] = {1.40, 1.40, 1.76, 1.87, };
200
+ static int naccess_GLU_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
201
+ static struct classifier_residue naccess_GLU_cfg = {
202
+ 4,
203
+ "GLU",
204
+ (char**) naccess_GLU_atom_name,
205
+ (double*) naccess_GLU_atom_radius,
206
+ (freesasa_atom_class*) naccess_GLU_atom_class,
207
+ {"GLU", 172.09, 41.72, 130.37, 112.13, 59.96, 0},
208
+ };
209
+
210
+ static const char *naccess_GLY_atom_name[] = {"CA", };
211
+ static double naccess_GLY_atom_radius[] = {1.87, };
212
+ static int naccess_GLY_atom_class[] = {FREESASA_ATOM_APOLAR, };
213
+ static struct classifier_residue naccess_GLY_cfg = {
214
+ 1,
215
+ "GLY",
216
+ (char**) naccess_GLY_atom_name,
217
+ (double*) naccess_GLY_atom_radius,
218
+ (freesasa_atom_class*) naccess_GLY_atom_class,
219
+ {"GLY", 80.30, 80.30, 0.00, 42.62, 37.69, 0},
220
+ };
221
+
222
+ static const char *naccess_HIS_atom_name[] = {"CG", "NE2", "CE1", "ND1", "CD2", };
223
+ static double naccess_HIS_atom_radius[] = {1.76, 1.65, 1.76, 1.65, 1.76, };
224
+ static int naccess_HIS_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
225
+ static struct classifier_residue naccess_HIS_cfg = {
226
+ 5,
227
+ "HIS",
228
+ (char**) naccess_HIS_atom_name,
229
+ (double*) naccess_HIS_atom_radius,
230
+ (freesasa_atom_class*) naccess_HIS_atom_class,
231
+ {"HIS", 182.75, 38.76, 143.99, 85.61, 97.14, 0},
232
+ };
233
+
234
+ static const char *naccess_I_atom_name[] = {"N3", "C8", "N1", "C4", "C6", "C2", "O6", "C5", "N7", "N9", };
235
+ static double naccess_I_atom_radius[] = {1.60, 1.80, 1.60, 1.80, 1.80, 1.80, 1.40, 1.80, 1.60, 1.60, };
236
+ static int naccess_I_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
237
+ static struct classifier_residue naccess_I_cfg = {
238
+ 10,
239
+ "I",
240
+ (char**) naccess_I_atom_name,
241
+ (double*) naccess_I_atom_radius,
242
+ (freesasa_atom_class*) naccess_I_atom_class,
243
+ {NULL, 0, 0, 0, 0, 0},
244
+ };
245
+
246
+ static const char *naccess_ILE_atom_name[] = {"CG1", "CG2", "CD1", };
247
+ static double naccess_ILE_atom_radius[] = {1.87, 1.87, 1.87, };
248
+ static int naccess_ILE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
249
+ static struct classifier_residue naccess_ILE_cfg = {
250
+ 3,
251
+ "ILE",
252
+ (char**) naccess_ILE_atom_name,
253
+ (double*) naccess_ILE_atom_radius,
254
+ (freesasa_atom_class*) naccess_ILE_atom_class,
255
+ {"ILE", 175.10, 41.16, 133.94, 36.10, 139.00, 0},
256
+ };
257
+
258
+ static const char *naccess_LEU_atom_name[] = {"CD2", "CD1", "CG", };
259
+ static double naccess_LEU_atom_radius[] = {1.87, 1.87, 1.87, };
260
+ static int naccess_LEU_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
261
+ static struct classifier_residue naccess_LEU_cfg = {
262
+ 3,
263
+ "LEU",
264
+ (char**) naccess_LEU_atom_name,
265
+ (double*) naccess_LEU_atom_radius,
266
+ (freesasa_atom_class*) naccess_LEU_atom_class,
267
+ {"LEU", 178.40, 39.50, 138.90, 36.45, 141.95, 0},
268
+ };
269
+
270
+ static const char *naccess_LYS_atom_name[] = {"CD", "NZ", "CE", "CG", };
271
+ static double naccess_LYS_atom_radius[] = {1.87, 1.50, 1.87, 1.87, };
272
+ static int naccess_LYS_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
273
+ static struct classifier_residue naccess_LYS_cfg = {
274
+ 4,
275
+ "LYS",
276
+ (char**) naccess_LYS_atom_name,
277
+ (double*) naccess_LYS_atom_radius,
278
+ (freesasa_atom_class*) naccess_LYS_atom_class,
279
+ {"LYS", 200.21, 41.72, 158.49, 84.31, 115.90, 0},
280
+ };
281
+
282
+ static const char *naccess_MET_atom_name[] = {"CE", "CG", "SD", };
283
+ static double naccess_MET_atom_radius[] = {1.87, 1.87, 1.85, };
284
+ static int naccess_MET_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
285
+ static struct classifier_residue naccess_MET_cfg = {
286
+ 3,
287
+ "MET",
288
+ (char**) naccess_MET_atom_name,
289
+ (double*) naccess_MET_atom_radius,
290
+ (freesasa_atom_class*) naccess_MET_atom_class,
291
+ {"MET", 193.72, 41.72, 152.00, 36.45, 157.27, 0},
292
+ };
293
+
294
+ static const char *naccess_MSE_atom_name[] = {"SE", };
295
+ static double naccess_MSE_atom_radius[] = {1.80, };
296
+ static int naccess_MSE_atom_class[] = {FREESASA_ATOM_APOLAR, };
297
+ static struct classifier_residue naccess_MSE_cfg = {
298
+ 1,
299
+ "MSE",
300
+ (char**) naccess_MSE_atom_name,
301
+ (double*) naccess_MSE_atom_radius,
302
+ (freesasa_atom_class*) naccess_MSE_atom_class,
303
+ {NULL, 0, 0, 0, 0, 0},
304
+ };
305
+
306
+ static const char *naccess_PHE_atom_name[] = {"CG", "CD1", "CE2", "CE1", "CZ", "CD2", };
307
+ static double naccess_PHE_atom_radius[] = {1.76, 1.76, 1.76, 1.76, 1.76, 1.76, };
308
+ static int naccess_PHE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
309
+ static struct classifier_residue naccess_PHE_cfg = {
310
+ 6,
311
+ "PHE",
312
+ (char**) naccess_PHE_atom_name,
313
+ (double*) naccess_PHE_atom_radius,
314
+ (freesasa_atom_class*) naccess_PHE_atom_class,
315
+ {"PHE", 199.40, 38.12, 161.27, 34.25, 165.14, 0},
316
+ };
317
+
318
+ static const char *naccess_PRO_atom_name[] = {"CG", "CD", };
319
+ static double naccess_PRO_atom_radius[] = {1.87, 1.87, };
320
+ static int naccess_PRO_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
321
+ static struct classifier_residue naccess_PRO_cfg = {
322
+ 2,
323
+ "PRO",
324
+ (char**) naccess_PRO_atom_name,
325
+ (double*) naccess_PRO_atom_radius,
326
+ (freesasa_atom_class*) naccess_PRO_atom_class,
327
+ {"PRO", 135.84, 27.09, 108.76, 15.17, 120.67, 0},
328
+ };
329
+
330
+ static const char *naccess_SEC_atom_name[] = {"SE", };
331
+ static double naccess_SEC_atom_radius[] = {1.80, };
332
+ static int naccess_SEC_atom_class[] = {FREESASA_ATOM_APOLAR, };
333
+ static struct classifier_residue naccess_SEC_cfg = {
334
+ 1,
335
+ "SEC",
336
+ (char**) naccess_SEC_atom_name,
337
+ (double*) naccess_SEC_atom_radius,
338
+ (freesasa_atom_class*) naccess_SEC_atom_class,
339
+ {NULL, 0, 0, 0, 0, 0},
340
+ };
341
+
342
+ static const char *naccess_SER_atom_name[] = {"OG", };
343
+ static double naccess_SER_atom_radius[] = {1.40, };
344
+ static int naccess_SER_atom_class[] = {FREESASA_ATOM_POLAR, };
345
+ static struct classifier_residue naccess_SER_cfg = {
346
+ 1,
347
+ "SER",
348
+ (char**) naccess_SER_atom_name,
349
+ (double*) naccess_SER_atom_radius,
350
+ (freesasa_atom_class*) naccess_SER_atom_class,
351
+ {"SER", 116.56, 43.38, 73.18, 68.03, 48.53, 0},
352
+ };
353
+
354
+ static const char *naccess_T_atom_name[] = {"C4", "C6", "O4", "C2", "C5", "N3", "C7", "O2", "N1", };
355
+ static double naccess_T_atom_radius[] = {1.80, 1.80, 1.40, 1.80, 1.80, 1.60, 1.80, 1.40, 1.60, };
356
+ static int naccess_T_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
357
+ static struct classifier_residue naccess_T_cfg = {
358
+ 9,
359
+ "T",
360
+ (char**) naccess_T_atom_name,
361
+ (double*) naccess_T_atom_radius,
362
+ (freesasa_atom_class*) naccess_T_atom_class,
363
+ {NULL, 0, 0, 0, 0, 0},
364
+ };
365
+
366
+ static const char *naccess_THR_atom_name[] = {"CG2", "OG1", };
367
+ static double naccess_THR_atom_radius[] = {1.87, 1.40, };
368
+ static int naccess_THR_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
369
+ static struct classifier_residue naccess_THR_cfg = {
370
+ 2,
371
+ "THR",
372
+ (char**) naccess_THR_atom_name,
373
+ (double*) naccess_THR_atom_radius,
374
+ (freesasa_atom_class*) naccess_THR_atom_class,
375
+ {"THR", 139.25, 41.70, 97.55, 63.50, 75.75, 0},
376
+ };
377
+
378
+ static const char *naccess_TRP_atom_name[] = {"CD1", "CZ2", "CE2", "NE1", "CG", "CE3", "CH2", "CZ3", "CD2", };
379
+ static double naccess_TRP_atom_radius[] = {1.76, 1.76, 1.76, 1.65, 1.76, 1.76, 1.76, 1.76, 1.76, };
380
+ static int naccess_TRP_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
381
+ static struct classifier_residue naccess_TRP_cfg = {
382
+ 9,
383
+ "TRP",
384
+ (char**) naccess_TRP_atom_name,
385
+ (double*) naccess_TRP_atom_radius,
386
+ (freesasa_atom_class*) naccess_TRP_atom_class,
387
+ {"TRP", 248.97, 42.38, 206.59, 59.83, 189.14, 0},
388
+ };
389
+
390
+ static const char *naccess_TYR_atom_name[] = {"CG", "CZ", "CE1", "CE2", "CD1", "OH", "CD2", };
391
+ static double naccess_TYR_atom_radius[] = {1.76, 1.76, 1.76, 1.76, 1.76, 1.40, 1.76, };
392
+ static int naccess_TYR_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
393
+ static struct classifier_residue naccess_TYR_cfg = {
394
+ 7,
395
+ "TYR",
396
+ (char**) naccess_TYR_atom_name,
397
+ (double*) naccess_TYR_atom_radius,
398
+ (freesasa_atom_class*) naccess_TYR_atom_class,
399
+ {"TYR", 212.23, 38.13, 174.10, 76.34, 135.89, 0},
400
+ };
401
+
402
+ static const char *naccess_U_atom_name[] = {"C2", "C4", "C6", "O4", "C5", "N3", "O2", "N1", };
403
+ static double naccess_U_atom_radius[] = {1.80, 1.80, 1.80, 1.40, 1.80, 1.60, 1.40, 1.60, };
404
+ static int naccess_U_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
405
+ static struct classifier_residue naccess_U_cfg = {
406
+ 8,
407
+ "U",
408
+ (char**) naccess_U_atom_name,
409
+ (double*) naccess_U_atom_radius,
410
+ (freesasa_atom_class*) naccess_U_atom_class,
411
+ {NULL, 0, 0, 0, 0, 0},
412
+ };
413
+
414
+ static const char *naccess_VAL_atom_name[] = {"CG2", "CG1", };
415
+ static double naccess_VAL_atom_radius[] = {1.87, 1.87, };
416
+ static int naccess_VAL_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
417
+ static struct classifier_residue naccess_VAL_cfg = {
418
+ 2,
419
+ "VAL",
420
+ (char**) naccess_VAL_atom_name,
421
+ (double*) naccess_VAL_atom_radius,
422
+ (freesasa_atom_class*) naccess_VAL_atom_class,
423
+ {"VAL", 151.40, 41.17, 110.23, 36.12, 115.28, 0},
424
+ };
425
+
426
+ static struct classifier_residue *naccess_residue_cfg[] = {
427
+ &naccess_A_cfg, &naccess_ALA_cfg, &naccess_ANY_cfg, &naccess_ARG_cfg, &naccess_ASN_cfg, &naccess_ASP_cfg, &naccess_C_cfg, &naccess_CYS_cfg, &naccess_DA_cfg, &naccess_DC_cfg, &naccess_DG_cfg, &naccess_DI_cfg, &naccess_DT_cfg, &naccess_DU_cfg, &naccess_G_cfg, &naccess_GLN_cfg, &naccess_GLU_cfg, &naccess_GLY_cfg, &naccess_HIS_cfg, &naccess_I_cfg, &naccess_ILE_cfg, &naccess_LEU_cfg, &naccess_LYS_cfg, &naccess_MET_cfg, &naccess_MSE_cfg, &naccess_PHE_cfg, &naccess_PRO_cfg, &naccess_SEC_cfg, &naccess_SER_cfg, &naccess_T_cfg, &naccess_THR_cfg, &naccess_TRP_cfg, &naccess_TYR_cfg, &naccess_U_cfg, &naccess_VAL_cfg, };
428
+
429
+ const freesasa_classifier freesasa_naccess_classifier = {
430
+ 35, (char**) naccess_residue_name,
431
+ "NACCESS",
432
+ (struct classifier_residue **) naccess_residue_cfg,
433
+ };
434
+
.venv_haddock/include/site/python3.12/freesasa/classifier_oons.c ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "classifier.h"
2
+
3
+ /* Autogenerated code from the script config2c.pl */
4
+
5
+ static const char *oons_residue_name[] = {"ACE", "ANY", "ARG", "ASN", "ASP", "ASX", "CSE", "CYS", "GLN", "GLU", "GLX", "HIS", "HOH", "ILE", "LEU", "LYS", "MET", "MSE", "NH2", "PHE", "PRO", "PYL", "SEC", "SER", "THR", "TRP", "TYR", "VAL", };
6
+ static const char *oons_ACE_atom_name[] = {"CH3", };
7
+ static double oons_ACE_atom_radius[] = {2.00, };
8
+ static int oons_ACE_atom_class[] = {FREESASA_ATOM_APOLAR, };
9
+ static struct classifier_residue oons_ACE_cfg = {
10
+ 1,
11
+ "ACE",
12
+ (char**) oons_ACE_atom_name,
13
+ (double*) oons_ACE_atom_radius,
14
+ (freesasa_atom_class*) oons_ACE_atom_class,
15
+ {NULL, 0, 0, 0, 0, 0},
16
+ };
17
+
18
+ static const char *oons_ANY_atom_name[] = {"N3", "O2", "N4", "N7", "CM2", "N9", "C5'", "C3'", "C1'", "C7", "OXT", "OP3", "C2", "C4'", "C5", "C8", "N1", "OP2", "C4", "N6", "C", "CB", "N2", "P", "OP1", "O2'", "O6", "O4'", "O5'", "O", "C2'", "CA", "O4", "O3'", "C6", "N", };
19
+ static double oons_ANY_atom_radius[] = {1.55, 1.40, 1.55, 1.55, 2.00, 1.55, 2.00, 1.75, 1.75, 1.75, 1.40, 1.40, 1.75, 1.75, 1.75, 1.75, 1.55, 1.40, 1.75, 1.55, 1.55, 2.00, 1.55, 1.80, 1.40, 1.40, 1.40, 1.40, 1.40, 1.40, 1.75, 2.00, 1.40, 1.40, 1.75, 1.55, };
20
+ static int oons_ANY_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
21
+ static struct classifier_residue oons_ANY_cfg = {
22
+ 36,
23
+ "ANY",
24
+ (char**) oons_ANY_atom_name,
25
+ (double*) oons_ANY_atom_radius,
26
+ (freesasa_atom_class*) oons_ANY_atom_class,
27
+ {NULL, 0, 0, 0, 0, 0},
28
+ };
29
+
30
+ static const char *oons_ARG_atom_name[] = {"NH1", "NH2", "CZ", "CD", "CG", "NE", };
31
+ static double oons_ARG_atom_radius[] = {1.55, 1.55, 2.00, 2.00, 2.00, 1.55, };
32
+ static int oons_ARG_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
33
+ static struct classifier_residue oons_ARG_cfg = {
34
+ 6,
35
+ "ARG",
36
+ (char**) oons_ARG_atom_name,
37
+ (double*) oons_ARG_atom_radius,
38
+ (freesasa_atom_class*) oons_ARG_atom_class,
39
+ {"ARG", 235.30, 38.31, 196.99, 125.27, 110.03, 0},
40
+ };
41
+
42
+ static const char *oons_ASN_atom_name[] = {"ND2", "OD1", "CG", };
43
+ static double oons_ASN_atom_radius[] = {1.55, 1.40, 1.55, };
44
+ static int oons_ASN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
45
+ static struct classifier_residue oons_ASN_cfg = {
46
+ 3,
47
+ "ASN",
48
+ (char**) oons_ASN_atom_name,
49
+ (double*) oons_ASN_atom_radius,
50
+ (freesasa_atom_class*) oons_ASN_atom_class,
51
+ {"ASN", 143.47, 38.26, 105.21, 97.51, 45.97, 0},
52
+ };
53
+
54
+ static const char *oons_ASP_atom_name[] = {"OD1", "CG", "OD2", };
55
+ static double oons_ASP_atom_radius[] = {1.40, 1.55, 1.40, };
56
+ static int oons_ASP_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
57
+ static struct classifier_residue oons_ASP_cfg = {
58
+ 3,
59
+ "ASP",
60
+ (char**) oons_ASP_atom_name,
61
+ (double*) oons_ASP_atom_radius,
62
+ (freesasa_atom_class*) oons_ASP_atom_class,
63
+ {"ASP", 141.20, 38.87, 102.33, 95.17, 46.03, 0},
64
+ };
65
+
66
+ static const char *oons_ASX_atom_name[] = {"XD1", "AD2", "XD2", "AD1", "CG", };
67
+ static double oons_ASX_atom_radius[] = {1.5, 1.5, 1.5, 1.5, 1.55, };
68
+ static int oons_ASX_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
69
+ static struct classifier_residue oons_ASX_cfg = {
70
+ 5,
71
+ "ASX",
72
+ (char**) oons_ASX_atom_name,
73
+ (double*) oons_ASX_atom_radius,
74
+ (freesasa_atom_class*) oons_ASX_atom_class,
75
+ {NULL, 0, 0, 0, 0, 0},
76
+ };
77
+
78
+ static const char *oons_CSE_atom_name[] = {"SE", };
79
+ static double oons_CSE_atom_radius[] = {1.90, };
80
+ static int oons_CSE_atom_class[] = {FREESASA_ATOM_POLAR, };
81
+ static struct classifier_residue oons_CSE_cfg = {
82
+ 1,
83
+ "CSE",
84
+ (char**) oons_CSE_atom_name,
85
+ (double*) oons_CSE_atom_radius,
86
+ (freesasa_atom_class*) oons_CSE_atom_class,
87
+ {NULL, 0, 0, 0, 0, 0},
88
+ };
89
+
90
+ static const char *oons_CYS_atom_name[] = {"SG", };
91
+ static double oons_CYS_atom_radius[] = {2.00, };
92
+ static int oons_CYS_atom_class[] = {FREESASA_ATOM_POLAR, };
93
+ static struct classifier_residue oons_CYS_cfg = {
94
+ 1,
95
+ "CYS",
96
+ (char**) oons_CYS_atom_name,
97
+ (double*) oons_CYS_atom_radius,
98
+ (freesasa_atom_class*) oons_CYS_atom_class,
99
+ {"CYS", 140.29, 38.44, 101.85, 98.30, 41.99, 0},
100
+ };
101
+
102
+ static const char *oons_GLN_atom_name[] = {"CD", "NE2", "OE1", "CG", };
103
+ static double oons_GLN_atom_radius[] = {1.55, 1.55, 1.40, 2.00, };
104
+ static int oons_GLN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
105
+ static struct classifier_residue oons_GLN_cfg = {
106
+ 4,
107
+ "GLN",
108
+ (char**) oons_GLN_atom_name,
109
+ (double*) oons_GLN_atom_radius,
110
+ (freesasa_atom_class*) oons_GLN_atom_class,
111
+ {"GLN", 176.23, 38.31, 137.92, 122.17, 54.06, 0},
112
+ };
113
+
114
+ static const char *oons_GLU_atom_name[] = {"CD", "OE1", "CG", "OE2", };
115
+ static double oons_GLU_atom_radius[] = {1.55, 1.40, 2.00, 1.40, };
116
+ static int oons_GLU_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
117
+ static struct classifier_residue oons_GLU_cfg = {
118
+ 4,
119
+ "GLU",
120
+ (char**) oons_GLU_atom_name,
121
+ (double*) oons_GLU_atom_radius,
122
+ (freesasa_atom_class*) oons_GLU_atom_class,
123
+ {"GLU", 172.43, 38.31, 134.11, 115.92, 56.51, 0},
124
+ };
125
+
126
+ static const char *oons_GLX_atom_name[] = {"XE1", "AE1", "AE2", "CD", "XE2", "CG", };
127
+ static double oons_GLX_atom_radius[] = {1.5, 1.5, 1.5, 1.55, 1.5, 2.00, };
128
+ static int oons_GLX_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
129
+ static struct classifier_residue oons_GLX_cfg = {
130
+ 6,
131
+ "GLX",
132
+ (char**) oons_GLX_atom_name,
133
+ (double*) oons_GLX_atom_radius,
134
+ (freesasa_atom_class*) oons_GLX_atom_class,
135
+ {NULL, 0, 0, 0, 0, 0},
136
+ };
137
+
138
+ static const char *oons_HIS_atom_name[] = {"ND1", "CE1", "NE2", "CG", "CD2", };
139
+ static double oons_HIS_atom_radius[] = {1.55, 1.75, 1.55, 1.75, 1.75, };
140
+ static int oons_HIS_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
141
+ static struct classifier_residue oons_HIS_cfg = {
142
+ 5,
143
+ "HIS",
144
+ (char**) oons_HIS_atom_name,
145
+ (double*) oons_HIS_atom_radius,
146
+ (freesasa_atom_class*) oons_HIS_atom_class,
147
+ {"HIS", 180.78, 36.04, 144.74, 73.26, 107.52, 0},
148
+ };
149
+
150
+ static const char *oons_HOH_atom_name[] = {"O", };
151
+ static double oons_HOH_atom_radius[] = {1.40, };
152
+ static int oons_HOH_atom_class[] = {FREESASA_ATOM_POLAR, };
153
+ static struct classifier_residue oons_HOH_cfg = {
154
+ 1,
155
+ "HOH",
156
+ (char**) oons_HOH_atom_name,
157
+ (double*) oons_HOH_atom_radius,
158
+ (freesasa_atom_class*) oons_HOH_atom_class,
159
+ {NULL, 0, 0, 0, 0, 0},
160
+ };
161
+
162
+ static const char *oons_ILE_atom_name[] = {"CG1", "CG2", "CD1", };
163
+ static double oons_ILE_atom_radius[] = {2.00, 2.00, 2.00, };
164
+ static int oons_ILE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
165
+ static struct classifier_residue oons_ILE_cfg = {
166
+ 3,
167
+ "ILE",
168
+ (char**) oons_ILE_atom_name,
169
+ (double*) oons_ILE_atom_radius,
170
+ (freesasa_atom_class*) oons_ILE_atom_class,
171
+ {"ILE", 182.12, 37.96, 144.16, 31.67, 150.45, 0},
172
+ };
173
+
174
+ static const char *oons_LEU_atom_name[] = {"CD1", "CG", "CD2", };
175
+ static double oons_LEU_atom_radius[] = {2.00, 2.00, 2.00, };
176
+ static int oons_LEU_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
177
+ static struct classifier_residue oons_LEU_cfg = {
178
+ 3,
179
+ "LEU",
180
+ (char**) oons_LEU_atom_name,
181
+ (double*) oons_LEU_atom_radius,
182
+ (freesasa_atom_class*) oons_LEU_atom_class,
183
+ {"LEU", 185.43, 35.34, 150.08, 31.73, 153.69, 0},
184
+ };
185
+
186
+ static const char *oons_LYS_atom_name[] = {"NZ", "CE", "CG", "CD", };
187
+ static double oons_LYS_atom_radius[] = {1.55, 2.00, 2.00, 2.00, };
188
+ static int oons_LYS_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
189
+ static struct classifier_residue oons_LYS_cfg = {
190
+ 4,
191
+ "LYS",
192
+ (char**) oons_LYS_atom_name,
193
+ (double*) oons_LYS_atom_radius,
194
+ (freesasa_atom_class*) oons_LYS_atom_class,
195
+ {"LYS", 205.80, 38.31, 167.49, 78.02, 127.78, 0},
196
+ };
197
+
198
+ static const char *oons_MET_atom_name[] = {"CE", "SD", "CG", };
199
+ static double oons_MET_atom_radius[] = {2.00, 2.00, 2.00, };
200
+ static int oons_MET_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
201
+ static struct classifier_residue oons_MET_cfg = {
202
+ 3,
203
+ "MET",
204
+ (char**) oons_MET_atom_name,
205
+ (double*) oons_MET_atom_radius,
206
+ (freesasa_atom_class*) oons_MET_atom_class,
207
+ {"MET", 201.66, 38.31, 163.35, 78.68, 122.98, 0},
208
+ };
209
+
210
+ static const char *oons_MSE_atom_name[] = {"CE", "SE", "CG", };
211
+ static double oons_MSE_atom_radius[] = {2.00, 1.90, 2.00, };
212
+ static int oons_MSE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
213
+ static struct classifier_residue oons_MSE_cfg = {
214
+ 3,
215
+ "MSE",
216
+ (char**) oons_MSE_atom_name,
217
+ (double*) oons_MSE_atom_radius,
218
+ (freesasa_atom_class*) oons_MSE_atom_class,
219
+ {NULL, 0, 0, 0, 0, 0},
220
+ };
221
+
222
+ static const char *oons_NH2_atom_name[] = {"NH2", };
223
+ static double oons_NH2_atom_radius[] = {1.55, };
224
+ static int oons_NH2_atom_class[] = {FREESASA_ATOM_POLAR, };
225
+ static struct classifier_residue oons_NH2_cfg = {
226
+ 1,
227
+ "NH2",
228
+ (char**) oons_NH2_atom_name,
229
+ (double*) oons_NH2_atom_radius,
230
+ (freesasa_atom_class*) oons_NH2_atom_class,
231
+ {NULL, 0, 0, 0, 0, 0},
232
+ };
233
+
234
+ static const char *oons_PHE_atom_name[] = {"CD1", "CZ", "CG", "CD2", "CE2", "CE1", };
235
+ static double oons_PHE_atom_radius[] = {1.75, 1.75, 1.75, 1.75, 1.75, 1.75, };
236
+ static int oons_PHE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
237
+ static struct classifier_residue oons_PHE_cfg = {
238
+ 6,
239
+ "PHE",
240
+ (char**) oons_PHE_atom_name,
241
+ (double*) oons_PHE_atom_radius,
242
+ (freesasa_atom_class*) oons_PHE_atom_class,
243
+ {"PHE", 199.28, 35.20, 164.08, 30.08, 169.20, 0},
244
+ };
245
+
246
+ static const char *oons_PRO_atom_name[] = {"CD", "CG", "CB", };
247
+ static double oons_PRO_atom_radius[] = {1.75, 1.75, 1.75, };
248
+ static int oons_PRO_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
249
+ static struct classifier_residue oons_PRO_cfg = {
250
+ 3,
251
+ "PRO",
252
+ (char**) oons_PRO_atom_name,
253
+ (double*) oons_PRO_atom_radius,
254
+ (freesasa_atom_class*) oons_PRO_atom_class,
255
+ {"PRO", 128.18, 31.08, 97.10, 13.95, 114.23, 0},
256
+ };
257
+
258
+ static const char *oons_PYL_atom_name[] = {"CD2", "CG2", "O2", "CA2", "CE2", "C2", "CG", "CD", "N2", "NZ", "CE", "CB2", };
259
+ static double oons_PYL_atom_radius[] = {1.75, 1.75, 1.40, 1.75, 1.75, 1.55, 2.00, 2.00, 1.55, 1.55, 2.00, 2.00, };
260
+ static int oons_PYL_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
261
+ static struct classifier_residue oons_PYL_cfg = {
262
+ 12,
263
+ "PYL",
264
+ (char**) oons_PYL_atom_name,
265
+ (double*) oons_PYL_atom_radius,
266
+ (freesasa_atom_class*) oons_PYL_atom_class,
267
+ {NULL, 0, 0, 0, 0, 0},
268
+ };
269
+
270
+ static const char *oons_SEC_atom_name[] = {"SE", };
271
+ static double oons_SEC_atom_radius[] = {1.90, };
272
+ static int oons_SEC_atom_class[] = {FREESASA_ATOM_POLAR, };
273
+ static struct classifier_residue oons_SEC_cfg = {
274
+ 1,
275
+ "SEC",
276
+ (char**) oons_SEC_atom_name,
277
+ (double*) oons_SEC_atom_radius,
278
+ (freesasa_atom_class*) oons_SEC_atom_class,
279
+ {NULL, 0, 0, 0, 0, 0},
280
+ };
281
+
282
+ static const char *oons_SER_atom_name[] = {"OG", };
283
+ static double oons_SER_atom_radius[] = {1.40, };
284
+ static int oons_SER_atom_class[] = {FREESASA_ATOM_POLAR, };
285
+ static struct classifier_residue oons_SER_cfg = {
286
+ 1,
287
+ "SER",
288
+ (char**) oons_SER_atom_name,
289
+ (double*) oons_SER_atom_radius,
290
+ (freesasa_atom_class*) oons_SER_atom_class,
291
+ {"SER", 118.43, 40.20, 78.23, 60.41, 58.02, 0},
292
+ };
293
+
294
+ static const char *oons_THR_atom_name[] = {"OG1", "CG2", };
295
+ static double oons_THR_atom_radius[] = {1.40, 2.00, };
296
+ static int oons_THR_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
297
+ static struct classifier_residue oons_THR_cfg = {
298
+ 2,
299
+ "THR",
300
+ (char**) oons_THR_atom_name,
301
+ (double*) oons_THR_atom_radius,
302
+ (freesasa_atom_class*) oons_THR_atom_class,
303
+ {"THR", 142.41, 38.32, 104.08, 56.42, 85.99, 0},
304
+ };
305
+
306
+ static const char *oons_TRP_atom_name[] = {"CD2", "CE3", "CE2", "CH2", "CD1", "CZ3", "CZ2", "NE1", "CG", };
307
+ static double oons_TRP_atom_radius[] = {1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.55, 1.75, };
308
+ static int oons_TRP_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
309
+ static struct classifier_residue oons_TRP_cfg = {
310
+ 9,
311
+ "TRP",
312
+ (char**) oons_TRP_atom_name,
313
+ (double*) oons_TRP_atom_radius,
314
+ (freesasa_atom_class*) oons_TRP_atom_class,
315
+ {"TRP", 247.08, 39.43, 207.65, 52.90, 194.18, 0},
316
+ };
317
+
318
+ static const char *oons_TYR_atom_name[] = {"CG", "CD2", "CD1", "CZ", "CE1", "OH", "CE2", };
319
+ static double oons_TYR_atom_radius[] = {1.75, 1.75, 1.75, 1.75, 1.75, 1.40, 1.75, };
320
+ static int oons_TYR_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
321
+ static struct classifier_residue oons_TYR_cfg = {
322
+ 7,
323
+ "TYR",
324
+ (char**) oons_TYR_atom_name,
325
+ (double*) oons_TYR_atom_radius,
326
+ (freesasa_atom_class*) oons_TYR_atom_class,
327
+ {"TYR", 212.31, 35.20, 177.11, 72.41, 139.90, 0},
328
+ };
329
+
330
+ static const char *oons_VAL_atom_name[] = {"CG1", "CG2", };
331
+ static double oons_VAL_atom_radius[] = {2.00, 2.00, };
332
+ static int oons_VAL_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
333
+ static struct classifier_residue oons_VAL_cfg = {
334
+ 2,
335
+ "VAL",
336
+ (char**) oons_VAL_atom_name,
337
+ (double*) oons_VAL_atom_radius,
338
+ (freesasa_atom_class*) oons_VAL_atom_class,
339
+ {"VAL", 157.64, 37.96, 119.68, 31.70, 125.94, 0},
340
+ };
341
+
342
+ static struct classifier_residue *oons_residue_cfg[] = {
343
+ &oons_ACE_cfg, &oons_ANY_cfg, &oons_ARG_cfg, &oons_ASN_cfg, &oons_ASP_cfg, &oons_ASX_cfg, &oons_CSE_cfg, &oons_CYS_cfg, &oons_GLN_cfg, &oons_GLU_cfg, &oons_GLX_cfg, &oons_HIS_cfg, &oons_HOH_cfg, &oons_ILE_cfg, &oons_LEU_cfg, &oons_LYS_cfg, &oons_MET_cfg, &oons_MSE_cfg, &oons_NH2_cfg, &oons_PHE_cfg, &oons_PRO_cfg, &oons_PYL_cfg, &oons_SEC_cfg, &oons_SER_cfg, &oons_THR_cfg, &oons_TRP_cfg, &oons_TYR_cfg, &oons_VAL_cfg, };
344
+
345
+ const freesasa_classifier freesasa_oons_classifier = {
346
+ 28, (char**) oons_residue_name,
347
+ "OONS",
348
+ (struct classifier_residue **) oons_residue_cfg,
349
+ };
350
+
.venv_haddock/include/site/python3.12/freesasa/classifier_protor.c ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "classifier.h"
2
+
3
+ /* Autogenerated code from the script config2c.pl */
4
+
5
+ static const char *protor_residue_name[] = {"A", "ACE", "ALA", "ARG", "ASN", "ASP", "ASX", "C", "CYS", "DA", "DC", "DG", "DI", "DT", "DU", "G", "GLN", "GLU", "GLX", "GLY", "HIS", "HOH", "I", "ILE", "LEU", "LYS", "MET", "MSE", "NH2", "PHE", "PRO", "PYL", "SEC", "SER", "T", "THR", "TRP", "TYR", "U", "VAL", };
6
+ static const char *protor_A_atom_name[] = {"C6", "O2'", "C2'", "OP1", "C5", "C4", "O3'", "OP3", "P", "C4'", "O4'", "C3'", "C8", "N6", "N9", "O5'", "N7", "OP2", "C5'", "N3", "C1'", "N1", "C2", };
7
+ static double protor_A_atom_radius[] = {1.61, 1.46, 1.88, 1.42, 1.61, 1.61, 1.46, 1.46, 1.8, 1.88, 1.46, 1.88, 1.76, 1.64, 1.64, 1.46, 1.64, 1.46, 1.88, 1.64, 1.88, 1.64, 1.76, };
8
+ static int protor_A_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
9
+ static struct classifier_residue protor_A_cfg = {
10
+ 23,
11
+ "A",
12
+ (char**) protor_A_atom_name,
13
+ (double*) protor_A_atom_radius,
14
+ (freesasa_atom_class*) protor_A_atom_class,
15
+ {NULL, 0, 0, 0, 0, 0},
16
+ };
17
+
18
+ static const char *protor_ACE_atom_name[] = {"O", "CH3", "C", };
19
+ static double protor_ACE_atom_radius[] = {1.42, 1.88, 1.76, };
20
+ static int protor_ACE_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
21
+ static struct classifier_residue protor_ACE_cfg = {
22
+ 3,
23
+ "ACE",
24
+ (char**) protor_ACE_atom_name,
25
+ (double*) protor_ACE_atom_radius,
26
+ (freesasa_atom_class*) protor_ACE_atom_class,
27
+ {NULL, 0, 0, 0, 0, 0},
28
+ };
29
+
30
+ static const char *protor_ALA_atom_name[] = {"N", "CB", "CA", "C", "O", "OXT", };
31
+ static double protor_ALA_atom_radius[] = {1.64, 1.88, 1.88, 1.61, 1.42, 1.46, };
32
+ static int protor_ALA_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
33
+ static struct classifier_residue protor_ALA_cfg = {
34
+ 6,
35
+ "ALA",
36
+ (char**) protor_ALA_atom_name,
37
+ (double*) protor_ALA_atom_radius,
38
+ (freesasa_atom_class*) protor_ALA_atom_class,
39
+ {"ALA", 108.76, 43.96, 64.80, 37.75, 71.01, 0},
40
+ };
41
+
42
+ static const char *protor_ARG_atom_name[] = {"C", "CA", "CB", "NH1", "OXT", "CZ", "CG", "O", "NE", "CD", "N", "NH2", };
43
+ static double protor_ARG_atom_radius[] = {1.61, 1.88, 1.88, 1.64, 1.46, 1.61, 1.88, 1.42, 1.64, 1.88, 1.64, 1.64, };
44
+ static int protor_ARG_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
45
+ static struct classifier_residue protor_ARG_cfg = {
46
+ 12,
47
+ "ARG",
48
+ (char**) protor_ARG_atom_name,
49
+ (double*) protor_ARG_atom_radius,
50
+ (freesasa_atom_class*) protor_ARG_atom_class,
51
+ {"ARG", 238.17, 42.00, 196.17, 165.00, 73.17, 0},
52
+ };
53
+
54
+ static const char *protor_ASN_atom_name[] = {"N", "CA", "CB", "C", "OD1", "O", "CG", "OXT", "ND2", };
55
+ static double protor_ASN_atom_radius[] = {1.64, 1.88, 1.88, 1.61, 1.42, 1.42, 1.61, 1.46, 1.64, };
56
+ static int protor_ASN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
57
+ static struct classifier_residue protor_ASN_cfg = {
58
+ 9,
59
+ "ASN",
60
+ (char**) protor_ASN_atom_name,
61
+ (double*) protor_ASN_atom_radius,
62
+ (freesasa_atom_class*) protor_ASN_atom_class,
63
+ {"ASN", 145.01, 41.53, 103.48, 103.46, 41.55, 0},
64
+ };
65
+
66
+ static const char *protor_ASP_atom_name[] = {"OD2", "N", "CG", "O", "OXT", "CA", "CB", "C", "OD1", };
67
+ static double protor_ASP_atom_radius[] = {1.46, 1.64, 1.61, 1.42, 1.46, 1.88, 1.88, 1.61, 1.42, };
68
+ static int protor_ASP_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
69
+ static struct classifier_residue protor_ASP_cfg = {
70
+ 9,
71
+ "ASP",
72
+ (char**) protor_ASP_atom_name,
73
+ (double*) protor_ASP_atom_radius,
74
+ (freesasa_atom_class*) protor_ASP_atom_class,
75
+ {"ASP", 142.76, 42.29, 100.47, 100.27, 42.49, 0},
76
+ };
77
+
78
+ static const char *protor_ASX_atom_name[] = {"XD2", "N", "O", "CG", "OXT", "CA", "CB", "XD1", "C", };
79
+ static double protor_ASX_atom_radius[] = {1.5, 1.64, 1.42, 1.61, 1.46, 1.88, 1.88, 1.5, 1.61, };
80
+ static int protor_ASX_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
81
+ static struct classifier_residue protor_ASX_cfg = {
82
+ 9,
83
+ "ASX",
84
+ (char**) protor_ASX_atom_name,
85
+ (double*) protor_ASX_atom_radius,
86
+ (freesasa_atom_class*) protor_ASX_atom_class,
87
+ {NULL, 0, 0, 0, 0, 0},
88
+ };
89
+
90
+ static const char *protor_C_atom_name[] = {"C2", "N1", "N3", "C1'", "C5'", "OP2", "O5'", "C3'", "O4'", "P", "C4'", "O2", "N4", "OP3", "O3'", "C4", "C5", "OP1", "C2'", "O2'", "C6", };
91
+ static double protor_C_atom_radius[] = {1.61, 1.64, 1.64, 1.88, 1.88, 1.46, 1.46, 1.88, 1.46, 1.8, 1.88, 1.42, 1.64, 1.46, 1.46, 1.61, 1.76, 1.42, 1.88, 1.46, 1.76, };
92
+ static int protor_C_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
93
+ static struct classifier_residue protor_C_cfg = {
94
+ 21,
95
+ "C",
96
+ (char**) protor_C_atom_name,
97
+ (double*) protor_C_atom_radius,
98
+ (freesasa_atom_class*) protor_C_atom_class,
99
+ {NULL, 0, 0, 0, 0, 0},
100
+ };
101
+
102
+ static const char *protor_CYS_atom_name[] = {"O", "OXT", "SG", "CA", "CB", "C", "N", };
103
+ static double protor_CYS_atom_radius[] = {1.42, 1.46, 1.77, 1.88, 1.88, 1.61, 1.64, };
104
+ static int protor_CYS_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
105
+ static struct classifier_residue protor_CYS_cfg = {
106
+ 7,
107
+ "CYS",
108
+ (char**) protor_CYS_atom_name,
109
+ (double*) protor_CYS_atom_radius,
110
+ (freesasa_atom_class*) protor_CYS_atom_class,
111
+ {"CYS", 132.20, 42.55, 89.66, 92.74, 39.47, 0},
112
+ };
113
+
114
+ static const char *protor_DA_atom_name[] = {"OP2", "C5'", "C1'", "N3", "N1", "C2", "N6", "N9", "O5'", "N7", "C3'", "C8", "OP3", "C4'", "P", "O4'", "C4", "O3'", "C5", "OP1", "C6", "C2'", };
115
+ static double protor_DA_atom_radius[] = {1.46, 1.88, 1.88, 1.64, 1.64, 1.76, 1.64, 1.64, 1.46, 1.64, 1.88, 1.76, 1.46, 1.88, 1.8, 1.46, 1.61, 1.46, 1.61, 1.42, 1.61, 1.88, };
116
+ static int protor_DA_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
117
+ static struct classifier_residue protor_DA_cfg = {
118
+ 22,
119
+ "DA",
120
+ (char**) protor_DA_atom_name,
121
+ (double*) protor_DA_atom_radius,
122
+ (freesasa_atom_class*) protor_DA_atom_class,
123
+ {NULL, 0, 0, 0, 0, 0},
124
+ };
125
+
126
+ static const char *protor_DC_atom_name[] = {"C5", "C4", "O3'", "C6", "C2'", "OP1", "O5'", "C5'", "OP2", "C2", "C1'", "N3", "N1", "C4'", "P", "N4", "O2", "OP3", "O4'", "C3'", };
127
+ static double protor_DC_atom_radius[] = {1.76, 1.61, 1.46, 1.76, 1.88, 1.42, 1.46, 1.88, 1.46, 1.61, 1.88, 1.64, 1.64, 1.88, 1.8, 1.64, 1.42, 1.46, 1.46, 1.88, };
128
+ static int protor_DC_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
129
+ static struct classifier_residue protor_DC_cfg = {
130
+ 20,
131
+ "DC",
132
+ (char**) protor_DC_atom_name,
133
+ (double*) protor_DC_atom_radius,
134
+ (freesasa_atom_class*) protor_DC_atom_class,
135
+ {NULL, 0, 0, 0, 0, 0},
136
+ };
137
+
138
+ static const char *protor_DG_atom_name[] = {"C8", "C3'", "N2", "P", "C4'", "OP3", "O4'", "C5'", "OP2", "C2", "C1'", "N3", "N1", "O5'", "N9", "N7", "O6", "OP1", "C6", "C2'", "C4", "O3'", "C5", };
139
+ static double protor_DG_atom_radius[] = {1.76, 1.88, 1.64, 1.8, 1.88, 1.46, 1.46, 1.88, 1.46, 1.61, 1.88, 1.64, 1.64, 1.46, 1.64, 1.64, 1.42, 1.42, 1.61, 1.88, 1.61, 1.46, 1.61, };
140
+ static int protor_DG_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
141
+ static struct classifier_residue protor_DG_cfg = {
142
+ 23,
143
+ "DG",
144
+ (char**) protor_DG_atom_name,
145
+ (double*) protor_DG_atom_radius,
146
+ (freesasa_atom_class*) protor_DG_atom_class,
147
+ {NULL, 0, 0, 0, 0, 0},
148
+ };
149
+
150
+ static const char *protor_DI_atom_name[] = {"N3", "N1", "C1'", "C2", "OP2", "C5'", "N7", "N9", "O5'", "C3'", "C8", "O4'", "OP3", "C4'", "P", "O3'", "C4", "C5", "OP1", "O6", "C2'", "C6", };
151
+ static double protor_DI_atom_radius[] = {1.64, 1.64, 1.88, 1.76, 1.46, 1.88, 1.64, 1.64, 1.46, 1.88, 1.76, 1.46, 1.46, 1.88, 1.8, 1.46, 1.61, 1.61, 1.42, 1.42, 1.88, 1.61, };
152
+ static int protor_DI_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
153
+ static struct classifier_residue protor_DI_cfg = {
154
+ 22,
155
+ "DI",
156
+ (char**) protor_DI_atom_name,
157
+ (double*) protor_DI_atom_radius,
158
+ (freesasa_atom_class*) protor_DI_atom_class,
159
+ {NULL, 0, 0, 0, 0, 0},
160
+ };
161
+
162
+ static const char *protor_DT_atom_name[] = {"OP2", "C5'", "N3", "C1'", "N1", "C2", "O5'", "C3'", "O4", "OP3", "O2", "P", "C4'", "O4'", "C4", "O3'", "C5", "C7", "OP1", "C6", "C2'", };
163
+ static double protor_DT_atom_radius[] = {1.46, 1.88, 1.64, 1.88, 1.64, 1.61, 1.46, 1.88, 1.42, 1.46, 1.42, 1.8, 1.88, 1.46, 1.61, 1.46, 1.61, 1.88, 1.42, 1.76, 1.88, };
164
+ static int protor_DT_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
165
+ static struct classifier_residue protor_DT_cfg = {
166
+ 21,
167
+ "DT",
168
+ (char**) protor_DT_atom_name,
169
+ (double*) protor_DT_atom_radius,
170
+ (freesasa_atom_class*) protor_DT_atom_class,
171
+ {NULL, 0, 0, 0, 0, 0},
172
+ };
173
+
174
+ static const char *protor_DU_atom_name[] = {"C5", "C4", "O3'", "C6", "C2'", "OP1", "O5'", "C5'", "OP2", "C2", "C1'", "N3", "N1", "C4'", "P", "OP3", "O2", "O4'", "C3'", "O4", };
175
+ static double protor_DU_atom_radius[] = {1.76, 1.61, 1.46, 1.76, 1.88, 1.42, 1.46, 1.88, 1.46, 1.61, 1.88, 1.64, 1.64, 1.88, 1.8, 1.46, 1.42, 1.46, 1.88, 1.42, };
176
+ static int protor_DU_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
177
+ static struct classifier_residue protor_DU_cfg = {
178
+ 20,
179
+ "DU",
180
+ (char**) protor_DU_atom_name,
181
+ (double*) protor_DU_atom_radius,
182
+ (freesasa_atom_class*) protor_DU_atom_class,
183
+ {NULL, 0, 0, 0, 0, 0},
184
+ };
185
+
186
+ static const char *protor_G_atom_name[] = {"O6", "OP1", "O2'", "C6", "C2'", "C4", "O3'", "C5", "C8", "C3'", "N2", "C4'", "P", "OP3", "O4'", "C5'", "OP2", "C2", "N1", "N3", "C1'", "N9", "O5'", "N7", };
187
+ static double protor_G_atom_radius[] = {1.42, 1.42, 1.46, 1.61, 1.88, 1.61, 1.46, 1.61, 1.76, 1.88, 1.64, 1.88, 1.8, 1.46, 1.46, 1.88, 1.46, 1.61, 1.64, 1.64, 1.88, 1.64, 1.46, 1.64, };
188
+ static int protor_G_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
189
+ static struct classifier_residue protor_G_cfg = {
190
+ 24,
191
+ "G",
192
+ (char**) protor_G_atom_name,
193
+ (double*) protor_G_atom_radius,
194
+ (freesasa_atom_class*) protor_G_atom_class,
195
+ {NULL, 0, 0, 0, 0, 0},
196
+ };
197
+
198
+ static const char *protor_GLN_atom_name[] = {"OE1", "CD", "N", "CG", "O", "OXT", "CB", "CA", "C", "NE2", };
199
+ static double protor_GLN_atom_radius[] = {1.42, 1.61, 1.64, 1.88, 1.42, 1.46, 1.88, 1.88, 1.61, 1.64, };
200
+ static int protor_GLN_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
201
+ static struct classifier_residue protor_GLN_cfg = {
202
+ 10,
203
+ "GLN",
204
+ (char**) protor_GLN_atom_name,
205
+ (double*) protor_GLN_atom_radius,
206
+ (freesasa_atom_class*) protor_GLN_atom_class,
207
+ {"GLN", 178.83, 42.00, 136.83, 131.85, 46.98, 0},
208
+ };
209
+
210
+ static const char *protor_GLU_atom_name[] = {"O", "CG", "OXT", "OE2", "CA", "CB", "C", "N", "OE1", "CD", };
211
+ static double protor_GLU_atom_radius[] = {1.42, 1.88, 1.46, 1.46, 1.88, 1.88, 1.61, 1.64, 1.42, 1.61, };
212
+ static int protor_GLU_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
213
+ static struct classifier_residue protor_GLU_cfg = {
214
+ 10,
215
+ "GLU",
216
+ (char**) protor_GLU_atom_name,
217
+ (double*) protor_GLU_atom_radius,
218
+ (freesasa_atom_class*) protor_GLU_atom_class,
219
+ {"GLU", 174.18, 42.00, 132.18, 122.48, 51.70, 0},
220
+ };
221
+
222
+ static const char *protor_GLX_atom_name[] = {"C", "CA", "CB", "XE1", "OXT", "O", "XE2", "CG", "CD", "N", };
223
+ static double protor_GLX_atom_radius[] = {1.61, 1.88, 1.88, 1.5, 1.46, 1.42, 1.5, 1.88, 1.61, 1.64, };
224
+ static int protor_GLX_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
225
+ static struct classifier_residue protor_GLX_cfg = {
226
+ 10,
227
+ "GLX",
228
+ (char**) protor_GLX_atom_name,
229
+ (double*) protor_GLX_atom_radius,
230
+ (freesasa_atom_class*) protor_GLX_atom_class,
231
+ {NULL, 0, 0, 0, 0, 0},
232
+ };
233
+
234
+ static const char *protor_GLY_atom_name[] = {"OXT", "O", "C", "CA", "N", };
235
+ static double protor_GLY_atom_radius[] = {1.46, 1.42, 1.61, 1.88, 1.64, };
236
+ static int protor_GLY_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
237
+ static struct classifier_residue protor_GLY_cfg = {
238
+ 5,
239
+ "GLY",
240
+ (char**) protor_GLY_atom_name,
241
+ (double*) protor_GLY_atom_radius,
242
+ (freesasa_atom_class*) protor_GLY_atom_class,
243
+ {"GLY", 81.09, 81.09, 0.00, 44.65, 36.44, 0},
244
+ };
245
+
246
+ static const char *protor_HIS_atom_name[] = {"ND1", "O", "CG", "OXT", "NE2", "CB", "CA", "C", "CD2", "N", "CE1", };
247
+ static double protor_HIS_atom_radius[] = {1.64, 1.42, 1.61, 1.46, 1.64, 1.88, 1.88, 1.61, 1.76, 1.64, 1.76, };
248
+ static int protor_HIS_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
249
+ static struct classifier_residue protor_HIS_cfg = {
250
+ 11,
251
+ "HIS",
252
+ (char**) protor_HIS_atom_name,
253
+ (double*) protor_HIS_atom_radius,
254
+ (freesasa_atom_class*) protor_HIS_atom_class,
255
+ {"HIS", 182.97, 39.09, 143.87, 85.94, 97.03, 0},
256
+ };
257
+
258
+ static const char *protor_HOH_atom_name[] = {"O", };
259
+ static double protor_HOH_atom_radius[] = {1.46, };
260
+ static int protor_HOH_atom_class[] = {FREESASA_ATOM_POLAR, };
261
+ static struct classifier_residue protor_HOH_cfg = {
262
+ 1,
263
+ "HOH",
264
+ (char**) protor_HOH_atom_name,
265
+ (double*) protor_HOH_atom_radius,
266
+ (freesasa_atom_class*) protor_HOH_atom_class,
267
+ {NULL, 0, 0, 0, 0, 0},
268
+ };
269
+
270
+ static const char *protor_I_atom_name[] = {"O3'", "C4", "C5", "OP1", "O6", "C2'", "C6", "O2'", "N3", "N1", "C1'", "C2", "OP2", "C5'", "N7", "N9", "O5'", "C8", "C3'", "O4'", "OP3", "P", "C4'", };
271
+ static double protor_I_atom_radius[] = {1.46, 1.61, 1.61, 1.42, 1.42, 1.88, 1.61, 1.46, 1.64, 1.64, 1.88, 1.76, 1.46, 1.88, 1.64, 1.64, 1.46, 1.76, 1.88, 1.46, 1.46, 1.8, 1.88, };
272
+ static int protor_I_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
273
+ static struct classifier_residue protor_I_cfg = {
274
+ 23,
275
+ "I",
276
+ (char**) protor_I_atom_name,
277
+ (double*) protor_I_atom_radius,
278
+ (freesasa_atom_class*) protor_I_atom_class,
279
+ {NULL, 0, 0, 0, 0, 0},
280
+ };
281
+
282
+ static const char *protor_ILE_atom_name[] = {"N", "OXT", "O", "CG1", "C", "CA", "CB", "CG2", "CD1", };
283
+ static double protor_ILE_atom_radius[] = {1.64, 1.46, 1.42, 1.88, 1.61, 1.88, 1.88, 1.88, 1.88, };
284
+ static int protor_ILE_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
285
+ static struct classifier_residue protor_ILE_cfg = {
286
+ 9,
287
+ "ILE",
288
+ (char**) protor_ILE_atom_name,
289
+ (double*) protor_ILE_atom_radius,
290
+ (freesasa_atom_class*) protor_ILE_atom_class,
291
+ {"ILE", 175.73, 41.49, 134.23, 36.85, 138.87, 0},
292
+ };
293
+
294
+ static const char *protor_LEU_atom_name[] = {"CD2", "N", "OXT", "O", "CG", "C", "CA", "CB", "CD1", };
295
+ static double protor_LEU_atom_radius[] = {1.88, 1.64, 1.46, 1.42, 1.88, 1.61, 1.88, 1.88, 1.88, };
296
+ static int protor_LEU_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
297
+ static struct classifier_residue protor_LEU_cfg = {
298
+ 9,
299
+ "LEU",
300
+ (char**) protor_LEU_atom_name,
301
+ (double*) protor_LEU_atom_radius,
302
+ (freesasa_atom_class*) protor_LEU_atom_class,
303
+ {"LEU", 179.56, 39.78, 139.78, 37.16, 142.39, 0},
304
+ };
305
+
306
+ static const char *protor_LYS_atom_name[] = {"NZ", "N", "CD", "CA", "CB", "C", "CE", "O", "CG", "OXT", };
307
+ static double protor_LYS_atom_radius[] = {1.64, 1.64, 1.88, 1.88, 1.88, 1.61, 1.88, 1.42, 1.88, 1.46, };
308
+ static int protor_LYS_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
309
+ static struct classifier_residue protor_LYS_cfg = {
310
+ 10,
311
+ "LYS",
312
+ (char**) protor_LYS_atom_name,
313
+ (double*) protor_LYS_atom_radius,
314
+ (freesasa_atom_class*) protor_LYS_atom_class,
315
+ {"LYS", 204.98, 42.00, 162.98, 93.88, 111.10, 0},
316
+ };
317
+
318
+ static const char *protor_MET_atom_name[] = {"N", "SD", "CA", "CB", "C", "O", "CG", "OXT", "CE", };
319
+ static double protor_MET_atom_radius[] = {1.64, 1.77, 1.88, 1.88, 1.61, 1.42, 1.88, 1.46, 1.88, };
320
+ static int protor_MET_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, };
321
+ static struct classifier_residue protor_MET_cfg = {
322
+ 9,
323
+ "MET",
324
+ (char**) protor_MET_atom_name,
325
+ (double*) protor_MET_atom_radius,
326
+ (freesasa_atom_class*) protor_MET_atom_class,
327
+ {"MET", 193.10, 42.00, 151.10, 75.48, 117.62, 0},
328
+ };
329
+
330
+ static const char *protor_MSE_atom_name[] = {"SE", "N", "C", "CA", "CB", "OXT", "O", "CG", "CE", };
331
+ static double protor_MSE_atom_radius[] = {1.9, 1.64, 1.61, 1.88, 1.88, 1.46, 1.42, 1.88, 1.88, };
332
+ static int protor_MSE_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
333
+ static struct classifier_residue protor_MSE_cfg = {
334
+ 9,
335
+ "MSE",
336
+ (char**) protor_MSE_atom_name,
337
+ (double*) protor_MSE_atom_radius,
338
+ (freesasa_atom_class*) protor_MSE_atom_class,
339
+ {NULL, 0, 0, 0, 0, 0},
340
+ };
341
+
342
+ static const char *protor_NH2_atom_name[] = {"N", };
343
+ static double protor_NH2_atom_radius[] = {1.64, };
344
+ static int protor_NH2_atom_class[] = {FREESASA_ATOM_POLAR, };
345
+ static struct classifier_residue protor_NH2_cfg = {
346
+ 1,
347
+ "NH2",
348
+ (char**) protor_NH2_atom_name,
349
+ (double*) protor_NH2_atom_radius,
350
+ (freesasa_atom_class*) protor_NH2_atom_class,
351
+ {NULL, 0, 0, 0, 0, 0},
352
+ };
353
+
354
+ static const char *protor_PHE_atom_name[] = {"CD1", "CA", "CB", "C", "CZ", "O", "CG", "OXT", "N", "CE1", "CE2", "CD2", };
355
+ static double protor_PHE_atom_radius[] = {1.76, 1.88, 1.88, 1.61, 1.76, 1.42, 1.61, 1.46, 1.64, 1.76, 1.76, 1.76, };
356
+ static int protor_PHE_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
357
+ static struct classifier_residue protor_PHE_cfg = {
358
+ 12,
359
+ "PHE",
360
+ (char**) protor_PHE_atom_name,
361
+ (double*) protor_PHE_atom_radius,
362
+ (freesasa_atom_class*) protor_PHE_atom_class,
363
+ {"PHE", 199.88, 38.43, 161.45, 34.94, 164.94, 0},
364
+ };
365
+
366
+ static const char *protor_PRO_atom_name[] = {"C", "CB", "CA", "OXT", "O", "CG", "CD", "N", };
367
+ static double protor_PRO_atom_radius[] = {1.61, 1.88, 1.88, 1.46, 1.42, 1.88, 1.88, 1.64, };
368
+ static int protor_PRO_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
369
+ static struct classifier_residue protor_PRO_cfg = {
370
+ 8,
371
+ "PRO",
372
+ (char**) protor_PRO_atom_name,
373
+ (double*) protor_PRO_atom_radius,
374
+ (freesasa_atom_class*) protor_PRO_atom_class,
375
+ {"PRO", 137.21, 27.51, 109.70, 16.09, 121.12, 0},
376
+ };
377
+
378
+ static const char *protor_PYL_atom_name[] = {"N2", "N", "CD", "CD2", "O2", "CA2", "C2", "CB", "OXT", "O", "CG", "NZ", "CE2", "CG2", "C", "CA", "CE", "CB2", };
379
+ static double protor_PYL_atom_radius[] = {1.64, 1.64, 1.88, 1.88, 1.42, 1.88, 1.61, 1.88, 1.46, 1.42, 1.88, 1.64, 1.76, 1.88, 1.61, 1.88, 1.88, 1.88, };
380
+ static int protor_PYL_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
381
+ static struct classifier_residue protor_PYL_cfg = {
382
+ 18,
383
+ "PYL",
384
+ (char**) protor_PYL_atom_name,
385
+ (double*) protor_PYL_atom_radius,
386
+ (freesasa_atom_class*) protor_PYL_atom_class,
387
+ {NULL, 0, 0, 0, 0, 0},
388
+ };
389
+
390
+ static const char *protor_SEC_atom_name[] = {"C", "SE", "CA", "CB", "N", "OXT", "O", };
391
+ static double protor_SEC_atom_radius[] = {1.61, 1.9, 1.88, 1.88, 1.64, 1.46, 1.42, };
392
+ static int protor_SEC_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
393
+ static struct classifier_residue protor_SEC_cfg = {
394
+ 7,
395
+ "SEC",
396
+ (char**) protor_SEC_atom_name,
397
+ (double*) protor_SEC_atom_radius,
398
+ (freesasa_atom_class*) protor_SEC_atom_class,
399
+ {NULL, 0, 0, 0, 0, 0},
400
+ };
401
+
402
+ static const char *protor_SER_atom_name[] = {"C", "CA", "CB", "N", "OXT", "O", "OG", };
403
+ static double protor_SER_atom_radius[] = {1.61, 1.88, 1.88, 1.64, 1.46, 1.42, 1.46, };
404
+ static int protor_SER_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
405
+ static struct classifier_residue protor_SER_cfg = {
406
+ 7,
407
+ "SER",
408
+ (char**) protor_SER_atom_name,
409
+ (double*) protor_SER_atom_radius,
410
+ (freesasa_atom_class*) protor_SER_atom_class,
411
+ {"SER", 118.34, 43.41, 74.93, 71.38, 46.96, 0},
412
+ };
413
+
414
+ static const char *protor_T_atom_name[] = {"O2", "OP3", "C4'", "P", "O4'", "C3'", "O4", "O5'", "OP2", "C5'", "N3", "C1'", "N1", "C2", "C6", "C2'", "OP1", "C5", "C7", "C4", "O3'", };
415
+ static double protor_T_atom_radius[] = {1.42, 1.46, 1.88, 1.8, 1.46, 1.88, 1.42, 1.46, 1.46, 1.88, 1.64, 1.88, 1.64, 1.61, 1.76, 1.88, 1.42, 1.61, 1.88, 1.61, 1.46, };
416
+ static int protor_T_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
417
+ static struct classifier_residue protor_T_cfg = {
418
+ 21,
419
+ "T",
420
+ (char**) protor_T_atom_name,
421
+ (double*) protor_T_atom_radius,
422
+ (freesasa_atom_class*) protor_T_atom_class,
423
+ {NULL, 0, 0, 0, 0, 0},
424
+ };
425
+
426
+ static const char *protor_THR_atom_name[] = {"OXT", "O", "OG1", "C", "CA", "CB", "CG2", "N", };
427
+ static double protor_THR_atom_radius[] = {1.46, 1.42, 1.46, 1.61, 1.88, 1.88, 1.88, 1.64, };
428
+ static int protor_THR_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, };
429
+ static struct classifier_residue protor_THR_cfg = {
430
+ 8,
431
+ "THR",
432
+ (char**) protor_THR_atom_name,
433
+ (double*) protor_THR_atom_radius,
434
+ (freesasa_atom_class*) protor_THR_atom_class,
435
+ {"THR", 140.60, 41.96, 98.64, 66.15, 74.45, 0},
436
+ };
437
+
438
+ static const char *protor_TRP_atom_name[] = {"CD1", "CA", "CB", "C", "CG", "O", "OXT", "CZ2", "N", "CZ3", "CE2", "NE1", "CD2", "CE3", "CH2", };
439
+ static double protor_TRP_atom_radius[] = {1.76, 1.88, 1.88, 1.61, 1.61, 1.42, 1.46, 1.76, 1.64, 1.76, 1.61, 1.64, 1.61, 1.76, 1.76, };
440
+ static int protor_TRP_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
441
+ static struct classifier_residue protor_TRP_cfg = {
442
+ 15,
443
+ "TRP",
444
+ (char**) protor_TRP_atom_name,
445
+ (double*) protor_TRP_atom_radius,
446
+ (freesasa_atom_class*) protor_TRP_atom_class,
447
+ {"TRP", 249.19, 42.59, 206.60, 61.64, 187.55, 0},
448
+ };
449
+
450
+ static const char *protor_TYR_atom_name[] = {"CD2", "OH", "CE2", "N", "CE1", "OXT", "CZ", "CG", "O", "CD1", "C", "CA", "CB", };
451
+ static double protor_TYR_atom_radius[] = {1.76, 1.46, 1.76, 1.64, 1.76, 1.46, 1.61, 1.61, 1.42, 1.76, 1.61, 1.88, 1.88, };
452
+ static int protor_TYR_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
453
+ static struct classifier_residue protor_TYR_cfg = {
454
+ 13,
455
+ "TYR",
456
+ (char**) protor_TYR_atom_name,
457
+ (double*) protor_TYR_atom_radius,
458
+ (freesasa_atom_class*) protor_TYR_atom_class,
459
+ {"TYR", 214.19, 38.43, 175.76, 81.12, 133.07, 0},
460
+ };
461
+
462
+ static const char *protor_U_atom_name[] = {"O4", "C3'", "O4'", "C4'", "P", "OP3", "O2", "C2", "N3", "N1", "C1'", "C5'", "OP2", "O5'", "OP1", "C2'", "O2'", "C6", "O3'", "C4", "C5", };
463
+ static double protor_U_atom_radius[] = {1.42, 1.88, 1.46, 1.88, 1.8, 1.46, 1.42, 1.61, 1.64, 1.64, 1.88, 1.88, 1.46, 1.46, 1.42, 1.88, 1.46, 1.76, 1.46, 1.61, 1.76, };
464
+ static int protor_U_atom_class[] = {FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, };
465
+ static struct classifier_residue protor_U_cfg = {
466
+ 21,
467
+ "U",
468
+ (char**) protor_U_atom_name,
469
+ (double*) protor_U_atom_radius,
470
+ (freesasa_atom_class*) protor_U_atom_class,
471
+ {NULL, 0, 0, 0, 0, 0},
472
+ };
473
+
474
+ static const char *protor_VAL_atom_name[] = {"CG2", "CB", "CA", "CG1", "C", "O", "OXT", "N", };
475
+ static double protor_VAL_atom_radius[] = {1.88, 1.88, 1.88, 1.88, 1.61, 1.42, 1.46, 1.64, };
476
+ static int protor_VAL_atom_class[] = {FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_APOLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, FREESASA_ATOM_POLAR, };
477
+ static struct classifier_residue protor_VAL_cfg = {
478
+ 8,
479
+ "VAL",
480
+ (char**) protor_VAL_atom_name,
481
+ (double*) protor_VAL_atom_radius,
482
+ (freesasa_atom_class*) protor_VAL_atom_class,
483
+ {"VAL", 151.97, 41.50, 110.46, 36.87, 115.09, 0},
484
+ };
485
+
486
+ static struct classifier_residue *protor_residue_cfg[] = {
487
+ &protor_A_cfg, &protor_ACE_cfg, &protor_ALA_cfg, &protor_ARG_cfg, &protor_ASN_cfg, &protor_ASP_cfg, &protor_ASX_cfg, &protor_C_cfg, &protor_CYS_cfg, &protor_DA_cfg, &protor_DC_cfg, &protor_DG_cfg, &protor_DI_cfg, &protor_DT_cfg, &protor_DU_cfg, &protor_G_cfg, &protor_GLN_cfg, &protor_GLU_cfg, &protor_GLX_cfg, &protor_GLY_cfg, &protor_HIS_cfg, &protor_HOH_cfg, &protor_I_cfg, &protor_ILE_cfg, &protor_LEU_cfg, &protor_LYS_cfg, &protor_MET_cfg, &protor_MSE_cfg, &protor_NH2_cfg, &protor_PHE_cfg, &protor_PRO_cfg, &protor_PYL_cfg, &protor_SEC_cfg, &protor_SER_cfg, &protor_T_cfg, &protor_THR_cfg, &protor_TRP_cfg, &protor_TYR_cfg, &protor_U_cfg, &protor_VAL_cfg, };
488
+
489
+ const freesasa_classifier freesasa_protor_classifier = {
490
+ 40, (char**) protor_residue_name,
491
+ "ProtOr",
492
+ (struct classifier_residue **) protor_residue_cfg,
493
+ };
494
+
.venv_haddock/include/site/python3.12/freesasa/coord.c ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+ #include <assert.h>
5
+ #include <math.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+
9
+ #include "coord.h"
10
+ #include "freesasa_internal.h"
11
+
12
+ coord_t *
13
+ freesasa_coord_new()
14
+ {
15
+ coord_t *c = malloc(sizeof(coord_t));
16
+ if (c != NULL) {
17
+ c->xyz = NULL;
18
+ c->n = 0;
19
+ c->is_linked = 0;
20
+ } else {
21
+ mem_fail();
22
+ }
23
+ return c;
24
+ }
25
+
26
+ void freesasa_coord_free(coord_t *c)
27
+ {
28
+ if (c) {
29
+ if (c->xyz && !c->is_linked) free(c->xyz);
30
+ free(c);
31
+ }
32
+ }
33
+ static void
34
+ coord_clear(coord_t *c)
35
+ {
36
+ assert(c);
37
+ assert(!c->is_linked);
38
+ if (c->xyz) {
39
+ free(c->xyz);
40
+ c->xyz = NULL;
41
+ }
42
+ c->n = 0;
43
+ }
44
+
45
+ coord_t *
46
+ freesasa_coord_clone(const coord_t *src)
47
+ {
48
+ coord_t *c = freesasa_coord_new();
49
+
50
+ assert(src);
51
+
52
+ if (c == NULL) {
53
+ mem_fail();
54
+ return NULL;
55
+ }
56
+
57
+ if (freesasa_coord_set_all(c, src->xyz, src->n) != FREESASA_SUCCESS) {
58
+ fail_msg("");
59
+ return NULL;
60
+ }
61
+
62
+ return c;
63
+ }
64
+
65
+ int freesasa_coord_copy(coord_t *target, const coord_t *src)
66
+ {
67
+ if (src->n != target->n) return FREESASA_FAIL;
68
+ memcpy(target->xyz, src->xyz, sizeof(double) * src->n * 3);
69
+ return FREESASA_SUCCESS;
70
+ }
71
+
72
+ coord_t *
73
+ freesasa_coord_new_linked(const double *xyz,
74
+ int n)
75
+ {
76
+ coord_t *c = freesasa_coord_new();
77
+
78
+ assert(xyz);
79
+ assert(n > 0);
80
+
81
+ if (c != NULL) {
82
+ c->xyz = (double *)xyz;
83
+ c->n = n;
84
+ c->is_linked = 1;
85
+ } else
86
+ mem_fail();
87
+ return c;
88
+ }
89
+
90
+ int freesasa_coord_append(coord_t *c,
91
+ const double *xyz,
92
+ int n)
93
+ {
94
+ int n_old;
95
+ double *xyz_old;
96
+
97
+ assert(c);
98
+ assert(xyz);
99
+ assert(!c->is_linked);
100
+
101
+ n_old = c->n;
102
+ xyz_old = c->xyz;
103
+
104
+ if (n == 0) return FREESASA_SUCCESS;
105
+
106
+ c->xyz = (double *)realloc(c->xyz, sizeof(double) * 3 * (c->n + n));
107
+ if (c->xyz == NULL) {
108
+ free(xyz_old);
109
+ return mem_fail();
110
+ }
111
+ c->n += n;
112
+
113
+ memcpy(&(c->xyz[3 * n_old]), xyz, sizeof(double) * n * 3);
114
+ return FREESASA_SUCCESS;
115
+ }
116
+
117
+ int freesasa_coord_append_xyz(coord_t *c,
118
+ const double *x,
119
+ const double *y,
120
+ const double *z, int n)
121
+ {
122
+ double *xyz;
123
+ int i;
124
+
125
+ assert(c);
126
+ assert(x);
127
+ assert(y);
128
+ assert(z);
129
+ assert(!c->is_linked);
130
+
131
+ if (n == 0) return FREESASA_SUCCESS;
132
+
133
+ xyz = malloc(sizeof(double) * n * 3);
134
+ if (xyz == NULL) return mem_fail();
135
+
136
+ for (i = 0; i < n; ++i) {
137
+ xyz[i * 3] = x[i];
138
+ xyz[i * 3 + 1] = y[i];
139
+ xyz[i * 3 + 2] = z[i];
140
+ }
141
+ if (freesasa_coord_append(c, xyz, n) == FREESASA_SUCCESS) {
142
+ free(xyz);
143
+ return FREESASA_SUCCESS;
144
+ }
145
+ return mem_fail();
146
+ }
147
+
148
+ void freesasa_coord_set_i(coord_t *c,
149
+ int i,
150
+ const double *xyz)
151
+ {
152
+ assert(c);
153
+ assert(xyz);
154
+ assert(i < c->n && i >= 0);
155
+ assert(!c->is_linked);
156
+
157
+ memcpy(&c->xyz[i * 3], xyz, 3 * sizeof(double));
158
+ }
159
+
160
+ void freesasa_coord_set_i_xyz(coord_t *c,
161
+ int i,
162
+ double x,
163
+ double y,
164
+ double z)
165
+ {
166
+ double *v_i;
167
+
168
+ assert(c);
169
+ assert(c->n > i);
170
+ assert(i >= 0);
171
+ assert(!c->is_linked);
172
+
173
+ v_i = &c->xyz[i * 3];
174
+
175
+ *(v_i++) = x;
176
+ *(v_i++) = y;
177
+ *v_i = z;
178
+ }
179
+
180
+ int freesasa_coord_set_all(coord_t *c,
181
+ const double *xyz,
182
+ int n)
183
+ {
184
+ int result;
185
+
186
+ assert(c);
187
+ assert(xyz);
188
+
189
+ coord_clear(c);
190
+ result = freesasa_coord_append(c, xyz, n);
191
+
192
+ if (result != FREESASA_SUCCESS) {
193
+ fail_msg("");
194
+ }
195
+
196
+ return result;
197
+ }
198
+
199
+ int freesasa_coord_set_all_xyz(coord_t *c,
200
+ const double *x,
201
+ const double *y,
202
+ const double *z,
203
+ int n)
204
+ {
205
+ assert(c);
206
+ assert(x);
207
+ assert(y);
208
+ assert(z);
209
+ coord_clear(c);
210
+ return freesasa_coord_append_xyz(c, x, y, z, n);
211
+ }
212
+
213
+ void freesasa_coord_set_length_i(coord_t *c,
214
+ int i,
215
+ double l)
216
+ {
217
+ double x, y, z, r;
218
+
219
+ assert(c);
220
+ assert(c->xyz);
221
+ assert(!c->is_linked);
222
+ assert(i >= 0 && i < c->n);
223
+ assert(l >= 0);
224
+
225
+ x = c->xyz[3 * i];
226
+ y = c->xyz[3 * i + 1];
227
+ z = c->xyz[3 * i + 2];
228
+ r = sqrt(x * x + y * y + z * z);
229
+ c->xyz[3 * i] *= l / r;
230
+ c->xyz[3 * i + 1] *= l / r;
231
+ c->xyz[3 * i + 2] *= l / r;
232
+ }
233
+
234
+ void freesasa_coord_set_length_all(coord_t *c,
235
+ double l)
236
+ {
237
+ int i;
238
+
239
+ assert(c);
240
+ assert(!c->is_linked);
241
+
242
+ for (i = 0; i < c->n; ++i)
243
+ freesasa_coord_set_length_i(c, i, l);
244
+ }
245
+
246
+ const double *
247
+ freesasa_coord_i(const coord_t *c,
248
+ int i)
249
+ {
250
+ assert(c);
251
+ assert(i < c->n);
252
+ assert(i >= 0);
253
+ return &c->xyz[3 * i];
254
+ }
255
+
256
+ double
257
+ freesasa_coord_dist(const coord_t *c,
258
+ int i,
259
+ int j)
260
+ {
261
+ return sqrt(freesasa_coord_dist2(c, i, j));
262
+ }
263
+
264
+ static inline double
265
+ dist2(const double *v1,
266
+ const double *v2)
267
+ {
268
+ double dx = v1[0] - v2[0], dy = v1[1] - v2[1], dz = v1[2] - v2[2];
269
+ return dx * dx + dy * dy + dz * dz;
270
+ }
271
+
272
+ double
273
+ freesasa_coord_dist2(const coord_t *c,
274
+ int i,
275
+ int j)
276
+ {
277
+ double *v1 = &c->xyz[3 * i];
278
+ double *v2 = &c->xyz[3 * j];
279
+ return dist2(v1, v2);
280
+ }
281
+
282
+ double
283
+ freesasa_coord_dist2_12(const coord_t *c1,
284
+ const coord_t *c2,
285
+ int i1,
286
+ int i2)
287
+ {
288
+ double *v1 = &c1->xyz[3 * i1];
289
+ double *v2 = &c2->xyz[3 * i2];
290
+ return dist2(v1, v2);
291
+ }
292
+
293
+ const double *
294
+ freesasa_coord_all(const coord_t *c)
295
+ {
296
+ assert(c);
297
+ return c->xyz;
298
+ }
299
+
300
+ int freesasa_coord_n(const coord_t *c)
301
+ {
302
+ assert(c);
303
+ return c->n;
304
+ }
305
+
306
+ void freesasa_coord_translate(coord_t *c,
307
+ const double *xyz)
308
+ {
309
+ assert(!c->is_linked);
310
+ assert(xyz);
311
+ freesasa_coord_translate_xyz(c, xyz[0], xyz[1], xyz[2]);
312
+ }
313
+
314
+ void freesasa_coord_translate_xyz(coord_t *c,
315
+ double x,
316
+ double y,
317
+ double z)
318
+ {
319
+ int i;
320
+
321
+ assert(c);
322
+ assert(!c->is_linked);
323
+
324
+ for (i = 0; i < c->n; ++i) {
325
+ c->xyz[3 * i] += x;
326
+ c->xyz[3 * i + 1] += y;
327
+ c->xyz[3 * i + 2] += z;
328
+ }
329
+ }
330
+
331
+ void freesasa_coord_scale(coord_t *c,
332
+ double s)
333
+ {
334
+ int i;
335
+
336
+ assert(c);
337
+ assert(!c->is_linked);
338
+
339
+ for (i = 0; i < c->n * 3; ++i) {
340
+ c->xyz[i] *= s;
341
+ }
342
+ }
.venv_haddock/include/site/python3.12/freesasa/coord.h ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREESASA_COORD_H
2
+ #define FREESASA_COORD_H
3
+
4
+ #ifdef __GNUC__
5
+ #define __attrib_pure__ __attribute__((pure))
6
+ #else
7
+ #define __attrib_pure__
8
+ #endif
9
+
10
+ /**
11
+ @file
12
+ @author Simon Mitternacht
13
+
14
+ This is only for interal use, error handling is done by asserts.
15
+ The header provides functions to store, copy and modify
16
+ coordinates through the type ::coord_t.
17
+
18
+ The distance calculation functions (freesasa_dist(),
19
+ freesasa_dist2() and freesasa_dist2_12()) are useful for code that
20
+ is not performance critical. When efficieny is a priority it is
21
+ better to use freesasa_coord_all() to obtain a pointer to the
22
+ array of coordinates and calculate directly using this..
23
+ */
24
+
25
+ /** Store a set of 3-dimensional coordinates in a contiguous array */
26
+ typedef struct coord_t {
27
+ /** number of 3-vectors */
28
+ int n;
29
+
30
+ /** If these coordinates are only a link to an externally stored
31
+ array this is 1, else 0. If it it is set, the coordinates can
32
+ not be changed and the array not freed. */
33
+ int is_linked;
34
+
35
+ /** array of all coordinates, dimension 3*n,
36
+ x_1,y_1,z_1,...,x_n,y_n,z_n. */
37
+ double *xyz;
38
+ } coord_t;
39
+
40
+ /**
41
+ Initialize new ::coord_t object.
42
+
43
+ Return value is dynamically allocated, should be freed with
44
+ freesasa_coord_free().
45
+
46
+ @return An empty ::coord_t object. Returns NULL if out of
47
+ memory.
48
+ */
49
+ coord_t *
50
+ freesasa_coord_new(void);
51
+
52
+ /**
53
+ Free resources allocated by ::coord_t object.
54
+
55
+ Will not free the coordinate array itself if it was initialized by
56
+ freesasa_coord_new_linked().
57
+ */
58
+ void freesasa_coord_free(coord_t *coord);
59
+
60
+ /**
61
+ Clone coordinates.
62
+
63
+ Creates a new ::coord_t object that is a copy of the
64
+ argument `src`.
65
+
66
+ Return value is dynamically allocated, should be freed with
67
+ freesasa_coord_free().
68
+
69
+ @param src Coordinates to be copied.
70
+ @return Copy of coordinates. NULL if out of memory.
71
+ */
72
+ coord_t *
73
+ freesasa_coord_clone(const coord_t *src);
74
+
75
+ /**
76
+ Copy coordinates
77
+
78
+ Copies value of source coordinates to target.
79
+
80
+ @param target Target coordinates
81
+ @param src Source coordinates
82
+ @return ::FREESASA_FAIL if size mismatch between src and target,
83
+ else ::FREESASA_SUCCESS
84
+ */
85
+ int freesasa_coord_copy(coord_t *target, const coord_t *src);
86
+
87
+ /**
88
+ Creates a `const` ::coord_t-object that is linked to an array of
89
+ coordinates owned by callee.
90
+
91
+ This allows repeated calculations on a changing object without
92
+ reinitialization. The returned ::coord_t-pointer is not
93
+ explicitly const, to allow it to be freed later, but objects
94
+ initiated through this interface will not change their
95
+ coordinates. It also allows ::coord_t to be used as a wrapper
96
+ for an array controlled by the caller.
97
+
98
+ Return value is dynamically allocated, should be freed with
99
+ freesasa_coord_free().
100
+
101
+ @param xyz Array of coordinates x1,y1,z1,x2,y2,z2,...
102
+ @param n Number of coordinates (array has size 3*n).
103
+ @return New linked ::coord_t object. NULL if out of memory.
104
+ */
105
+ coord_t *
106
+ freesasa_coord_new_linked(const double *xyz,
107
+ int n);
108
+
109
+ /**
110
+ Append coordinates to ::coord_t object from one array.
111
+
112
+ @param coord A ::coord_t object
113
+ @param xyz Array of coordinates x1,y1,z1,x2,y2,z2,...
114
+ @param n Number of coordinates (array has size 3*n).
115
+ @return FREESASA_SUCCESS if successful, FREESASA_FAIL if out of memory.
116
+ */
117
+ int freesasa_coord_append(coord_t *coord,
118
+ const double *xyz,
119
+ int n);
120
+
121
+ /**
122
+ Append coordinates to ::coord_t object from three
123
+ separate arrays.
124
+
125
+ @param coord A ::coord_t object
126
+ @param x Array of x-coordinates
127
+ @param y Array of x-coordinates
128
+ @param z Array of x-coordinates
129
+ @param n Size of arrays x, y and z.
130
+ @return FREESASA_SUCCESS if successful, FREESASA_FAIL if out of memory.
131
+ */
132
+ int freesasa_coord_append_xyz(coord_t *coord,
133
+ const double *x,
134
+ const double *y,
135
+ const double *z,
136
+ int n);
137
+
138
+ /**
139
+ Set given coordinate.
140
+
141
+ Bounds-checking of i is handled by asserts for efficiency,
142
+ i.e. only done in debug-mode.
143
+
144
+ @param coord A ::coord_t object
145
+ @param i Index
146
+ @param xyz Array with coordinates x,y,z.
147
+ */
148
+ void freesasa_coord_set_i(coord_t *coord,
149
+ int i,
150
+ const double *xyz);
151
+
152
+ /**
153
+ Set given coordinate.
154
+
155
+ Bounds-checking of i is handled by asserts for efficiency,
156
+ i.e. only done in debug-mode.
157
+
158
+ @param coord A ::coord_t object
159
+ @param i Index
160
+ @param x x-coordinate.
161
+ @param y y-coordinate.
162
+ @param z z-coordinate
163
+ */
164
+ void freesasa_coord_set_i_xyz(coord_t *coord,
165
+ int i,
166
+ double x,
167
+ double y,
168
+ double z);
169
+
170
+ /**
171
+ Reset everything.
172
+
173
+ Allocates memory to allow array of size n.
174
+
175
+ @param coord A ::coord_t object
176
+ @param xyz Array of coordinates x1,y1,z1,x2,y2,z2,...
177
+ @param n Number of coordinates (array has size 3*n).
178
+ @return FREESASA_SUCCESS if successful, FREESASA_FAIL if out of memory.
179
+ */
180
+ int freesasa_coord_set_all(coord_t *coord,
181
+ const double *xyz,
182
+ int n);
183
+
184
+ /**
185
+ Reset everything.
186
+
187
+ Allocates memory to allow array of size n.
188
+
189
+ @param coord A ::coord_t object
190
+ @param x Array of x-coordinates
191
+ @param y Array of x-coordinates
192
+ @param z Array of x-coordinates
193
+ @param n Size of arrays x, y and z.
194
+ @return FREESASA_SUCCESS if successful, FREESASA_FAIL if out of memory.
195
+ */
196
+ int freesasa_coord_set_all_xyz(coord_t *coord,
197
+ const double *x,
198
+ const double *y,
199
+ const double *z,
200
+ int n);
201
+
202
+ /**
203
+ Set length of a given coordinate vector. Useful for test-points in
204
+ S&R.
205
+
206
+ Bounds-checking of `i` and `length` is handled by asserts for
207
+ efficiency, i.e. only done in debug-mode.
208
+
209
+ @param coord A ::coord_t object
210
+ @param i Index
211
+ @param length Desired length (>= 0)
212
+ */
213
+ void freesasa_coord_set_length_i(coord_t *coord,
214
+ int i,
215
+ double length);
216
+
217
+ /**
218
+ Set length of all coordinate vectors to the same length.
219
+
220
+ This means all coordinates are on the same sphere.
221
+
222
+ Bounds-checking of length is handled by asserts for
223
+ efficiency, i.e. only done in debug-mode.
224
+
225
+ @param coord A ::coord_t object
226
+ @param length Desired length (>= 0)
227
+ */
228
+ void freesasa_coord_set_length_all(coord_t *coord,
229
+ double length);
230
+
231
+ /**
232
+ Coordinates for a given index.
233
+
234
+ Bounds-checking of `i` is handled by asserts for efficiency,
235
+ i.e. only done in debug-mode.
236
+
237
+ @param coord A ::coord_t object
238
+ @param i Index
239
+ @return Array with coordinates x,y,z
240
+ */
241
+ const double *
242
+ freesasa_coord_i(const coord_t *coord,
243
+ int i);
244
+
245
+ /**
246
+ Calculate distance between two coordinate vectors. For speed,
247
+ arguments aren't checked.
248
+
249
+ @param coord A ::coord_t object
250
+ @param i first index
251
+ @param j second index
252
+ @return Distance between coorsinate i and j.
253
+ */
254
+ double freesasa_coord_dist(const coord_t *coord,
255
+ int i,
256
+ int j)
257
+ __attrib_pure__;
258
+
259
+ /**
260
+ Calculate square distance between two coordinate vectors. For
261
+ speed, arguments aren't checked.
262
+
263
+ @param coord A ::coord_t object
264
+ @param i First index
265
+ @param j Second index
266
+ @return Square distance between coordinate i and j
267
+ */
268
+ double
269
+ freesasa_coord_dist2(const coord_t *coord,
270
+ int i,
271
+ int j)
272
+ __attrib_pure__;
273
+
274
+ /**
275
+ Calculate square distance between two coordinate vectors in
276
+ separate coordinate sets. For speed, arguments aren't checked.
277
+
278
+ @param c1 First set of coordinates
279
+ @param c2 Second set of coordinates
280
+ @param i1 Index in first set
281
+ @param i2 Index in second set
282
+ @return Square distance between coordinates i1 and i2
283
+ */
284
+ double freesasa_coord_dist2_12(const coord_t *c1,
285
+ const coord_t *c2,
286
+ int i1,
287
+ int i2)
288
+ __attrib_pure__;
289
+
290
+ /**
291
+ All coordinates as an array.
292
+
293
+ @param coord A ::coord_t object
294
+ @return Array of coordinates x1,y1,z1,x2,y2,z2,...
295
+ */
296
+ const double *
297
+ freesasa_coord_all(const coord_t *coord) __attrib_pure__;
298
+
299
+ /**
300
+ Number of coordinates.
301
+
302
+ @param coord A ::coord_t object
303
+ @return Number of coordinates
304
+ */
305
+ int freesasa_coord_n(const coord_t *coord) __attrib_pure__;
306
+
307
+ /**
308
+ Translate all coordinates by same vector.
309
+
310
+ @param coord A ::coord_t object
311
+ @param xyz Array describing translation vector x,y,z.
312
+ */
313
+ void freesasa_coord_translate(coord_t *coord,
314
+ const double *xyz);
315
+
316
+ /**
317
+ Translate all coordinates by same vector.
318
+
319
+ @param coord A ::coord_t object
320
+ @param x x-coordinate of translation vector
321
+ @param y y-coordinate of translation vector
322
+ @param z z-coordinate of translation vector
323
+ */
324
+ void freesasa_coord_translate_xyz(coord_t *coord,
325
+ double x,
326
+ double y,
327
+ double z);
328
+
329
+ /**
330
+ Scale all coordinates by given factor.
331
+
332
+ @param coord A ::coord_t object
333
+ @param a Factor to scale by
334
+ */
335
+ void freesasa_coord_scale(coord_t *coord,
336
+ double a);
337
+
338
+ #undef __attrib_pure__
339
+
340
+ #endif
.venv_haddock/include/site/python3.12/freesasa/freesasa.c ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * This source file contains everything that is in freesasa.h
3
+ * interface and does not have a natural home in any of the other
4
+ * source files.
5
+ */
6
+
7
+ #if HAVE_CONFIG_H
8
+ #include <config.h>
9
+ #endif
10
+ #include <assert.h>
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+
14
+ #include "freesasa_internal.h"
15
+
16
+ #ifdef PACKAGE_VERSION
17
+ const char *freesasa_version = PACKAGE_VERSION;
18
+ #else
19
+ const char *freesasa_version = "";
20
+ #endif
21
+
22
+ #ifdef PACKAGE_STRING
23
+ const char *freesasa_string = PACKAGE_STRING;
24
+ #else
25
+ const char *freesasa_string = "FreeSASA";
26
+ #endif
27
+
28
+ /* Allows compilation with different defaults
29
+ depending on USE_THREADS. but still exposing the value in a header
30
+ that doesn't depend on USE_THREADS */
31
+ #if USE_THREADS
32
+ #define DEF_NUMBER_THREADS 2
33
+ #else
34
+ #define DEF_NUMBER_THREADS 1
35
+ #endif
36
+ const int FREESASA_DEF_NUMBER_THREADS = DEF_NUMBER_THREADS;
37
+
38
+ const freesasa_parameters freesasa_default_parameters = {
39
+ FREESASA_DEF_ALGORITHM,
40
+ FREESASA_DEF_PROBE_RADIUS,
41
+ FREESASA_DEF_SR_N,
42
+ FREESASA_DEF_LR_N,
43
+ DEF_NUMBER_THREADS};
44
+
45
+ static freesasa_result *
46
+ result_new(int n)
47
+ {
48
+ freesasa_result *result = malloc(sizeof(freesasa_result));
49
+
50
+ if (result == NULL) {
51
+ mem_fail();
52
+ return NULL;
53
+ }
54
+
55
+ result->sasa = malloc(sizeof(double) * n);
56
+
57
+ if (result->sasa == NULL) {
58
+ mem_fail();
59
+ freesasa_result_free(result);
60
+ return NULL;
61
+ }
62
+
63
+ result->n_atoms = n;
64
+
65
+ return result;
66
+ }
67
+
68
+ void freesasa_result_free(freesasa_result *r)
69
+ {
70
+ if (r) {
71
+ free(r->sasa);
72
+ free(r);
73
+ }
74
+ }
75
+
76
+ freesasa_result *
77
+ freesasa_calc(const coord_t *c,
78
+ const double *radii,
79
+ const freesasa_parameters *parameters)
80
+
81
+ {
82
+ freesasa_result *result;
83
+ int ret = FREESASA_SUCCESS, i;
84
+
85
+ assert(c);
86
+ assert(radii);
87
+
88
+ result = result_new(freesasa_coord_n(c));
89
+
90
+ if (result == NULL) {
91
+ fail_msg("");
92
+ return NULL;
93
+ }
94
+
95
+ if (parameters == NULL) parameters = &freesasa_default_parameters;
96
+
97
+ switch (parameters->alg) {
98
+ case FREESASA_SHRAKE_RUPLEY:
99
+ ret = freesasa_shrake_rupley(result->sasa, c, radii, parameters);
100
+ break;
101
+ case FREESASA_LEE_RICHARDS:
102
+ ret = freesasa_lee_richards(result->sasa, c, radii, parameters);
103
+ break;
104
+ default:
105
+ assert(0); /* should never get here */
106
+ break;
107
+ }
108
+ if (ret == FREESASA_FAIL) {
109
+ freesasa_result_free(result);
110
+ return NULL;
111
+ }
112
+
113
+ result->total = 0;
114
+ for (i = 0; i < freesasa_coord_n(c); ++i) {
115
+ result->total += result->sasa[i];
116
+ }
117
+ result->parameters = *parameters;
118
+
119
+ return result;
120
+ }
121
+
122
+ freesasa_result *
123
+ freesasa_calc_coord(const double *xyz,
124
+ const double *radii,
125
+ int n,
126
+ const freesasa_parameters *parameters)
127
+ {
128
+ coord_t *coord = NULL;
129
+ freesasa_result *result = NULL;
130
+
131
+ assert(xyz);
132
+ assert(radii);
133
+ assert(n > 0);
134
+
135
+ coord = freesasa_coord_new_linked(xyz, n);
136
+ if (coord != NULL) result = freesasa_calc(coord, radii, parameters);
137
+ if (result == NULL) fail_msg("");
138
+
139
+ freesasa_coord_free(coord);
140
+
141
+ return result;
142
+ }
143
+
144
+ freesasa_result *
145
+ freesasa_calc_structure(const freesasa_structure *structure,
146
+ const freesasa_parameters *parameters)
147
+ {
148
+ assert(structure);
149
+
150
+ return freesasa_calc(freesasa_structure_xyz(structure),
151
+ freesasa_structure_radius(structure),
152
+ parameters);
153
+ }
154
+
155
+ freesasa_node *
156
+ freesasa_calc_tree(const freesasa_structure *structure,
157
+ const freesasa_parameters *parameters,
158
+ const char *name)
159
+ {
160
+ freesasa_node *tree = NULL;
161
+ freesasa_result *result;
162
+
163
+ assert(structure);
164
+
165
+ result = freesasa_calc(freesasa_structure_xyz(structure),
166
+ freesasa_structure_radius(structure),
167
+ parameters);
168
+
169
+ if (result != NULL) {
170
+ tree = freesasa_tree_init(result, structure, name);
171
+ } else {
172
+ fail_msg("");
173
+ }
174
+
175
+ if (tree == NULL) {
176
+ fail_msg("");
177
+ }
178
+
179
+ freesasa_result_free(result);
180
+
181
+ return tree;
182
+ }
183
+
184
+ static inline void
185
+ count_err(int return_value, int *n_err)
186
+ {
187
+ if (return_value == FREESASA_FAIL) {
188
+ (*n_err)++;
189
+ }
190
+ }
191
+
192
+ int freesasa_tree_export(FILE *file,
193
+ freesasa_node *root,
194
+ int options)
195
+ {
196
+ int n_err = 0;
197
+
198
+ assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
199
+
200
+ if (options & FREESASA_LOG) {
201
+ count_err(freesasa_write_log(file, root), &n_err);
202
+ }
203
+ if (options & FREESASA_RES) {
204
+ count_err(freesasa_write_res(file, root), &n_err);
205
+ }
206
+ if (options & FREESASA_SEQ) {
207
+ count_err(freesasa_write_seq(file, root), &n_err);
208
+ }
209
+ if (options & FREESASA_PDB) {
210
+ count_err(freesasa_write_pdb(file, root), &n_err);
211
+ }
212
+ if (options & FREESASA_RSA) {
213
+ count_err(freesasa_write_rsa(file, root, options), &n_err);
214
+ }
215
+ if (options & FREESASA_JSON) {
216
+ #if USE_JSON
217
+ count_err(freesasa_write_json(file, root, options), &n_err);
218
+ #else
219
+ return fail_msg("library was built without support for JSON output");
220
+ #endif
221
+ }
222
+ if (options & FREESASA_XML) {
223
+ #if USE_XML
224
+ count_err(freesasa_write_xml(file, root, options), &n_err);
225
+ #else
226
+ return fail_msg("library was built without support for XML output");
227
+ #endif
228
+ }
229
+ if (n_err > 0) {
230
+ return fail_msg("there were errors when writing output");
231
+ }
232
+ return FREESASA_SUCCESS;
233
+ }
234
+
235
+ freesasa_result *
236
+ freesasa_result_clone(const freesasa_result *result)
237
+ {
238
+ freesasa_result *clone = result_new(result->n_atoms);
239
+
240
+ if (clone == NULL) {
241
+ fail_msg("");
242
+ return NULL;
243
+ }
244
+
245
+ clone->n_atoms = result->n_atoms;
246
+ clone->total = result->total;
247
+ clone->parameters = result->parameters;
248
+ memcpy(clone->sasa, result->sasa, sizeof(double) * clone->n_atoms);
249
+
250
+ return clone;
251
+ }
252
+
253
+ const char *
254
+ freesasa_alg_name(freesasa_algorithm alg)
255
+ {
256
+ switch (alg) {
257
+ case FREESASA_SHRAKE_RUPLEY:
258
+ return "Shrake & Rupley";
259
+ case FREESASA_LEE_RICHARDS:
260
+ return "Lee & Richards";
261
+ default:
262
+ // This should never happen
263
+ assert(0 && "Illegal algorithm");
264
+ return "Unknown algorithm";
265
+ }
266
+ }
.venv_haddock/include/site/python3.12/freesasa/freesasa_internal.h ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREESASA_INTERNAL_H
2
+ #define FREESASA_INTERNAL_H
3
+
4
+ #ifdef _MSC_VER
5
+ #define _CRT_SECURE_NO_WARNINGS
6
+ #endif
7
+
8
+ /* These are included here so that the _CRT_SECURE_.. macro above will have the desired effect */
9
+ #include <stdio.h>
10
+ #include <string.h>
11
+
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
15
+
16
+ #include "coord.h"
17
+ #include "freesasa.h"
18
+
19
+ /** The name of the library, to be used in error messages and logging */
20
+ extern const char *freesasa_name;
21
+
22
+ /** The name of the package, to be used in regular output (includes version) */
23
+ extern const char *freesasa_string;
24
+
25
+ /** A ::freesasa_nodearea with `name == NULL` and all values 0 */
26
+ extern const freesasa_nodearea freesasa_nodearea_null;
27
+
28
+ /** Shortcut for memory error generation */
29
+ #define mem_fail() freesasa_mem_fail(__FILE__, __LINE__)
30
+
31
+ /** Shortcut for error message with position information, should be used by default */
32
+ #define fail_msg(...) freesasa_fail_wloc(__FILE__, __LINE__, __VA_ARGS__)
33
+
34
+ #ifdef _MSC_VER
35
+ #define inline __inline
36
+ #define strdup _strdup
37
+ #define fmax(a, b) (((a) > (b)) ? (a) : (b))
38
+ #define fmin(a, b) (((a) < (b)) ? (a) : (b))
39
+ #include <float.h>
40
+ #define isfinite _finite
41
+ #endif
42
+
43
+ #if defined(_MSC_VER) && !defined(__func__)
44
+ #define __func__ __FUNCTION__
45
+ #endif
46
+
47
+ #if defined(_MSC_VER) && _MSC_VER >= 1400
48
+ #define restrict __restrict
49
+ #endif
50
+ #if defined(_MSC_VER) && _MSC_VER < 1400
51
+ #define restrict
52
+ #endif
53
+
54
+ /* The library is intended to be compiled with C99, but this macro
55
+ allows us to compile it with C89 too, to test MSC compatibility */
56
+ #ifdef __STRICT_ANSI__
57
+ #define restrict
58
+ #define inline
59
+ #endif
60
+
61
+ /**
62
+ Calculate SASA using S&R algorithm.
63
+
64
+ @param sasa The results are written to this array, the user has to
65
+ make sure it is large enough.
66
+ @param c Coordinates of the object to calculate SASA for.
67
+ @param radii Array of radii for each sphere.
68
+ @param param Parameters specifying resolution, probe radius and
69
+ number of threads. If NULL :.freesasa_default_parameters is used.
70
+ @return ::FREESASA_SUCCESS on success, ::FREESASA_WARN if multiple
71
+ threads are requested when compiled in single-threaded mode (with
72
+ error message). ::FREESASA_FAIL if memory allocation failure.
73
+ */
74
+ int freesasa_shrake_rupley(double *sasa,
75
+ const coord_t *c,
76
+ const double *radii,
77
+ const freesasa_parameters *param);
78
+
79
+ /**
80
+ Calculate SASA using L&R algorithm.
81
+
82
+ Solvent accessible surface area for each atom is written to the
83
+ array 'sasa'. The user is responsible for making sure this has the
84
+ right size. The argument grid sets the distance between grid
85
+ points in Å. Returns FREESASA_SUCCESS on success, FREESASA_WARN if
86
+ multiple threads are requested when compiled in single-threaded
87
+ mode (with error message).
88
+
89
+ @param sasa The results are written to this array, the user has to
90
+ make sure it is large enough.
91
+ @param c Coordinates of the object to calculate SASA for.
92
+ @param radii Array of radii for each sphere.
93
+ @param param Parameters specifying resolution, probe radius and
94
+ number of threads. If NULL :.freesasa_default_parameters is used.
95
+ @return ::FREESASA_SUCCESS on success, ::FREESASA_WARN if
96
+ multiple threads are requested when compiled in single-threaded
97
+ mode (with error message). ::FREESASA_FAIL if memory allocation
98
+ failure.
99
+ */
100
+ int freesasa_lee_richards(double *sasa,
101
+ const coord_t *c,
102
+ const double *radii,
103
+ const freesasa_parameters *param);
104
+
105
+ /**
106
+ Calculate SASA based on a coordinate object, radii and parameters
107
+
108
+ Wrapper for freesasa_lee_richards() and freesasa_shrake_rupley()
109
+ that creates a result object.
110
+
111
+ Return value is dynamically allocated, should be freed with
112
+ freesasa_result_free().
113
+
114
+ @param c Coordinates
115
+ @param radii Atomi radii
116
+ @param parameters Parameters
117
+ @return Result of calculation, NULL if something went wrong.
118
+ */
119
+ freesasa_result *
120
+ freesasa_calc(const coord_t *c,
121
+ const double *radii,
122
+ const freesasa_parameters *parameters);
123
+
124
+ int freesasa_write_log(FILE *log,
125
+ freesasa_node *root);
126
+
127
+ /**
128
+ Print RSA-file
129
+
130
+ @param output Output-file.
131
+ @param root A tree with stored results.
132
+ @param options Bitfield with option ::FREESASA_OUTPUT_SKIP_REL to specify
133
+ if REL column should be populated or not. If the classifier has no
134
+ reference values, it will be left empty either way.
135
+ @return ::FREESASA_SUCCESS on success, ::FREESASA_FAIL if problems
136
+ writing to file.
137
+ */
138
+ int freesasa_write_rsa(FILE *output,
139
+ freesasa_node *root,
140
+ int options);
141
+
142
+ /**
143
+ Export to JSON
144
+
145
+ Not thread-safe.
146
+
147
+ @param output Output-file.
148
+ @param root A tree with stored results.
149
+ @param parameters Parameters used in the calculation (NULL means
150
+ defaults are assumed).
151
+ @param options Bitfield with options ::FREESASA_OUTPUT_STRUCTURE,
152
+ ::FREESASA_OUTPUT_CHAIN and ::FREESASA_OUTPUT_RESIDUE, that specify
153
+ depth of the tree to output. If `options == 0` all levels are
154
+ written. The options ::FREESASA_OUTPUT_SKIP_REL specifies
155
+ if REL column should be populated or not. If the classifier has no
156
+ reference values, it will be left empty either way.
157
+ @return ::FREESASA_SUCCESS on success, ::FREESASA_FAIL if problems
158
+ writing to file.
159
+ */
160
+ int freesasa_write_json(FILE *ouput,
161
+ freesasa_node *root,
162
+ int options);
163
+ /**
164
+ Export to XML
165
+
166
+ @param output Output-file.
167
+ @param root A tree with stored results.
168
+ @param parameters Parameters used in the calculation (NULL means
169
+ defaults are assumed).
170
+ @param options Bitfield with options ::FREESASA_OUTPUT_STRUCTURE,
171
+ ::FREESASA_OUTPUT_CHAIN and ::FREESASA_OUTPUT_RESIDUE, that specify
172
+ depth of the tree to output. If `options == 0` all levels
173
+ written. The options ::FREESASA_OUTPUT_SKIP_REL specifies
174
+ if REL column should be populated or not. If the classifier has no
175
+ reference values, it will be left empty either way.
176
+ @return ::FREESASA_SUCCESS on success, ::FREESASA_FAIL if problems
177
+ writing to file.
178
+ */
179
+ int freesasa_write_xml(FILE *ouput,
180
+ freesasa_node *root,
181
+ int options);
182
+
183
+ /**
184
+ Write SASA values and atomic radii to new PDB-file.
185
+
186
+ Takes PDB information from the provided structure and writes a new
187
+ PDB-file to output, where the B-factors have been replaced with
188
+ the atom's SASA values in the results, and the occupancy
189
+ factors with the radii.
190
+
191
+ Will only work if the structure was initialized from a PDB-file, i.e.
192
+ using freesasa_structure_from_pdb() or freesasa_structure_array().
193
+
194
+ @param output Output-file
195
+ @param structure A ::freesasa_node of type ::FREESASA_NODE_STRUCTURE
196
+ @return ::FREESASA_SUCCESS if file written successfully.
197
+ ::FREESASA_FAIL if there is no previous PDB input to base output
198
+ on or if there were problems writing to the file.
199
+ */
200
+ int freesasa_write_pdb(FILE *output,
201
+ freesasa_node *structure);
202
+
203
+ /**
204
+ Write per-residue-type output
205
+ */
206
+ int freesasa_write_res(FILE *log,
207
+ freesasa_node *root);
208
+
209
+ /**
210
+ Write SASA per residue in sequence output
211
+ */
212
+ int freesasa_write_seq(FILE *log,
213
+ freesasa_node *root);
214
+
215
+ /**
216
+ Write standard log message.
217
+ */
218
+ int freesasa_write_log(FILE *log,
219
+ freesasa_node *root);
220
+
221
+ /**
222
+ Clone results object
223
+ */
224
+ freesasa_result *
225
+ freesasa_result_clone(const freesasa_result *result);
226
+
227
+ /**
228
+ Clone selection object
229
+ */
230
+ freesasa_selection *
231
+ freesasa_selection_clone(const freesasa_selection *selection);
232
+
233
+ /**
234
+ Get coordinates.
235
+
236
+ @param structure A structure.
237
+ @return The coordinates of the structure as a ::coord_t struct.
238
+ */
239
+ const coord_t *
240
+ freesasa_structure_xyz(const freesasa_structure *structure);
241
+
242
+ /**
243
+ The class of an atom, in the classifier used to initialize the structure.
244
+
245
+ @param structure A structure.
246
+ @param i Atom index.
247
+ @return The class.
248
+ */
249
+ freesasa_atom_class
250
+ freesasa_structure_atom_class(const freesasa_structure *structure,
251
+ int i);
252
+
253
+ /**
254
+ The PDB line used to generate the atom.
255
+
256
+ @param structure A structure.
257
+ @param i Atom index.
258
+ @return The line, NULL if structure wasn't generated from a PDB file.
259
+ */
260
+ const char *
261
+ freesasa_structure_atom_pdb_line(const freesasa_structure *structure,
262
+ int i);
263
+
264
+ /**
265
+ Add a reference number to the document used to generate the structure from a CIF file,
266
+ used when exporting to CIF file.
267
+
268
+ @param structure A structure.
269
+ @param ref Reference number for document. >= 1.
270
+ @param release_func A function that can be called when freeing the structure, to trigger
271
+ the destructor for the CIF document. This can be NULL if one wants another mode
272
+ of control over the CIF document.
273
+ @return ::FREESASA_SUCCESS if success.
274
+ ::FREESASA_FAIL if memory allocation error.
275
+ */
276
+ void freesasa_structure_set_cif_ref(freesasa_structure *structure,
277
+ size_t ref,
278
+ void (*release_func)(size_t));
279
+
280
+ /**
281
+ Retrieve the reference number for the CIF document used to generate the structure
282
+ from a CIF file.
283
+
284
+ @param structure A structure.
285
+ @return The reference number. 0 if structure is not from CIF file.
286
+ */
287
+ size_t freesasa_structure_cif_ref(const freesasa_structure *structure);
288
+
289
+ /**
290
+ Retrieve the reference number for the CIF document used to generate the structure
291
+ from a CIF file, in a structure node.
292
+
293
+ @param node A node of type ::FREESASA_NODE_STRUCTURE.
294
+ @return Reference to CIF document.
295
+
296
+ @ingroup node
297
+ */
298
+ size_t
299
+ freesasa_node_structure_cif_ref(const freesasa_node *node);
300
+
301
+ const freesasa_nodearea *
302
+ freesasa_structure_residue_reference(const freesasa_structure *structure,
303
+ int r_i);
304
+ /**
305
+ Get the index of a chain.
306
+
307
+ @param structure A structure.
308
+ @param chain The chain label.
309
+ @return The index of `chain` in the structure. ::FREESASA_FAIL
310
+ if `chain` not found.
311
+ */
312
+ int freesasa_structure_chain_index(const freesasa_structure *structure,
313
+ char chain);
314
+
315
+ /**
316
+ Extract area to provided ::freesasa_nodearea object
317
+
318
+ Main-chain / side-chain atoms are defined by
319
+ ::freesasa_backbone_classifier.
320
+
321
+ @param area Area will be stored here
322
+ @param structure Structure to use for classification
323
+ @param result The areas to use
324
+ @param atom_index Index of atom in question
325
+ @return ::FREESASA_SUCCESS. ::FREESASA_FAIL if memory
326
+ allocation for name fails.
327
+ */
328
+ int freesasa_atom_nodearea(freesasa_nodearea *area,
329
+ const freesasa_structure *structure,
330
+ const freesasa_result *result,
331
+ int atom_index);
332
+
333
+ /**
334
+ Adds all members of term to corresponding members of sum
335
+
336
+ @param sum Object to add to
337
+ @param term Object to add
338
+ */
339
+ void freesasa_add_nodearea(freesasa_nodearea *sum,
340
+ const freesasa_nodearea *term);
341
+
342
+ /**
343
+ Compute nodearea for a range of atoms
344
+ */
345
+ void freesasa_range_nodearea(freesasa_nodearea *area,
346
+ const freesasa_structure *structure,
347
+ const freesasa_result *result,
348
+ int first_atom,
349
+ int last_atom);
350
+
351
+ /**
352
+ Calculate relative SASA values for a residue
353
+
354
+ If the array `ref_values` does not have an entry that has the same
355
+ `name` as `abs`, `rel->name` will be `NULL`.
356
+
357
+ @param rel Store results here, will have same name as `abs`
358
+ @param abs Absolute SASA for residue
359
+ @param reference Reference SASA for the residue
360
+ */
361
+ void freesasa_residue_rel_nodearea(freesasa_nodearea *rel,
362
+ const freesasa_nodearea *abs,
363
+ const freesasa_nodearea *reference);
364
+
365
+ /**
366
+ Is an atom a backbone atom
367
+
368
+ @param atom_name Name of atom
369
+ @return 1 if the atom_name equals CA, N, O or C after whitespace
370
+ is trimmed, 0 else. (i.e. does not check if it is an actual atom)
371
+ */
372
+ int freesasa_atom_is_backbone(const char *atom_name);
373
+
374
+ /**
375
+ Holds range in a file, to be initalized with ftell() and used
376
+ with fseek().
377
+ */
378
+ struct file_range {
379
+ long begin; /**< Position of beginning of range */
380
+ long end; /**< Position of end of range */
381
+ };
382
+
383
+ /**
384
+ For convenience, get a file range that covers a whole file.
385
+
386
+ @param file The file to study
387
+ @return the ::file_range.
388
+ */
389
+ struct file_range
390
+ freesasa_whole_file(FILE *file);
391
+
392
+ /**
393
+ Algorithm name
394
+
395
+ @param algorithm The algorithm
396
+ @return Name
397
+ */
398
+ const char *
399
+ freesasa_alg_name(freesasa_algorithm algorithm);
400
+
401
+ /**
402
+ Print failure message using format string and arguments.
403
+
404
+ Prefer using the macro fail_msg().
405
+
406
+ @param format Format string
407
+ @return ::FREESASA_FAIL
408
+ */
409
+ int freesasa_fail(const char *format, ...);
410
+
411
+ /**
412
+ Print warning message using format string and arguments.
413
+
414
+ @param format Format string
415
+ @return ::FREESASA_WARN
416
+ */
417
+ int freesasa_warn(const char *format, ...);
418
+
419
+ /**
420
+ Print warning message using function, file and line-number.
421
+
422
+ Usually used via the macro mem_fail().
423
+
424
+ @param func Name of the function that failed
425
+ @param file The file where the function is.
426
+ @param line Line number for the error.
427
+ @return ::FREESASA_FAIL
428
+ */
429
+ int freesasa_mem_fail(const char *file,
430
+ int line);
431
+
432
+ /**
433
+ Returns string explaining return values of pthread_create() and
434
+ pthread_join().
435
+
436
+ @param error_code The error code
437
+ @return A string describing the error code.
438
+ */
439
+ const char *
440
+ freesasa_thread_error(int error_code);
441
+
442
+ /**
443
+ Prints fail message with function name, file name, and line number.
444
+
445
+ Mainly intended to be used by the macros fail_msg() and mem_fail().
446
+
447
+ @param file The file name
448
+ @param line The line number
449
+ @param msg The error message
450
+ @return ::FREESASA_FAIL
451
+ */
452
+ int freesasa_fail_wloc(const char *file,
453
+ int line,
454
+ const char *format,
455
+ ...);
456
+
457
+ #ifdef __cplusplus
458
+ }
459
+ #endif
460
+
461
+ #endif /* FREESASA_INTERNAL_H */
.venv_haddock/include/site/python3.12/freesasa/lexer.c ADDED
@@ -0,0 +1,2129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #line 2 "lexer.c"
2
+
3
+ #line 4 "lexer.c"
4
+
5
+ #define YY_INT_ALIGNED short int
6
+
7
+ /* A lexical scanner generated by flex */
8
+
9
+ #define FLEX_SCANNER
10
+ #define YY_FLEX_MAJOR_VERSION 2
11
+ #define YY_FLEX_MINOR_VERSION 6
12
+ #define YY_FLEX_SUBMINOR_VERSION 1
13
+ #if YY_FLEX_SUBMINOR_VERSION > 0
14
+ #define FLEX_BETA
15
+ #endif
16
+
17
+ /* First, we deal with platform-specific or compiler-specific issues. */
18
+
19
+ /* begin standard C headers. */
20
+ #include <stdio.h>
21
+ #include <string.h>
22
+ #include <errno.h>
23
+ #include <stdlib.h>
24
+
25
+ /* end standard C headers. */
26
+
27
+ /* flex integer type definitions */
28
+
29
+ #ifndef FLEXINT_H
30
+ #define FLEXINT_H
31
+
32
+ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
+
34
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
+
36
+ /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37
+ * if you want the limit (max/min) macros for int types.
38
+ */
39
+ #ifndef __STDC_LIMIT_MACROS
40
+ #define __STDC_LIMIT_MACROS 1
41
+ #endif
42
+
43
+ #include <inttypes.h>
44
+ typedef int8_t flex_int8_t;
45
+ typedef uint8_t flex_uint8_t;
46
+ typedef int16_t flex_int16_t;
47
+ typedef uint16_t flex_uint16_t;
48
+ typedef int32_t flex_int32_t;
49
+ typedef uint32_t flex_uint32_t;
50
+ #else
51
+ typedef signed char flex_int8_t;
52
+ typedef short int flex_int16_t;
53
+ typedef int flex_int32_t;
54
+ typedef unsigned char flex_uint8_t;
55
+ typedef unsigned short int flex_uint16_t;
56
+ typedef unsigned int flex_uint32_t;
57
+
58
+ /* Limits of integral types. */
59
+ #ifndef INT8_MIN
60
+ #define INT8_MIN (-128)
61
+ #endif
62
+ #ifndef INT16_MIN
63
+ #define INT16_MIN (-32767-1)
64
+ #endif
65
+ #ifndef INT32_MIN
66
+ #define INT32_MIN (-2147483647-1)
67
+ #endif
68
+ #ifndef INT8_MAX
69
+ #define INT8_MAX (127)
70
+ #endif
71
+ #ifndef INT16_MAX
72
+ #define INT16_MAX (32767)
73
+ #endif
74
+ #ifndef INT32_MAX
75
+ #define INT32_MAX (2147483647)
76
+ #endif
77
+ #ifndef UINT8_MAX
78
+ #define UINT8_MAX (255U)
79
+ #endif
80
+ #ifndef UINT16_MAX
81
+ #define UINT16_MAX (65535U)
82
+ #endif
83
+ #ifndef UINT32_MAX
84
+ #define UINT32_MAX (4294967295U)
85
+ #endif
86
+
87
+ #endif /* ! C99 */
88
+
89
+ #endif /* ! FLEXINT_H */
90
+
91
+ /* TODO: this is always defined, so inline it */
92
+ #define yyconst const
93
+
94
+ #if defined(__GNUC__) && __GNUC__ >= 3
95
+ #define yynoreturn __attribute__((__noreturn__))
96
+ #else
97
+ #define yynoreturn
98
+ #endif
99
+
100
+ /* Returned upon end-of-file. */
101
+ #define YY_NULL 0
102
+
103
+ /* Promotes a possibly negative, possibly signed char to an unsigned
104
+ * integer for use as an array index. If the signed char is negative,
105
+ * we want to instead treat it as an 8-bit unsigned char, hence the
106
+ * double cast.
107
+ */
108
+ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
109
+
110
+ /* An opaque pointer. */
111
+ #ifndef YY_TYPEDEF_YY_SCANNER_T
112
+ #define YY_TYPEDEF_YY_SCANNER_T
113
+ typedef void* yyscan_t;
114
+ #endif
115
+
116
+ /* For convenience, these vars (plus the bison vars far below)
117
+ are macros in the reentrant scanner. */
118
+ #define yyin yyg->yyin_r
119
+ #define yyout yyg->yyout_r
120
+ #define yyextra yyg->yyextra_r
121
+ #define yyleng yyg->yyleng_r
122
+ #define yytext yyg->yytext_r
123
+ #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
124
+ #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
125
+ #define yy_flex_debug yyg->yy_flex_debug_r
126
+
127
+ /* Enter a start condition. This macro really ought to take a parameter,
128
+ * but we do it the disgusting crufty way forced on us by the ()-less
129
+ * definition of BEGIN.
130
+ */
131
+ #define BEGIN yyg->yy_start = 1 + 2 *
132
+
133
+ /* Translate the current start state into a value that can be later handed
134
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
135
+ * compatibility.
136
+ */
137
+ #define YY_START ((yyg->yy_start - 1) / 2)
138
+ #define YYSTATE YY_START
139
+
140
+ /* Action number for EOF rule of a given start state. */
141
+ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
142
+
143
+ /* Special action meaning "start processing a new file". */
144
+ #define YY_NEW_FILE freesasa_yyrestart(yyin ,yyscanner )
145
+
146
+ #define YY_END_OF_BUFFER_CHAR 0
147
+
148
+ /* Size of default input buffer. */
149
+ #ifndef YY_BUF_SIZE
150
+ #ifdef __ia64__
151
+ /* On IA-64, the buffer size is 16k, not 8k.
152
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
153
+ * Ditto for the __ia64__ case accordingly.
154
+ */
155
+ #define YY_BUF_SIZE 32768
156
+ #else
157
+ #define YY_BUF_SIZE 16384
158
+ #endif /* __ia64__ */
159
+ #endif
160
+
161
+ /* The state buf must be large enough to hold one state per character in the main buffer.
162
+ */
163
+ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
164
+
165
+ #ifndef YY_TYPEDEF_YY_BUFFER_STATE
166
+ #define YY_TYPEDEF_YY_BUFFER_STATE
167
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
168
+ #endif
169
+
170
+ #ifndef YY_TYPEDEF_YY_SIZE_T
171
+ #define YY_TYPEDEF_YY_SIZE_T
172
+ typedef size_t yy_size_t;
173
+ #endif
174
+
175
+ #define EOB_ACT_CONTINUE_SCAN 0
176
+ #define EOB_ACT_END_OF_FILE 1
177
+ #define EOB_ACT_LAST_MATCH 2
178
+
179
+ #define YY_LESS_LINENO(n)
180
+ #define YY_LINENO_REWIND_TO(ptr)
181
+
182
+ /* Return all but the first "n" matched characters back to the input stream. */
183
+ #define yyless(n) \
184
+ do \
185
+ { \
186
+ /* Undo effects of setting up yytext. */ \
187
+ int yyless_macro_arg = (n); \
188
+ YY_LESS_LINENO(yyless_macro_arg);\
189
+ *yy_cp = yyg->yy_hold_char; \
190
+ YY_RESTORE_YY_MORE_OFFSET \
191
+ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
192
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
193
+ } \
194
+ while ( 0 )
195
+
196
+ #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
197
+
198
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
199
+ #define YY_STRUCT_YY_BUFFER_STATE
200
+ struct yy_buffer_state
201
+ {
202
+ FILE *yy_input_file;
203
+
204
+ char *yy_ch_buf; /* input buffer */
205
+ char *yy_buf_pos; /* current position in input buffer */
206
+
207
+ /* Size of input buffer in bytes, not including room for EOB
208
+ * characters.
209
+ */
210
+ int yy_buf_size;
211
+
212
+ /* Number of characters read into yy_ch_buf, not including EOB
213
+ * characters.
214
+ */
215
+ int yy_n_chars;
216
+
217
+ /* Whether we "own" the buffer - i.e., we know we created it,
218
+ * and can realloc() it to grow it, and should free() it to
219
+ * delete it.
220
+ */
221
+ int yy_is_our_buffer;
222
+
223
+ /* Whether this is an "interactive" input source; if so, and
224
+ * if we're using stdio for input, then we want to use getc()
225
+ * instead of fread(), to make sure we stop fetching input after
226
+ * each newline.
227
+ */
228
+ int yy_is_interactive;
229
+
230
+ /* Whether we're considered to be at the beginning of a line.
231
+ * If so, '^' rules will be active on the next match, otherwise
232
+ * not.
233
+ */
234
+ int yy_at_bol;
235
+
236
+ int yy_bs_lineno; /**< The line count. */
237
+ int yy_bs_column; /**< The column count. */
238
+
239
+ /* Whether to try to fill the input buffer when we reach the
240
+ * end of it.
241
+ */
242
+ int yy_fill_buffer;
243
+
244
+ int yy_buffer_status;
245
+
246
+ #define YY_BUFFER_NEW 0
247
+ #define YY_BUFFER_NORMAL 1
248
+ /* When an EOF's been seen but there's still some text to process
249
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
250
+ * shouldn't try reading from the input source any more. We might
251
+ * still have a bunch of tokens to match, though, because of
252
+ * possible backing-up.
253
+ *
254
+ * When we actually see the EOF, we change the status to "new"
255
+ * (via freesasa_yyrestart()), so that the user can continue scanning by
256
+ * just pointing yyin at a new input file.
257
+ */
258
+ #define YY_BUFFER_EOF_PENDING 2
259
+
260
+ };
261
+ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
262
+
263
+ /* We provide macros for accessing buffer states in case in the
264
+ * future we want to put the buffer states in a more general
265
+ * "scanner state".
266
+ *
267
+ * Returns the top of the stack, or NULL.
268
+ */
269
+ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
270
+ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
271
+ : NULL)
272
+
273
+ /* Same as previous macro, but useful when we know that the buffer stack is not
274
+ * NULL or when we need an lvalue. For internal use only.
275
+ */
276
+ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
277
+
278
+ void freesasa_yyrestart (FILE *input_file ,yyscan_t yyscanner );
279
+ void freesasa_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
280
+ YY_BUFFER_STATE freesasa_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
281
+ void freesasa_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
282
+ void freesasa_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
283
+ void freesasa_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
284
+ void freesasa_yypop_buffer_state (yyscan_t yyscanner );
285
+
286
+ static void freesasa_yyensure_buffer_stack (yyscan_t yyscanner );
287
+ static void freesasa_yy_load_buffer_state (yyscan_t yyscanner );
288
+ static void freesasa_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
289
+
290
+ #define YY_FLUSH_BUFFER freesasa_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
291
+
292
+ YY_BUFFER_STATE freesasa_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
293
+ YY_BUFFER_STATE freesasa_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
294
+ YY_BUFFER_STATE freesasa_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
295
+
296
+ void *freesasa_yyalloc (yy_size_t ,yyscan_t yyscanner );
297
+ void *freesasa_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
298
+ void freesasa_yyfree (void * ,yyscan_t yyscanner );
299
+
300
+ #define yy_new_buffer freesasa_yy_create_buffer
301
+
302
+ #define yy_set_interactive(is_interactive) \
303
+ { \
304
+ if ( ! YY_CURRENT_BUFFER ){ \
305
+ freesasa_yyensure_buffer_stack (yyscanner); \
306
+ YY_CURRENT_BUFFER_LVALUE = \
307
+ freesasa_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
308
+ } \
309
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
310
+ }
311
+
312
+ #define yy_set_bol(at_bol) \
313
+ { \
314
+ if ( ! YY_CURRENT_BUFFER ){\
315
+ freesasa_yyensure_buffer_stack (yyscanner); \
316
+ YY_CURRENT_BUFFER_LVALUE = \
317
+ freesasa_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
318
+ } \
319
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
320
+ }
321
+
322
+ #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
323
+
324
+ #define freesasa_yywrap(yyscanner) (/*CONSTCOND*/1)
325
+ #define YY_SKIP_YYWRAP
326
+
327
+ typedef unsigned char YY_CHAR;
328
+
329
+ typedef int yy_state_type;
330
+
331
+ #define yytext_ptr yytext_r
332
+
333
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
334
+ static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
335
+ static int yy_get_next_buffer (yyscan_t yyscanner );
336
+ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
337
+
338
+ /* Done after the current pattern has been matched and before the
339
+ * corresponding action - sets up yytext.
340
+ */
341
+ #define YY_DO_BEFORE_ACTION \
342
+ yyg->yytext_ptr = yy_bp; \
343
+ yyleng = (int) (yy_cp - yy_bp); \
344
+ yyg->yy_hold_char = *yy_cp; \
345
+ *yy_cp = '\0'; \
346
+ yyg->yy_c_buf_p = yy_cp;
347
+
348
+ #define YY_NUM_RULES 19
349
+ #define YY_END_OF_BUFFER 20
350
+ /* This struct is not used in this scanner,
351
+ but its presence is necessary. */
352
+ struct yy_trans_info
353
+ {
354
+ flex_int32_t yy_verify;
355
+ flex_int32_t yy_nxt;
356
+ };
357
+ static yyconst flex_int16_t yy_accept[52] =
358
+ { 0,
359
+ 15, 15, 20, 19, 15, 13, 11, 4, 5, 3,
360
+ 1, 2, 16, 17, 17, 17, 17, 17, 17, 17,
361
+ 19, 12, 15, 0, 18, 17, 16, 17, 17, 17,
362
+ 17, 17, 12, 17, 17, 14, 11, 17, 17, 13,
363
+ 17, 17, 17, 9, 7, 6, 17, 10, 17, 8,
364
+ 0
365
+ } ;
366
+
367
+ static yyconst YY_CHAR yy_ec[256] =
368
+ { 0,
369
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
370
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
371
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
372
+ 1, 2, 3, 1, 1, 1, 1, 4, 5, 6,
373
+ 7, 1, 8, 9, 10, 1, 1, 11, 11, 11,
374
+ 11, 11, 11, 11, 11, 11, 11, 1, 1, 1,
375
+ 1, 1, 1, 1, 12, 13, 14, 15, 16, 17,
376
+ 17, 18, 19, 17, 17, 20, 21, 22, 23, 17,
377
+ 17, 24, 25, 26, 17, 17, 17, 17, 27, 17,
378
+ 1, 28, 1, 1, 17, 1, 29, 30, 31, 32,
379
+
380
+ 33, 17, 17, 34, 35, 17, 17, 36, 37, 38,
381
+ 39, 17, 17, 40, 41, 42, 17, 17, 17, 17,
382
+ 43, 17, 1, 44, 1, 1, 1, 1, 1, 1,
383
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
384
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
385
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
386
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
387
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
389
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
390
+
391
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
392
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
394
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396
+ 1, 1, 1, 1, 1
397
+ } ;
398
+
399
+ static yyconst YY_CHAR yy_meta[45] =
400
+ { 0,
401
+ 1, 1, 1, 1, 2, 1, 1, 3, 3, 3,
402
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
403
+ 3, 3, 3, 3, 3, 3, 3, 1, 3, 3,
404
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
405
+ 3, 3, 3, 1
406
+ } ;
407
+
408
+ static yyconst flex_uint16_t yy_base[54] =
409
+ { 0,
410
+ 0, 0, 68, 281, 64, 281, 281, 281, 281, 56,
411
+ 281, 51, 40, 47, 53, 62, 92, 68, 74, 101,
412
+ 49, 281, 52, 44, 281, 42, 108, 115, 124, 52,
413
+ 114, 126, 118, 138, 152, 281, 147, 159, 180, 172,
414
+ 208, 187, 183, 203, 210, 214, 185, 211, 239, 232,
415
+ 281, 43, 277
416
+ } ;
417
+
418
+ static yyconst flex_int16_t yy_def[54] =
419
+ { 0,
420
+ 51, 1, 51, 51, 51, 51, 51, 51, 51, 52,
421
+ 51, 52, 53, 53, 53, 53, 53, 53, 53, 53,
422
+ 51, 51, 51, 52, 51, 51, 53, 53, 53, 17,
423
+ 17, 17, 17, 17, 17, 51, 17, 17, 17, 17,
424
+ 17, 17, 41, 41, 41, 41, 17, 17, 17, 17,
425
+ 0, 51, 51
426
+ } ;
427
+
428
+ static yyconst flex_uint16_t yy_nxt[326] =
429
+ { 0,
430
+ 4, 5, 6, 7, 4, 8, 9, 10, 11, 12,
431
+ 13, 14, 15, 16, 15, 15, 15, 15, 15, 15,
432
+ 15, 17, 18, 19, 20, 15, 15, 21, 14, 15,
433
+ 16, 15, 15, 15, 15, 15, 15, 17, 18, 19,
434
+ 20, 15, 15, 22, 26, 24, 26, 24, 25, 24,
435
+ 27, 26, 25, 23, 24, 25, 24, 26, 36, 25,
436
+ 24, 25, 24, 38, 25, 23, 26, 51, 29, 24,
437
+ 25, 24, 26, 51, 28, 24, 25, 24, 26, 30,
438
+ 38, 24, 25, 24, 29, 51, 51, 51, 51, 34,
439
+ 28, 33, 51, 51, 51, 30, 26, 51, 51, 24,
440
+
441
+ 25, 24, 51, 31, 51, 26, 34, 33, 24, 25,
442
+ 24, 51, 26, 51, 32, 24, 25, 24, 27, 26,
443
+ 31, 51, 24, 25, 24, 28, 51, 35, 26, 28,
444
+ 32, 24, 25, 24, 39, 51, 28, 28, 37, 51,
445
+ 28, 51, 28, 35, 51, 51, 28, 51, 28, 28,
446
+ 39, 40, 28, 51, 28, 37, 28, 51, 28, 51,
447
+ 28, 51, 41, 28, 28, 51, 28, 40, 51, 28,
448
+ 28, 51, 42, 51, 28, 28, 28, 43, 41, 51,
449
+ 28, 28, 51, 28, 51, 28, 51, 28, 42, 51,
450
+ 28, 28, 51, 43, 28, 44, 28, 28, 28, 47,
451
+
452
+ 28, 28, 28, 51, 48, 51, 51, 49, 28, 28,
453
+ 28, 51, 44, 28, 51, 28, 47, 28, 28, 28,
454
+ 48, 28, 28, 49, 28, 28, 45, 51, 28, 46,
455
+ 28, 28, 28, 28, 51, 28, 28, 28, 51, 28,
456
+ 28, 51, 45, 28, 28, 46, 28, 28, 28, 28,
457
+ 28, 28, 51, 51, 28, 51, 51, 51, 50, 51,
458
+ 28, 28, 51, 51, 51, 51, 51, 28, 51, 51,
459
+ 28, 51, 51, 51, 50, 51, 51, 28, 28, 28,
460
+ 3, 51, 51, 51, 51, 51, 51, 51, 51, 51,
461
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
462
+
463
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
464
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
465
+ 51, 51, 51, 51, 51
466
+ } ;
467
+
468
+ static yyconst flex_int16_t yy_chk[326] =
469
+ { 0,
470
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
471
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
472
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
473
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
474
+ 1, 1, 1, 1, 13, 52, 26, 13, 13, 13,
475
+ 13, 14, 24, 23, 14, 14, 14, 15, 21, 12,
476
+ 15, 15, 15, 30, 10, 5, 16, 3, 14, 16,
477
+ 16, 16, 18, 0, 30, 18, 18, 18, 19, 16,
478
+ 30, 19, 19, 19, 14, 0, 0, 0, 0, 19,
479
+ 30, 18, 0, 0, 0, 16, 17, 0, 0, 17,
480
+
481
+ 17, 17, 0, 17, 0, 20, 19, 18, 20, 20,
482
+ 20, 0, 27, 0, 17, 27, 27, 27, 27, 28,
483
+ 17, 0, 28, 28, 28, 31, 0, 20, 29, 33,
484
+ 17, 29, 29, 29, 31, 0, 31, 32, 29, 0,
485
+ 33, 0, 31, 20, 0, 0, 33, 0, 32, 34,
486
+ 31, 32, 31, 0, 32, 29, 33, 0, 37, 0,
487
+ 34, 0, 34, 35, 32, 0, 34, 32, 0, 37,
488
+ 38, 0, 35, 0, 35, 37, 34, 38, 34, 0,
489
+ 35, 38, 0, 40, 0, 37, 0, 38, 35, 0,
490
+ 35, 39, 0, 38, 40, 39, 47, 38, 42, 42,
491
+
492
+ 40, 43, 39, 0, 43, 0, 0, 47, 39, 42,
493
+ 40, 0, 39, 47, 0, 42, 42, 43, 39, 41,
494
+ 43, 44, 48, 47, 44, 42, 41, 0, 45, 41,
495
+ 41, 45, 46, 48, 0, 46, 41, 44, 0, 48,
496
+ 44, 0, 41, 50, 45, 41, 41, 45, 46, 48,
497
+ 49, 46, 0, 0, 50, 0, 0, 0, 49, 0,
498
+ 50, 49, 0, 0, 0, 0, 0, 49, 0, 0,
499
+ 50, 0, 0, 0, 49, 0, 0, 49, 53, 53,
500
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
501
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
502
+
503
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
504
+ 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
505
+ 51, 51, 51, 51, 51
506
+ } ;
507
+
508
+ /* The intent behind this definition is that it'll catch
509
+ * any uses of REJECT which flex missed.
510
+ */
511
+ #define REJECT reject_used_but_not_detected
512
+ #define yymore() yymore_used_but_not_detected
513
+ #define YY_MORE_ADJ 0
514
+ #define YY_RESTORE_YY_MORE_OFFSET
515
+ #line 1 "lexer.l"
516
+ #line 2 "lexer.l"
517
+
518
+ #include "selection.h"
519
+ #include "parser.h"
520
+ #include "freesasa_internal.h"
521
+
522
+ #include <stdio.h>
523
+
524
+ #define YY_NO_UNISTD_H 1
525
+ #line 526 "lexer.c"
526
+
527
+ #define INITIAL 0
528
+
529
+ #ifndef YY_EXTRA_TYPE
530
+ #define YY_EXTRA_TYPE void *
531
+ #endif
532
+
533
+ /* Holds the entire state of the reentrant scanner. */
534
+ struct yyguts_t
535
+ {
536
+
537
+ /* User-defined. Not touched by flex. */
538
+ YY_EXTRA_TYPE yyextra_r;
539
+
540
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
541
+ FILE *yyin_r, *yyout_r;
542
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
543
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
544
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
545
+ char yy_hold_char;
546
+ int yy_n_chars;
547
+ int yyleng_r;
548
+ char *yy_c_buf_p;
549
+ int yy_init;
550
+ int yy_start;
551
+ int yy_did_buffer_switch_on_eof;
552
+ int yy_start_stack_ptr;
553
+ int yy_start_stack_depth;
554
+ int *yy_start_stack;
555
+ yy_state_type yy_last_accepting_state;
556
+ char* yy_last_accepting_cpos;
557
+
558
+ int yylineno_r;
559
+ int yy_flex_debug_r;
560
+
561
+ char *yytext_r;
562
+ int yy_more_flag;
563
+ int yy_more_len;
564
+
565
+ YYSTYPE * yylval_r;
566
+
567
+ }; /* end struct yyguts_t */
568
+
569
+ static int yy_init_globals (yyscan_t yyscanner );
570
+
571
+ /* This must go here because YYSTYPE and YYLTYPE are included
572
+ * from bison output in section 1.*/
573
+ # define yylval yyg->yylval_r
574
+
575
+ int freesasa_yylex_init (yyscan_t* scanner);
576
+
577
+ int freesasa_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
578
+
579
+ /* Accessor methods to globals.
580
+ These are made visible to non-reentrant scanners for convenience. */
581
+
582
+ int freesasa_yylex_destroy (yyscan_t yyscanner );
583
+
584
+ int freesasa_yyget_debug (yyscan_t yyscanner );
585
+
586
+ void freesasa_yyset_debug (int debug_flag ,yyscan_t yyscanner );
587
+
588
+ YY_EXTRA_TYPE freesasa_yyget_extra (yyscan_t yyscanner );
589
+
590
+ void freesasa_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
591
+
592
+ FILE *freesasa_yyget_in (yyscan_t yyscanner );
593
+
594
+ void freesasa_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
595
+
596
+ FILE *freesasa_yyget_out (yyscan_t yyscanner );
597
+
598
+ void freesasa_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
599
+
600
+ int freesasa_yyget_leng (yyscan_t yyscanner );
601
+
602
+ char *freesasa_yyget_text (yyscan_t yyscanner );
603
+
604
+ int freesasa_yyget_lineno (yyscan_t yyscanner );
605
+
606
+ void freesasa_yyset_lineno (int _line_number ,yyscan_t yyscanner );
607
+
608
+ int freesasa_yyget_column (yyscan_t yyscanner );
609
+
610
+ void freesasa_yyset_column (int _column_no ,yyscan_t yyscanner );
611
+
612
+ YYSTYPE * freesasa_yyget_lval (yyscan_t yyscanner );
613
+
614
+ void freesasa_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
615
+
616
+ /* Macros after this point can all be overridden by user definitions in
617
+ * section 1.
618
+ */
619
+
620
+ #ifndef YY_SKIP_YYWRAP
621
+ #ifdef __cplusplus
622
+ extern "C" int freesasa_yywrap (yyscan_t yyscanner );
623
+ #else
624
+ extern int freesasa_yywrap (yyscan_t yyscanner );
625
+ #endif
626
+ #endif
627
+
628
+ #ifndef YY_NO_UNPUT
629
+
630
+ static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
631
+
632
+ #endif
633
+
634
+ #ifndef yytext_ptr
635
+ static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
636
+ #endif
637
+
638
+ #ifdef YY_NEED_STRLEN
639
+ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
640
+ #endif
641
+
642
+ #ifndef YY_NO_INPUT
643
+
644
+ #ifdef __cplusplus
645
+ static int yyinput (yyscan_t yyscanner );
646
+ #else
647
+ static int input (yyscan_t yyscanner );
648
+ #endif
649
+
650
+ #endif
651
+
652
+ /* Amount of stuff to slurp up with each read. */
653
+ #ifndef YY_READ_BUF_SIZE
654
+ #ifdef __ia64__
655
+ /* On IA-64, the buffer size is 16k, not 8k */
656
+ #define YY_READ_BUF_SIZE 16384
657
+ #else
658
+ #define YY_READ_BUF_SIZE 8192
659
+ #endif /* __ia64__ */
660
+ #endif
661
+
662
+ /* Copy whatever the last rule matched to the standard output. */
663
+ #ifndef ECHO
664
+ /* This used to be an fputs(), but since the string might contain NUL's,
665
+ * we now use fwrite().
666
+ */
667
+ #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
668
+ #endif
669
+
670
+ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
671
+ * is returned in "result".
672
+ */
673
+ #ifndef YY_INPUT
674
+ #define YY_INPUT(buf,result,max_size) \
675
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
676
+ { \
677
+ int c = '*'; \
678
+ size_t n; \
679
+ for ( n = 0; n < max_size && \
680
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
681
+ buf[n] = (char) c; \
682
+ if ( c == '\n' ) \
683
+ buf[n++] = (char) c; \
684
+ if ( c == EOF && ferror( yyin ) ) \
685
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
686
+ result = n; \
687
+ } \
688
+ else \
689
+ { \
690
+ errno=0; \
691
+ while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
692
+ { \
693
+ if( errno != EINTR) \
694
+ { \
695
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
696
+ break; \
697
+ } \
698
+ errno=0; \
699
+ clearerr(yyin); \
700
+ } \
701
+ }\
702
+ \
703
+
704
+ #endif
705
+
706
+ /* No semi-colon after return; correct usage is to write "yyterminate();" -
707
+ * we don't want an extra ';' after the "return" because that will cause
708
+ * some compilers to complain about unreachable statements.
709
+ */
710
+ #ifndef yyterminate
711
+ #define yyterminate() return YY_NULL
712
+ #endif
713
+
714
+ /* Number of entries by which start-condition stack grows. */
715
+ #ifndef YY_START_STACK_INCR
716
+ #define YY_START_STACK_INCR 25
717
+ #endif
718
+
719
+ /* Report a fatal error. */
720
+ #ifndef YY_FATAL_ERROR
721
+ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
722
+ #endif
723
+
724
+ /* end tables serialization structures and prototypes */
725
+
726
+ /* Default declaration of generated scanner - a define so the user can
727
+ * easily add parameters.
728
+ */
729
+ #ifndef YY_DECL
730
+ #define YY_DECL_IS_OURS 1
731
+
732
+ extern int freesasa_yylex \
733
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
734
+
735
+ #define YY_DECL int freesasa_yylex \
736
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
737
+ #endif /* !YY_DECL */
738
+
739
+ /* Code executed at the beginning of each rule, after yytext and yyleng
740
+ * have been set up.
741
+ */
742
+ #ifndef YY_USER_ACTION
743
+ #define YY_USER_ACTION
744
+ #endif
745
+
746
+ /* Code executed at the end of each rule. */
747
+ #ifndef YY_BREAK
748
+ #define YY_BREAK /*LINTED*/break;
749
+ #endif
750
+
751
+ #define YY_RULE_SETUP \
752
+ YY_USER_ACTION
753
+
754
+ /** The main scanner function which does all the work.
755
+ */
756
+ YY_DECL
757
+ {
758
+ yy_state_type yy_current_state;
759
+ char *yy_cp, *yy_bp;
760
+ int yy_act;
761
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
762
+
763
+ yylval = yylval_param;
764
+
765
+ if ( !yyg->yy_init )
766
+ {
767
+ yyg->yy_init = 1;
768
+
769
+ #ifdef YY_USER_INIT
770
+ YY_USER_INIT;
771
+ #endif
772
+
773
+ if ( ! yyg->yy_start )
774
+ yyg->yy_start = 1; /* first start state */
775
+
776
+ if ( ! yyin )
777
+ yyin = stdin;
778
+
779
+ if ( ! yyout )
780
+ yyout = stdout;
781
+
782
+ if ( ! YY_CURRENT_BUFFER ) {
783
+ freesasa_yyensure_buffer_stack (yyscanner);
784
+ YY_CURRENT_BUFFER_LVALUE =
785
+ freesasa_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
786
+ }
787
+
788
+ freesasa_yy_load_buffer_state(yyscanner );
789
+ }
790
+
791
+ {
792
+ #line 32 "lexer.l"
793
+
794
+
795
+ #line 796 "lexer.c"
796
+
797
+ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
798
+ {
799
+ yy_cp = yyg->yy_c_buf_p;
800
+
801
+ /* Support of yytext. */
802
+ *yy_cp = yyg->yy_hold_char;
803
+
804
+ /* yy_bp points to the position in yy_ch_buf of the start of
805
+ * the current run.
806
+ */
807
+ yy_bp = yy_cp;
808
+
809
+ yy_current_state = yyg->yy_start;
810
+ yy_match:
811
+ do
812
+ {
813
+ YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
814
+ if ( yy_accept[yy_current_state] )
815
+ {
816
+ yyg->yy_last_accepting_state = yy_current_state;
817
+ yyg->yy_last_accepting_cpos = yy_cp;
818
+ }
819
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
820
+ {
821
+ yy_current_state = (int) yy_def[yy_current_state];
822
+ if ( yy_current_state >= 52 )
823
+ yy_c = yy_meta[(unsigned int) yy_c];
824
+ }
825
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
826
+ ++yy_cp;
827
+ }
828
+ while ( yy_current_state != 51 );
829
+ yy_cp = yyg->yy_last_accepting_cpos;
830
+ yy_current_state = yyg->yy_last_accepting_state;
831
+
832
+ yy_find_action:
833
+ yy_act = yy_accept[yy_current_state];
834
+
835
+ YY_DO_BEFORE_ACTION;
836
+
837
+ do_action: /* This label is used only to access EOF actions. */
838
+
839
+ switch ( yy_act )
840
+ { /* beginning of action switch */
841
+ case 0: /* must back up */
842
+ /* undo the effects of YY_DO_BEFORE_ACTION */
843
+ *yy_cp = yyg->yy_hold_char;
844
+ yy_cp = yyg->yy_last_accepting_cpos;
845
+ yy_current_state = yyg->yy_last_accepting_state;
846
+ goto yy_find_action;
847
+
848
+ case 1:
849
+ YY_RULE_SETUP
850
+ #line 34 "lexer.l"
851
+ { return ','; }
852
+ YY_BREAK
853
+ case 2:
854
+ YY_RULE_SETUP
855
+ #line 35 "lexer.l"
856
+ { return '-'; }
857
+ YY_BREAK
858
+ case 3:
859
+ YY_RULE_SETUP
860
+ #line 36 "lexer.l"
861
+ { return '+'; }
862
+ YY_BREAK
863
+ case 4:
864
+ YY_RULE_SETUP
865
+ #line 37 "lexer.l"
866
+ { return '('; }
867
+ YY_BREAK
868
+ case 5:
869
+ YY_RULE_SETUP
870
+ #line 38 "lexer.l"
871
+ { return ')'; }
872
+ YY_BREAK
873
+ case 6:
874
+ YY_RULE_SETUP
875
+ #line 40 "lexer.l"
876
+ { return T_RESN; }
877
+ YY_BREAK
878
+ case 7:
879
+ YY_RULE_SETUP
880
+ #line 41 "lexer.l"
881
+ { return T_RESI; }
882
+ YY_BREAK
883
+ case 8:
884
+ YY_RULE_SETUP
885
+ #line 42 "lexer.l"
886
+ { return T_SYMBOL; }
887
+ YY_BREAK
888
+ case 9:
889
+ YY_RULE_SETUP
890
+ #line 43 "lexer.l"
891
+ { return T_NAME; }
892
+ YY_BREAK
893
+ case 10:
894
+ YY_RULE_SETUP
895
+ #line 44 "lexer.l"
896
+ { return T_CHAIN; }
897
+ YY_BREAK
898
+ case 11:
899
+ YY_RULE_SETUP
900
+ #line 46 "lexer.l"
901
+ { return T_AND; }
902
+ YY_BREAK
903
+ case 12:
904
+ YY_RULE_SETUP
905
+ #line 47 "lexer.l"
906
+ { return T_OR; }
907
+ YY_BREAK
908
+ case 13:
909
+ YY_RULE_SETUP
910
+ #line 48 "lexer.l"
911
+ { return T_NOT; }
912
+ YY_BREAK
913
+ case 14:
914
+ YY_RULE_SETUP
915
+ #line 49 "lexer.l"
916
+ { return T_MINUS; }
917
+ YY_BREAK
918
+ case 15:
919
+ /* rule 15 can match eol */
920
+ YY_RULE_SETUP
921
+ #line 51 "lexer.l"
922
+ {}
923
+ YY_BREAK
924
+ case 16:
925
+ YY_RULE_SETUP
926
+ #line 52 "lexer.l"
927
+ { yylval->value = strdup(yytext); return T_NUMBER; }
928
+ YY_BREAK
929
+ case 17:
930
+ YY_RULE_SETUP
931
+ #line 53 "lexer.l"
932
+ { yylval->value = strdup(yytext); return T_ID; }
933
+ YY_BREAK
934
+ case 18:
935
+ *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
936
+ yyg->yy_c_buf_p = yy_cp -= 1;
937
+ YY_DO_BEFORE_ACTION; /* set up yytext again */
938
+ YY_RULE_SETUP
939
+ #line 54 "lexer.l"
940
+ { yylval->value = strdup(yytext); return T_SELID; }
941
+ YY_BREAK
942
+ case 19:
943
+ YY_RULE_SETUP
944
+ #line 55 "lexer.l"
945
+ ECHO;
946
+ YY_BREAK
947
+ #line 948 "lexer.c"
948
+ case YY_STATE_EOF(INITIAL):
949
+ yyterminate();
950
+
951
+ case YY_END_OF_BUFFER:
952
+ {
953
+ /* Amount of text matched not including the EOB char. */
954
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
955
+
956
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
957
+ *yy_cp = yyg->yy_hold_char;
958
+ YY_RESTORE_YY_MORE_OFFSET
959
+
960
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
961
+ {
962
+ /* We're scanning a new file or input source. It's
963
+ * possible that this happened because the user
964
+ * just pointed yyin at a new source and called
965
+ * freesasa_yylex(). If so, then we have to assure
966
+ * consistency between YY_CURRENT_BUFFER and our
967
+ * globals. Here is the right place to do so, because
968
+ * this is the first action (other than possibly a
969
+ * back-up) that will match for the new input source.
970
+ */
971
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
972
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
973
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
974
+ }
975
+
976
+ /* Note that here we test for yy_c_buf_p "<=" to the position
977
+ * of the first EOB in the buffer, since yy_c_buf_p will
978
+ * already have been incremented past the NUL character
979
+ * (since all states make transitions on EOB to the
980
+ * end-of-buffer state). Contrast this with the test
981
+ * in input().
982
+ */
983
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
984
+ { /* This was really a NUL. */
985
+ yy_state_type yy_next_state;
986
+
987
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
988
+
989
+ yy_current_state = yy_get_previous_state( yyscanner );
990
+
991
+ /* Okay, we're now positioned to make the NUL
992
+ * transition. We couldn't have
993
+ * yy_get_previous_state() go ahead and do it
994
+ * for us because it doesn't know how to deal
995
+ * with the possibility of jamming (and we don't
996
+ * want to build jamming into it because then it
997
+ * will run more slowly).
998
+ */
999
+
1000
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1001
+
1002
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1003
+
1004
+ if ( yy_next_state )
1005
+ {
1006
+ /* Consume the NUL. */
1007
+ yy_cp = ++yyg->yy_c_buf_p;
1008
+ yy_current_state = yy_next_state;
1009
+ goto yy_match;
1010
+ }
1011
+
1012
+ else
1013
+ {
1014
+ yy_cp = yyg->yy_last_accepting_cpos;
1015
+ yy_current_state = yyg->yy_last_accepting_state;
1016
+ goto yy_find_action;
1017
+ }
1018
+ }
1019
+
1020
+ else switch ( yy_get_next_buffer( yyscanner ) )
1021
+ {
1022
+ case EOB_ACT_END_OF_FILE:
1023
+ {
1024
+ yyg->yy_did_buffer_switch_on_eof = 0;
1025
+
1026
+ if ( freesasa_yywrap(yyscanner ) )
1027
+ {
1028
+ /* Note: because we've taken care in
1029
+ * yy_get_next_buffer() to have set up
1030
+ * yytext, we can now set up
1031
+ * yy_c_buf_p so that if some total
1032
+ * hoser (like flex itself) wants to
1033
+ * call the scanner after we return the
1034
+ * YY_NULL, it'll still work - another
1035
+ * YY_NULL will get returned.
1036
+ */
1037
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1038
+
1039
+ yy_act = YY_STATE_EOF(YY_START);
1040
+ goto do_action;
1041
+ }
1042
+
1043
+ else
1044
+ {
1045
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
1046
+ YY_NEW_FILE;
1047
+ }
1048
+ break;
1049
+ }
1050
+
1051
+ case EOB_ACT_CONTINUE_SCAN:
1052
+ yyg->yy_c_buf_p =
1053
+ yyg->yytext_ptr + yy_amount_of_matched_text;
1054
+
1055
+ yy_current_state = yy_get_previous_state( yyscanner );
1056
+
1057
+ yy_cp = yyg->yy_c_buf_p;
1058
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1059
+ goto yy_match;
1060
+
1061
+ case EOB_ACT_LAST_MATCH:
1062
+ yyg->yy_c_buf_p =
1063
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1064
+
1065
+ yy_current_state = yy_get_previous_state( yyscanner );
1066
+
1067
+ yy_cp = yyg->yy_c_buf_p;
1068
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1069
+ goto yy_find_action;
1070
+ }
1071
+ break;
1072
+ }
1073
+
1074
+ default:
1075
+ YY_FATAL_ERROR(
1076
+ "fatal flex scanner internal error--no action found" );
1077
+ } /* end of action switch */
1078
+ } /* end of scanning one token */
1079
+ } /* end of user's declarations */
1080
+ } /* end of freesasa_yylex */
1081
+
1082
+ /* yy_get_next_buffer - try to read in a new buffer
1083
+ *
1084
+ * Returns a code representing an action:
1085
+ * EOB_ACT_LAST_MATCH -
1086
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1087
+ * EOB_ACT_END_OF_FILE - end of file
1088
+ */
1089
+ static int yy_get_next_buffer (yyscan_t yyscanner)
1090
+ {
1091
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1092
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1093
+ char *source = yyg->yytext_ptr;
1094
+ yy_size_t number_to_move, i;
1095
+ int ret_val;
1096
+
1097
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1098
+ YY_FATAL_ERROR(
1099
+ "fatal flex scanner internal error--end of buffer missed" );
1100
+
1101
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1102
+ { /* Don't try to fill the buffer, so this is an EOF. */
1103
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1104
+ {
1105
+ /* We matched a single character, the EOB, so
1106
+ * treat this as a final EOF.
1107
+ */
1108
+ return EOB_ACT_END_OF_FILE;
1109
+ }
1110
+
1111
+ else
1112
+ {
1113
+ /* We matched some text prior to the EOB, first
1114
+ * process it.
1115
+ */
1116
+ return EOB_ACT_LAST_MATCH;
1117
+ }
1118
+ }
1119
+
1120
+ /* Try to read more data. */
1121
+
1122
+ /* First move last chars to start of buffer. */
1123
+ number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1124
+
1125
+ for ( i = 0; i < number_to_move; ++i )
1126
+ *(dest++) = *(source++);
1127
+
1128
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1129
+ /* don't do the read, it's not guaranteed to return an EOF,
1130
+ * just force an EOF
1131
+ */
1132
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1133
+
1134
+ else
1135
+ {
1136
+ int num_to_read =
1137
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1138
+
1139
+ while ( num_to_read <= 0 )
1140
+ { /* Not enough room in the buffer - grow it. */
1141
+
1142
+ /* just a shorter name for the current buffer */
1143
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1144
+
1145
+ int yy_c_buf_p_offset =
1146
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1147
+
1148
+ if ( b->yy_is_our_buffer )
1149
+ {
1150
+ int new_size = b->yy_buf_size * 2;
1151
+
1152
+ if ( new_size <= 0 )
1153
+ b->yy_buf_size += b->yy_buf_size / 8;
1154
+ else
1155
+ b->yy_buf_size *= 2;
1156
+
1157
+ b->yy_ch_buf = (char *)
1158
+ /* Include room in for 2 EOB chars. */
1159
+ freesasa_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1160
+ }
1161
+ else
1162
+ /* Can't grow it, we don't own it. */
1163
+ b->yy_ch_buf = NULL;
1164
+
1165
+ if ( ! b->yy_ch_buf )
1166
+ YY_FATAL_ERROR(
1167
+ "fatal error - scanner input buffer overflow" );
1168
+
1169
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1170
+
1171
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1172
+ number_to_move - 1;
1173
+
1174
+ }
1175
+
1176
+ if ( num_to_read > YY_READ_BUF_SIZE )
1177
+ num_to_read = YY_READ_BUF_SIZE;
1178
+
1179
+ /* Read in more data. */
1180
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1181
+ yyg->yy_n_chars, num_to_read );
1182
+
1183
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1184
+ }
1185
+
1186
+ if ( yyg->yy_n_chars == 0 )
1187
+ {
1188
+ if ( number_to_move == YY_MORE_ADJ )
1189
+ {
1190
+ ret_val = EOB_ACT_END_OF_FILE;
1191
+ freesasa_yyrestart(yyin ,yyscanner);
1192
+ }
1193
+
1194
+ else
1195
+ {
1196
+ ret_val = EOB_ACT_LAST_MATCH;
1197
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1198
+ YY_BUFFER_EOF_PENDING;
1199
+ }
1200
+ }
1201
+
1202
+ else
1203
+ ret_val = EOB_ACT_CONTINUE_SCAN;
1204
+
1205
+ if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1206
+ /* Extend the array by 50%, plus the number we really need. */
1207
+ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1208
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) freesasa_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1209
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1210
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1211
+ }
1212
+
1213
+ yyg->yy_n_chars += number_to_move;
1214
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1215
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1216
+
1217
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1218
+
1219
+ return ret_val;
1220
+ }
1221
+
1222
+ /* yy_get_previous_state - get the state just before the EOB char was reached */
1223
+
1224
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1225
+ {
1226
+ yy_state_type yy_current_state;
1227
+ char *yy_cp;
1228
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1229
+
1230
+ yy_current_state = yyg->yy_start;
1231
+
1232
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1233
+ {
1234
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1235
+ if ( yy_accept[yy_current_state] )
1236
+ {
1237
+ yyg->yy_last_accepting_state = yy_current_state;
1238
+ yyg->yy_last_accepting_cpos = yy_cp;
1239
+ }
1240
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1241
+ {
1242
+ yy_current_state = (int) yy_def[yy_current_state];
1243
+ if ( yy_current_state >= 52 )
1244
+ yy_c = yy_meta[(unsigned int) yy_c];
1245
+ }
1246
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1247
+ }
1248
+
1249
+ return yy_current_state;
1250
+ }
1251
+
1252
+ /* yy_try_NUL_trans - try to make a transition on the NUL character
1253
+ *
1254
+ * synopsis
1255
+ * next_state = yy_try_NUL_trans( current_state );
1256
+ */
1257
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1258
+ {
1259
+ int yy_is_jam;
1260
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1261
+ char *yy_cp = yyg->yy_c_buf_p;
1262
+
1263
+ YY_CHAR yy_c = 1;
1264
+ if ( yy_accept[yy_current_state] )
1265
+ {
1266
+ yyg->yy_last_accepting_state = yy_current_state;
1267
+ yyg->yy_last_accepting_cpos = yy_cp;
1268
+ }
1269
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1270
+ {
1271
+ yy_current_state = (int) yy_def[yy_current_state];
1272
+ if ( yy_current_state >= 52 )
1273
+ yy_c = yy_meta[(unsigned int) yy_c];
1274
+ }
1275
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
1276
+ yy_is_jam = (yy_current_state == 51);
1277
+
1278
+ (void)yyg;
1279
+ return yy_is_jam ? 0 : yy_current_state;
1280
+ }
1281
+
1282
+ #ifndef YY_NO_UNPUT
1283
+
1284
+ static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
1285
+ {
1286
+ char *yy_cp;
1287
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1288
+
1289
+ yy_cp = yyg->yy_c_buf_p;
1290
+
1291
+ /* undo effects of setting up yytext */
1292
+ *yy_cp = yyg->yy_hold_char;
1293
+
1294
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1295
+ { /* need to shift things up to make room */
1296
+ /* +2 for EOB chars. */
1297
+ int number_to_move = yyg->yy_n_chars + 2;
1298
+ char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1299
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1300
+ char *source =
1301
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1302
+
1303
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1304
+ *--dest = *--source;
1305
+
1306
+ yy_cp += (int) (dest - source);
1307
+ yy_bp += (int) (dest - source);
1308
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1309
+ yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1310
+
1311
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1312
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
1313
+ }
1314
+
1315
+ *--yy_cp = (char) c;
1316
+
1317
+ yyg->yytext_ptr = yy_bp;
1318
+ yyg->yy_hold_char = *yy_cp;
1319
+ yyg->yy_c_buf_p = yy_cp;
1320
+ }
1321
+
1322
+ #endif
1323
+
1324
+ #ifndef YY_NO_INPUT
1325
+ #ifdef __cplusplus
1326
+ static int yyinput (yyscan_t yyscanner)
1327
+ #else
1328
+ static int input (yyscan_t yyscanner)
1329
+ #endif
1330
+
1331
+ {
1332
+ int c;
1333
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1334
+
1335
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1336
+
1337
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1338
+ {
1339
+ /* yy_c_buf_p now points to the character we want to return.
1340
+ * If this occurs *before* the EOB characters, then it's a
1341
+ * valid NUL; if not, then we've hit the end of the buffer.
1342
+ */
1343
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1344
+ /* This was really a NUL. */
1345
+ *yyg->yy_c_buf_p = '\0';
1346
+
1347
+ else
1348
+ { /* need more input */
1349
+ int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1350
+ ++yyg->yy_c_buf_p;
1351
+
1352
+ switch ( yy_get_next_buffer( yyscanner ) )
1353
+ {
1354
+ case EOB_ACT_LAST_MATCH:
1355
+ /* This happens because yy_g_n_b()
1356
+ * sees that we've accumulated a
1357
+ * token and flags that we need to
1358
+ * try matching the token before
1359
+ * proceeding. But for input(),
1360
+ * there's no matching to consider.
1361
+ * So convert the EOB_ACT_LAST_MATCH
1362
+ * to EOB_ACT_END_OF_FILE.
1363
+ */
1364
+
1365
+ /* Reset buffer status. */
1366
+ freesasa_yyrestart(yyin ,yyscanner);
1367
+
1368
+ /*FALLTHROUGH*/
1369
+
1370
+ case EOB_ACT_END_OF_FILE:
1371
+ {
1372
+ if ( freesasa_yywrap(yyscanner ) )
1373
+ return 0;
1374
+
1375
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
1376
+ YY_NEW_FILE;
1377
+ #ifdef __cplusplus
1378
+ return yyinput(yyscanner);
1379
+ #else
1380
+ return input(yyscanner);
1381
+ #endif
1382
+ }
1383
+
1384
+ case EOB_ACT_CONTINUE_SCAN:
1385
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1386
+ break;
1387
+ }
1388
+ }
1389
+ }
1390
+
1391
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1392
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1393
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1394
+
1395
+ return c;
1396
+ }
1397
+ #endif /* ifndef YY_NO_INPUT */
1398
+
1399
+ /** Immediately switch to a different input stream.
1400
+ * @param input_file A readable stream.
1401
+ * @param yyscanner The scanner object.
1402
+ * @note This function does not reset the start condition to @c INITIAL .
1403
+ */
1404
+ void freesasa_yyrestart (FILE * input_file , yyscan_t yyscanner)
1405
+ {
1406
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1407
+
1408
+ if ( ! YY_CURRENT_BUFFER ){
1409
+ freesasa_yyensure_buffer_stack (yyscanner);
1410
+ YY_CURRENT_BUFFER_LVALUE =
1411
+ freesasa_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1412
+ }
1413
+
1414
+ freesasa_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1415
+ freesasa_yy_load_buffer_state(yyscanner );
1416
+ }
1417
+
1418
+ /** Switch to a different input buffer.
1419
+ * @param new_buffer The new input buffer.
1420
+ * @param yyscanner The scanner object.
1421
+ */
1422
+ void freesasa_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1423
+ {
1424
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1425
+
1426
+ /* TODO. We should be able to replace this entire function body
1427
+ * with
1428
+ * freesasa_yypop_buffer_state();
1429
+ * freesasa_yypush_buffer_state(new_buffer);
1430
+ */
1431
+ freesasa_yyensure_buffer_stack (yyscanner);
1432
+ if ( YY_CURRENT_BUFFER == new_buffer )
1433
+ return;
1434
+
1435
+ if ( YY_CURRENT_BUFFER )
1436
+ {
1437
+ /* Flush out information for old buffer. */
1438
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1439
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1440
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1441
+ }
1442
+
1443
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1444
+ freesasa_yy_load_buffer_state(yyscanner );
1445
+
1446
+ /* We don't actually know whether we did this switch during
1447
+ * EOF (freesasa_yywrap()) processing, but the only time this flag
1448
+ * is looked at is after freesasa_yywrap() is called, so it's safe
1449
+ * to go ahead and always set it.
1450
+ */
1451
+ yyg->yy_did_buffer_switch_on_eof = 1;
1452
+ }
1453
+
1454
+ static void freesasa_yy_load_buffer_state (yyscan_t yyscanner)
1455
+ {
1456
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1457
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1458
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1459
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1460
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
1461
+ }
1462
+
1463
+ /** Allocate and initialize an input buffer state.
1464
+ * @param file A readable stream.
1465
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1466
+ * @param yyscanner The scanner object.
1467
+ * @return the allocated buffer state.
1468
+ */
1469
+ YY_BUFFER_STATE freesasa_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1470
+ {
1471
+ YY_BUFFER_STATE b;
1472
+
1473
+ b = (YY_BUFFER_STATE) freesasa_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1474
+ if ( ! b )
1475
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yy_create_buffer()" );
1476
+
1477
+ b->yy_buf_size = (yy_size_t)size;
1478
+
1479
+ /* yy_ch_buf has to be 2 characters longer than the size given because
1480
+ * we need to put in 2 end-of-buffer characters.
1481
+ */
1482
+ b->yy_ch_buf = (char *) freesasa_yyalloc(b->yy_buf_size + 2 ,yyscanner );
1483
+ if ( ! b->yy_ch_buf )
1484
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yy_create_buffer()" );
1485
+
1486
+ b->yy_is_our_buffer = 1;
1487
+
1488
+ freesasa_yy_init_buffer(b,file ,yyscanner);
1489
+
1490
+ return b;
1491
+ }
1492
+
1493
+ /** Destroy the buffer.
1494
+ * @param b a buffer created with freesasa_yy_create_buffer()
1495
+ * @param yyscanner The scanner object.
1496
+ */
1497
+ void freesasa_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1498
+ {
1499
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1500
+
1501
+ if ( ! b )
1502
+ return;
1503
+
1504
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1505
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1506
+
1507
+ if ( b->yy_is_our_buffer )
1508
+ freesasa_yyfree((void *) b->yy_ch_buf ,yyscanner );
1509
+
1510
+ freesasa_yyfree((void *) b ,yyscanner );
1511
+ }
1512
+
1513
+ /* Initializes or reinitializes a buffer.
1514
+ * This function is sometimes called more than once on the same buffer,
1515
+ * such as during a freesasa_yyrestart() or at EOF.
1516
+ */
1517
+ static void freesasa_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1518
+
1519
+ {
1520
+ int oerrno = errno;
1521
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1522
+
1523
+ freesasa_yy_flush_buffer(b ,yyscanner);
1524
+
1525
+ b->yy_input_file = file;
1526
+ b->yy_fill_buffer = 1;
1527
+
1528
+ /* If b is the current buffer, then freesasa_yy_init_buffer was _probably_
1529
+ * called from freesasa_yyrestart() or through yy_get_next_buffer.
1530
+ * In that case, we don't want to reset the lineno or column.
1531
+ */
1532
+ if (b != YY_CURRENT_BUFFER){
1533
+ b->yy_bs_lineno = 1;
1534
+ b->yy_bs_column = 0;
1535
+ }
1536
+
1537
+ b->yy_is_interactive = 0;
1538
+
1539
+ errno = oerrno;
1540
+ }
1541
+
1542
+ /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1543
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1544
+ * @param yyscanner The scanner object.
1545
+ */
1546
+ void freesasa_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1547
+ {
1548
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1549
+ if ( ! b )
1550
+ return;
1551
+
1552
+ b->yy_n_chars = 0;
1553
+
1554
+ /* We always need two end-of-buffer characters. The first causes
1555
+ * a transition to the end-of-buffer state. The second causes
1556
+ * a jam in that state.
1557
+ */
1558
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1559
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1560
+
1561
+ b->yy_buf_pos = &b->yy_ch_buf[0];
1562
+
1563
+ b->yy_at_bol = 1;
1564
+ b->yy_buffer_status = YY_BUFFER_NEW;
1565
+
1566
+ if ( b == YY_CURRENT_BUFFER )
1567
+ freesasa_yy_load_buffer_state(yyscanner );
1568
+ }
1569
+
1570
+ /** Pushes the new state onto the stack. The new state becomes
1571
+ * the current state. This function will allocate the stack
1572
+ * if necessary.
1573
+ * @param new_buffer The new state.
1574
+ * @param yyscanner The scanner object.
1575
+ */
1576
+ void freesasa_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1577
+ {
1578
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1579
+ if (new_buffer == NULL)
1580
+ return;
1581
+
1582
+ freesasa_yyensure_buffer_stack(yyscanner);
1583
+
1584
+ /* This block is copied from freesasa_yy_switch_to_buffer. */
1585
+ if ( YY_CURRENT_BUFFER )
1586
+ {
1587
+ /* Flush out information for old buffer. */
1588
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1589
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1590
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1591
+ }
1592
+
1593
+ /* Only push if top exists. Otherwise, replace top. */
1594
+ if (YY_CURRENT_BUFFER)
1595
+ yyg->yy_buffer_stack_top++;
1596
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1597
+
1598
+ /* copied from freesasa_yy_switch_to_buffer. */
1599
+ freesasa_yy_load_buffer_state(yyscanner );
1600
+ yyg->yy_did_buffer_switch_on_eof = 1;
1601
+ }
1602
+
1603
+ /** Removes and deletes the top of the stack, if present.
1604
+ * The next element becomes the new top.
1605
+ * @param yyscanner The scanner object.
1606
+ */
1607
+ void freesasa_yypop_buffer_state (yyscan_t yyscanner)
1608
+ {
1609
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1610
+ if (!YY_CURRENT_BUFFER)
1611
+ return;
1612
+
1613
+ freesasa_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1614
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1615
+ if (yyg->yy_buffer_stack_top > 0)
1616
+ --yyg->yy_buffer_stack_top;
1617
+
1618
+ if (YY_CURRENT_BUFFER) {
1619
+ freesasa_yy_load_buffer_state(yyscanner );
1620
+ yyg->yy_did_buffer_switch_on_eof = 1;
1621
+ }
1622
+ }
1623
+
1624
+ /* Allocates the stack if it does not exist.
1625
+ * Guarantees space for at least one push.
1626
+ */
1627
+ static void freesasa_yyensure_buffer_stack (yyscan_t yyscanner)
1628
+ {
1629
+ int num_to_alloc;
1630
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1631
+
1632
+ if (!yyg->yy_buffer_stack) {
1633
+
1634
+ /* First allocation is just for 2 elements, since we don't know if this
1635
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
1636
+ * immediate realloc on the next call.
1637
+ */
1638
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1639
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)freesasa_yyalloc
1640
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
1641
+ , yyscanner);
1642
+ if ( ! yyg->yy_buffer_stack )
1643
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yyensure_buffer_stack()" );
1644
+
1645
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1646
+
1647
+ yyg->yy_buffer_stack_max = num_to_alloc;
1648
+ yyg->yy_buffer_stack_top = 0;
1649
+ return;
1650
+ }
1651
+
1652
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1653
+
1654
+ /* Increase the buffer to prepare for a possible push. */
1655
+ yy_size_t grow_size = 8 /* arbitrary grow size */;
1656
+
1657
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1658
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)freesasa_yyrealloc
1659
+ (yyg->yy_buffer_stack,
1660
+ num_to_alloc * sizeof(struct yy_buffer_state*)
1661
+ , yyscanner);
1662
+ if ( ! yyg->yy_buffer_stack )
1663
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yyensure_buffer_stack()" );
1664
+
1665
+ /* zero only the new slots.*/
1666
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1667
+ yyg->yy_buffer_stack_max = num_to_alloc;
1668
+ }
1669
+ }
1670
+
1671
+ /** Setup the input buffer state to scan directly from a user-specified character buffer.
1672
+ * @param base the character buffer
1673
+ * @param size the size in bytes of the character buffer
1674
+ * @param yyscanner The scanner object.
1675
+ * @return the newly allocated buffer state object.
1676
+ */
1677
+ YY_BUFFER_STATE freesasa_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1678
+ {
1679
+ YY_BUFFER_STATE b;
1680
+
1681
+ if ( size < 2 ||
1682
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
1683
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
1684
+ /* They forgot to leave room for the EOB's. */
1685
+ return NULL;
1686
+
1687
+ b = (YY_BUFFER_STATE) freesasa_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1688
+ if ( ! b )
1689
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yy_scan_buffer()" );
1690
+
1691
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1692
+ b->yy_buf_pos = b->yy_ch_buf = base;
1693
+ b->yy_is_our_buffer = 0;
1694
+ b->yy_input_file = NULL;
1695
+ b->yy_n_chars = b->yy_buf_size;
1696
+ b->yy_is_interactive = 0;
1697
+ b->yy_at_bol = 1;
1698
+ b->yy_fill_buffer = 0;
1699
+ b->yy_buffer_status = YY_BUFFER_NEW;
1700
+
1701
+ freesasa_yy_switch_to_buffer(b ,yyscanner );
1702
+
1703
+ return b;
1704
+ }
1705
+
1706
+ /** Setup the input buffer state to scan a string. The next call to freesasa_yylex() will
1707
+ * scan from a @e copy of @a str.
1708
+ * @param yystr a NUL-terminated string to scan
1709
+ * @param yyscanner The scanner object.
1710
+ * @return the newly allocated buffer state object.
1711
+ * @note If you want to scan bytes that may contain NUL values, then use
1712
+ * freesasa_yy_scan_bytes() instead.
1713
+ */
1714
+ YY_BUFFER_STATE freesasa_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1715
+ {
1716
+
1717
+ return freesasa_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
1718
+ }
1719
+
1720
+ /** Setup the input buffer state to scan the given bytes. The next call to freesasa_yylex() will
1721
+ * scan from a @e copy of @a bytes.
1722
+ * @param yybytes the byte buffer to scan
1723
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1724
+ * @param yyscanner The scanner object.
1725
+ * @return the newly allocated buffer state object.
1726
+ */
1727
+ YY_BUFFER_STATE freesasa_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
1728
+ {
1729
+ YY_BUFFER_STATE b;
1730
+ char *buf;
1731
+ yy_size_t n;
1732
+ yy_size_t i;
1733
+
1734
+ /* Get memory for full buffer, including space for trailing EOB's. */
1735
+ n = (yy_size_t) _yybytes_len + 2;
1736
+ buf = (char *) freesasa_yyalloc(n ,yyscanner );
1737
+ if ( ! buf )
1738
+ YY_FATAL_ERROR( "out of dynamic memory in freesasa_yy_scan_bytes()" );
1739
+
1740
+ for ( i = 0; i < _yybytes_len; ++i )
1741
+ buf[i] = yybytes[i];
1742
+
1743
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1744
+
1745
+ b = freesasa_yy_scan_buffer(buf,n ,yyscanner);
1746
+ if ( ! b )
1747
+ YY_FATAL_ERROR( "bad buffer in freesasa_yy_scan_bytes()" );
1748
+
1749
+ /* It's okay to grow etc. this buffer, and we should throw it
1750
+ * away when we're done.
1751
+ */
1752
+ b->yy_is_our_buffer = 1;
1753
+
1754
+ return b;
1755
+ }
1756
+
1757
+ #ifndef YY_EXIT_FAILURE
1758
+ #define YY_EXIT_FAILURE 2
1759
+ #endif
1760
+
1761
+ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1762
+ {
1763
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1764
+ (void)yyg;
1765
+ (void) fprintf( stderr, "%s\n", msg );
1766
+ exit( YY_EXIT_FAILURE );
1767
+ }
1768
+
1769
+ /* Redefine yyless() so it works in section 3 code. */
1770
+
1771
+ #undef yyless
1772
+ #define yyless(n) \
1773
+ do \
1774
+ { \
1775
+ /* Undo effects of setting up yytext. */ \
1776
+ int yyless_macro_arg = (n); \
1777
+ YY_LESS_LINENO(yyless_macro_arg);\
1778
+ yytext[yyleng] = yyg->yy_hold_char; \
1779
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1780
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1781
+ *yyg->yy_c_buf_p = '\0'; \
1782
+ yyleng = yyless_macro_arg; \
1783
+ } \
1784
+ while ( 0 )
1785
+
1786
+ /* Accessor methods (get/set functions) to struct members. */
1787
+
1788
+ /** Get the user-defined data for this scanner.
1789
+ * @param yyscanner The scanner object.
1790
+ */
1791
+ YY_EXTRA_TYPE freesasa_yyget_extra (yyscan_t yyscanner)
1792
+ {
1793
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1794
+ return yyextra;
1795
+ }
1796
+
1797
+ /** Get the current line number.
1798
+ * @param yyscanner The scanner object.
1799
+ */
1800
+ int freesasa_yyget_lineno (yyscan_t yyscanner)
1801
+ {
1802
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1803
+
1804
+ if (! YY_CURRENT_BUFFER)
1805
+ return 0;
1806
+
1807
+ return yylineno;
1808
+ }
1809
+
1810
+ /** Get the current column number.
1811
+ * @param yyscanner The scanner object.
1812
+ */
1813
+ int freesasa_yyget_column (yyscan_t yyscanner)
1814
+ {
1815
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1816
+
1817
+ if (! YY_CURRENT_BUFFER)
1818
+ return 0;
1819
+
1820
+ return yycolumn;
1821
+ }
1822
+
1823
+ /** Get the input stream.
1824
+ * @param yyscanner The scanner object.
1825
+ */
1826
+ FILE *freesasa_yyget_in (yyscan_t yyscanner)
1827
+ {
1828
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1829
+ return yyin;
1830
+ }
1831
+
1832
+ /** Get the output stream.
1833
+ * @param yyscanner The scanner object.
1834
+ */
1835
+ FILE *freesasa_yyget_out (yyscan_t yyscanner)
1836
+ {
1837
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1838
+ return yyout;
1839
+ }
1840
+
1841
+ /** Get the length of the current token.
1842
+ * @param yyscanner The scanner object.
1843
+ */
1844
+ int freesasa_yyget_leng (yyscan_t yyscanner)
1845
+ {
1846
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1847
+ return yyleng;
1848
+ }
1849
+
1850
+ /** Get the current token.
1851
+ * @param yyscanner The scanner object.
1852
+ */
1853
+
1854
+ char *freesasa_yyget_text (yyscan_t yyscanner)
1855
+ {
1856
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1857
+ return yytext;
1858
+ }
1859
+
1860
+ /** Set the user-defined data. This data is never touched by the scanner.
1861
+ * @param user_defined The data to be associated with this scanner.
1862
+ * @param yyscanner The scanner object.
1863
+ */
1864
+ void freesasa_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
1865
+ {
1866
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1867
+ yyextra = user_defined ;
1868
+ }
1869
+
1870
+ /** Set the current line number.
1871
+ * @param _line_number line number
1872
+ * @param yyscanner The scanner object.
1873
+ */
1874
+ void freesasa_yyset_lineno (int _line_number , yyscan_t yyscanner)
1875
+ {
1876
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1877
+
1878
+ /* lineno is only valid if an input buffer exists. */
1879
+ if (! YY_CURRENT_BUFFER )
1880
+ YY_FATAL_ERROR( "freesasa_yyset_lineno called with no buffer" );
1881
+
1882
+ yylineno = _line_number;
1883
+ }
1884
+
1885
+ /** Set the current column.
1886
+ * @param _column_no column number
1887
+ * @param yyscanner The scanner object.
1888
+ */
1889
+ void freesasa_yyset_column (int _column_no , yyscan_t yyscanner)
1890
+ {
1891
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1892
+
1893
+ /* column is only valid if an input buffer exists. */
1894
+ if (! YY_CURRENT_BUFFER )
1895
+ YY_FATAL_ERROR( "freesasa_yyset_column called with no buffer" );
1896
+
1897
+ yycolumn = _column_no;
1898
+ }
1899
+
1900
+ /** Set the input stream. This does not discard the current
1901
+ * input buffer.
1902
+ * @param _in_str A readable stream.
1903
+ * @param yyscanner The scanner object.
1904
+ * @see freesasa_yy_switch_to_buffer
1905
+ */
1906
+ void freesasa_yyset_in (FILE * _in_str , yyscan_t yyscanner)
1907
+ {
1908
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1909
+ yyin = _in_str ;
1910
+ }
1911
+
1912
+ void freesasa_yyset_out (FILE * _out_str , yyscan_t yyscanner)
1913
+ {
1914
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1915
+ yyout = _out_str ;
1916
+ }
1917
+
1918
+ int freesasa_yyget_debug (yyscan_t yyscanner)
1919
+ {
1920
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1921
+ return yy_flex_debug;
1922
+ }
1923
+
1924
+ void freesasa_yyset_debug (int _bdebug , yyscan_t yyscanner)
1925
+ {
1926
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1927
+ yy_flex_debug = _bdebug ;
1928
+ }
1929
+
1930
+ /* Accessor methods for yylval and yylloc */
1931
+
1932
+ YYSTYPE * freesasa_yyget_lval (yyscan_t yyscanner)
1933
+ {
1934
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1935
+ return yylval;
1936
+ }
1937
+
1938
+ void freesasa_yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
1939
+ {
1940
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1941
+ yylval = yylval_param;
1942
+ }
1943
+
1944
+ /* User-visible API */
1945
+
1946
+ /* freesasa_yylex_init is special because it creates the scanner itself, so it is
1947
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
1948
+ * That's why we explicitly handle the declaration, instead of using our macros.
1949
+ */
1950
+
1951
+ int freesasa_yylex_init(yyscan_t* ptr_yy_globals)
1952
+
1953
+ {
1954
+ if (ptr_yy_globals == NULL){
1955
+ errno = EINVAL;
1956
+ return 1;
1957
+ }
1958
+
1959
+ *ptr_yy_globals = (yyscan_t) freesasa_yyalloc ( sizeof( struct yyguts_t ), NULL );
1960
+
1961
+ if (*ptr_yy_globals == NULL){
1962
+ errno = ENOMEM;
1963
+ return 1;
1964
+ }
1965
+
1966
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
1967
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
1968
+
1969
+ return yy_init_globals ( *ptr_yy_globals );
1970
+ }
1971
+
1972
+ /* freesasa_yylex_init_extra has the same functionality as freesasa_yylex_init, but follows the
1973
+ * convention of taking the scanner as the last argument. Note however, that
1974
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
1975
+ * is the reason, too, why this function also must handle its own declaration).
1976
+ * The user defined value in the first argument will be available to freesasa_yyalloc in
1977
+ * the yyextra field.
1978
+ */
1979
+
1980
+ int freesasa_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
1981
+
1982
+ {
1983
+ struct yyguts_t dummy_yyguts;
1984
+
1985
+ freesasa_yyset_extra (yy_user_defined, &dummy_yyguts);
1986
+
1987
+ if (ptr_yy_globals == NULL){
1988
+ errno = EINVAL;
1989
+ return 1;
1990
+ }
1991
+
1992
+ *ptr_yy_globals = (yyscan_t) freesasa_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
1993
+
1994
+ if (*ptr_yy_globals == NULL){
1995
+ errno = ENOMEM;
1996
+ return 1;
1997
+ }
1998
+
1999
+ /* By setting to 0xAA, we expose bugs in
2000
+ yy_init_globals. Leave at 0x00 for releases. */
2001
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2002
+
2003
+ freesasa_yyset_extra (yy_user_defined, *ptr_yy_globals);
2004
+
2005
+ return yy_init_globals ( *ptr_yy_globals );
2006
+ }
2007
+
2008
+ static int yy_init_globals (yyscan_t yyscanner)
2009
+ {
2010
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2011
+ /* Initialization is the same as for the non-reentrant scanner.
2012
+ * This function is called from freesasa_yylex_destroy(), so don't allocate here.
2013
+ */
2014
+
2015
+ yyg->yy_buffer_stack = NULL;
2016
+ yyg->yy_buffer_stack_top = 0;
2017
+ yyg->yy_buffer_stack_max = 0;
2018
+ yyg->yy_c_buf_p = NULL;
2019
+ yyg->yy_init = 0;
2020
+ yyg->yy_start = 0;
2021
+
2022
+ yyg->yy_start_stack_ptr = 0;
2023
+ yyg->yy_start_stack_depth = 0;
2024
+ yyg->yy_start_stack = NULL;
2025
+
2026
+ /* Defined in main.c */
2027
+ #ifdef YY_STDINIT
2028
+ yyin = stdin;
2029
+ yyout = stdout;
2030
+ #else
2031
+ yyin = NULL;
2032
+ yyout = NULL;
2033
+ #endif
2034
+
2035
+ /* For future reference: Set errno on error, since we are called by
2036
+ * freesasa_yylex_init()
2037
+ */
2038
+ return 0;
2039
+ }
2040
+
2041
+ /* freesasa_yylex_destroy is for both reentrant and non-reentrant scanners. */
2042
+ int freesasa_yylex_destroy (yyscan_t yyscanner)
2043
+ {
2044
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2045
+
2046
+ /* Pop the buffer stack, destroying each element. */
2047
+ while(YY_CURRENT_BUFFER){
2048
+ freesasa_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2049
+ YY_CURRENT_BUFFER_LVALUE = NULL;
2050
+ freesasa_yypop_buffer_state(yyscanner);
2051
+ }
2052
+
2053
+ /* Destroy the stack itself. */
2054
+ freesasa_yyfree(yyg->yy_buffer_stack ,yyscanner);
2055
+ yyg->yy_buffer_stack = NULL;
2056
+
2057
+ /* Destroy the start condition stack. */
2058
+ freesasa_yyfree(yyg->yy_start_stack ,yyscanner );
2059
+ yyg->yy_start_stack = NULL;
2060
+
2061
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
2062
+ * freesasa_yylex() is called, initialization will occur. */
2063
+ yy_init_globals( yyscanner);
2064
+
2065
+ /* Destroy the main struct (reentrant only). */
2066
+ freesasa_yyfree ( yyscanner , yyscanner );
2067
+ yyscanner = NULL;
2068
+ return 0;
2069
+ }
2070
+
2071
+ /*
2072
+ * Internal utility routines.
2073
+ */
2074
+
2075
+ #ifndef yytext_ptr
2076
+ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2077
+ {
2078
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2079
+ (void)yyg;
2080
+
2081
+ int i;
2082
+ for ( i = 0; i < n; ++i )
2083
+ s1[i] = s2[i];
2084
+ }
2085
+ #endif
2086
+
2087
+ #ifdef YY_NEED_STRLEN
2088
+ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2089
+ {
2090
+ int n;
2091
+ for ( n = 0; s[n]; ++n )
2092
+ ;
2093
+
2094
+ return n;
2095
+ }
2096
+ #endif
2097
+
2098
+ void *freesasa_yyalloc (yy_size_t size , yyscan_t yyscanner)
2099
+ {
2100
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2101
+ (void)yyg;
2102
+ return malloc(size);
2103
+ }
2104
+
2105
+ void *freesasa_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2106
+ {
2107
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2108
+ (void)yyg;
2109
+
2110
+ /* The cast to (char *) in the following accommodates both
2111
+ * implementations that use char* generic pointers, and those
2112
+ * that use void* generic pointers. It works with the latter
2113
+ * because both ANSI C and C++ allow castless assignment from
2114
+ * any pointer type to void*, and deal with argument conversions
2115
+ * as though doing an assignment.
2116
+ */
2117
+ return realloc(ptr, size);
2118
+ }
2119
+
2120
+ void freesasa_yyfree (void * ptr , yyscan_t yyscanner)
2121
+ {
2122
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2123
+ (void)yyg;
2124
+ free( (char *) ptr ); /* see freesasa_yyrealloc() for (char *) cast */
2125
+ }
2126
+
2127
+ #define YYTABLES_NAME "yytables"
2128
+
2129
+ #line 55 "lexer.l"
.venv_haddock/include/site/python3.12/freesasa/lexer.h ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef freesasa_yyHEADER_H
2
+ #define freesasa_yyHEADER_H 1
3
+ #define freesasa_yyIN_HEADER 1
4
+
5
+ #line 6 "lexer.h"
6
+
7
+ #line 8 "lexer.h"
8
+
9
+ #define YY_INT_ALIGNED short int
10
+
11
+ /* A lexical scanner generated by flex */
12
+
13
+ #define FLEX_SCANNER
14
+ #define YY_FLEX_MAJOR_VERSION 2
15
+ #define YY_FLEX_MINOR_VERSION 6
16
+ #define YY_FLEX_SUBMINOR_VERSION 1
17
+ #if YY_FLEX_SUBMINOR_VERSION > 0
18
+ #define FLEX_BETA
19
+ #endif
20
+
21
+ /* First, we deal with platform-specific or compiler-specific issues. */
22
+
23
+ /* begin standard C headers. */
24
+ #include <stdio.h>
25
+ #include <string.h>
26
+ #include <errno.h>
27
+ #include <stdlib.h>
28
+
29
+ /* end standard C headers. */
30
+
31
+ /* flex integer type definitions */
32
+
33
+ #ifndef FLEXINT_H
34
+ #define FLEXINT_H
35
+
36
+ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
37
+
38
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
39
+
40
+ /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
41
+ * if you want the limit (max/min) macros for int types.
42
+ */
43
+ #ifndef __STDC_LIMIT_MACROS
44
+ #define __STDC_LIMIT_MACROS 1
45
+ #endif
46
+
47
+ #include <inttypes.h>
48
+ typedef int8_t flex_int8_t;
49
+ typedef uint8_t flex_uint8_t;
50
+ typedef int16_t flex_int16_t;
51
+ typedef uint16_t flex_uint16_t;
52
+ typedef int32_t flex_int32_t;
53
+ typedef uint32_t flex_uint32_t;
54
+ #else
55
+ typedef signed char flex_int8_t;
56
+ typedef short int flex_int16_t;
57
+ typedef int flex_int32_t;
58
+ typedef unsigned char flex_uint8_t;
59
+ typedef unsigned short int flex_uint16_t;
60
+ typedef unsigned int flex_uint32_t;
61
+
62
+ /* Limits of integral types. */
63
+ #ifndef INT8_MIN
64
+ #define INT8_MIN (-128)
65
+ #endif
66
+ #ifndef INT16_MIN
67
+ #define INT16_MIN (-32767-1)
68
+ #endif
69
+ #ifndef INT32_MIN
70
+ #define INT32_MIN (-2147483647-1)
71
+ #endif
72
+ #ifndef INT8_MAX
73
+ #define INT8_MAX (127)
74
+ #endif
75
+ #ifndef INT16_MAX
76
+ #define INT16_MAX (32767)
77
+ #endif
78
+ #ifndef INT32_MAX
79
+ #define INT32_MAX (2147483647)
80
+ #endif
81
+ #ifndef UINT8_MAX
82
+ #define UINT8_MAX (255U)
83
+ #endif
84
+ #ifndef UINT16_MAX
85
+ #define UINT16_MAX (65535U)
86
+ #endif
87
+ #ifndef UINT32_MAX
88
+ #define UINT32_MAX (4294967295U)
89
+ #endif
90
+
91
+ #endif /* ! C99 */
92
+
93
+ #endif /* ! FLEXINT_H */
94
+
95
+ /* TODO: this is always defined, so inline it */
96
+ #define yyconst const
97
+
98
+ #if defined(__GNUC__) && __GNUC__ >= 3
99
+ #define yynoreturn __attribute__((__noreturn__))
100
+ #else
101
+ #define yynoreturn
102
+ #endif
103
+
104
+ /* An opaque pointer. */
105
+ #ifndef YY_TYPEDEF_YY_SCANNER_T
106
+ #define YY_TYPEDEF_YY_SCANNER_T
107
+ typedef void* yyscan_t;
108
+ #endif
109
+
110
+ /* For convenience, these vars (plus the bison vars far below)
111
+ are macros in the reentrant scanner. */
112
+ #define yyin yyg->yyin_r
113
+ #define yyout yyg->yyout_r
114
+ #define yyextra yyg->yyextra_r
115
+ #define yyleng yyg->yyleng_r
116
+ #define yytext yyg->yytext_r
117
+ #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
118
+ #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
119
+ #define yy_flex_debug yyg->yy_flex_debug_r
120
+
121
+ /* Size of default input buffer. */
122
+ #ifndef YY_BUF_SIZE
123
+ #ifdef __ia64__
124
+ /* On IA-64, the buffer size is 16k, not 8k.
125
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
126
+ * Ditto for the __ia64__ case accordingly.
127
+ */
128
+ #define YY_BUF_SIZE 32768
129
+ #else
130
+ #define YY_BUF_SIZE 16384
131
+ #endif /* __ia64__ */
132
+ #endif
133
+
134
+ #ifndef YY_TYPEDEF_YY_BUFFER_STATE
135
+ #define YY_TYPEDEF_YY_BUFFER_STATE
136
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
137
+ #endif
138
+
139
+ #ifndef YY_TYPEDEF_YY_SIZE_T
140
+ #define YY_TYPEDEF_YY_SIZE_T
141
+ typedef size_t yy_size_t;
142
+ #endif
143
+
144
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
145
+ #define YY_STRUCT_YY_BUFFER_STATE
146
+ struct yy_buffer_state
147
+ {
148
+ FILE *yy_input_file;
149
+
150
+ char *yy_ch_buf; /* input buffer */
151
+ char *yy_buf_pos; /* current position in input buffer */
152
+
153
+ /* Size of input buffer in bytes, not including room for EOB
154
+ * characters.
155
+ */
156
+ int yy_buf_size;
157
+
158
+ /* Number of characters read into yy_ch_buf, not including EOB
159
+ * characters.
160
+ */
161
+ int yy_n_chars;
162
+
163
+ /* Whether we "own" the buffer - i.e., we know we created it,
164
+ * and can realloc() it to grow it, and should free() it to
165
+ * delete it.
166
+ */
167
+ int yy_is_our_buffer;
168
+
169
+ /* Whether this is an "interactive" input source; if so, and
170
+ * if we're using stdio for input, then we want to use getc()
171
+ * instead of fread(), to make sure we stop fetching input after
172
+ * each newline.
173
+ */
174
+ int yy_is_interactive;
175
+
176
+ /* Whether we're considered to be at the beginning of a line.
177
+ * If so, '^' rules will be active on the next match, otherwise
178
+ * not.
179
+ */
180
+ int yy_at_bol;
181
+
182
+ int yy_bs_lineno; /**< The line count. */
183
+ int yy_bs_column; /**< The column count. */
184
+
185
+ /* Whether to try to fill the input buffer when we reach the
186
+ * end of it.
187
+ */
188
+ int yy_fill_buffer;
189
+
190
+ int yy_buffer_status;
191
+
192
+ };
193
+ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
194
+
195
+ void freesasa_yyrestart (FILE *input_file ,yyscan_t yyscanner );
196
+ void freesasa_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
197
+ YY_BUFFER_STATE freesasa_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
198
+ void freesasa_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
199
+ void freesasa_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
200
+ void freesasa_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
201
+ void freesasa_yypop_buffer_state (yyscan_t yyscanner );
202
+
203
+ YY_BUFFER_STATE freesasa_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
204
+ YY_BUFFER_STATE freesasa_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
205
+ YY_BUFFER_STATE freesasa_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
206
+
207
+ void *freesasa_yyalloc (yy_size_t ,yyscan_t yyscanner );
208
+ void *freesasa_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
209
+ void freesasa_yyfree (void * ,yyscan_t yyscanner );
210
+
211
+ #define freesasa_yywrap(yyscanner) (/*CONSTCOND*/1)
212
+ #define YY_SKIP_YYWRAP
213
+
214
+ #define yytext_ptr yytext_r
215
+
216
+ #ifdef YY_HEADER_EXPORT_START_CONDITIONS
217
+ #define INITIAL 0
218
+
219
+ #endif
220
+
221
+ #ifndef YY_EXTRA_TYPE
222
+ #define YY_EXTRA_TYPE void *
223
+ #endif
224
+
225
+ int freesasa_yylex_init (yyscan_t* scanner);
226
+
227
+ int freesasa_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
228
+
229
+ /* Accessor methods to globals.
230
+ These are made visible to non-reentrant scanners for convenience. */
231
+
232
+ int freesasa_yylex_destroy (yyscan_t yyscanner );
233
+
234
+ int freesasa_yyget_debug (yyscan_t yyscanner );
235
+
236
+ void freesasa_yyset_debug (int debug_flag ,yyscan_t yyscanner );
237
+
238
+ YY_EXTRA_TYPE freesasa_yyget_extra (yyscan_t yyscanner );
239
+
240
+ void freesasa_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
241
+
242
+ FILE *freesasa_yyget_in (yyscan_t yyscanner );
243
+
244
+ void freesasa_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
245
+
246
+ FILE *freesasa_yyget_out (yyscan_t yyscanner );
247
+
248
+ void freesasa_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
249
+
250
+ int freesasa_yyget_leng (yyscan_t yyscanner );
251
+
252
+ char *freesasa_yyget_text (yyscan_t yyscanner );
253
+
254
+ int freesasa_yyget_lineno (yyscan_t yyscanner );
255
+
256
+ void freesasa_yyset_lineno (int _line_number ,yyscan_t yyscanner );
257
+
258
+ int freesasa_yyget_column (yyscan_t yyscanner );
259
+
260
+ void freesasa_yyset_column (int _column_no ,yyscan_t yyscanner );
261
+
262
+ YYSTYPE * freesasa_yyget_lval (yyscan_t yyscanner );
263
+
264
+ void freesasa_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
265
+
266
+ /* Macros after this point can all be overridden by user definitions in
267
+ * section 1.
268
+ */
269
+
270
+ #ifndef YY_SKIP_YYWRAP
271
+ #ifdef __cplusplus
272
+ extern "C" int freesasa_yywrap (yyscan_t yyscanner );
273
+ #else
274
+ extern int freesasa_yywrap (yyscan_t yyscanner );
275
+ #endif
276
+ #endif
277
+
278
+ #ifndef yytext_ptr
279
+ static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
280
+ #endif
281
+
282
+ #ifdef YY_NEED_STRLEN
283
+ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
284
+ #endif
285
+
286
+ #ifndef YY_NO_INPUT
287
+
288
+ #endif
289
+
290
+ /* Amount of stuff to slurp up with each read. */
291
+ #ifndef YY_READ_BUF_SIZE
292
+ #ifdef __ia64__
293
+ /* On IA-64, the buffer size is 16k, not 8k */
294
+ #define YY_READ_BUF_SIZE 16384
295
+ #else
296
+ #define YY_READ_BUF_SIZE 8192
297
+ #endif /* __ia64__ */
298
+ #endif
299
+
300
+ /* Number of entries by which start-condition stack grows. */
301
+ #ifndef YY_START_STACK_INCR
302
+ #define YY_START_STACK_INCR 25
303
+ #endif
304
+
305
+ /* Default declaration of generated scanner - a define so the user can
306
+ * easily add parameters.
307
+ */
308
+ #ifndef YY_DECL
309
+ #define YY_DECL_IS_OURS 1
310
+
311
+ extern int freesasa_yylex \
312
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
313
+
314
+ #define YY_DECL int freesasa_yylex \
315
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
316
+ #endif /* !YY_DECL */
317
+
318
+ /* yy_get_previous_state - get the state just before the EOB char was reached */
319
+
320
+ #undef YY_NEW_FILE
321
+ #undef YY_FLUSH_BUFFER
322
+ #undef yy_set_bol
323
+ #undef yy_new_buffer
324
+ #undef yy_set_interactive
325
+ #undef YY_DO_BEFORE_ACTION
326
+
327
+ #ifdef YY_DECL_IS_OURS
328
+ #undef YY_DECL_IS_OURS
329
+ #undef YY_DECL
330
+ #endif
331
+
332
+ #line 55 "lexer.l"
333
+
334
+ #line 335 "lexer.h"
335
+ #undef freesasa_yyIN_HEADER
336
+ #endif /* freesasa_yyHEADER_H */
.venv_haddock/include/site/python3.12/freesasa/log.c ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <errno.h>
7
+ #include <stdlib.h>
8
+
9
+ #include "classifier.h"
10
+ #include "freesasa_internal.h"
11
+
12
+ /** to control error messages (used for debugging and testing) */
13
+ static freesasa_verbosity verbosity;
14
+
15
+ int freesasa_set_verbosity(freesasa_verbosity s)
16
+ {
17
+ if (s == FREESASA_V_NORMAL ||
18
+ s == FREESASA_V_NOWARNINGS ||
19
+ s == FREESASA_V_SILENT ||
20
+ s == FREESASA_V_DEBUG) {
21
+ verbosity = s;
22
+ return FREESASA_SUCCESS;
23
+ }
24
+ return FREESASA_WARN;
25
+ }
26
+
27
+ freesasa_verbosity
28
+ freesasa_get_verbosity(void)
29
+ {
30
+ return verbosity;
31
+ }
32
+
33
+ static int
34
+ write_result(FILE *log,
35
+ freesasa_node *result)
36
+ {
37
+ const char *name = NULL;
38
+ freesasa_node *structure = NULL, *chain = NULL;
39
+ const freesasa_nodearea *area = NULL;
40
+
41
+ assert(log);
42
+ assert(freesasa_node_type(result) == FREESASA_NODE_RESULT);
43
+
44
+ name = freesasa_node_name(result);
45
+ structure = freesasa_node_children(result);
46
+ assert(structure);
47
+ area = freesasa_node_area(structure);
48
+ assert(area);
49
+
50
+ fprintf(log, "\nINPUT\n");
51
+ if (name == NULL)
52
+ fprintf(log, "source : unknown\n");
53
+ else
54
+ fprintf(log, "source : %s\n", name);
55
+ fprintf(log, "chains : %s\n", freesasa_node_structure_chain_labels(structure));
56
+ fprintf(log, "model : %d\n", freesasa_node_structure_model(structure));
57
+ fprintf(log, "atoms : %d\n", freesasa_node_structure_n_atoms(structure));
58
+
59
+ fprintf(log, "\nRESULTS (A^2)\n");
60
+ fprintf(log, "Total : %10.2f\n", area->total);
61
+ fprintf(log, "Apolar : %10.2f\n", area->apolar);
62
+ fprintf(log, "Polar : %10.2f\n", area->polar);
63
+ if (area->unknown > 0) {
64
+ fprintf(log, "Unknown : %10.2f\n", area->unknown);
65
+ }
66
+
67
+ chain = freesasa_node_children(structure);
68
+ while (chain) {
69
+ area = freesasa_node_area(chain);
70
+ assert(area);
71
+ fprintf(log, "CHAIN %s : %10.2f\n", freesasa_node_name(chain), area->total);
72
+ chain = freesasa_node_next(chain);
73
+ }
74
+
75
+ fflush(log);
76
+ if (ferror(log)) {
77
+ return fail_msg(strerror(errno));
78
+ }
79
+
80
+ return FREESASA_SUCCESS;
81
+ }
82
+
83
+ static int
84
+ write_selections(FILE *log,
85
+ freesasa_node *result)
86
+ {
87
+ freesasa_node *structure = freesasa_node_children(result);
88
+ const freesasa_selection **selection;
89
+
90
+ while (structure) {
91
+ selection = freesasa_node_structure_selections(structure);
92
+ if (selection && *selection) {
93
+ fprintf(log, "\nSELECTIONS\n");
94
+ while (*selection) {
95
+ fprintf(log, "%s : %10.2f\n",
96
+ freesasa_selection_name(*selection),
97
+ freesasa_selection_area(*selection));
98
+ ++selection;
99
+ }
100
+ }
101
+ structure = freesasa_node_next(structure);
102
+ }
103
+
104
+ fflush(log);
105
+ if (ferror(log)) {
106
+ return fail_msg(strerror(errno));
107
+ }
108
+
109
+ return FREESASA_SUCCESS;
110
+ }
111
+
112
+ static int
113
+ write_parameters(FILE *log,
114
+ const freesasa_parameters *parameters)
115
+ {
116
+ const freesasa_parameters *p = parameters;
117
+
118
+ assert(log);
119
+
120
+ if (p == NULL) p = &freesasa_default_parameters;
121
+
122
+ fprintf(log, "\nPARAMETERS\n");
123
+
124
+ fprintf(log, "algorithm : %s\n", freesasa_alg_name(p->alg));
125
+ fprintf(log, "probe-radius : %.3f\n", p->probe_radius);
126
+ #if USE_THREADS
127
+ fprintf(log, "threads : %d\n", p->n_threads);
128
+ #endif
129
+
130
+ switch (p->alg) {
131
+ case FREESASA_SHRAKE_RUPLEY:
132
+ fprintf(log, "testpoints : %d\n", p->shrake_rupley_n_points);
133
+ break;
134
+ case FREESASA_LEE_RICHARDS:
135
+ fprintf(log, "slices : %d\n", p->lee_richards_n_slices);
136
+ break;
137
+ default:
138
+ assert(0);
139
+ break;
140
+ }
141
+
142
+ fflush(log);
143
+ if (ferror(log)) {
144
+ return fail_msg(strerror(errno));
145
+ }
146
+
147
+ return FREESASA_SUCCESS;
148
+ }
149
+
150
+ int freesasa_write_res(FILE *log,
151
+ freesasa_node *root)
152
+ {
153
+ freesasa_node *result, *structure, *chain, *residue;
154
+ int n_res = freesasa_classify_n_residue_types() + 1, i_res, i;
155
+ double *residue_area = malloc(sizeof(double) * n_res);
156
+
157
+ assert(log);
158
+ assert(root);
159
+ assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
160
+
161
+ if (residue_area == NULL) return mem_fail();
162
+
163
+ result = freesasa_node_children(root);
164
+ while (result) {
165
+ for (i = 0; i < n_res; ++i)
166
+ residue_area[i] = 0;
167
+ structure = freesasa_node_children(result);
168
+ while (structure) {
169
+ chain = freesasa_node_children(structure);
170
+ while (chain) {
171
+ residue = freesasa_node_children(chain);
172
+ while (residue) {
173
+ assert(freesasa_node_type(residue) == FREESASA_NODE_RESIDUE);
174
+ i_res = freesasa_classify_residue(freesasa_node_name(residue));
175
+ residue_area[i_res] += freesasa_node_area(residue)->total;
176
+ residue = freesasa_node_next(residue);
177
+ }
178
+ chain = freesasa_node_next(chain);
179
+ }
180
+ structure = freesasa_node_next(structure);
181
+ }
182
+
183
+ fprintf(log, "# Residue types in %s\n", freesasa_node_name(result));
184
+ for (i_res = 0; i_res < n_res; ++i_res) {
185
+ double sasa = residue_area[i_res];
186
+ if (i_res < 20 || sasa > 0) {
187
+ fprintf(log, "RES %s : %10.2f\n",
188
+ freesasa_classify_residue_name(i_res),
189
+ sasa);
190
+ }
191
+ }
192
+ fprintf(log, "\n");
193
+
194
+ result = freesasa_node_next(result);
195
+ }
196
+
197
+ fflush(log);
198
+ if (ferror(log)) {
199
+ return fail_msg(strerror(errno));
200
+ }
201
+
202
+ return FREESASA_SUCCESS;
203
+ }
204
+
205
+ int freesasa_write_seq(FILE *log,
206
+ freesasa_node *root)
207
+ {
208
+ freesasa_node *result, *structure, *chain, *residue;
209
+
210
+ assert(log);
211
+ assert(root);
212
+ assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
213
+
214
+ result = freesasa_node_children(root);
215
+
216
+ while (result) {
217
+ structure = freesasa_node_children(result);
218
+ fprintf(log, "# Residues in %s\n", freesasa_node_name(result));
219
+ while (structure) {
220
+ chain = freesasa_node_children(structure);
221
+ while (chain) {
222
+ residue = freesasa_node_children(chain);
223
+ while (residue) {
224
+ assert(freesasa_node_type(residue) == FREESASA_NODE_RESIDUE);
225
+ fprintf(log, "SEQ %s %s %s : %7.2f\n",
226
+ freesasa_node_name(chain),
227
+ freesasa_node_residue_number(residue),
228
+ freesasa_node_name(residue),
229
+ freesasa_node_area(residue)->total);
230
+ residue = freesasa_node_next(residue);
231
+ }
232
+ chain = freesasa_node_next(chain);
233
+ }
234
+ structure = freesasa_node_next(structure);
235
+ }
236
+ fprintf(log, "\n");
237
+ result = freesasa_node_next(result);
238
+ }
239
+
240
+ fflush(log);
241
+ if (ferror(log)) {
242
+ return fail_msg(strerror(errno));
243
+ }
244
+
245
+ return FREESASA_SUCCESS;
246
+ }
247
+
248
+ int freesasa_write_log(FILE *log,
249
+ freesasa_node *root)
250
+ {
251
+ freesasa_node *result = freesasa_node_children(root);
252
+ int several = (freesasa_node_next(result) != NULL); /* are there more than one result */
253
+ int err = 0;
254
+
255
+ assert(log);
256
+ assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
257
+
258
+ if (write_parameters(log, freesasa_node_result_parameters(result)) == FREESASA_FAIL)
259
+ ++err;
260
+
261
+ while (result) {
262
+ if (several) fprintf(log, "\n\n####################\n");
263
+ if (write_result(log, result) == FREESASA_FAIL) ++err;
264
+ if (write_selections(log, result) == FREESASA_FAIL) ++err;
265
+ result = freesasa_node_next(result);
266
+ }
267
+ if (err) return FREESASA_FAIL;
268
+
269
+ return FREESASA_SUCCESS;
270
+ }
.venv_haddock/include/site/python3.12/freesasa/nb.c ADDED
@@ -0,0 +1,642 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+ #include <assert.h>
5
+ #include <math.h>
6
+ #include <stdlib.h>
7
+
8
+ #include "freesasa_internal.h"
9
+ #include "nb.h"
10
+
11
+ #ifndef FREESASA_NB_CHUNK
12
+ #define FREESASA_NB_CHUNK 128
13
+ #endif
14
+
15
+ typedef struct cell cell;
16
+ struct cell {
17
+ cell *nb[17]; /** includes self, only forward neighbors */
18
+ int *atom; /** indices of the atoms/coordinates in a cell */
19
+ int n_nb; /** number of neighbors to cell */
20
+ int n_atoms; /** number of atoms in cell */
21
+ };
22
+
23
+ static cell empty_cell = {{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
24
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
25
+ NULL,
26
+ 0,
27
+ 0};
28
+
29
+ /** cell lists, divide space into boxes */
30
+ typedef struct cell_list {
31
+ cell *cell; /** the cells */
32
+ int n; /** number of cells */
33
+ int nx, ny, nz; /** number of cells along each axis */
34
+ double d; /** cell size */
35
+ double x_max, x_min;
36
+ double y_max, y_min;
37
+ double z_max, z_min;
38
+ } cell_list;
39
+
40
+ static struct cell_list empty_cell_list = {NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
41
+
42
+ /** Finds the bounds of the cell list and writes them to the provided cell list */
43
+ static void
44
+ cell_list_bounds(cell_list *c,
45
+ const coord_t *coord)
46
+ {
47
+ const int n = freesasa_coord_n(coord);
48
+ int i;
49
+ double d = c->d;
50
+ const double *restrict v = freesasa_coord_i(coord, 0);
51
+ double x = v[0], X = v[0], y = v[1], Y = v[1], z = v[2], Z = v[2];
52
+
53
+ for (i = 1; i < n; ++i) {
54
+ v = freesasa_coord_i(coord, i);
55
+ x = fmin(v[0], x);
56
+ X = fmax(v[0], X);
57
+ y = fmin(v[1], y);
58
+ Y = fmax(v[1], Y);
59
+ z = fmin(v[2], z);
60
+ Z = fmax(v[2], Z);
61
+ }
62
+ c->x_min = x - d / 2.;
63
+ c->x_max = X + d / 2.;
64
+ c->y_min = y - d / 2.;
65
+ c->y_max = Y + d / 2.;
66
+ c->z_min = z - d / 2.;
67
+ c->z_max = Z + d / 2.;
68
+ c->nx = (int)ceil((c->x_max - c->x_min) / d);
69
+ c->ny = (int)ceil((c->y_max - c->y_min) / d);
70
+ c->nz = (int)ceil((c->z_max - c->z_min) / d);
71
+ c->n = c->nx * c->ny * c->nz;
72
+ }
73
+
74
+ static inline int
75
+ cell_index(const cell_list *c,
76
+ int ix,
77
+ int iy,
78
+ int iz)
79
+ {
80
+ assert(ix >= 0 && ix < c->nx);
81
+ assert(iy >= 0 && iy < c->ny);
82
+ return ix + c->nx * (iy + c->ny * iz);
83
+ }
84
+
85
+ /** Fill the neighbor list for a given cell, only "forward" neighbors considered */
86
+ static void
87
+ fill_nb(cell_list *c,
88
+ int ix,
89
+ int iy,
90
+ int iz)
91
+ {
92
+ cell *cell = &c->cell[cell_index(c, ix, iy, iz)];
93
+ int n = 0, i, j, k;
94
+ int xmin = ix > 0 ? ix - 1 : 0;
95
+ int xmax = ix < c->nx - 1 ? ix + 1 : ix;
96
+ int ymin = iy > 0 ? iy - 1 : 0;
97
+ int ymax = iy < c->ny - 1 ? iy + 1 : iy;
98
+ int zmin = iz > 0 ? iz - 1 : 0;
99
+ int zmax = iz < c->nz - 1 ? iz + 1 : iz;
100
+ for (i = xmin; i <= xmax; ++i) {
101
+ for (j = ymin; j <= ymax; ++j) {
102
+ for (k = zmin; k <= zmax; ++k) {
103
+ /* Scalar product between (i-ix,j-iy,k-iz) and (1,1,1) should
104
+ be non-negative. Using only forward neighbors means
105
+ there's no double counting when comparing cells */
106
+ if (i - ix + j - iy + k - iz >= 0) {
107
+ cell->nb[n] = &c->cell[cell_index(c, i, j, k)];
108
+ ++n;
109
+ }
110
+ }
111
+ }
112
+ }
113
+ cell->n_nb = n;
114
+ assert(n > 0);
115
+ }
116
+
117
+ /** find neighbors to all cells */
118
+ static void
119
+ get_nb(cell_list *c)
120
+ {
121
+ int ix, iy, iz;
122
+
123
+ for (ix = 0; ix < c->nx; ++ix) {
124
+ for (iy = 0; iy < c->ny; ++iy) {
125
+ for (iz = 0; iz < c->nz; ++iz) {
126
+ fill_nb(c, ix, iy, iz);
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ /** Get the cell index of a given atom */
133
+ static int
134
+ coord2cell_index(const cell_list *c,
135
+ const double *restrict xyz)
136
+ {
137
+ double d = c->d;
138
+ int ix = (int)((xyz[0] - c->x_min) / d);
139
+ int iy = (int)((xyz[1] - c->y_min) / d);
140
+ int iz = (int)((xyz[2] - c->z_min) / d);
141
+
142
+ return cell_index(c, ix, iy, iz);
143
+ }
144
+
145
+ /**
146
+ Assigns cells to each coordinate. Returns FREESASA_FAIL if realloc
147
+ fails, FREESASA_SUCCESS else.
148
+ */
149
+ static int
150
+ fill_cells(cell_list *c,
151
+ const coord_t *coord)
152
+ {
153
+ int i;
154
+ cell *cell;
155
+ int *a;
156
+ const double *restrict v;
157
+
158
+ for (i = 0; i < c->n; ++i) {
159
+ c->cell[i].n_atoms = 0;
160
+ }
161
+
162
+ for (i = 0; i < freesasa_coord_n(coord); ++i) {
163
+ v = freesasa_coord_i(coord, i);
164
+ cell = &c->cell[coord2cell_index(c, v)];
165
+ ++cell->n_atoms;
166
+ a = cell->atom;
167
+ cell->atom = realloc(cell->atom, sizeof(int) * cell->n_atoms);
168
+ if (!cell->atom) {
169
+ cell->atom = a;
170
+ return mem_fail();
171
+ }
172
+ cell->atom[cell->n_atoms - 1] = i;
173
+ }
174
+ return FREESASA_SUCCESS;
175
+ }
176
+
177
+ /** Frees an object created by cell_list_new(). */
178
+ static void
179
+ cell_list_free(cell_list *c)
180
+ {
181
+ int i;
182
+
183
+ if (c) {
184
+ if (c->cell) {
185
+ for (i = 0; i < c->n; ++i)
186
+ free(c->cell[i].atom);
187
+ }
188
+ free(c->cell);
189
+ free(c);
190
+ }
191
+ }
192
+
193
+ /**
194
+ Creates a cell list with provided cell-size assigning cells to
195
+ each of the provided coordinates. The created cell list should be
196
+ freed using cell_list_free().
197
+
198
+ Returns NULL if there are malloc fails.
199
+ */
200
+ static cell_list *
201
+ cell_list_new(double cell_size,
202
+ const coord_t *coord)
203
+ {
204
+ int i;
205
+ cell_list *c;
206
+
207
+ assert(cell_size > 0);
208
+ assert(coord);
209
+
210
+ c = malloc(sizeof(cell_list));
211
+ if (!c) {
212
+ mem_fail();
213
+ return NULL;
214
+ }
215
+
216
+ *c = empty_cell_list;
217
+
218
+ c->d = cell_size;
219
+ cell_list_bounds(c, coord);
220
+
221
+ c->cell = malloc(sizeof(cell) * c->n);
222
+ if (!c->cell) {
223
+ cell_list_free(c);
224
+ mem_fail();
225
+ return NULL;
226
+ }
227
+
228
+ for (i = 0; i < c->n; ++i)
229
+ c->cell[i] = empty_cell;
230
+
231
+ if (fill_cells(c, coord)) {
232
+ cell_list_free(c);
233
+ mem_fail();
234
+ return NULL;
235
+ }
236
+
237
+ get_nb(c);
238
+ return c;
239
+ }
240
+
241
+ /** assumes max value in a is positive */
242
+ static double
243
+ max_array(const double *a,
244
+ int n)
245
+ {
246
+ int i;
247
+ double max = 0;
248
+
249
+ for (i = 0; i < n; ++i) {
250
+ max = fmax(a[i], max);
251
+ }
252
+
253
+ return max;
254
+ }
255
+
256
+ /**
257
+ Allocate memory for ::nb_list object. Tries to free everything
258
+ and returns NULL if malloc somewhere along the way.
259
+ */
260
+ static nb_list *
261
+ freesasa_nb_alloc(int n)
262
+ {
263
+ int i;
264
+ nb_list *nb;
265
+
266
+ assert(n > 0);
267
+
268
+ nb = malloc(sizeof(nb_list));
269
+ if (!nb) {
270
+ mem_fail();
271
+ return NULL;
272
+ }
273
+
274
+ nb->n = n;
275
+
276
+ /* in case the mallocs break, we can clean up in a safer way */
277
+ nb->nn = NULL;
278
+ nb->nb = NULL;
279
+ nb->capacity = NULL;
280
+ nb->xyd = nb->xd = nb->yd = NULL;
281
+
282
+ nb->nn = malloc(sizeof(int) * n);
283
+ nb->nb = malloc(sizeof(int *) * n);
284
+ nb->xyd = malloc(sizeof(double *) * n);
285
+ nb->xd = malloc(sizeof(double *) * n);
286
+ nb->yd = malloc(sizeof(double *) * n);
287
+ nb->capacity = malloc(sizeof(int) * n);
288
+
289
+ if (!nb->nn || !nb->nb || !nb->xyd ||
290
+ !nb->xd || !nb->yd || !nb->capacity) {
291
+ free(nb->nn);
292
+ free(nb->nb);
293
+ free(nb->xyd);
294
+ free(nb->xd);
295
+ free(nb->yd);
296
+ free(nb->capacity);
297
+ free(nb);
298
+ mem_fail();
299
+ return NULL;
300
+ }
301
+
302
+ for (i = 0; i < n; ++i) {
303
+ nb->nn[i] = 0;
304
+ nb->capacity[i] = FREESASA_NB_CHUNK;
305
+ /* again prepare for a potential cleanup */
306
+ nb->nb[i] = NULL;
307
+ nb->xyd[i] = nb->xd[i] = nb->yd[i] = NULL;
308
+ }
309
+ for (i = 0; i < n; ++i) {
310
+ nb->nb[i] = malloc(sizeof(int) * FREESASA_NB_CHUNK);
311
+ nb->xyd[i] = malloc(sizeof(double) * FREESASA_NB_CHUNK);
312
+ nb->xd[i] = malloc(sizeof(double) * FREESASA_NB_CHUNK);
313
+ nb->yd[i] = malloc(sizeof(double) * FREESASA_NB_CHUNK);
314
+ if (!nb->nb[i] || !nb->xyd[i] || !nb->xd[i] || !nb->yd[i]) {
315
+ freesasa_nb_free(nb);
316
+ mem_fail();
317
+ return NULL;
318
+ }
319
+ }
320
+ return nb;
321
+ }
322
+
323
+ void freesasa_nb_free(nb_list *nb)
324
+ {
325
+ int n, i;
326
+
327
+ if (nb != NULL) {
328
+ n = nb->n;
329
+ if (nb->nb)
330
+ for (i = 0; i < n; ++i)
331
+ free(nb->nb[i]);
332
+ if (nb->xyd)
333
+ for (i = 0; i < n; ++i)
334
+ free(nb->xyd[i]);
335
+ if (nb->xd)
336
+ for (i = 0; i < n; ++i)
337
+ free(nb->xd[i]);
338
+ if (nb->yd)
339
+ for (i = 0; i < n; ++i)
340
+ free(nb->yd[i]);
341
+ free(nb->nb);
342
+ free(nb->nn);
343
+ free(nb->capacity);
344
+ free(nb->xyd);
345
+ free(nb->xd);
346
+ free(nb->yd);
347
+ free(nb);
348
+ }
349
+ }
350
+
351
+ /**
352
+ Increases sizes of arrays when they cross a threshold. Returns
353
+ FREESASA_FAIL if realloc fails, FREESASA_SUCCESS else
354
+ */
355
+ static int
356
+ chunk_up(nb_list *nb_list,
357
+ int i)
358
+ {
359
+ int nni = nb_list->nn[i];
360
+ int **nbi, *nbi_b, new_cap;
361
+ double **xydi, **xdi, **ydi, *xydi_b, *xdi_b, *ydi_b;
362
+
363
+ if (nni > nb_list->capacity[i]) {
364
+ nbi = &nb_list->nb[i];
365
+ nbi_b = *nbi;
366
+ xydi = &nb_list->xyd[i];
367
+ xdi = &nb_list->xd[i];
368
+ ydi = &nb_list->yd[i];
369
+ xydi_b = *xydi;
370
+ xdi_b = *xdi;
371
+ ydi_b = *ydi;
372
+ new_cap = (nb_list->capacity[i] += FREESASA_NB_CHUNK);
373
+
374
+ *nbi = realloc(*nbi, sizeof(int) * new_cap);
375
+ if (*nbi == NULL) {
376
+ nb_list->nb[i] = nbi_b;
377
+ return mem_fail();
378
+ }
379
+
380
+ *xydi = realloc(*xydi, sizeof(double) * new_cap);
381
+ if (*xydi == NULL) {
382
+ nb_list->xyd[i] = xydi_b;
383
+ return mem_fail();
384
+ }
385
+
386
+ *xdi = realloc(*xdi, sizeof(double) * new_cap);
387
+ if (*xdi == NULL) {
388
+ nb_list->xd[i] = xdi_b;
389
+ return mem_fail();
390
+ }
391
+
392
+ *ydi = realloc(*ydi, sizeof(double) * new_cap);
393
+ if (*ydi == NULL) {
394
+ nb_list->yd[i] = ydi_b;
395
+ return mem_fail();
396
+ }
397
+ }
398
+ return FREESASA_SUCCESS;
399
+ }
400
+
401
+ /**
402
+ Assumes the coordinates i and j have been determined to be
403
+ neighbors and adds them both to the provided nb lists,
404
+ symmetrically.
405
+
406
+ Returns FREESASA_FAIL if can't allocate memory. FREESASA_SUCCESS
407
+ else.
408
+ */
409
+ static int
410
+ nb_add_pair(nb_list *nb_list,
411
+ int i,
412
+ int j,
413
+ double dx,
414
+ double dy)
415
+ {
416
+ int **nb;
417
+ int *nn = nb_list->nn;
418
+ int nni, nnj;
419
+ double **xyd;
420
+ double **xd;
421
+ double **yd;
422
+ double d;
423
+
424
+ assert(i != j);
425
+
426
+ nni = nn[i]++;
427
+ nnj = nn[j]++;
428
+
429
+ if (chunk_up(nb_list, i)) return mem_fail();
430
+ if (chunk_up(nb_list, j)) return mem_fail();
431
+
432
+ nb = nb_list->nb;
433
+ xyd = nb_list->xyd;
434
+ xd = nb_list->xd;
435
+ yd = nb_list->yd;
436
+
437
+ nb[i][nni] = j;
438
+ nb[j][nnj] = i;
439
+
440
+ d = sqrt(dx * dx + dy * dy);
441
+
442
+ xyd[i][nni] = d;
443
+ xyd[j][nnj] = d;
444
+
445
+ xd[i][nni] = dx;
446
+ xd[j][nnj] = -dx;
447
+ yd[i][nni] = dy;
448
+ yd[j][nnj] = -dy;
449
+
450
+ return FREESASA_SUCCESS;
451
+ }
452
+
453
+ /**
454
+ Fills the nb list for all contacts between coordinates
455
+ belonging to the cells ci and cj. Handles the case ci == cj
456
+ correctly.
457
+ */
458
+ static int
459
+ nb_calc_cell_pair(nb_list *nb_list,
460
+ const coord_t *coord,
461
+ const double *radii,
462
+ const cell *ci,
463
+ const cell *cj)
464
+ {
465
+ const double *restrict v = freesasa_coord_all(coord);
466
+ double ri, rj, xi, yi, zi, xj, yj, zj,
467
+ dx, dy, dz, cut2;
468
+ int i, j, ia, ja;
469
+
470
+ for (i = 0; i < ci->n_atoms; ++i) {
471
+ ia = ci->atom[i];
472
+ ri = radii[ia];
473
+ xi = v[ia * 3];
474
+ yi = v[ia * 3 + 1];
475
+ zi = v[ia * 3 + 2];
476
+ if (ci == cj)
477
+ j = i + 1;
478
+ else
479
+ j = 0;
480
+ /** the following loop is performance critical */
481
+ for (; j < cj->n_atoms; ++j) {
482
+ ja = cj->atom[j];
483
+ rj = radii[ja];
484
+ xj = v[ja * 3];
485
+ yj = v[ja * 3 + 1];
486
+ zj = v[ja * 3 + 2];
487
+ cut2 = (ri + rj) * (ri + rj);
488
+ dx = xj - xi;
489
+ dy = yj - yi;
490
+ dz = zj - zi;
491
+ if (dx * dx + dy * dy + dz * dz < cut2) {
492
+ if (nb_add_pair(nb_list, ia, ja, dx, dy))
493
+ return mem_fail();
494
+ }
495
+ }
496
+ }
497
+ return FREESASA_SUCCESS;
498
+ }
499
+
500
+ /**
501
+ Iterates through the cells and records all contacts in the
502
+ provided nb list
503
+ */
504
+ static int
505
+ nb_fill_list(nb_list *nb_list,
506
+ cell_list *c,
507
+ const coord_t *coord,
508
+ const double *radii)
509
+ {
510
+ int nc = c->n, ic, jc;
511
+ cell *ci, *cj;
512
+
513
+ for (ic = 0; ic < nc; ++ic) {
514
+ ci = &c->cell[ic];
515
+ for (jc = 0; jc < ci->n_nb; ++jc) {
516
+ cj = ci->nb[jc];
517
+ if (nb_calc_cell_pair(nb_list, coord, radii, ci, cj))
518
+ return mem_fail();
519
+ }
520
+ }
521
+ return FREESASA_SUCCESS;
522
+ }
523
+
524
+ nb_list *
525
+ freesasa_nb_new(const coord_t *coord,
526
+ const double *radii)
527
+ {
528
+ double cell_size;
529
+ cell_list *c;
530
+ int n;
531
+ nb_list *nb;
532
+
533
+ if (coord == NULL || radii == NULL) return NULL;
534
+
535
+ n = freesasa_coord_n(coord);
536
+ nb = freesasa_nb_alloc(n);
537
+
538
+ if (!nb) {
539
+ mem_fail();
540
+ return NULL;
541
+ }
542
+
543
+ cell_size = 2 * max_array(radii, n);
544
+ assert(cell_size > 0);
545
+ c = cell_list_new(cell_size, coord);
546
+ if (c == NULL ||
547
+ nb_fill_list(nb, c, coord, radii)) {
548
+ mem_fail();
549
+ freesasa_nb_free(nb);
550
+ nb = NULL;
551
+ }
552
+
553
+ /* the cell lists are only a tool to generate the neighbor lists */
554
+ cell_list_free(c);
555
+
556
+ return nb;
557
+ }
558
+
559
+ int freesasa_nb_contact(const nb_list *nb,
560
+ int i,
561
+ int j)
562
+ {
563
+ int k;
564
+ assert(nb != NULL);
565
+ assert(i < nb->n && i >= 0);
566
+ assert(j < nb->n && j >= 0);
567
+
568
+ for (k = 0; k < nb->nn[i]; ++k) {
569
+ if (nb->nb[i][k] == j) return 1;
570
+ }
571
+
572
+ return 0;
573
+ }
574
+
575
+ #if USE_CHECK
576
+ #include <check.h>
577
+ #include <math.h>
578
+
579
+ START_TEST(test_cell)
580
+ {
581
+ int na, i;
582
+ const int n_atoms = 6;
583
+ static const double v[] = {0, 0, 0, 1, 1, 1, -1, 1, -1, 2, 0, -2, 2, 2, 0, -5, 5, 5};
584
+ static const double r[] = {4, 2, 2, 2, 2, 2};
585
+ double r_max;
586
+ cell_list *c;
587
+ coord_t *coord = freesasa_coord_new();
588
+ cell ci;
589
+
590
+ freesasa_coord_append(coord, v, n_atoms);
591
+ r_max = max_array(r, n_atoms);
592
+ ck_assert(fabs(r_max - 4) < 1e-10);
593
+ c = cell_list_new(r_max, coord);
594
+ ck_assert(c != NULL);
595
+ ck_assert(c->cell != NULL);
596
+ ck_assert(fabs(c->d - r_max) < 1e-10);
597
+
598
+ /* check bounds */
599
+ ck_assert(c->x_min < -5);
600
+ ck_assert(c->x_max > 2);
601
+ ck_assert(c->y_min < 0);
602
+ ck_assert(c->y_max > 5);
603
+ ck_assert(c->z_min < -2);
604
+ ck_assert(c->z_max > 5);
605
+
606
+ /* check number of cells */
607
+ ck_assert(c->nx * c->d >= 7);
608
+ ck_assert(c->nx <= ceil(7 / r_max) + 1);
609
+ ck_assert(c->ny * c->d >= 5);
610
+ ck_assert(c->ny <= ceil(5 / r_max) + 1);
611
+ ck_assert(c->nz * c->d >= 7);
612
+ ck_assert(c->nz <= ceil(7 / r_max) + 1);
613
+ ck_assert_int_eq(c->n, c->nx * c->ny * c->nz);
614
+
615
+ /* check the individual cells */
616
+ na = 0;
617
+ ck_assert_int_eq(c->cell[0].n_nb, 8);
618
+ ck_assert_int_eq(c->cell[c->n - 1].n_nb, 1);
619
+ for (i = 0; i < c->n; ++i) {
620
+ ci = c->cell[i];
621
+ ck_assert(ci.n_atoms >= 0);
622
+ if (ci.n_atoms > 0) ck_assert(ci.atom != NULL);
623
+ ck_assert_int_ge(ci.n_nb, 1);
624
+ ck_assert_int_le(ci.n_nb, 17);
625
+ na += ci.n_atoms;
626
+ }
627
+ ck_assert_int_eq(na, n_atoms);
628
+ cell_list_free(c);
629
+ freesasa_coord_free(coord);
630
+ }
631
+ END_TEST
632
+
633
+ TCase *
634
+ test_nb_static()
635
+ {
636
+ TCase *tc = tcase_create("nb.c static");
637
+ tcase_add_test(tc, test_cell);
638
+
639
+ return tc;
640
+ }
641
+
642
+ #endif /* USE_CHECK */
.venv_haddock/include/site/python3.12/freesasa/nb.h ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREESASA_NB_H
2
+ #define FREESASA_NB_H
3
+
4
+ #include <stdlib.h>
5
+
6
+ #include "coord.h"
7
+
8
+ /**
9
+ @file
10
+ @author Simon Mitternacht
11
+
12
+ Functions to compute neighbor lists. The function
13
+ freesasa_nb_contact() is mainly intended for checking consistency,
14
+ in performance-critical code it is advisible to use the struct (as
15
+ demonstrated in sasa_lr.c and sasa_sr.c).
16
+ */
17
+
18
+ /** Neighbor list */
19
+ typedef struct {
20
+ int n; /**< number of elements */
21
+ int **nb; /**< neighbors to each element */
22
+ int *nn; /**< number of neighbors to each element */
23
+ double **xyd; /**< distance between neighbors in xy-plane */
24
+ double **xd; /**< signed distance between neighbors along x-axis */
25
+ double **yd; /**< signed distance between neighbors along y-axis */
26
+ int *capacity; /**< keeps track of memory chunks (don't change this) */
27
+ } nb_list;
28
+
29
+ /**
30
+ Creates a neigbor list based on a set of coordinates with
31
+ corresponding sphere radii.
32
+
33
+ Implemented using cell lists, giving O(N) performance. Should be
34
+ freed with freesasa_nb_free(). For efficient calculations
35
+ using this list the members of the returned struct should be used
36
+ directly and not freesasa_nb_contact().
37
+
38
+ @param coord a set of coordinates
39
+ @param radii radii for the coordinates
40
+ @return a neigbor list. Returns NULL if either argument is null or
41
+ if there were any problems constructing the list (see error
42
+ messages).
43
+ */
44
+ nb_list *
45
+ freesasa_nb_new(const coord_t *coord,
46
+ const double *radii);
47
+
48
+ /**
49
+ Frees a neigbor list created by freesasa_nb_new().
50
+
51
+ @param nb The neigbor list to free
52
+ */
53
+ void freesasa_nb_free(nb_list *nb);
54
+
55
+ /**
56
+ Checks if two atoms are in contact. Only included for reference.
57
+
58
+ @param nb The neigbor list
59
+ @param i Index of first coordinate
60
+ @param j Index of second coordinate
61
+ @return 1 if contact, 0 else.
62
+ */
63
+ int freesasa_nb_contact(const nb_list *nb,
64
+ int i,
65
+ int j);
66
+
67
+ #endif /* FREESASA_NB_H */
.venv_haddock/include/site/python3.12/freesasa/parser.c ADDED
@@ -0,0 +1,1639 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* A Bison parser, made by GNU Bison 3.0.4. */
2
+
3
+ /* Bison implementation for Yacc-like parsers in C
4
+
5
+ Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
+
20
+ /* As a special exception, you may create a larger work that contains
21
+ part or all of the Bison parser skeleton and distribute that work
22
+ under terms of your choice, so long as that work isn't itself a
23
+ parser generator using the skeleton or a modified version thereof
24
+ as a parser skeleton. Alternatively, if you modify or redistribute
25
+ the parser skeleton itself, you may (at your option) remove this
26
+ special exception, which will cause the skeleton and the resulting
27
+ Bison output files to be licensed under the GNU General Public
28
+ License without this special exception.
29
+
30
+ This special exception was added by the Free Software Foundation in
31
+ version 2.2 of Bison. */
32
+
33
+ /* C LALR(1) parser skeleton written by Richard Stallman, by
34
+ simplifying the original so-called "semantic" parser. */
35
+
36
+ /* All symbols defined below should begin with yy or YY, to avoid
37
+ infringing on user name space. This should be done even for local
38
+ variables, as they might otherwise be expanded by user macros.
39
+ There are some unavoidable exceptions within include files to
40
+ define necessary library symbols; they are noted "INFRINGES ON
41
+ USER NAME SPACE" below. */
42
+
43
+ /* Identify Bison output. */
44
+ #define YYBISON 1
45
+
46
+ /* Bison version. */
47
+ #define YYBISON_VERSION "3.0.4"
48
+
49
+ /* Skeleton name. */
50
+ #define YYSKELETON_NAME "yacc.c"
51
+
52
+ /* Pure parsers. */
53
+ #define YYPURE 2
54
+
55
+ /* Push parsers. */
56
+ #define YYPUSH 0
57
+
58
+ /* Pull parsers. */
59
+ #define YYPULL 1
60
+
61
+
62
+ /* Substitute the variable and function names. */
63
+ #define yyparse freesasa_yyparse
64
+ #define yylex freesasa_yylex
65
+ #define yyerror freesasa_yyerror
66
+ #define yydebug freesasa_yydebug
67
+ #define yynerrs freesasa_yynerrs
68
+
69
+
70
+ /* Copy the first part of user declarations. */
71
+ #line 1 "parser.y" /* yacc.c:339 */
72
+
73
+
74
+ #include "selection.h"
75
+ #include "parser.h"
76
+ #include "lexer.h"
77
+ extern int freesasa_selection_parse_error(expression *e, yyscan_t scanner, const char *msg);
78
+ int freesasa_yyerror(expression **expression, yyscan_t scanner, const char *msg) {
79
+ return freesasa_selection_parse_error(*expression,scanner,msg);
80
+ }
81
+
82
+
83
+ #line 84 "parser.c" /* yacc.c:339 */
84
+
85
+ # ifndef YY_NULLPTR
86
+ # if defined __cplusplus && 201103L <= __cplusplus
87
+ # define YY_NULLPTR nullptr
88
+ # else
89
+ # define YY_NULLPTR 0
90
+ # endif
91
+ # endif
92
+
93
+ /* Enabling verbose error messages. */
94
+ #ifdef YYERROR_VERBOSE
95
+ # undef YYERROR_VERBOSE
96
+ # define YYERROR_VERBOSE 1
97
+ #else
98
+ # define YYERROR_VERBOSE 0
99
+ #endif
100
+
101
+ /* In a future release of Bison, this section will be replaced
102
+ by #include "parser.h". */
103
+ #ifndef YY_FREESASA_YY_PARSER_H_INCLUDED
104
+ # define YY_FREESASA_YY_PARSER_H_INCLUDED
105
+ /* Debug traces. */
106
+ #ifndef YYDEBUG
107
+ # define YYDEBUG 0
108
+ #endif
109
+ #if YYDEBUG
110
+ extern int freesasa_yydebug;
111
+ #endif
112
+ /* "%code requires" blocks. */
113
+ #line 13 "parser.y" /* yacc.c:355 */
114
+
115
+
116
+ #ifndef FREESASA_TYPEDEF_YY_SCANNER_T
117
+ #define FREESASA_TYPEDEF_YY_SCANNER_T
118
+ typedef void* freesasa_yyscan_t;
119
+ #endif
120
+
121
+
122
+ #line 123 "parser.c" /* yacc.c:355 */
123
+
124
+ /* Token type. */
125
+ #ifndef YYTOKENTYPE
126
+ # define YYTOKENTYPE
127
+ enum yytokentype
128
+ {
129
+ T_NUMBER = 258,
130
+ T_ID = 259,
131
+ T_SELID = 260,
132
+ T_AND = 261,
133
+ T_OR = 262,
134
+ T_NOT = 263,
135
+ T_RESN = 264,
136
+ T_RESI = 265,
137
+ T_SYMBOL = 266,
138
+ T_NAME = 267,
139
+ T_CHAIN = 268,
140
+ T_MINUS = 269,
141
+ ATOM = 270
142
+ };
143
+ #endif
144
+
145
+ /* Value type. */
146
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
147
+
148
+ union YYSTYPE
149
+ {
150
+ #line 30 "parser.y" /* yacc.c:355 */
151
+
152
+ const char *value;
153
+ expression *expression;
154
+
155
+ #line 156 "parser.c" /* yacc.c:355 */
156
+ };
157
+
158
+ typedef union YYSTYPE YYSTYPE;
159
+ # define YYSTYPE_IS_TRIVIAL 1
160
+ # define YYSTYPE_IS_DECLARED 1
161
+ #endif
162
+
163
+
164
+
165
+ int freesasa_yyparse (expression **expression, freesasa_yyscan_t scanner);
166
+
167
+ #endif /* !YY_FREESASA_YY_PARSER_H_INCLUDED */
168
+
169
+ /* Copy the second part of user declarations. */
170
+
171
+ #line 172 "parser.c" /* yacc.c:358 */
172
+
173
+ #ifdef short
174
+ # undef short
175
+ #endif
176
+
177
+ #ifdef YYTYPE_UINT8
178
+ typedef YYTYPE_UINT8 yytype_uint8;
179
+ #else
180
+ typedef unsigned char yytype_uint8;
181
+ #endif
182
+
183
+ #ifdef YYTYPE_INT8
184
+ typedef YYTYPE_INT8 yytype_int8;
185
+ #else
186
+ typedef signed char yytype_int8;
187
+ #endif
188
+
189
+ #ifdef YYTYPE_UINT16
190
+ typedef YYTYPE_UINT16 yytype_uint16;
191
+ #else
192
+ typedef unsigned short int yytype_uint16;
193
+ #endif
194
+
195
+ #ifdef YYTYPE_INT16
196
+ typedef YYTYPE_INT16 yytype_int16;
197
+ #else
198
+ typedef short int yytype_int16;
199
+ #endif
200
+
201
+ #ifndef YYSIZE_T
202
+ # ifdef __SIZE_TYPE__
203
+ # define YYSIZE_T __SIZE_TYPE__
204
+ # elif defined size_t
205
+ # define YYSIZE_T size_t
206
+ # elif ! defined YYSIZE_T
207
+ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
208
+ # define YYSIZE_T size_t
209
+ # else
210
+ # define YYSIZE_T unsigned int
211
+ # endif
212
+ #endif
213
+
214
+ #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
215
+
216
+ #ifndef YY_
217
+ # if defined YYENABLE_NLS && YYENABLE_NLS
218
+ # if ENABLE_NLS
219
+ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
220
+ # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
221
+ # endif
222
+ # endif
223
+ # ifndef YY_
224
+ # define YY_(Msgid) Msgid
225
+ # endif
226
+ #endif
227
+
228
+ #ifndef YY_ATTRIBUTE
229
+ # if (defined __GNUC__ \
230
+ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
231
+ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
232
+ # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
233
+ # else
234
+ # define YY_ATTRIBUTE(Spec) /* empty */
235
+ # endif
236
+ #endif
237
+
238
+ #ifndef YY_ATTRIBUTE_PURE
239
+ # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
240
+ #endif
241
+
242
+ #ifndef YY_ATTRIBUTE_UNUSED
243
+ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
244
+ #endif
245
+
246
+ #if !defined _Noreturn \
247
+ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
248
+ # if defined _MSC_VER && 1200 <= _MSC_VER
249
+ # define _Noreturn __declspec (noreturn)
250
+ # else
251
+ # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
252
+ # endif
253
+ #endif
254
+
255
+ /* Suppress unused-variable warnings by "using" E. */
256
+ #if ! defined lint || defined __GNUC__
257
+ # define YYUSE(E) ((void) (E))
258
+ #else
259
+ # define YYUSE(E) /* empty */
260
+ #endif
261
+
262
+ #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
263
+ /* Suppress an incorrect diagnostic about yylval being uninitialized. */
264
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
265
+ _Pragma ("GCC diagnostic push") \
266
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
267
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
268
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
269
+ _Pragma ("GCC diagnostic pop")
270
+ #else
271
+ # define YY_INITIAL_VALUE(Value) Value
272
+ #endif
273
+ #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
274
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
275
+ # define YY_IGNORE_MAYBE_UNINITIALIZED_END
276
+ #endif
277
+ #ifndef YY_INITIAL_VALUE
278
+ # define YY_INITIAL_VALUE(Value) /* Nothing. */
279
+ #endif
280
+
281
+
282
+ #if ! defined yyoverflow || YYERROR_VERBOSE
283
+
284
+ /* The parser invokes alloca or malloc; define the necessary symbols. */
285
+
286
+ # ifdef YYSTACK_USE_ALLOCA
287
+ # if YYSTACK_USE_ALLOCA
288
+ # ifdef __GNUC__
289
+ # define YYSTACK_ALLOC __builtin_alloca
290
+ # elif defined __BUILTIN_VA_ARG_INCR
291
+ # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
292
+ # elif defined _AIX
293
+ # define YYSTACK_ALLOC __alloca
294
+ # elif defined _MSC_VER
295
+ # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
296
+ # define alloca _alloca
297
+ # else
298
+ # define YYSTACK_ALLOC alloca
299
+ # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
300
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
301
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
302
+ # ifndef EXIT_SUCCESS
303
+ # define EXIT_SUCCESS 0
304
+ # endif
305
+ # endif
306
+ # endif
307
+ # endif
308
+ # endif
309
+
310
+ # ifdef YYSTACK_ALLOC
311
+ /* Pacify GCC's 'empty if-body' warning. */
312
+ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
313
+ # ifndef YYSTACK_ALLOC_MAXIMUM
314
+ /* The OS might guarantee only one guard page at the bottom of the stack,
315
+ and a page size can be as small as 4096 bytes. So we cannot safely
316
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
317
+ to allow for a few compiler-allocated temporary stack slots. */
318
+ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
319
+ # endif
320
+ # else
321
+ # define YYSTACK_ALLOC YYMALLOC
322
+ # define YYSTACK_FREE YYFREE
323
+ # ifndef YYSTACK_ALLOC_MAXIMUM
324
+ # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
325
+ # endif
326
+ # if (defined __cplusplus && ! defined EXIT_SUCCESS \
327
+ && ! ((defined YYMALLOC || defined malloc) \
328
+ && (defined YYFREE || defined free)))
329
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
330
+ # ifndef EXIT_SUCCESS
331
+ # define EXIT_SUCCESS 0
332
+ # endif
333
+ # endif
334
+ # ifndef YYMALLOC
335
+ # define YYMALLOC malloc
336
+ # if ! defined malloc && ! defined EXIT_SUCCESS
337
+ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
338
+ # endif
339
+ # endif
340
+ # ifndef YYFREE
341
+ # define YYFREE free
342
+ # if ! defined free && ! defined EXIT_SUCCESS
343
+ void free (void *); /* INFRINGES ON USER NAME SPACE */
344
+ # endif
345
+ # endif
346
+ # endif
347
+ #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
348
+
349
+
350
+ #if (! defined yyoverflow \
351
+ && (! defined __cplusplus \
352
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
353
+
354
+ /* A type that is properly aligned for any stack member. */
355
+ union yyalloc
356
+ {
357
+ yytype_int16 yyss_alloc;
358
+ YYSTYPE yyvs_alloc;
359
+ };
360
+
361
+ /* The size of the maximum gap between one aligned stack and the next. */
362
+ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
363
+
364
+ /* The size of an array large to enough to hold all stacks, each with
365
+ N elements. */
366
+ # define YYSTACK_BYTES(N) \
367
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
368
+ + YYSTACK_GAP_MAXIMUM)
369
+
370
+ # define YYCOPY_NEEDED 1
371
+
372
+ /* Relocate STACK from its old location to the new one. The
373
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
374
+ elements in the stack, and YYPTR gives the new location of the
375
+ stack. Advance YYPTR to a properly aligned location for the next
376
+ stack. */
377
+ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
378
+ do \
379
+ { \
380
+ YYSIZE_T yynewbytes; \
381
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
382
+ Stack = &yyptr->Stack_alloc; \
383
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
384
+ yyptr += yynewbytes / sizeof (*yyptr); \
385
+ } \
386
+ while (0)
387
+
388
+ #endif
389
+
390
+ #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
391
+ /* Copy COUNT objects from SRC to DST. The source and destination do
392
+ not overlap. */
393
+ # ifndef YYCOPY
394
+ # if defined __GNUC__ && 1 < __GNUC__
395
+ # define YYCOPY(Dst, Src, Count) \
396
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
397
+ # else
398
+ # define YYCOPY(Dst, Src, Count) \
399
+ do \
400
+ { \
401
+ YYSIZE_T yyi; \
402
+ for (yyi = 0; yyi < (Count); yyi++) \
403
+ (Dst)[yyi] = (Src)[yyi]; \
404
+ } \
405
+ while (0)
406
+ # endif
407
+ # endif
408
+ #endif /* !YYCOPY_NEEDED */
409
+
410
+ /* YYFINAL -- State number of the termination state. */
411
+ #define YYFINAL 4
412
+ /* YYLAST -- Last index in YYTABLE. */
413
+ #define YYLAST 45
414
+
415
+ /* YYNTOKENS -- Number of terminals. */
416
+ #define YYNTOKENS 21
417
+ /* YYNNTS -- Number of nonterminals. */
418
+ #define YYNNTS 7
419
+ /* YYNRULES -- Number of rules. */
420
+ #define YYNRULES 24
421
+ /* YYNSTATES -- Number of states. */
422
+ #define YYNSTATES 44
423
+
424
+ /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
425
+ by yylex, with out-of-bounds checking. */
426
+ #define YYUNDEFTOK 2
427
+ #define YYMAXUTOK 270
428
+
429
+ #define YYTRANSLATE(YYX) \
430
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
431
+
432
+ /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
433
+ as returned by yylex, without out-of-bounds checking. */
434
+ static const yytype_uint8 yytranslate[] =
435
+ {
436
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440
+ 19, 20, 2, 16, 18, 17, 2, 2, 2, 2,
441
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
462
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
463
+ 15
464
+ };
465
+
466
+ #if YYDEBUG
467
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
468
+ static const yytype_uint8 yyrline[] =
469
+ {
470
+ 0, 68, 68, 72, 73, 74, 75, 76, 77, 78,
471
+ 79, 80, 84, 85, 89, 90, 91, 92, 93, 97,
472
+ 98, 99, 103, 104, 105
473
+ };
474
+ #endif
475
+
476
+ #if YYDEBUG || YYERROR_VERBOSE || 0
477
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
478
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
479
+ static const char *const yytname[] =
480
+ {
481
+ "$end", "error", "$undefined", "T_NUMBER", "T_ID", "T_SELID", "T_AND",
482
+ "T_OR", "T_NOT", "T_RESN", "T_RESI", "T_SYMBOL", "T_NAME", "T_CHAIN",
483
+ "T_MINUS", "ATOM", "'+'", "'-'", "','", "'('", "')'", "$accept", "stmt",
484
+ "expr", "list", "r_range", "c_range", "id", YY_NULLPTR
485
+ };
486
+ #endif
487
+
488
+ # ifdef YYPRINT
489
+ /* YYTOKNUM[NUM] -- (External) token number corresponding to the
490
+ (internal) symbol number NUM (which must be that of a token). */
491
+ static const yytype_uint16 yytoknum[] =
492
+ {
493
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
494
+ 265, 266, 267, 268, 269, 270, 43, 45, 44, 40,
495
+ 41
496
+ };
497
+ # endif
498
+
499
+ #define YYPACT_NINF -20
500
+
501
+ #define yypact_value_is_default(Yystate) \
502
+ (!!((Yystate) == (-20)))
503
+
504
+ #define YYTABLE_NINF -1
505
+
506
+ #define yytable_value_is_error(Yytable_value) \
507
+ 0
508
+
509
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
510
+ STATE-NUM. */
511
+ static const yytype_int8 yypact[] =
512
+ {
513
+ -3, -12, 14, 26, -20, 26, 7, 1, 7, 7,
514
+ 7, 26, 10, -20, -20, -20, 19, -20, 15, 7,
515
+ 16, 12, -20, -20, 24, 25, 13, 26, 26, -20,
516
+ 7, -20, 1, 7, 7, 7, -20, -20, 35, -20,
517
+ -20, -20, -20, -20
518
+ };
519
+
520
+ /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
521
+ Performed when YYTABLE does not specify something else to do. Zero
522
+ means the default is an error. */
523
+ static const yytype_uint8 yydefact[] =
524
+ {
525
+ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
526
+ 0, 0, 2, 6, 22, 23, 0, 7, 12, 0,
527
+ 8, 14, 9, 10, 11, 19, 0, 0, 0, 24,
528
+ 0, 17, 0, 18, 0, 0, 3, 4, 5, 13,
529
+ 15, 16, 20, 21
530
+ };
531
+
532
+ /* YYPGOTO[NTERM-NUM]. */
533
+ static const yytype_int8 yypgoto[] =
534
+ {
535
+ -20, -20, -4, 0, -19, 9, -7
536
+ };
537
+
538
+ /* YYDEFGOTO[NTERM-NUM]. */
539
+ static const yytype_int8 yydefgoto[] =
540
+ {
541
+ -1, 2, 12, 17, 20, 24, 18
542
+ };
543
+
544
+ /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
545
+ positive, shift that token. If negative, reduce the rule whose
546
+ number is the opposite. If YYTABLE_NINF, syntax error. */
547
+ static const yytype_uint8 yytable[] =
548
+ {
549
+ 21, 13, 1, 25, 14, 15, 3, 26, 22, 23,
550
+ 14, 15, 31, 40, 4, 16, 27, 28, 19, 27,
551
+ 28, 16, 29, 37, 38, 21, 41, 25, 43, 33,
552
+ 39, 30, 32, 36, 5, 6, 7, 8, 9, 10,
553
+ 34, 27, 35, 42, 0, 11
554
+ };
555
+
556
+ static const yytype_int8 yycheck[] =
557
+ {
558
+ 7, 5, 5, 10, 3, 4, 18, 11, 8, 9,
559
+ 3, 4, 19, 32, 0, 14, 6, 7, 17, 6,
560
+ 7, 14, 3, 27, 28, 32, 33, 34, 35, 17,
561
+ 30, 16, 16, 20, 8, 9, 10, 11, 12, 13,
562
+ 16, 6, 17, 34, -1, 19
563
+ };
564
+
565
+ /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
566
+ symbol of state STATE-NUM. */
567
+ static const yytype_uint8 yystos[] =
568
+ {
569
+ 0, 5, 22, 18, 0, 8, 9, 10, 11, 12,
570
+ 13, 19, 23, 23, 3, 4, 14, 24, 27, 17,
571
+ 25, 27, 24, 24, 26, 27, 23, 6, 7, 3,
572
+ 16, 27, 16, 17, 16, 17, 20, 23, 23, 24,
573
+ 25, 27, 26, 27
574
+ };
575
+
576
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
577
+ static const yytype_uint8 yyr1[] =
578
+ {
579
+ 0, 21, 22, 23, 23, 23, 23, 23, 23, 23,
580
+ 23, 23, 24, 24, 25, 25, 25, 25, 25, 26,
581
+ 26, 26, 27, 27, 27
582
+ };
583
+
584
+ /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
585
+ static const yytype_uint8 yyr2[] =
586
+ {
587
+ 0, 2, 3, 3, 3, 3, 2, 2, 2, 2,
588
+ 2, 2, 1, 3, 1, 3, 3, 2, 2, 1,
589
+ 3, 3, 1, 1, 2
590
+ };
591
+
592
+
593
+ #define yyerrok (yyerrstatus = 0)
594
+ #define yyclearin (yychar = YYEMPTY)
595
+ #define YYEMPTY (-2)
596
+ #define YYEOF 0
597
+
598
+ #define YYACCEPT goto yyacceptlab
599
+ #define YYABORT goto yyabortlab
600
+ #define YYERROR goto yyerrorlab
601
+
602
+
603
+ #define YYRECOVERING() (!!yyerrstatus)
604
+
605
+ #define YYBACKUP(Token, Value) \
606
+ do \
607
+ if (yychar == YYEMPTY) \
608
+ { \
609
+ yychar = (Token); \
610
+ yylval = (Value); \
611
+ YYPOPSTACK (yylen); \
612
+ yystate = *yyssp; \
613
+ goto yybackup; \
614
+ } \
615
+ else \
616
+ { \
617
+ yyerror (expression, scanner, YY_("syntax error: cannot back up")); \
618
+ YYERROR; \
619
+ } \
620
+ while (0)
621
+
622
+ /* Error token number */
623
+ #define YYTERROR 1
624
+ #define YYERRCODE 256
625
+
626
+
627
+
628
+ /* Enable debugging if requested. */
629
+ #if YYDEBUG
630
+
631
+ # ifndef YYFPRINTF
632
+ # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
633
+ # define YYFPRINTF fprintf
634
+ # endif
635
+
636
+ # define YYDPRINTF(Args) \
637
+ do { \
638
+ if (yydebug) \
639
+ YYFPRINTF Args; \
640
+ } while (0)
641
+
642
+ /* This macro is provided for backward compatibility. */
643
+ #ifndef YY_LOCATION_PRINT
644
+ # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
645
+ #endif
646
+
647
+
648
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
649
+ do { \
650
+ if (yydebug) \
651
+ { \
652
+ YYFPRINTF (stderr, "%s ", Title); \
653
+ yy_symbol_print (stderr, \
654
+ Type, Value, expression, scanner); \
655
+ YYFPRINTF (stderr, "\n"); \
656
+ } \
657
+ } while (0)
658
+
659
+
660
+ /*----------------------------------------.
661
+ | Print this symbol's value on YYOUTPUT. |
662
+ `----------------------------------------*/
663
+
664
+ static void
665
+ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, expression **expression, freesasa_yyscan_t scanner)
666
+ {
667
+ FILE *yyo = yyoutput;
668
+ YYUSE (yyo);
669
+ YYUSE (expression);
670
+ YYUSE (scanner);
671
+ if (!yyvaluep)
672
+ return;
673
+ # ifdef YYPRINT
674
+ if (yytype < YYNTOKENS)
675
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
676
+ # endif
677
+ YYUSE (yytype);
678
+ }
679
+
680
+
681
+ /*--------------------------------.
682
+ | Print this symbol on YYOUTPUT. |
683
+ `--------------------------------*/
684
+
685
+ static void
686
+ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, expression **expression, freesasa_yyscan_t scanner)
687
+ {
688
+ YYFPRINTF (yyoutput, "%s %s (",
689
+ yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
690
+
691
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep, expression, scanner);
692
+ YYFPRINTF (yyoutput, ")");
693
+ }
694
+
695
+ /*------------------------------------------------------------------.
696
+ | yy_stack_print -- Print the state stack from its BOTTOM up to its |
697
+ | TOP (included). |
698
+ `------------------------------------------------------------------*/
699
+
700
+ static void
701
+ yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
702
+ {
703
+ YYFPRINTF (stderr, "Stack now");
704
+ for (; yybottom <= yytop; yybottom++)
705
+ {
706
+ int yybot = *yybottom;
707
+ YYFPRINTF (stderr, " %d", yybot);
708
+ }
709
+ YYFPRINTF (stderr, "\n");
710
+ }
711
+
712
+ # define YY_STACK_PRINT(Bottom, Top) \
713
+ do { \
714
+ if (yydebug) \
715
+ yy_stack_print ((Bottom), (Top)); \
716
+ } while (0)
717
+
718
+
719
+ /*------------------------------------------------.
720
+ | Report that the YYRULE is going to be reduced. |
721
+ `------------------------------------------------*/
722
+
723
+ static void
724
+ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, expression **expression, freesasa_yyscan_t scanner)
725
+ {
726
+ unsigned long int yylno = yyrline[yyrule];
727
+ int yynrhs = yyr2[yyrule];
728
+ int yyi;
729
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
730
+ yyrule - 1, yylno);
731
+ /* The symbols being reduced. */
732
+ for (yyi = 0; yyi < yynrhs; yyi++)
733
+ {
734
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
735
+ yy_symbol_print (stderr,
736
+ yystos[yyssp[yyi + 1 - yynrhs]],
737
+ &(yyvsp[(yyi + 1) - (yynrhs)])
738
+ , expression, scanner);
739
+ YYFPRINTF (stderr, "\n");
740
+ }
741
+ }
742
+
743
+ # define YY_REDUCE_PRINT(Rule) \
744
+ do { \
745
+ if (yydebug) \
746
+ yy_reduce_print (yyssp, yyvsp, Rule, expression, scanner); \
747
+ } while (0)
748
+
749
+ /* Nonzero means print parse trace. It is left uninitialized so that
750
+ multiple parsers can coexist. */
751
+ int yydebug;
752
+ #else /* !YYDEBUG */
753
+ # define YYDPRINTF(Args)
754
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
755
+ # define YY_STACK_PRINT(Bottom, Top)
756
+ # define YY_REDUCE_PRINT(Rule)
757
+ #endif /* !YYDEBUG */
758
+
759
+
760
+ /* YYINITDEPTH -- initial size of the parser's stacks. */
761
+ #ifndef YYINITDEPTH
762
+ # define YYINITDEPTH 200
763
+ #endif
764
+
765
+ /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
766
+ if the built-in stack extension method is used).
767
+
768
+ Do not make this value too large; the results are undefined if
769
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
770
+ evaluated with infinite-precision integer arithmetic. */
771
+
772
+ #ifndef YYMAXDEPTH
773
+ # define YYMAXDEPTH 10000
774
+ #endif
775
+
776
+
777
+ #if YYERROR_VERBOSE
778
+
779
+ # ifndef yystrlen
780
+ # if defined __GLIBC__ && defined _STRING_H
781
+ # define yystrlen strlen
782
+ # else
783
+ /* Return the length of YYSTR. */
784
+ static YYSIZE_T
785
+ yystrlen (const char *yystr)
786
+ {
787
+ YYSIZE_T yylen;
788
+ for (yylen = 0; yystr[yylen]; yylen++)
789
+ continue;
790
+ return yylen;
791
+ }
792
+ # endif
793
+ # endif
794
+
795
+ # ifndef yystpcpy
796
+ # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
797
+ # define yystpcpy stpcpy
798
+ # else
799
+ /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
800
+ YYDEST. */
801
+ static char *
802
+ yystpcpy (char *yydest, const char *yysrc)
803
+ {
804
+ char *yyd = yydest;
805
+ const char *yys = yysrc;
806
+
807
+ while ((*yyd++ = *yys++) != '\0')
808
+ continue;
809
+
810
+ return yyd - 1;
811
+ }
812
+ # endif
813
+ # endif
814
+
815
+ # ifndef yytnamerr
816
+ /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
817
+ quotes and backslashes, so that it's suitable for yyerror. The
818
+ heuristic is that double-quoting is unnecessary unless the string
819
+ contains an apostrophe, a comma, or backslash (other than
820
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
821
+ null, do not copy; instead, return the length of what the result
822
+ would have been. */
823
+ static YYSIZE_T
824
+ yytnamerr (char *yyres, const char *yystr)
825
+ {
826
+ if (*yystr == '"')
827
+ {
828
+ YYSIZE_T yyn = 0;
829
+ char const *yyp = yystr;
830
+
831
+ for (;;)
832
+ switch (*++yyp)
833
+ {
834
+ case '\'':
835
+ case ',':
836
+ goto do_not_strip_quotes;
837
+
838
+ case '\\':
839
+ if (*++yyp != '\\')
840
+ goto do_not_strip_quotes;
841
+ /* Fall through. */
842
+ default:
843
+ if (yyres)
844
+ yyres[yyn] = *yyp;
845
+ yyn++;
846
+ break;
847
+
848
+ case '"':
849
+ if (yyres)
850
+ yyres[yyn] = '\0';
851
+ return yyn;
852
+ }
853
+ do_not_strip_quotes: ;
854
+ }
855
+
856
+ if (! yyres)
857
+ return yystrlen (yystr);
858
+
859
+ return yystpcpy (yyres, yystr) - yyres;
860
+ }
861
+ # endif
862
+
863
+ /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
864
+ about the unexpected token YYTOKEN for the state stack whose top is
865
+ YYSSP.
866
+
867
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
868
+ not large enough to hold the message. In that case, also set
869
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
870
+ required number of bytes is too large to store. */
871
+ static int
872
+ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
873
+ yytype_int16 *yyssp, int yytoken)
874
+ {
875
+ YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
876
+ YYSIZE_T yysize = yysize0;
877
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
878
+ /* Internationalized format string. */
879
+ const char *yyformat = YY_NULLPTR;
880
+ /* Arguments of yyformat. */
881
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
882
+ /* Number of reported tokens (one for the "unexpected", one per
883
+ "expected"). */
884
+ int yycount = 0;
885
+
886
+ /* There are many possibilities here to consider:
887
+ - If this state is a consistent state with a default action, then
888
+ the only way this function was invoked is if the default action
889
+ is an error action. In that case, don't check for expected
890
+ tokens because there are none.
891
+ - The only way there can be no lookahead present (in yychar) is if
892
+ this state is a consistent state with a default action. Thus,
893
+ detecting the absence of a lookahead is sufficient to determine
894
+ that there is no unexpected or expected token to report. In that
895
+ case, just report a simple "syntax error".
896
+ - Don't assume there isn't a lookahead just because this state is a
897
+ consistent state with a default action. There might have been a
898
+ previous inconsistent state, consistent state with a non-default
899
+ action, or user semantic action that manipulated yychar.
900
+ - Of course, the expected token list depends on states to have
901
+ correct lookahead information, and it depends on the parser not
902
+ to perform extra reductions after fetching a lookahead from the
903
+ scanner and before detecting a syntax error. Thus, state merging
904
+ (from LALR or IELR) and default reductions corrupt the expected
905
+ token list. However, the list is correct for canonical LR with
906
+ one exception: it will still contain any token that will not be
907
+ accepted due to an error action in a later state.
908
+ */
909
+ if (yytoken != YYEMPTY)
910
+ {
911
+ int yyn = yypact[*yyssp];
912
+ yyarg[yycount++] = yytname[yytoken];
913
+ if (!yypact_value_is_default (yyn))
914
+ {
915
+ /* Start YYX at -YYN if negative to avoid negative indexes in
916
+ YYCHECK. In other words, skip the first -YYN actions for
917
+ this state because they are default actions. */
918
+ int yyxbegin = yyn < 0 ? -yyn : 0;
919
+ /* Stay within bounds of both yycheck and yytname. */
920
+ int yychecklim = YYLAST - yyn + 1;
921
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
922
+ int yyx;
923
+
924
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
925
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
926
+ && !yytable_value_is_error (yytable[yyx + yyn]))
927
+ {
928
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
929
+ {
930
+ yycount = 1;
931
+ yysize = yysize0;
932
+ break;
933
+ }
934
+ yyarg[yycount++] = yytname[yyx];
935
+ {
936
+ YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
937
+ if (! (yysize <= yysize1
938
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
939
+ return 2;
940
+ yysize = yysize1;
941
+ }
942
+ }
943
+ }
944
+ }
945
+
946
+ switch (yycount)
947
+ {
948
+ # define YYCASE_(N, S) \
949
+ case N: \
950
+ yyformat = S; \
951
+ break
952
+ YYCASE_(0, YY_("syntax error"));
953
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
954
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
955
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
956
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
957
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
958
+ # undef YYCASE_
959
+ }
960
+
961
+ {
962
+ YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
963
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
964
+ return 2;
965
+ yysize = yysize1;
966
+ }
967
+
968
+ if (*yymsg_alloc < yysize)
969
+ {
970
+ *yymsg_alloc = 2 * yysize;
971
+ if (! (yysize <= *yymsg_alloc
972
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
973
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
974
+ return 1;
975
+ }
976
+
977
+ /* Avoid sprintf, as that infringes on the user's name space.
978
+ Don't have undefined behavior even if the translation
979
+ produced a string with the wrong number of "%s"s. */
980
+ {
981
+ char *yyp = *yymsg;
982
+ int yyi = 0;
983
+ while ((*yyp = *yyformat) != '\0')
984
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
985
+ {
986
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
987
+ yyformat += 2;
988
+ }
989
+ else
990
+ {
991
+ yyp++;
992
+ yyformat++;
993
+ }
994
+ }
995
+ return 0;
996
+ }
997
+ #endif /* YYERROR_VERBOSE */
998
+
999
+ /*-----------------------------------------------.
1000
+ | Release the memory associated to this symbol. |
1001
+ `-----------------------------------------------*/
1002
+
1003
+ static void
1004
+ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, expression **expression, freesasa_yyscan_t scanner)
1005
+ {
1006
+ YYUSE (yyvaluep);
1007
+ YYUSE (expression);
1008
+ YYUSE (scanner);
1009
+ if (!yymsg)
1010
+ yymsg = "Deleting";
1011
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1012
+
1013
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1014
+ YYUSE (yytype);
1015
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
1016
+ }
1017
+
1018
+
1019
+
1020
+
1021
+ /*----------.
1022
+ | yyparse. |
1023
+ `----------*/
1024
+
1025
+ int
1026
+ yyparse (expression **expression, freesasa_yyscan_t scanner)
1027
+ {
1028
+ /* The lookahead symbol. */
1029
+ int yychar;
1030
+
1031
+
1032
+ /* The semantic value of the lookahead symbol. */
1033
+ /* Default value used for initialization, for pacifying older GCCs
1034
+ or non-GCC compilers. */
1035
+ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1036
+ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1037
+
1038
+ /* Number of syntax errors so far. */
1039
+ int yynerrs;
1040
+
1041
+ int yystate;
1042
+ /* Number of tokens to shift before error messages enabled. */
1043
+ int yyerrstatus;
1044
+
1045
+ /* The stacks and their tools:
1046
+ 'yyss': related to states.
1047
+ 'yyvs': related to semantic values.
1048
+
1049
+ Refer to the stacks through separate pointers, to allow yyoverflow
1050
+ to reallocate them elsewhere. */
1051
+
1052
+ /* The state stack. */
1053
+ yytype_int16 yyssa[YYINITDEPTH];
1054
+ yytype_int16 *yyss;
1055
+ yytype_int16 *yyssp;
1056
+
1057
+ /* The semantic value stack. */
1058
+ YYSTYPE yyvsa[YYINITDEPTH];
1059
+ YYSTYPE *yyvs;
1060
+ YYSTYPE *yyvsp;
1061
+
1062
+ YYSIZE_T yystacksize;
1063
+
1064
+ int yyn;
1065
+ int yyresult;
1066
+ /* Lookahead token as an internal (translated) token number. */
1067
+ int yytoken = 0;
1068
+ /* The variables used to return semantic value and location from the
1069
+ action routines. */
1070
+ YYSTYPE yyval;
1071
+
1072
+ #if YYERROR_VERBOSE
1073
+ /* Buffer for error messages, and its allocated size. */
1074
+ char yymsgbuf[128];
1075
+ char *yymsg = yymsgbuf;
1076
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1077
+ #endif
1078
+
1079
+ #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1080
+
1081
+ /* The number of symbols on the RHS of the reduced rule.
1082
+ Keep to zero when no symbol should be popped. */
1083
+ int yylen = 0;
1084
+
1085
+ yyssp = yyss = yyssa;
1086
+ yyvsp = yyvs = yyvsa;
1087
+ yystacksize = YYINITDEPTH;
1088
+
1089
+ YYDPRINTF ((stderr, "Starting parse\n"));
1090
+
1091
+ yystate = 0;
1092
+ yyerrstatus = 0;
1093
+ yynerrs = 0;
1094
+ yychar = YYEMPTY; /* Cause a token to be read. */
1095
+ goto yysetstate;
1096
+
1097
+ /*------------------------------------------------------------.
1098
+ | yynewstate -- Push a new state, which is found in yystate. |
1099
+ `------------------------------------------------------------*/
1100
+ yynewstate:
1101
+ /* In all cases, when you get here, the value and location stacks
1102
+ have just been pushed. So pushing a state here evens the stacks. */
1103
+ yyssp++;
1104
+
1105
+ yysetstate:
1106
+ *yyssp = yystate;
1107
+
1108
+ if (yyss + yystacksize - 1 <= yyssp)
1109
+ {
1110
+ /* Get the current used size of the three stacks, in elements. */
1111
+ YYSIZE_T yysize = yyssp - yyss + 1;
1112
+
1113
+ #ifdef yyoverflow
1114
+ {
1115
+ /* Give user a chance to reallocate the stack. Use copies of
1116
+ these so that the &'s don't force the real ones into
1117
+ memory. */
1118
+ YYSTYPE *yyvs1 = yyvs;
1119
+ yytype_int16 *yyss1 = yyss;
1120
+
1121
+ /* Each stack pointer address is followed by the size of the
1122
+ data in use in that stack, in bytes. This used to be a
1123
+ conditional around just the two extra args, but that might
1124
+ be undefined if yyoverflow is a macro. */
1125
+ yyoverflow (YY_("memory exhausted"),
1126
+ &yyss1, yysize * sizeof (*yyssp),
1127
+ &yyvs1, yysize * sizeof (*yyvsp),
1128
+ &yystacksize);
1129
+
1130
+ yyss = yyss1;
1131
+ yyvs = yyvs1;
1132
+ }
1133
+ #else /* no yyoverflow */
1134
+ # ifndef YYSTACK_RELOCATE
1135
+ goto yyexhaustedlab;
1136
+ # else
1137
+ /* Extend the stack our own way. */
1138
+ if (YYMAXDEPTH <= yystacksize)
1139
+ goto yyexhaustedlab;
1140
+ yystacksize *= 2;
1141
+ if (YYMAXDEPTH < yystacksize)
1142
+ yystacksize = YYMAXDEPTH;
1143
+
1144
+ {
1145
+ yytype_int16 *yyss1 = yyss;
1146
+ union yyalloc *yyptr =
1147
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1148
+ if (! yyptr)
1149
+ goto yyexhaustedlab;
1150
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
1151
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1152
+ # undef YYSTACK_RELOCATE
1153
+ if (yyss1 != yyssa)
1154
+ YYSTACK_FREE (yyss1);
1155
+ }
1156
+ # endif
1157
+ #endif /* no yyoverflow */
1158
+
1159
+ yyssp = yyss + yysize - 1;
1160
+ yyvsp = yyvs + yysize - 1;
1161
+
1162
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1163
+ (unsigned long int) yystacksize));
1164
+
1165
+ if (yyss + yystacksize - 1 <= yyssp)
1166
+ YYABORT;
1167
+ }
1168
+
1169
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1170
+
1171
+ if (yystate == YYFINAL)
1172
+ YYACCEPT;
1173
+
1174
+ goto yybackup;
1175
+
1176
+ /*-----------.
1177
+ | yybackup. |
1178
+ `-----------*/
1179
+ yybackup:
1180
+
1181
+ /* Do appropriate processing given the current state. Read a
1182
+ lookahead token if we need one and don't already have one. */
1183
+
1184
+ /* First try to decide what to do without reference to lookahead token. */
1185
+ yyn = yypact[yystate];
1186
+ if (yypact_value_is_default (yyn))
1187
+ goto yydefault;
1188
+
1189
+ /* Not known => get a lookahead token if don't already have one. */
1190
+
1191
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1192
+ if (yychar == YYEMPTY)
1193
+ {
1194
+ YYDPRINTF ((stderr, "Reading a token: "));
1195
+ yychar = yylex (&yylval, scanner);
1196
+ }
1197
+
1198
+ if (yychar <= YYEOF)
1199
+ {
1200
+ yychar = yytoken = YYEOF;
1201
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
1202
+ }
1203
+ else
1204
+ {
1205
+ yytoken = YYTRANSLATE (yychar);
1206
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1207
+ }
1208
+
1209
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
1210
+ detect an error, take that action. */
1211
+ yyn += yytoken;
1212
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1213
+ goto yydefault;
1214
+ yyn = yytable[yyn];
1215
+ if (yyn <= 0)
1216
+ {
1217
+ if (yytable_value_is_error (yyn))
1218
+ goto yyerrlab;
1219
+ yyn = -yyn;
1220
+ goto yyreduce;
1221
+ }
1222
+
1223
+ /* Count tokens shifted since error; after three, turn off error
1224
+ status. */
1225
+ if (yyerrstatus)
1226
+ yyerrstatus--;
1227
+
1228
+ /* Shift the lookahead token. */
1229
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1230
+
1231
+ /* Discard the shifted token. */
1232
+ yychar = YYEMPTY;
1233
+
1234
+ yystate = yyn;
1235
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1236
+ *++yyvsp = yylval;
1237
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
1238
+
1239
+ goto yynewstate;
1240
+
1241
+
1242
+ /*-----------------------------------------------------------.
1243
+ | yydefault -- do the default action for the current state. |
1244
+ `-----------------------------------------------------------*/
1245
+ yydefault:
1246
+ yyn = yydefact[yystate];
1247
+ if (yyn == 0)
1248
+ goto yyerrlab;
1249
+ goto yyreduce;
1250
+
1251
+
1252
+ /*-----------------------------.
1253
+ | yyreduce -- Do a reduction. |
1254
+ `-----------------------------*/
1255
+ yyreduce:
1256
+ /* yyn is the number of a rule to reduce with. */
1257
+ yylen = yyr2[yyn];
1258
+
1259
+ /* If YYLEN is nonzero, implement the default value of the action:
1260
+ '$$ = $1'.
1261
+
1262
+ Otherwise, the following line sets YYVAL to garbage.
1263
+ This behavior is undocumented and Bison
1264
+ users should not rely upon it. Assigning to YYVAL
1265
+ unconditionally makes the parser a bit smaller, and it avoids a
1266
+ GCC warning that YYVAL may be used uninitialized. */
1267
+ yyval = yyvsp[1-yylen];
1268
+
1269
+
1270
+ YY_REDUCE_PRINT (yyn);
1271
+ switch (yyn)
1272
+ {
1273
+ case 2:
1274
+ #line 68 "parser.y" /* yacc.c:1646 */
1275
+ { *expression = freesasa_selection_create((yyvsp[0].expression), (yyvsp[-2].value)); }
1276
+ #line 1277 "parser.c" /* yacc.c:1646 */
1277
+ break;
1278
+
1279
+ case 3:
1280
+ #line 72 "parser.y" /* yacc.c:1646 */
1281
+ { (yyval.expression) = (yyvsp[-1].expression); }
1282
+ #line 1283 "parser.c" /* yacc.c:1646 */
1283
+ break;
1284
+
1285
+ case 4:
1286
+ #line 73 "parser.y" /* yacc.c:1646 */
1287
+ { (yyval.expression) = freesasa_selection_operation(E_AND, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1288
+ #line 1289 "parser.c" /* yacc.c:1646 */
1289
+ break;
1290
+
1291
+ case 5:
1292
+ #line 74 "parser.y" /* yacc.c:1646 */
1293
+ { (yyval.expression) = freesasa_selection_operation(E_OR, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1294
+ #line 1295 "parser.c" /* yacc.c:1646 */
1295
+ break;
1296
+
1297
+ case 6:
1298
+ #line 75 "parser.y" /* yacc.c:1646 */
1299
+ { (yyval.expression) = freesasa_selection_operation(E_NOT, NULL, (yyvsp[0].expression)); }
1300
+ #line 1301 "parser.c" /* yacc.c:1646 */
1301
+ break;
1302
+
1303
+ case 7:
1304
+ #line 76 "parser.y" /* yacc.c:1646 */
1305
+ { (yyval.expression) = freesasa_selection_selector(E_RESN, (yyvsp[0].expression)); }
1306
+ #line 1307 "parser.c" /* yacc.c:1646 */
1307
+ break;
1308
+
1309
+ case 8:
1310
+ #line 77 "parser.y" /* yacc.c:1646 */
1311
+ { (yyval.expression) = freesasa_selection_selector(E_RESI, (yyvsp[0].expression)); }
1312
+ #line 1313 "parser.c" /* yacc.c:1646 */
1313
+ break;
1314
+
1315
+ case 9:
1316
+ #line 78 "parser.y" /* yacc.c:1646 */
1317
+ { (yyval.expression) = freesasa_selection_selector(E_SYMBOL, (yyvsp[0].expression)); }
1318
+ #line 1319 "parser.c" /* yacc.c:1646 */
1319
+ break;
1320
+
1321
+ case 10:
1322
+ #line 79 "parser.y" /* yacc.c:1646 */
1323
+ { (yyval.expression) = freesasa_selection_selector(E_NAME, (yyvsp[0].expression)); }
1324
+ #line 1325 "parser.c" /* yacc.c:1646 */
1325
+ break;
1326
+
1327
+ case 11:
1328
+ #line 80 "parser.y" /* yacc.c:1646 */
1329
+ { (yyval.expression) = freesasa_selection_selector(E_CHAIN, (yyvsp[0].expression)); }
1330
+ #line 1331 "parser.c" /* yacc.c:1646 */
1331
+ break;
1332
+
1333
+ case 12:
1334
+ #line 84 "parser.y" /* yacc.c:1646 */
1335
+ { (yyval.expression) = (yyvsp[0].expression); }
1336
+ #line 1337 "parser.c" /* yacc.c:1646 */
1337
+ break;
1338
+
1339
+ case 13:
1340
+ #line 85 "parser.y" /* yacc.c:1646 */
1341
+ { (yyval.expression) = freesasa_selection_operation(E_PLUS, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1342
+ #line 1343 "parser.c" /* yacc.c:1646 */
1343
+ break;
1344
+
1345
+ case 14:
1346
+ #line 89 "parser.y" /* yacc.c:1646 */
1347
+ { (yyval.expression) = (yyvsp[0].expression); }
1348
+ #line 1349 "parser.c" /* yacc.c:1646 */
1349
+ break;
1350
+
1351
+ case 15:
1352
+ #line 90 "parser.y" /* yacc.c:1646 */
1353
+ { (yyval.expression) = freesasa_selection_operation(E_PLUS, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1354
+ #line 1355 "parser.c" /* yacc.c:1646 */
1355
+ break;
1356
+
1357
+ case 16:
1358
+ #line 91 "parser.y" /* yacc.c:1646 */
1359
+ { (yyval.expression) = freesasa_selection_operation(E_RANGE, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1360
+ #line 1361 "parser.c" /* yacc.c:1646 */
1361
+ break;
1362
+
1363
+ case 17:
1364
+ #line 92 "parser.y" /* yacc.c:1646 */
1365
+ { (yyval.expression) = freesasa_selection_operation(E_RANGE_OPEN_L, NULL, (yyvsp[0].expression)); }
1366
+ #line 1367 "parser.c" /* yacc.c:1646 */
1367
+ break;
1368
+
1369
+ case 18:
1370
+ #line 93 "parser.y" /* yacc.c:1646 */
1371
+ { (yyval.expression) = freesasa_selection_operation(E_RANGE_OPEN_R, (yyvsp[-1].expression), NULL); }
1372
+ #line 1373 "parser.c" /* yacc.c:1646 */
1373
+ break;
1374
+
1375
+ case 19:
1376
+ #line 97 "parser.y" /* yacc.c:1646 */
1377
+ { (yyval.expression) = (yyvsp[0].expression); }
1378
+ #line 1379 "parser.c" /* yacc.c:1646 */
1379
+ break;
1380
+
1381
+ case 20:
1382
+ #line 98 "parser.y" /* yacc.c:1646 */
1383
+ { (yyval.expression) = freesasa_selection_operation(E_PLUS, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1384
+ #line 1385 "parser.c" /* yacc.c:1646 */
1385
+ break;
1386
+
1387
+ case 21:
1388
+ #line 99 "parser.y" /* yacc.c:1646 */
1389
+ { (yyval.expression) = freesasa_selection_operation(E_RANGE, (yyvsp[-2].expression), (yyvsp[0].expression)); }
1390
+ #line 1391 "parser.c" /* yacc.c:1646 */
1391
+ break;
1392
+
1393
+ case 22:
1394
+ #line 103 "parser.y" /* yacc.c:1646 */
1395
+ { (yyval.expression) = freesasa_selection_atom(E_NUMBER, (yyvsp[0].value)); }
1396
+ #line 1397 "parser.c" /* yacc.c:1646 */
1397
+ break;
1398
+
1399
+ case 23:
1400
+ #line 104 "parser.y" /* yacc.c:1646 */
1401
+ { (yyval.expression) = freesasa_selection_atom(E_ID, (yyvsp[0].value)); }
1402
+ #line 1403 "parser.c" /* yacc.c:1646 */
1403
+ break;
1404
+
1405
+ case 24:
1406
+ #line 105 "parser.y" /* yacc.c:1646 */
1407
+ { (yyval.expression) = freesasa_selection_atom(E_NEGNUM, (yyvsp[0].value)); }
1408
+ #line 1409 "parser.c" /* yacc.c:1646 */
1409
+ break;
1410
+
1411
+
1412
+ #line 1413 "parser.c" /* yacc.c:1646 */
1413
+ default: break;
1414
+ }
1415
+ /* User semantic actions sometimes alter yychar, and that requires
1416
+ that yytoken be updated with the new translation. We take the
1417
+ approach of translating immediately before every use of yytoken.
1418
+ One alternative is translating here after every semantic action,
1419
+ but that translation would be missed if the semantic action invokes
1420
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1421
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1422
+ incorrect destructor might then be invoked immediately. In the
1423
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
1424
+ to an incorrect destructor call or verbose syntax error message
1425
+ before the lookahead is translated. */
1426
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1427
+
1428
+ YYPOPSTACK (yylen);
1429
+ yylen = 0;
1430
+ YY_STACK_PRINT (yyss, yyssp);
1431
+
1432
+ *++yyvsp = yyval;
1433
+
1434
+ /* Now 'shift' the result of the reduction. Determine what state
1435
+ that goes to, based on the state we popped back to and the rule
1436
+ number reduced by. */
1437
+
1438
+ yyn = yyr1[yyn];
1439
+
1440
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1441
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1442
+ yystate = yytable[yystate];
1443
+ else
1444
+ yystate = yydefgoto[yyn - YYNTOKENS];
1445
+
1446
+ goto yynewstate;
1447
+
1448
+
1449
+ /*--------------------------------------.
1450
+ | yyerrlab -- here on detecting error. |
1451
+ `--------------------------------------*/
1452
+ yyerrlab:
1453
+ /* Make sure we have latest lookahead translation. See comments at
1454
+ user semantic actions for why this is necessary. */
1455
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1456
+
1457
+ /* If not already recovering from an error, report this error. */
1458
+ if (!yyerrstatus)
1459
+ {
1460
+ ++yynerrs;
1461
+ #if ! YYERROR_VERBOSE
1462
+ yyerror (expression, scanner, YY_("syntax error"));
1463
+ #else
1464
+ # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1465
+ yyssp, yytoken)
1466
+ {
1467
+ char const *yymsgp = YY_("syntax error");
1468
+ int yysyntax_error_status;
1469
+ yysyntax_error_status = YYSYNTAX_ERROR;
1470
+ if (yysyntax_error_status == 0)
1471
+ yymsgp = yymsg;
1472
+ else if (yysyntax_error_status == 1)
1473
+ {
1474
+ if (yymsg != yymsgbuf)
1475
+ YYSTACK_FREE (yymsg);
1476
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1477
+ if (!yymsg)
1478
+ {
1479
+ yymsg = yymsgbuf;
1480
+ yymsg_alloc = sizeof yymsgbuf;
1481
+ yysyntax_error_status = 2;
1482
+ }
1483
+ else
1484
+ {
1485
+ yysyntax_error_status = YYSYNTAX_ERROR;
1486
+ yymsgp = yymsg;
1487
+ }
1488
+ }
1489
+ yyerror (expression, scanner, yymsgp);
1490
+ if (yysyntax_error_status == 2)
1491
+ goto yyexhaustedlab;
1492
+ }
1493
+ # undef YYSYNTAX_ERROR
1494
+ #endif
1495
+ }
1496
+
1497
+
1498
+
1499
+ if (yyerrstatus == 3)
1500
+ {
1501
+ /* If just tried and failed to reuse lookahead token after an
1502
+ error, discard it. */
1503
+
1504
+ if (yychar <= YYEOF)
1505
+ {
1506
+ /* Return failure if at end of input. */
1507
+ if (yychar == YYEOF)
1508
+ YYABORT;
1509
+ }
1510
+ else
1511
+ {
1512
+ yydestruct ("Error: discarding",
1513
+ yytoken, &yylval, expression, scanner);
1514
+ yychar = YYEMPTY;
1515
+ }
1516
+ }
1517
+
1518
+ /* Else will try to reuse lookahead token after shifting the error
1519
+ token. */
1520
+ goto yyerrlab1;
1521
+
1522
+
1523
+ /*---------------------------------------------------.
1524
+ | yyerrorlab -- error raised explicitly by YYERROR. |
1525
+ `---------------------------------------------------*/
1526
+ yyerrorlab:
1527
+
1528
+ /* Pacify compilers like GCC when the user code never invokes
1529
+ YYERROR and the label yyerrorlab therefore never appears in user
1530
+ code. */
1531
+ if (/*CONSTCOND*/ 0)
1532
+ goto yyerrorlab;
1533
+
1534
+ /* Do not reclaim the symbols of the rule whose action triggered
1535
+ this YYERROR. */
1536
+ YYPOPSTACK (yylen);
1537
+ yylen = 0;
1538
+ YY_STACK_PRINT (yyss, yyssp);
1539
+ yystate = *yyssp;
1540
+ goto yyerrlab1;
1541
+
1542
+
1543
+ /*-------------------------------------------------------------.
1544
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |
1545
+ `-------------------------------------------------------------*/
1546
+ yyerrlab1:
1547
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
1548
+
1549
+ for (;;)
1550
+ {
1551
+ yyn = yypact[yystate];
1552
+ if (!yypact_value_is_default (yyn))
1553
+ {
1554
+ yyn += YYTERROR;
1555
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1556
+ {
1557
+ yyn = yytable[yyn];
1558
+ if (0 < yyn)
1559
+ break;
1560
+ }
1561
+ }
1562
+
1563
+ /* Pop the current state because it cannot handle the error token. */
1564
+ if (yyssp == yyss)
1565
+ YYABORT;
1566
+
1567
+
1568
+ yydestruct ("Error: popping",
1569
+ yystos[yystate], yyvsp, expression, scanner);
1570
+ YYPOPSTACK (1);
1571
+ yystate = *yyssp;
1572
+ YY_STACK_PRINT (yyss, yyssp);
1573
+ }
1574
+
1575
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1576
+ *++yyvsp = yylval;
1577
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
1578
+
1579
+
1580
+ /* Shift the error token. */
1581
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1582
+
1583
+ yystate = yyn;
1584
+ goto yynewstate;
1585
+
1586
+
1587
+ /*-------------------------------------.
1588
+ | yyacceptlab -- YYACCEPT comes here. |
1589
+ `-------------------------------------*/
1590
+ yyacceptlab:
1591
+ yyresult = 0;
1592
+ goto yyreturn;
1593
+
1594
+ /*-----------------------------------.
1595
+ | yyabortlab -- YYABORT comes here. |
1596
+ `-----------------------------------*/
1597
+ yyabortlab:
1598
+ yyresult = 1;
1599
+ goto yyreturn;
1600
+
1601
+ #if !defined yyoverflow || YYERROR_VERBOSE
1602
+ /*-------------------------------------------------.
1603
+ | yyexhaustedlab -- memory exhaustion comes here. |
1604
+ `-------------------------------------------------*/
1605
+ yyexhaustedlab:
1606
+ yyerror (expression, scanner, YY_("memory exhausted"));
1607
+ yyresult = 2;
1608
+ /* Fall through. */
1609
+ #endif
1610
+
1611
+ yyreturn:
1612
+ if (yychar != YYEMPTY)
1613
+ {
1614
+ /* Make sure we have latest lookahead translation. See comments at
1615
+ user semantic actions for why this is necessary. */
1616
+ yytoken = YYTRANSLATE (yychar);
1617
+ yydestruct ("Cleanup: discarding lookahead",
1618
+ yytoken, &yylval, expression, scanner);
1619
+ }
1620
+ /* Do not reclaim the symbols of the rule whose action triggered
1621
+ this YYABORT or YYACCEPT. */
1622
+ YYPOPSTACK (yylen);
1623
+ YY_STACK_PRINT (yyss, yyssp);
1624
+ while (yyssp != yyss)
1625
+ {
1626
+ yydestruct ("Cleanup: popping",
1627
+ yystos[*yyssp], yyvsp, expression, scanner);
1628
+ YYPOPSTACK (1);
1629
+ }
1630
+ #ifndef yyoverflow
1631
+ if (yyss != yyssa)
1632
+ YYSTACK_FREE (yyss);
1633
+ #endif
1634
+ #if YYERROR_VERBOSE
1635
+ if (yymsg != yymsgbuf)
1636
+ YYSTACK_FREE (yymsg);
1637
+ #endif
1638
+ return yyresult;
1639
+ }
.venv_haddock/include/site/python3.12/freesasa/parser.h ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* A Bison parser, made by GNU Bison 3.0.4. */
2
+
3
+ /* Bison interface for Yacc-like parsers in C
4
+
5
+ Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
+
20
+ /* As a special exception, you may create a larger work that contains
21
+ part or all of the Bison parser skeleton and distribute that work
22
+ under terms of your choice, so long as that work isn't itself a
23
+ parser generator using the skeleton or a modified version thereof
24
+ as a parser skeleton. Alternatively, if you modify or redistribute
25
+ the parser skeleton itself, you may (at your option) remove this
26
+ special exception, which will cause the skeleton and the resulting
27
+ Bison output files to be licensed under the GNU General Public
28
+ License without this special exception.
29
+
30
+ This special exception was added by the Free Software Foundation in
31
+ version 2.2 of Bison. */
32
+
33
+ #ifndef YY_FREESASA_YY_PARSER_H_INCLUDED
34
+ # define YY_FREESASA_YY_PARSER_H_INCLUDED
35
+ /* Debug traces. */
36
+ #ifndef YYDEBUG
37
+ # define YYDEBUG 0
38
+ #endif
39
+ #if YYDEBUG
40
+ extern int freesasa_yydebug;
41
+ #endif
42
+ /* "%code requires" blocks. */
43
+ #line 13 "parser.y" /* yacc.c:1909 */
44
+
45
+
46
+ #ifndef FREESASA_TYPEDEF_YY_SCANNER_T
47
+ #define FREESASA_TYPEDEF_YY_SCANNER_T
48
+ typedef void* freesasa_yyscan_t;
49
+ #endif
50
+
51
+
52
+ #line 53 "parser.h" /* yacc.c:1909 */
53
+
54
+ /* Token type. */
55
+ #ifndef YYTOKENTYPE
56
+ # define YYTOKENTYPE
57
+ enum yytokentype
58
+ {
59
+ T_NUMBER = 258,
60
+ T_ID = 259,
61
+ T_SELID = 260,
62
+ T_AND = 261,
63
+ T_OR = 262,
64
+ T_NOT = 263,
65
+ T_RESN = 264,
66
+ T_RESI = 265,
67
+ T_SYMBOL = 266,
68
+ T_NAME = 267,
69
+ T_CHAIN = 268,
70
+ T_MINUS = 269,
71
+ ATOM = 270
72
+ };
73
+ #endif
74
+
75
+ /* Value type. */
76
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
77
+
78
+ union YYSTYPE
79
+ {
80
+ #line 30 "parser.y" /* yacc.c:1909 */
81
+
82
+ const char *value;
83
+ expression *expression;
84
+
85
+ #line 86 "parser.h" /* yacc.c:1909 */
86
+ };
87
+
88
+ typedef union YYSTYPE YYSTYPE;
89
+ # define YYSTYPE_IS_TRIVIAL 1
90
+ # define YYSTYPE_IS_DECLARED 1
91
+ #endif
92
+
93
+
94
+
95
+ int freesasa_yyparse (expression **expression, freesasa_yyscan_t scanner);
96
+
97
+ #endif /* !YY_FREESASA_YY_PARSER_H_INCLUDED */
.venv_haddock/include/site/python3.12/freesasa/pdb.c ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <errno.h>
7
+ #include <stdlib.h>
8
+
9
+ #include "freesasa_internal.h"
10
+ #include "pdb.h"
11
+
12
+ /* len >= 6 */
13
+ static inline int
14
+ pdb_line_check(const char *line, size_t len)
15
+ {
16
+ assert(line);
17
+ if (len < 6) return FREESASA_FAIL;
18
+ if (strlen(line) < len) return FREESASA_FAIL;
19
+ if (strncmp("ATOM", line, 4) != 0 &&
20
+ strncmp("HETATM", line, 6) != 0) {
21
+ return FREESASA_FAIL;
22
+ }
23
+ return FREESASA_SUCCESS;
24
+ }
25
+
26
+ /**
27
+ Extracts a double from the line of maximum width characters, to
28
+ allow checking for empty fields (instead of just reading the first
29
+ float that comes along.
30
+ */
31
+ static inline int
32
+ pdb_get_double(const char *line, size_t width, double *val)
33
+ {
34
+ /* allow truncated lines */
35
+ char buf[PDB_LINE_STRL];
36
+ float tmp;
37
+
38
+ if (strlen(line) < width) width = strlen(line);
39
+
40
+ memcpy(buf, line, width);
41
+ buf[width] = '\0';
42
+
43
+ if (sscanf(buf, "%f", &tmp) == 1) {
44
+ *val = tmp;
45
+ return FREESASA_SUCCESS;
46
+ }
47
+
48
+ return FREESASA_FAIL;
49
+ }
50
+
51
+ int freesasa_pdb_get_models(FILE *pdb,
52
+ struct file_range **ranges)
53
+ {
54
+ char line[PDB_MAX_LINE_STRL];
55
+ int n = 0, n_end = 0, error = 0;
56
+ long last_pos = ftell(pdb);
57
+ struct file_range *it = NULL, *itb;
58
+
59
+ assert(pdb != NULL);
60
+
61
+ while (fgets(line, PDB_MAX_LINE_STRL, pdb) != NULL) {
62
+ if (strncmp("MODEL", line, 5) == 0) {
63
+ ++n;
64
+ itb = it;
65
+ it = realloc(it, sizeof(struct file_range) * n);
66
+ if (!it) {
67
+ free(itb);
68
+ error = mem_fail();
69
+ break;
70
+ }
71
+ it[n - 1].begin = last_pos;
72
+ }
73
+ if (strncmp("ENDMDL", line, 6) == 0) {
74
+ ++n_end;
75
+ if (n != n_end) {
76
+ error = fail_msg("mismatch between MODEL and ENDMDL in input");
77
+ break;
78
+ }
79
+ it[n - 1].end = ftell(pdb);
80
+ }
81
+ last_pos = ftell(pdb);
82
+ }
83
+ if (n == 0) { /* when there are no models, the whole file is the model */
84
+ free(it);
85
+ it = NULL;
86
+ }
87
+ if (error == FREESASA_FAIL) {
88
+ free(it);
89
+ *ranges = NULL;
90
+ return FREESASA_FAIL;
91
+ }
92
+ *ranges = it;
93
+ return n;
94
+ }
95
+
96
+ int freesasa_pdb_get_chains(FILE *pdb,
97
+ struct file_range model,
98
+ struct file_range **ranges,
99
+ int options)
100
+ {
101
+ /* it is assumed that 'model' is valid for 'pdb' */
102
+
103
+ int n_chains = 0;
104
+ char line[PDB_MAX_LINE_STRL];
105
+ struct file_range *chains = NULL, *chb;
106
+ char last_chain = '\0';
107
+ long last_pos = model.begin;
108
+
109
+ assert(pdb);
110
+ assert(ranges);
111
+
112
+ *ranges = NULL;
113
+
114
+ /* for each model, find file ranges for each chain, store them
115
+ in the dynamically growing array chains */
116
+ fseek(pdb, model.begin, SEEK_SET);
117
+ while (fgets(line, PDB_MAX_LINE_STRL, pdb) != NULL &&
118
+ ftell(pdb) < model.end) {
119
+ if (strncmp("ATOM", line, 4) == 0 || ((options & FREESASA_INCLUDE_HETATM) &&
120
+ (strncmp("HETATM", line, 6) == 0))) {
121
+ char chain = freesasa_pdb_get_chain_label(line);
122
+ if (chain != last_chain) {
123
+ if (n_chains > 0) chains[n_chains - 1].end = last_pos;
124
+ ++n_chains;
125
+ chb = chains;
126
+ chains = realloc(chains, sizeof(struct file_range) * n_chains);
127
+ if (!chains) {
128
+ free(chb);
129
+ return mem_fail();
130
+ }
131
+ chains[n_chains - 1].begin = last_pos;
132
+ last_chain = chain;
133
+ }
134
+ }
135
+ last_pos = ftell(pdb);
136
+ }
137
+
138
+ if (n_chains > 0) {
139
+ chains[n_chains - 1].end = last_pos;
140
+ chains[0].begin = model.begin; /* preserve model info */
141
+ *ranges = chains;
142
+ } else {
143
+ *ranges = NULL;
144
+ }
145
+ return n_chains;
146
+ }
147
+
148
+ int freesasa_pdb_get_atom_name(char *name,
149
+ const char *line)
150
+ {
151
+ assert(name);
152
+ assert(line);
153
+ if (pdb_line_check(line, PDB_ATOM_NAME_STRL + 12) == FREESASA_FAIL) {
154
+ name[0] = '\0';
155
+ return FREESASA_FAIL;
156
+ }
157
+ strncpy(name, line + 12, PDB_ATOM_NAME_STRL);
158
+ name[PDB_ATOM_NAME_STRL] = '\0';
159
+ return FREESASA_SUCCESS;
160
+ }
161
+
162
+ int freesasa_pdb_get_res_name(char *name,
163
+ const char *line)
164
+ {
165
+ assert(name);
166
+ assert(line);
167
+ if (pdb_line_check(line, PDB_ATOM_RES_NAME_STRL + 17) == FREESASA_FAIL) {
168
+ name[0] = '\0';
169
+ return FREESASA_FAIL;
170
+ }
171
+ strncpy(name, line + 17, PDB_ATOM_RES_NAME_STRL);
172
+ name[PDB_ATOM_RES_NAME_STRL] = '\0';
173
+ return FREESASA_SUCCESS;
174
+ }
175
+
176
+ int freesasa_pdb_get_coord(double *xyz,
177
+ const char *line)
178
+ {
179
+ int n_coord = 24; /* 54-30+1 */
180
+ char coord_section[25];
181
+
182
+ assert(xyz);
183
+ assert(line);
184
+
185
+ if (pdb_line_check(line, 54) == FREESASA_FAIL) {
186
+ return FREESASA_FAIL;
187
+ }
188
+
189
+ strncpy(coord_section, line + 30, n_coord);
190
+ coord_section[n_coord] = '\0';
191
+
192
+ if (sscanf(coord_section, "%lf%lf%lf", &xyz[0], &xyz[1], &xyz[2]) != 3) {
193
+ return fail_msg("could not read coordinates from line '%s'", line);
194
+ }
195
+
196
+ return FREESASA_SUCCESS;
197
+ }
198
+
199
+ int freesasa_pdb_get_res_number(char *number,
200
+ const char *line)
201
+ {
202
+ assert(number);
203
+ assert(line);
204
+ if (pdb_line_check(line, PDB_ATOM_RES_NUMBER_STRL + 22) == FREESASA_FAIL) {
205
+ number[0] = '\0';
206
+ return FREESASA_FAIL;
207
+ }
208
+ strncpy(number, line + 22, PDB_ATOM_RES_NUMBER_STRL);
209
+ number[PDB_ATOM_RES_NUMBER_STRL] = '\0';
210
+ return FREESASA_SUCCESS;
211
+ }
212
+ char freesasa_pdb_get_chain_label(const char *line)
213
+ {
214
+ assert(line);
215
+ if (pdb_line_check(line, 21) == FREESASA_FAIL) return '\0';
216
+ return line[21];
217
+ }
218
+
219
+ char freesasa_pdb_get_alt_coord_label(const char *line)
220
+ {
221
+ assert(line);
222
+ if (pdb_line_check(line, 16) == FREESASA_FAIL) return '\0';
223
+ return line[16];
224
+ }
225
+
226
+ int freesasa_pdb_get_symbol(char *symbol,
227
+ const char *line)
228
+ {
229
+ assert(line);
230
+ if (pdb_line_check(line, 76 + PDB_ATOM_SYMBOL_STRL) == FREESASA_FAIL) {
231
+ symbol[0] = '\0';
232
+ return FREESASA_FAIL;
233
+ }
234
+ strncpy(symbol, line + 76, 2);
235
+ symbol[2] = '\0';
236
+ return FREESASA_SUCCESS;
237
+ }
238
+
239
+ int freesasa_pdb_get_occupancy(double *occ,
240
+ const char *line)
241
+ {
242
+ assert(line);
243
+ /* allow truncated lines */
244
+ if (pdb_line_check(line, 55) == FREESASA_SUCCESS)
245
+ return pdb_get_double(line + 54, 6, occ);
246
+ return FREESASA_FAIL;
247
+ }
248
+
249
+ int freesasa_pdb_get_bfactor(double *bfac,
250
+ const char *line)
251
+ {
252
+ assert(line);
253
+ /* allow truncated lines */
254
+ if (pdb_line_check(line, 61) == FREESASA_SUCCESS)
255
+ return pdb_get_double(line + 60, 6, bfac);
256
+ return FREESASA_FAIL;
257
+ }
258
+
259
+ int freesasa_pdb_ishydrogen(const char *line)
260
+ {
261
+ assert(line);
262
+ char symbol[PDB_ATOM_SYMBOL_STRL + 1];
263
+ freesasa_pdb_get_symbol(symbol, line);
264
+
265
+ if (pdb_line_check(line, 13) == FREESASA_FAIL) return FREESASA_FAIL;
266
+
267
+ /* Check symbol first */
268
+ if (strncmp(symbol, " H", 2) == 0) return 1;
269
+ if (strncmp(symbol, " D", 2) == 0) return 1;
270
+ /* If the symbol is not blank and not H or D */
271
+ if (!(strncmp(symbol, " ", 2) == 0)) return 0;
272
+
273
+ /* When symbol is missing */
274
+ /* Cover elements such as Cd, Nd, Th, etc. ("CD ", "ND ") */
275
+ if (!(line[12] == ' ' || (line[12] >= '1' && line[12] <= '9'))) return 0;
276
+ /* Hydrogen, atom name "H**" or " H**" */
277
+ if (line[12] == 'H' || line[13] == 'H') return 1;
278
+ /* Deuterium */
279
+ if (line[12] == 'D' || line[13] == 'D') return 1;
280
+ return 0;
281
+ }
282
+
283
+ static int
284
+ write_pdb_impl(FILE *output,
285
+ freesasa_node *structure)
286
+ {
287
+ char buf[PDB_LINE_STRL + 1], buf2[6];
288
+ int model;
289
+ double radius;
290
+ const char *line = NULL;
291
+ freesasa_node *chain = NULL, *residue = NULL, *atom = NULL;
292
+ const freesasa_nodearea *area = NULL;
293
+ const char *last_res_name = NULL, *last_res_number = NULL, *last_chain = NULL;
294
+
295
+ assert(freesasa_node_type(structure) == FREESASA_NODE_STRUCTURE);
296
+
297
+ model = freesasa_node_structure_model(structure);
298
+ if (model > 0)
299
+ fprintf(output, "MODEL %4d\n", model);
300
+ else
301
+ fprintf(output, "MODEL 1\n");
302
+
303
+ chain = freesasa_node_children(structure);
304
+
305
+ /* Write ATOM entries */
306
+ while (chain) {
307
+ residue = freesasa_node_children(chain);
308
+ while (residue) {
309
+ atom = freesasa_node_children(residue);
310
+ while (atom) {
311
+ line = freesasa_node_atom_pdb_line(atom);
312
+ area = freesasa_node_area(atom);
313
+ radius = freesasa_node_atom_radius(atom);
314
+
315
+ if (line == NULL) {
316
+ return fail_msg("PDB input not valid or not present");
317
+ }
318
+
319
+ strncpy(buf, line, PDB_LINE_STRL);
320
+ sprintf(&buf[54], "%6.2f%6.2f", radius, area->total);
321
+ fprintf(output, "%s\n", buf);
322
+
323
+ atom = freesasa_node_next(atom);
324
+ }
325
+ last_res_name = freesasa_node_name(residue);
326
+ last_res_number = freesasa_node_residue_number(residue);
327
+ residue = freesasa_node_next(residue);
328
+ }
329
+ last_chain = freesasa_node_name(chain);
330
+ chain = freesasa_node_next(chain);
331
+ }
332
+
333
+ /* Write TER and ENDMDL lines */
334
+ strncpy(buf2, &buf[6], 5);
335
+ buf2[5] = '\0';
336
+ fprintf(output, "TER %5d %4s %c%5s\nENDMDL\n",
337
+ atoi(buf2) + 1, last_res_name, last_chain[0], last_res_number);
338
+
339
+ fflush(output);
340
+ if (ferror(output)) {
341
+ return fail_msg(strerror(errno));
342
+ }
343
+
344
+ return FREESASA_SUCCESS;
345
+ }
346
+
347
+ int freesasa_write_pdb(FILE *output,
348
+ freesasa_node *root)
349
+ {
350
+ freesasa_node *result = freesasa_node_children(root), *structure;
351
+
352
+ assert(output);
353
+ assert(root);
354
+ assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
355
+
356
+ fprintf(output, "REMARK 999 This PDB file was generated by %s.\n", freesasa_string);
357
+ fprintf(output, "REMARK 999 In the ATOM records temperature factors have been\n"
358
+ "REMARK 999 replaced by the SASA of the atom, and the occupancy\n"
359
+ "REMARK 999 by the radius used in the calculation.\n");
360
+
361
+ while (result) {
362
+ structure = freesasa_node_children(result);
363
+ while (structure) {
364
+ if (write_pdb_impl(output, structure) == FREESASA_FAIL) {
365
+ return fail_msg("");
366
+ }
367
+ structure = freesasa_node_next(structure);
368
+ }
369
+ result = freesasa_node_next(result);
370
+ }
371
+
372
+ return FREESASA_SUCCESS;
373
+ }
374
+
375
+ #if USE_CHECK
376
+ #include <check.h>
377
+ #include <math.h>
378
+
379
+ START_TEST(test_pdb)
380
+ {
381
+ double v;
382
+ ck_assert(pdb_line_check("", 6) == FREESASA_FAIL);
383
+ ck_assert(pdb_line_check("ATOM", 4) == FREESASA_FAIL);
384
+ ck_assert(pdb_line_check("ATOM", 6) == FREESASA_FAIL);
385
+ ck_assert(pdb_line_check("HETAT", 6) == FREESASA_FAIL);
386
+ ck_assert(pdb_line_check("HETAT ", 6) == FREESASA_FAIL);
387
+ ck_assert(pdb_line_check("BLA BLA BLA", 10) == FREESASA_FAIL);
388
+ ck_assert(pdb_line_check("BLA BLA BLA", 11) == FREESASA_FAIL);
389
+ ck_assert(pdb_line_check("BLA BLA BLA", 12) == FREESASA_FAIL);
390
+
391
+ /* these will pass, although they would be useless */
392
+ ck_assert(pdb_line_check("ATOM ", 6) == FREESASA_SUCCESS);
393
+ ck_assert(pdb_line_check("HETATM", 6) == FREESASA_SUCCESS);
394
+
395
+ /* a more likely type of error */
396
+ ck_assert(pdb_line_check("HETATM", 7) == FREESASA_FAIL);
397
+
398
+ /* The normal case */
399
+ ck_assert(pdb_line_check("ATOM 1 N MET A 1 27.340 "
400
+ "24.430 2.614 1.00 9.67 N ",
401
+ 80) == FREESASA_SUCCESS);
402
+
403
+ v = 0;
404
+ ck_assert(pdb_get_double("1.23", 4, &v) == FREESASA_SUCCESS);
405
+ ck_assert(fabs(1.23 - v) < 1e-5);
406
+ v = 0;
407
+ ck_assert(pdb_get_double(" 1.23", 5, &v) == FREESASA_SUCCESS);
408
+ ck_assert(fabs(1.23 - v) < 1e-5);
409
+ v = 0;
410
+ ck_assert(pdb_get_double("1.23", 10, &v) == FREESASA_SUCCESS);
411
+ ck_assert(fabs(1.23 - v) < 1e-5);
412
+ v = 0;
413
+ ck_assert(pdb_get_double("1.23 4.56", 10, &v) == FREESASA_SUCCESS);
414
+ ck_assert(fabs(1.23 - v) < 1e-5);
415
+
416
+ ck_assert(pdb_get_double(" ", 10, &v) == FREESASA_FAIL);
417
+ ck_assert(pdb_get_double(" 1.23", 4, &v) == FREESASA_FAIL);
418
+ ck_assert(pdb_get_double("abc", 10, &v) == FREESASA_FAIL);
419
+ ck_assert(pdb_get_double("a 1.23", 6, &v) == FREESASA_FAIL);
420
+ }
421
+ END_TEST
422
+
423
+ TCase *
424
+ test_pdb_static()
425
+ {
426
+ TCase *tc = tcase_create("pdb.c static");
427
+ tcase_add_test(tc, test_pdb);
428
+
429
+ return tc;
430
+ }
431
+
432
+ #endif /* USE_CHECK */
.venv_haddock/include/site/python3.12/freesasa/pdb.h ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef FREESASA_PDB_H
2
+ #define FREESASA_PDB_H
3
+
4
+ #include "freesasa.h"
5
+ #include "freesasa_internal.h"
6
+
7
+ /**
8
+ @file
9
+ @author Simon Mitternacht
10
+
11
+ The following functions all extract info from the PDB lines `ATOM`
12
+ and `HETATM`. Valid lines have to begin with either `ATOM` or
13
+ `HETATM` and be sufficiently long to contain the value in
14
+ question.
15
+ */
16
+
17
+ #define PDB_ATOM_NAME_STRL 4 /**< Length of strings with atom names, such as `" CA "`. */
18
+ #define PDB_ATOM_RES_NAME_STRL 3 /**< Length of string with residue names, such as `"ALA"`. */
19
+ #define PDB_ATOM_RES_NUMBER_STRL 5 /**< Length of string with residue number, such as `" 123"`. */
20
+ #define PDB_ATOM_SYMBOL_STRL 2 /**< Length for string with element symbol, such "FE". */
21
+ #define PDB_LINE_STRL 80 /**< Length of a line in PDB file. */
22
+ #define PDB_MAX_LINE_STRL 120 /**< for reading, allows nonstandard input with extra fields. */
23
+
24
+ /**
25
+ Finds the location of all MODEL entries in the file pdb, returns
26
+ the number of models found.
27
+
28
+ The array *ranges will be dynamically allocated to contain a
29
+ file ranges for each model.
30
+
31
+ @return Returns 0 if no MODEL lines were found (for example an
32
+ X-ray structure with only one model) and sets *ranges to
33
+ NULL. A return value of 0 doesn't have to mean the file is
34
+ empty. ::FREESASA_FAIL if malloc-failure.
35
+ */
36
+ int freesasa_pdb_get_models(FILE *pdb,
37
+ struct file_range **ranges);
38
+
39
+ /**
40
+ Finds the location of all chains within the file range 'model'.
41
+
42
+ @param pdb The pdb-file
43
+ @param model The ::file_range to search for chains within.
44
+ @param ranges The address to a dynamically allocated array
45
+ containing the ::file_range of each chain will be stored here.
46
+ @param options Bitfield, can be used to set
47
+ ::FREESASA_INCLUDE_HETATM.
48
+ @return Number of chains found. Returns ::FREESASA_FAIL if memory
49
+ allocation fails.
50
+ */
51
+ int freesasa_pdb_get_chains(FILE *pdb,
52
+ struct file_range model,
53
+ struct file_range **ranges,
54
+ int options);
55
+ /**
56
+ Get atom name from a PDB line.
57
+
58
+ Extracts the whole atom name field from an `ATOM` or `HETATM` PDB
59
+ line, including padding, i.e. a string of ::PDB_ATOM_NAME_STRL
60
+ characters. For example `" CA "` for a regular C-alpha. If the
61
+ line is invalid, the name will be an empty string and the function
62
+ returns ::FREESASA_FAIL.
63
+
64
+ @param name The name is written to this string.
65
+ @param line Line from a PDB file.
66
+ @return ::FREESASA_SUCCESS if input is readable, else ::FREESASA_FAIL.
67
+ */
68
+ int freesasa_pdb_get_atom_name(char *name,
69
+ const char *line);
70
+
71
+ /**
72
+ Get residue name from a PDB line.
73
+
74
+ Extracts the whole residue name from an `ATOM` or `HETATM` PDB
75
+ line, i.e. a string of ::PDB_ATOM_RES_NAME_STRL characters. For
76
+ example `"ALA"` for an Alanine. If theline is invalid, the name
77
+ will be an empty string and the function returns ::FREESASA_FAIL.
78
+
79
+ @param name The name is written to this string.
80
+ @param line Line from a PDB file.
81
+ @return ::FREESASA_SUCCESS if input is readable, else ::FREESASA_FAIL.
82
+ */
83
+ int freesasa_pdb_get_res_name(char *name,
84
+ const char *line);
85
+
86
+ /**
87
+ Get atom coordinates from a PDB line.
88
+
89
+ Extracts x-, y- and z-coordinates from an `ATOM` or `HETATM` PDB
90
+ line. If the line is invalid, the function returns ::FREESASA_FAIL
91
+ and coord will remain unchanged.
92
+
93
+ @param coord The coordiantes are written to this array as x,y,z.
94
+ @param line Line from a PDB file.
95
+ @return ::FREESASA_SUCCESS if input is readable, else ::FREESASA_FAIL.
96
+ */
97
+ int freesasa_pdb_get_coord(double *coord,
98
+ const char *line);
99
+
100
+ /**
101
+ Get residue number from a PDB line.
102
+
103
+ Extracts residue number (ResSeq) as a string from an `ATOM` or
104
+ `HETATM` PDB line as a string. String format is used because not
105
+ all residue-numbers are numbers. The string should have length
106
+ ::PDB_ATOM_RES_NUMBER_STRL. If the line is invalid, the number will be an
107
+ empty string and the function returns ::FREESASA_FAIL.
108
+
109
+ @param number The residue number will be saved to this string.
110
+ @param line Line from a PDB file.
111
+ @return ::FREESASA_SUCCESS if input is readable, else ::FREESASA_FAIL.
112
+ */
113
+ int freesasa_pdb_get_res_number(char *number,
114
+ const char *line);
115
+
116
+ /**
117
+ Get chain label from PDB line.
118
+
119
+ Extracts the one character chain label (Chain identifier) from an
120
+ `ATOM` or `HETATM` PDB line (i.e. `'A'`, `'B'`, `'C'`, ...)
121
+
122
+ @param line Line from a PDB file.
123
+ @return The chain label. If the line is invalid, the function
124
+ returns '\0'.
125
+ */
126
+ char freesasa_pdb_get_chain_label(const char *line);
127
+
128
+ /**
129
+ Get alternate coordinate label from PDB line.
130
+
131
+ If there is more than one set of coordinates for an atom there
132
+ will be a label 'A', 'B', etc (Alternate location indicator). Else
133
+ the label is ' '.
134
+
135
+ @param line Line from a PDB file.
136
+ @return The label. If line is invalid, the function returns
137
+ '\0'.
138
+ */
139
+ char freesasa_pdb_get_alt_coord_label(const char *line);
140
+
141
+ /**
142
+ Get element symbol from PDB line.
143
+
144
+ Writes padded string to argument symbol, i.e. " C", "SE", etc.
145
+
146
+ @param symbol The symbol will be written to this string.
147
+ @param line Line from a PDB file.
148
+ @return ::FREESASA_SUCCESS line has 78 or more characters. ::FREESASA_FAIL if
149
+ line too short. Does not check if symbol is valid.
150
+ */
151
+ int freesasa_pdb_get_symbol(char *symbol,
152
+ const char *line);
153
+
154
+ /**
155
+ Get occupancy from PDB line
156
+
157
+ @param occ The occupancy will be written to this location.
158
+ @param line Line from a PDB file
159
+
160
+ @return ::FREESASA_SUCCESS if line is long enough, starts with
161
+ ATOM or HETATM, and characters 55-60 contain a number.
162
+ */
163
+ int freesasa_pdb_get_occupancy(double *occ,
164
+ const char *line);
165
+ /**
166
+ Get temperature factor (B-factor) from PDB line
167
+
168
+ @param bfac The B-factor will be written to this location.
169
+ @param line Line from a PDB file
170
+ @return ::FREESASA_SUCCESS if line is long enough, starts with
171
+ ATOM or HETATM, and characters 61-66 contain a number.
172
+ */
173
+ int freesasa_pdb_get_bfactor(double *bfac,
174
+ const char *line);
175
+
176
+ /**
177
+ Is atom Hydrogen?
178
+
179
+ Checks if an atom from an `ATOM` or `HETATM` PDB line is Hydrogen.
180
+
181
+ @param line Line from a PDB file.
182
+ @return 1 if Hydrogen (or deuterium). 0 otherwise. If line is
183
+ invalid, the function returns ::FREESASA_FAIL.
184
+ */
185
+ int freesasa_pdb_ishydrogen(const char *line);
186
+
187
+ #endif /* FREESASA_PDB_H */
.venv_haddock/include/site/python3.12/freesasa/rsa.c ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <errno.h>
7
+ #include <math.h>
8
+ #include <stdlib.h>
9
+
10
+ #include "classifier.h"
11
+ #include "freesasa_internal.h"
12
+ #include "pdb.h"
13
+
14
+ void freesasa_residue_rel_nodearea(freesasa_nodearea *rel,
15
+ const freesasa_nodearea *abs,
16
+ const freesasa_nodearea *ref)
17
+ {
18
+ rel->total = 100. * abs->total / ref->total;
19
+ rel->side_chain = 100. * abs->side_chain / ref->side_chain;
20
+ rel->main_chain = 100. * abs->main_chain / ref->main_chain;
21
+ rel->polar = 100. * abs->polar / ref->polar;
22
+ rel->apolar = 100. * abs->apolar / ref->apolar;
23
+ rel->name = abs->name;
24
+ }
25
+
26
+ static void
27
+ rsa_print_header(FILE *output,
28
+ const char *config_name,
29
+ const char *protein_name,
30
+ const char *chains,
31
+ const freesasa_parameters *parameters,
32
+ int options)
33
+ {
34
+ freesasa_algorithm alg = parameters->alg;
35
+ #ifdef PACKAGE_VERSION
36
+ fprintf(output, "REM FreeSASA " PACKAGE_VERSION "\n");
37
+ #else
38
+ fprintf(output, "REM FreeSASA\n");
39
+ #endif
40
+ fprintf(output, "REM Absolute and relative SASAs for %s\n", protein_name);
41
+ if (!(options & FREESASA_OUTPUT_SKIP_REL))
42
+ fprintf(output, "REM Atomic radii and reference values for relative SASA: %s\n", config_name);
43
+ else
44
+ fprintf(output, "REM No reference values available to calculate relative SASA\n");
45
+ fprintf(output, "REM Chains: %s\n", chains);
46
+ fprintf(output, "REM Algorithm: %s\n", freesasa_alg_name(alg));
47
+ fprintf(output, "REM Probe-radius: %.2f\n", parameters->probe_radius);
48
+ if (alg == FREESASA_LEE_RICHARDS) {
49
+ fprintf(output, "REM Slices: %d\n", parameters->lee_richards_n_slices);
50
+ } else if (alg == FREESASA_SHRAKE_RUPLEY) {
51
+ fprintf(output, "REM Test-points: %d\n", parameters->shrake_rupley_n_points);
52
+ }
53
+ fprintf(output, "REM RES _ NUM All-atoms Total-Side Main-Chain Non-polar All polar\n");
54
+ fprintf(output, "REM ABS REL ABS REL ABS REL ABS REL ABS REL\n");
55
+ }
56
+
57
+ static inline void
58
+ rsa_print_abs_rel(FILE *output,
59
+ double abs,
60
+ double rel)
61
+ {
62
+ fprintf(output, "%7.2f", abs);
63
+ if (isfinite(rel))
64
+ fprintf(output, "%6.1f", rel);
65
+ else
66
+ fprintf(output, " N/A");
67
+ }
68
+
69
+ static inline void
70
+ rsa_print_abs_only(FILE *output,
71
+ double abs)
72
+ {
73
+ fprintf(output, "%7.2f", abs);
74
+ fprintf(output, " N/A");
75
+ }
76
+
77
+ static int
78
+ rsa_print_residue(FILE *output,
79
+ int iaa,
80
+ const freesasa_nodearea *abs,
81
+ const freesasa_nodearea *rel,
82
+ freesasa_node *residue)
83
+ {
84
+ const char *resi_str;
85
+ char chain;
86
+
87
+ resi_str = freesasa_node_residue_number(residue);
88
+ chain = freesasa_node_name(freesasa_node_parent(residue))[0];
89
+
90
+ fprintf(output, "RES %s %c%s ", abs->name, chain, resi_str);
91
+ if (rel->name != NULL) {
92
+ rsa_print_abs_rel(output, abs->total, rel->total);
93
+ rsa_print_abs_rel(output, abs->side_chain, rel->side_chain);
94
+ rsa_print_abs_rel(output, abs->main_chain, rel->main_chain);
95
+ rsa_print_abs_rel(output, abs->apolar, rel->apolar);
96
+ rsa_print_abs_rel(output, abs->polar, rel->polar);
97
+ } else {
98
+ rsa_print_abs_only(output, abs->total);
99
+ rsa_print_abs_only(output, abs->side_chain);
100
+ rsa_print_abs_only(output, abs->main_chain);
101
+ rsa_print_abs_only(output, abs->apolar);
102
+ rsa_print_abs_only(output, abs->polar);
103
+ }
104
+ fprintf(output, "\n");
105
+ return FREESASA_SUCCESS;
106
+ }
107
+
108
+ int freesasa_write_rsa(FILE *output,
109
+ freesasa_node *tree,
110
+ int options)
111
+ {
112
+ freesasa_node *residue, *chain, *structure_node, *result_node;
113
+ const freesasa_nodearea *abs, *reference;
114
+ freesasa_nodearea rel;
115
+ int res_index, chain_index;
116
+ const freesasa_parameters *parameters;
117
+
118
+ assert(output);
119
+ assert(tree);
120
+
121
+ result_node = freesasa_node_children(tree);
122
+ parameters = freesasa_node_result_parameters(result_node);
123
+ structure_node = freesasa_node_children(result_node);
124
+ chain = freesasa_node_children(structure_node);
125
+
126
+ rsa_print_header(output, freesasa_node_classified_by(result_node),
127
+ freesasa_node_name(result_node), freesasa_node_name(structure_node), parameters, options);
128
+
129
+ res_index = chain_index = 0;
130
+ while (chain) {
131
+ residue = freesasa_node_children(chain);
132
+ while (residue) {
133
+ abs = freesasa_node_area(residue);
134
+ reference = freesasa_node_residue_reference(residue);
135
+ if (reference && !(options & FREESASA_OUTPUT_SKIP_REL)) {
136
+ freesasa_residue_rel_nodearea(&rel, abs, reference);
137
+ } else {
138
+ rel = freesasa_nodearea_null;
139
+ }
140
+ rsa_print_residue(output, res_index, abs, &rel, residue);
141
+ ++res_index;
142
+ residue = freesasa_node_next(residue);
143
+ }
144
+ chain = freesasa_node_next(chain);
145
+ }
146
+
147
+ fprintf(output, "END Absolute sums over single chains surface\n");
148
+
149
+ chain = freesasa_node_children(structure_node);
150
+ chain_index = 0;
151
+ while (chain) {
152
+ const char *name = freesasa_node_name(chain);
153
+ abs = freesasa_node_area(chain);
154
+
155
+ fprintf(output, "CHAIN%3d %c %10.1f %10.1f %10.1f %10.1f %10.1f\n",
156
+ chain_index + 1, name[0], abs->total, abs->side_chain,
157
+ abs->main_chain, abs->apolar, abs->polar);
158
+
159
+ ++chain_index;
160
+ chain = freesasa_node_next(chain);
161
+ }
162
+
163
+ abs = freesasa_node_area(structure_node);
164
+ fprintf(output, "END Absolute sums over all chains\n");
165
+ fprintf(output, "TOTAL %10.1f %10.1f %10.1f %10.1f %10.1f\n",
166
+ abs->total, abs->side_chain, abs->main_chain, abs->apolar, abs->polar);
167
+
168
+ fflush(output);
169
+ if (ferror(output)) {
170
+ return fail_msg(strerror(errno));
171
+ }
172
+
173
+ return FREESASA_SUCCESS;
174
+ }
.venv_haddock/include/site/python3.12/freesasa/sasa_lr.c ADDED
@@ -0,0 +1,487 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+ #include <assert.h>
5
+ #include <errno.h>
6
+ #include <stdio.h>
7
+ #include <stdlib.h>
8
+ #include <string.h>
9
+
10
+ #ifdef _MSC_VER
11
+ #define _USE_MATH_DEFINES
12
+ #endif
13
+ #include <math.h>
14
+
15
+ #if USE_THREADS
16
+ #include <pthread.h>
17
+ #define MAX_LR_THREADS 16
18
+ #else
19
+ #define MAX_LR_THREADS 1
20
+ #endif
21
+
22
+ #include "freesasa_internal.h"
23
+ #include "nb.h"
24
+
25
+ const double TWOPI = 2 * M_PI;
26
+
27
+ /* calculation parameters and data (results stored in *sasa) */
28
+ typedef struct {
29
+ int n_atoms;
30
+ double *radii; /* including probe */
31
+ const coord_t *xyz;
32
+ nb_list *adj;
33
+ int n_slices_per_atom;
34
+ double *sasa; /* results */
35
+ double *arc[MAX_LR_THREADS], *z_nb[MAX_LR_THREADS], *R_nb[MAX_LR_THREADS];
36
+ int n_threads;
37
+ } lr_data;
38
+
39
+ typedef struct {
40
+ int first_atom;
41
+ int last_atom;
42
+ int thread_id;
43
+ lr_data *lr;
44
+ } lr_thread_interval;
45
+
46
+ #if USE_THREADS
47
+ static int lr_do_threads(int n_threads, lr_data *);
48
+ static void *lr_thread(void *arg);
49
+ #endif
50
+
51
+ /** Returns the are of atom i */
52
+ static double
53
+ atom_area(lr_data *lr, int i, int thread_id);
54
+
55
+ /** Sum of exposed arcs based on buried arc intervals arc, assumes no
56
+ intervals cross zero */
57
+ static double
58
+ exposed_arc_length(double *restrict arc, int n);
59
+
60
+ /** Release contenst of lr_data pointer*/
61
+ static void
62
+ release_lr(lr_data *lr)
63
+ {
64
+ int i;
65
+
66
+ free(lr->radii);
67
+ freesasa_nb_free(lr->adj);
68
+ lr->radii = NULL;
69
+ lr->adj = NULL;
70
+
71
+ for (i = 0; i < lr->n_threads; ++i) {
72
+ free(lr->arc[i]);
73
+ free(lr->z_nb[i]);
74
+ free(lr->R_nb[i]);
75
+ }
76
+ }
77
+
78
+ /* Allocate some helper arrays in area calculation that need to be pre-allocated */
79
+ static int
80
+ alloc_lr_calc_arrays(lr_data *lr, int n_threads)
81
+ {
82
+ int max_nni = 0, i, nni;
83
+ const int n_atoms = lr->n_atoms;
84
+
85
+ for (i = 0; i < n_atoms; ++i) {
86
+ nni = lr->adj->nn[i];
87
+ max_nni = max_nni < nni ? nni : max_nni;
88
+ }
89
+
90
+ for (i = 0; i < n_threads; ++i) {
91
+ lr->arc[i] = malloc(sizeof(double) * 4 * max_nni);
92
+ lr->z_nb[i] = malloc(sizeof(double) * max_nni);
93
+ lr->R_nb[i] = malloc(sizeof(double) * max_nni);
94
+
95
+ if (!lr->arc[i] || !lr->z_nb[i] || !lr->R_nb[i]) {
96
+ return mem_fail();
97
+ }
98
+ }
99
+
100
+ return FREESASA_SUCCESS;
101
+ }
102
+
103
+ /** Initialize object to be used for L&R calculation */
104
+ static int
105
+ init_lr(lr_data *lr,
106
+ double *sasa,
107
+ const coord_t *xyz,
108
+ const double *atom_radii,
109
+ double probe_radius,
110
+ int n_slices_per_atom,
111
+ int n_threads)
112
+ {
113
+ const int n_atoms = freesasa_coord_n(xyz);
114
+ int i;
115
+
116
+ lr->n_atoms = n_atoms;
117
+ lr->xyz = xyz;
118
+ lr->adj = NULL;
119
+ lr->n_slices_per_atom = n_slices_per_atom;
120
+ lr->sasa = sasa;
121
+ lr->n_threads = n_threads;
122
+
123
+ for (i = 0; i < n_threads; ++i) {
124
+ lr->arc[i] = NULL;
125
+ lr->z_nb[i] = NULL;
126
+ lr->R_nb[i] = NULL;
127
+ }
128
+
129
+ lr->radii = malloc(sizeof(double) * n_atoms);
130
+ if (lr->radii == NULL) {
131
+ return mem_fail();
132
+ }
133
+
134
+ /* init some arrays */
135
+ for (i = 0; i < n_atoms; ++i) {
136
+ lr->radii[i] = atom_radii[i] + probe_radius;
137
+ sasa[i] = 0.;
138
+ }
139
+
140
+ /* determine which atoms are neighbours */
141
+ lr->adj = freesasa_nb_new(xyz, lr->radii);
142
+
143
+ if (lr->adj == NULL) {
144
+ release_lr(lr);
145
+ return fail_msg("");
146
+ }
147
+
148
+ if (alloc_lr_calc_arrays(lr, n_threads)) {
149
+ release_lr(lr);
150
+ return fail_msg("");
151
+ }
152
+
153
+ return FREESASA_SUCCESS;
154
+ }
155
+
156
+ int freesasa_lee_richards(double *sasa,
157
+ const coord_t *xyz,
158
+ const double *atom_radii,
159
+ const freesasa_parameters *param)
160
+ {
161
+ int return_value, n_atoms, n_threads, resolution, i;
162
+ double probe_radius;
163
+ lr_data lr;
164
+
165
+ assert(sasa);
166
+ assert(xyz);
167
+ assert(atom_radii);
168
+
169
+ if (param == NULL) param = &freesasa_default_parameters;
170
+
171
+ return_value = FREESASA_SUCCESS;
172
+ n_atoms = freesasa_coord_n(xyz);
173
+ n_threads = param->n_threads;
174
+ resolution = param->lee_richards_n_slices;
175
+ probe_radius = param->probe_radius;
176
+
177
+ if (n_threads > MAX_LR_THREADS) {
178
+ return fail_msg("L&R does not support more than %d threads", MAX_LR_THREADS);
179
+ }
180
+
181
+ if (resolution <= 0) {
182
+ return fail_msg("%f slices per atom invalid resolution in L&R, must be > 0\n", resolution);
183
+ }
184
+
185
+ if (n_atoms == 0) {
186
+ return freesasa_warn("in %s(): empty coordinates", __func__);
187
+ }
188
+
189
+ if (n_threads > n_atoms) {
190
+ n_threads = n_atoms;
191
+ freesasa_warn("no sense in having more threads than atoms, only using %d threads",
192
+ n_threads);
193
+ }
194
+
195
+ if (init_lr(&lr, sasa, xyz, atom_radii, probe_radius, resolution, n_threads))
196
+ return FREESASA_FAIL;
197
+
198
+ if (n_threads > 1) {
199
+ #if USE_THREADS
200
+ return_value = lr_do_threads(n_threads, &lr);
201
+ #else
202
+ return_value = freesasa_warn("in %s(): program compiled for single-threaded use, "
203
+ "but multiple threads were requested, will "
204
+ "proceed in single-threaded mode\n",
205
+ __func__);
206
+ n_threads = 1;
207
+ #endif /* pthread */
208
+ }
209
+ if (n_threads == 1) {
210
+ for (i = 0; i < lr.n_atoms; ++i) {
211
+ lr.sasa[i] = atom_area(&lr, i, 0);
212
+ }
213
+ }
214
+ release_lr(&lr);
215
+ return return_value;
216
+ }
217
+
218
+ #if USE_THREADS
219
+ static int
220
+ lr_do_threads(int n_threads,
221
+ lr_data *lr)
222
+ {
223
+ pthread_t thread[MAX_LR_THREADS];
224
+ lr_thread_interval t_data[MAX_LR_THREADS];
225
+ int n_perthread = lr->n_atoms / n_threads, res;
226
+ int threads_created = 0, return_value = FREESASA_SUCCESS;
227
+ int t;
228
+
229
+ for (t = 0; t < n_threads; ++t) {
230
+ t_data[t].first_atom = t * n_perthread;
231
+ if (t == n_threads - 1) {
232
+ t_data[t].last_atom = lr->n_atoms - 1;
233
+ } else {
234
+ t_data[t].last_atom = (t + 1) * n_perthread - 1;
235
+ }
236
+ t_data[t].lr = lr;
237
+ t_data[t].thread_id = t;
238
+ res = pthread_create(&thread[t], NULL, lr_thread,
239
+ (void *)&t_data[t]);
240
+ if (res) {
241
+ return_value = fail_msg(freesasa_thread_error(res));
242
+ break;
243
+ }
244
+ ++threads_created;
245
+ }
246
+ for (int t = 0; t < threads_created; ++t) {
247
+ res = pthread_join(thread[t], NULL);
248
+ if (res) {
249
+ return_value = fail_msg(freesasa_thread_error(res));
250
+ }
251
+ }
252
+ return return_value;
253
+ }
254
+
255
+ static void *
256
+ lr_thread(void *arg)
257
+ {
258
+ int i;
259
+ lr_thread_interval *ti = ((lr_thread_interval *)arg);
260
+
261
+ for (i = ti->first_atom; i <= ti->last_atom; ++i) {
262
+ /* the different threads write to different parts of the
263
+ array, so locking shouldn't be necessary */
264
+ ti->lr->sasa[i] = atom_area(ti->lr, i, ti->thread_id);
265
+ }
266
+ pthread_exit(NULL);
267
+ }
268
+ #endif /* USE_THREADS */
269
+
270
+ static double
271
+ atom_area(lr_data *lr,
272
+ int i,
273
+ int thread_id)
274
+ {
275
+ /* This function is large because a large number of pre-calculated
276
+ arrays need to be accessed efficiently. Partially dereferenced
277
+ here to make access more efficient.
278
+
279
+ Variables are named according to the documentation (see page
280
+ "Geometry of Lee & Richards' algorithm") */
281
+
282
+ const int nni = lr->adj->nn[i];
283
+ const double *restrict const v = freesasa_coord_all(lr->xyz);
284
+ const double *restrict const R = lr->radii;
285
+ const int *restrict const nbi = lr->adj->nb[i];
286
+ const double *restrict const xydi = lr->adj->xyd[i];
287
+ const double *restrict const xdi = lr->adj->xd[i];
288
+ const double *restrict const ydi = lr->adj->yd[i];
289
+ const double zi = v[3 * i + 2], Ri = R[i];
290
+ const int ns = lr->n_slices_per_atom;
291
+
292
+ int j, islice, n_arcs, is_buried, narc2;
293
+ double *arc = lr->arc[thread_id],
294
+ *z_nb = lr->z_nb[thread_id],
295
+ *R_nb = lr->R_nb[thread_id];
296
+ double z, delta, sasa = 0, alpha, beta, inf, sup;
297
+ double zj, di, dj, dij, Rj, Ri_prime2, Ri_prime, Rj_prime2, Rj_prime;
298
+
299
+ for (j = 0; j < nni; ++j) {
300
+ z_nb[j] = v[3 * nbi[j] + 2];
301
+ R_nb[j] = R[nbi[j]];
302
+ }
303
+
304
+ delta = 2 * Ri / ns;
305
+ z = zi - Ri - 0.5 * delta;
306
+ for (islice = 0; islice < ns; ++islice) {
307
+ z += delta;
308
+ di = fabs(zi - z);
309
+ Ri_prime2 = Ri * Ri - di * di;
310
+ if (Ri_prime2 < 0) continue; /* handle round-off errors */
311
+ Ri_prime = sqrt(Ri_prime2);
312
+ if (Ri_prime <= 0) continue; /* more round-off errors */
313
+ n_arcs = 0;
314
+ is_buried = 0;
315
+ for (j = 0; j < nni; ++j) {
316
+ zj = z_nb[j];
317
+ dj = fabs(zj - z);
318
+ Rj = R_nb[j];
319
+
320
+ if (dj < Rj) {
321
+ Rj_prime2 = Rj * Rj - dj * dj;
322
+ Rj_prime = sqrt(Rj_prime2);
323
+ dij = xydi[j];
324
+ if (dij >= Ri_prime + Rj_prime) { /* atoms aren't in contact */
325
+ continue;
326
+ }
327
+ if (dij + Ri_prime < Rj_prime) { /* circle i is completely inside j */
328
+ is_buried = 1;
329
+ break;
330
+ }
331
+ if (dij + Rj_prime < Ri_prime) { /* circle j is completely inside i */
332
+ continue;
333
+ }
334
+ /* arc of circle i intersected by circle j */
335
+ alpha = acos((Ri_prime2 + dij * dij - Rj_prime2) / (2.0 * Ri_prime * dij));
336
+ /* position of mid-point of intersection along circle i */
337
+ beta = atan2(ydi[j], xdi[j]) + M_PI;
338
+ inf = beta - alpha;
339
+ sup = beta + alpha;
340
+ if (inf < 0) inf += TWOPI;
341
+ if (sup > 2 * M_PI) sup -= TWOPI;
342
+ narc2 = 2 * n_arcs;
343
+ /* store the arc, if arc passes 2*PI split into two */
344
+ if (sup < inf) {
345
+ /* store arcs as contiguous pairs of angles */
346
+ arc[narc2] = 0;
347
+ arc[narc2 + 1] = sup;
348
+ /* second arc */
349
+ arc[narc2 + 2] = inf;
350
+ arc[narc2 + 3] = TWOPI;
351
+ n_arcs += 2;
352
+ } else {
353
+ arc[narc2] = inf;
354
+ arc[narc2 + 1] = sup;
355
+ ++n_arcs;
356
+ }
357
+ }
358
+ }
359
+ if (is_buried == 0) {
360
+ sasa += delta * Ri * exposed_arc_length(arc, n_arcs);
361
+ }
362
+ }
363
+ return sasa;
364
+ }
365
+
366
+ /* insertion sort (faster than qsort for these short lists) */
367
+ inline static void
368
+ sort_arcs(double *restrict arc,
369
+ int n)
370
+ {
371
+ double tmp[2];
372
+ double *end = arc + 2 * n, *arcj, *arci;
373
+ for (arci = arc + 2; arci < end; arci += 2) {
374
+ *tmp = *arci;
375
+ *(tmp + 1) = *(arci + 1);
376
+ arcj = arci;
377
+ while (arcj > arc && *(arcj - 2) > tmp[0]) {
378
+ *arcj = *(arcj - 2);
379
+ *(arcj + 1) = *(arcj - 1);
380
+ arcj -= 2;
381
+ }
382
+ *arcj = *tmp;
383
+ *(arcj + 1) = *(tmp + 1);
384
+ }
385
+ }
386
+
387
+ /* sort arcs by start-point, loop through them to sum parts of circle
388
+ not covered by any of the arcs */
389
+ inline static double
390
+ exposed_arc_length(double *restrict arc,
391
+ int n)
392
+ {
393
+ int i2;
394
+ double sum, sup, tmp;
395
+
396
+ if (n == 0) return TWOPI;
397
+
398
+ sort_arcs(arc, n);
399
+ sum = arc[0];
400
+ sup = arc[1];
401
+ /* in the following it is assumed that the arc[i2] <= arc[i2+1] */
402
+ for (i2 = 2; i2 < 2 * n; i2 += 2) {
403
+ if (sup < arc[i2]) sum += arc[i2] - sup;
404
+ tmp = arc[i2 + 1];
405
+ if (tmp > sup) sup = tmp;
406
+ }
407
+ return sum + TWOPI - sup;
408
+ }
409
+
410
+ #if USE_CHECK
411
+ #include <check.h>
412
+
413
+ static int
414
+ is_identical(const double *l1, const double *l2, int n)
415
+ {
416
+ int i;
417
+
418
+ for (i = 0; i < n; ++i) {
419
+ if (l1[i] != l2[i]) return 0;
420
+ }
421
+
422
+ return 1;
423
+ }
424
+
425
+ static int
426
+ is_sorted(const double *list, int n)
427
+ {
428
+ int i;
429
+
430
+ for (i = 0; i < n - 1; ++i)
431
+ if (list[2 * i] > list[2 * i + 1]) return 0;
432
+
433
+ return 1;
434
+ }
435
+
436
+ START_TEST(test_sort_arcs)
437
+ {
438
+ double a_ref[] = {0, 1, 2, 3}, b_ref[] = {-2, 0, -1, 0, -1, 1};
439
+ double a1[4] = {0, 1, 2, 3}, a2[4] = {2, 3, 0, 1};
440
+ double b1[6] = {-2, 0, -1, 0, -1, 1}, b2[6] = {-1, 1, -2, 0, -1, 1};
441
+ sort_arcs(a1, 2);
442
+ sort_arcs(a2, 2);
443
+ sort_arcs(b1, 3);
444
+ sort_arcs(b2, 3);
445
+ ck_assert(is_sorted(a1, 2));
446
+ ck_assert(is_sorted(a2, 2));
447
+ ck_assert(is_sorted(b1, 3));
448
+ ck_assert(is_sorted(b2, 3));
449
+ ck_assert(is_identical(a_ref, a1, 4));
450
+ ck_assert(is_identical(a_ref, a2, 4));
451
+ ck_assert(is_identical(b_ref, b1, 6));
452
+ }
453
+ END_TEST
454
+
455
+ START_TEST(test_exposed_arc_length)
456
+ {
457
+ double a1[4] = {0, 0.1 * TWOPI, 0.9 * TWOPI, TWOPI}, a2[4] = {0.9 * TWOPI, TWOPI, 0, 0.1 * TWOPI};
458
+ double a3[4] = {0, TWOPI, 1, 2}, a4[4] = {1, 2, 0, TWOPI};
459
+ double a5[4] = {0.1 * TWOPI, 0.2 * TWOPI, 0.5 * TWOPI, 0.6 * TWOPI};
460
+ double a6[4] = {0.1 * TWOPI, 0.2 * TWOPI, 0.5 * TWOPI, 0.6 * TWOPI};
461
+ double a7[4] = {0.1 * TWOPI, 0.3 * TWOPI, 0.15 * TWOPI, 0.2 * TWOPI};
462
+ double a8[4] = {0.15 * TWOPI, 0.2 * TWOPI, 0.1 * TWOPI, 0.3 * TWOPI};
463
+ double a9[10] = {0.05, 0.1, 0.5, 0.6, 0, 0.15, 0.7, 0.8, 0.75, TWOPI};
464
+ ck_assert(fabs(exposed_arc_length(a1, 2) - 0.8 * TWOPI) < 1e-10);
465
+ ck_assert(fabs(exposed_arc_length(a2, 2) - 0.8 * TWOPI) < 1e-10);
466
+ ck_assert(fabs(exposed_arc_length(a3, 2)) < 1e-10);
467
+ ck_assert(fabs(exposed_arc_length(a4, 2)) < 1e-10);
468
+ ck_assert(fabs(exposed_arc_length(a5, 2) - 0.8 * TWOPI) < 1e-10);
469
+ ck_assert(fabs(exposed_arc_length(a6, 2) - 0.8 * TWOPI) < 1e-10);
470
+ ck_assert(fabs(exposed_arc_length(a7, 2) - 0.8 * TWOPI) < 1e-10);
471
+ ck_assert(fabs(exposed_arc_length(a8, 2) - 0.8 * TWOPI) < 1e-10);
472
+ ck_assert(fabs(exposed_arc_length(a9, 5) - 0.45) < 1e-10);
473
+ /* can't think of anything more qualitatively different here */
474
+ }
475
+ END_TEST
476
+
477
+ TCase *
478
+ test_LR_static()
479
+ {
480
+ TCase *tc = tcase_create("sasa_lr.c static");
481
+ tcase_add_test(tc, test_sort_arcs);
482
+ tcase_add_test(tc, test_exposed_arc_length);
483
+
484
+ return tc;
485
+ }
486
+
487
+ #endif /* USE_CHECK */
.venv_haddock/include/site/python3.12/freesasa/sasa_sr.c ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+ #include <assert.h>
5
+ #include <stdio.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+
9
+ #ifdef _MSC_VER
10
+ #define _USE_MATH_DEFINES
11
+ #endif
12
+ #include <math.h>
13
+
14
+ #if USE_THREADS
15
+ #include <pthread.h>
16
+ #define MAX_SR_THREADS 16
17
+ #else
18
+ #define MAX_SR_THREADS 1
19
+ #endif
20
+
21
+ #include "freesasa_internal.h"
22
+ #include "nb.h"
23
+
24
+ #ifdef __GNUC__
25
+ #define __attrib_pure__ __attribute__((pure))
26
+ #else
27
+ #define __attrib_pure__
28
+ #endif
29
+
30
+ /* calculation parameters (results stored in *sasa) */
31
+ typedef struct {
32
+ int i1, i2; /* for multithreading, range of atoms */
33
+ int thread_index;
34
+ int n_atoms;
35
+ int n_points;
36
+ int n_threads;
37
+ double probe_radius;
38
+ const coord_t *xyz;
39
+ coord_t *srp; /* test-points */
40
+ coord_t *tp_local[MAX_SR_THREADS]; /* coord object for storing intermediates */
41
+ int *spcount[MAX_SR_THREADS];
42
+ double *r;
43
+ double *r2;
44
+ nb_list *nb;
45
+ double *sasa;
46
+ } sr_data;
47
+
48
+ #if USE_THREADS
49
+ static int sr_do_threads(int n_threads, sr_data *sr);
50
+ static void *sr_thread(void *arg);
51
+ #endif
52
+
53
+ static double
54
+ sr_atom_area(int i, const sr_data *sr, int thread_index) __attrib_pure__;
55
+
56
+ static coord_t *
57
+ test_points(int N)
58
+ {
59
+ /* Golden section spiral on a sphere
60
+ from http://web.archive.org/web/20120421191837/http://www.cgafaq.info/wiki/Evenly_distributed_points_on_sphere */
61
+ double dlong = M_PI * (3 - sqrt(5)), dz = 2.0 / N, longitude = 0, z = 1 - dz / 2, r;
62
+ coord_t *coord = freesasa_coord_new();
63
+ double *tp = malloc(3 * N * sizeof(double)), *p;
64
+ if (tp == NULL || coord == NULL) {
65
+ mem_fail();
66
+ goto cleanup;
67
+ }
68
+
69
+ for (p = tp; p - tp < 3 * N; p += 3) {
70
+ r = sqrt(1 - z * z);
71
+ p[0] = cos(longitude) * r;
72
+ p[1] = sin(longitude) * r;
73
+ p[2] = z;
74
+ z -= dz;
75
+ longitude += dlong;
76
+ }
77
+
78
+ if (freesasa_coord_append(coord, tp, N) == FREESASA_FAIL) {
79
+ fail_msg("");
80
+ goto cleanup;
81
+ }
82
+ free(tp);
83
+
84
+ return coord;
85
+
86
+ cleanup:
87
+ free(tp);
88
+ freesasa_coord_free(coord);
89
+ return NULL;
90
+ }
91
+
92
+ /* free contents */
93
+ void release_sr(sr_data *sr)
94
+ {
95
+ int i;
96
+
97
+ freesasa_coord_free(sr->srp);
98
+ freesasa_nb_free(sr->nb);
99
+ free(sr->r);
100
+ free(sr->r2);
101
+
102
+ for (i = 0; i < sr->n_threads; ++i) {
103
+ freesasa_coord_free(sr->tp_local[i]);
104
+ free(sr->spcount[i]);
105
+ }
106
+ }
107
+
108
+ int init_sr(sr_data *sr,
109
+ double *sasa,
110
+ const coord_t *xyz,
111
+ const double *r,
112
+ double probe_radius,
113
+ int n_points,
114
+ int n_threads)
115
+ {
116
+ int n_atoms = freesasa_coord_n(xyz), i;
117
+ coord_t *srp = test_points(n_points);
118
+ double ri;
119
+
120
+ if (srp == NULL) return fail_msg("failed to initialize test points");
121
+
122
+ /* store parameters and reference arrays */
123
+ sr->n_atoms = n_atoms;
124
+ sr->n_points = n_points;
125
+ sr->n_threads = n_threads;
126
+ sr->probe_radius = probe_radius;
127
+ sr->xyz = xyz;
128
+ sr->srp = srp;
129
+ sr->sasa = sasa;
130
+ sr->nb = NULL;
131
+
132
+ /* should be done before any mallocs (to avoid problems in potential cleanup) */
133
+ for (i = 0; i < n_threads; ++i) {
134
+ sr->tp_local[i] = NULL;
135
+ sr->spcount[i] = NULL;
136
+ }
137
+
138
+ sr->r = malloc(sizeof(double) * n_atoms);
139
+ sr->r2 = malloc(sizeof(double) * n_atoms);
140
+
141
+ if (sr->r == NULL || sr->r2 == NULL) goto cleanup;
142
+
143
+ for (i = 0; i < n_atoms; ++i) {
144
+ ri = r[i] + probe_radius;
145
+ sr->r[i] = ri;
146
+ sr->r2[i] = ri * ri;
147
+ }
148
+
149
+ for (i = 0; i < n_threads; ++i) {
150
+ sr->tp_local[i] = freesasa_coord_clone(sr->srp);
151
+ sr->spcount[i] = malloc(sizeof(int) * n_points);
152
+ if (sr->tp_local[i] == NULL || sr->spcount[i] == NULL) {
153
+ goto cleanup;
154
+ }
155
+ }
156
+
157
+ /* calculate distances */
158
+ sr->nb = freesasa_nb_new(xyz, sr->r);
159
+ if (sr->nb == NULL) goto cleanup;
160
+
161
+ return FREESASA_SUCCESS;
162
+
163
+ cleanup:
164
+ release_sr(sr);
165
+ return mem_fail();
166
+ }
167
+
168
+ int freesasa_shrake_rupley(double *sasa,
169
+ const coord_t *xyz,
170
+ const double *r,
171
+ const freesasa_parameters *param)
172
+ {
173
+ int i, n_atoms, n_threads = param->n_threads, resolution, return_value;
174
+ double probe_radius = param->probe_radius;
175
+ sr_data sr;
176
+
177
+ assert(sasa);
178
+ assert(xyz);
179
+ assert(r);
180
+
181
+ if (param == NULL) param = &freesasa_default_parameters;
182
+
183
+ n_atoms = freesasa_coord_n(xyz);
184
+ n_threads = param->n_threads;
185
+ resolution = param->shrake_rupley_n_points;
186
+ return_value = FREESASA_SUCCESS;
187
+
188
+ if (n_threads > MAX_SR_THREADS) {
189
+ return fail_msg("S&R does not support more than %d threads", MAX_SR_THREADS);
190
+ }
191
+ if (resolution <= 0) {
192
+ return fail_msg("%f test points invalid resolution in S&R, must be > 0\n", resolution);
193
+ }
194
+ if (n_atoms == 0) return freesasa_warn("in %s(): empty coordinates", __func__);
195
+ if (n_threads > n_atoms) {
196
+ n_threads = n_atoms;
197
+ freesasa_warn("no sense in having more threads than atoms, only using %d threads",
198
+ n_threads);
199
+ }
200
+
201
+ if (init_sr(&sr, sasa, xyz, r, probe_radius, resolution, n_threads))
202
+ return FREESASA_FAIL;
203
+
204
+ /* calculate SASA */
205
+ if (n_threads > 1) {
206
+ #if USE_THREADS
207
+ return_value = sr_do_threads(n_threads, &sr);
208
+ #else
209
+ return_value = freesasa_warn("in %s(): program compiled for single-threaded use, "
210
+ "but multiple threads were requested, will "
211
+ "proceed in single-threaded mode\n",
212
+ __func__);
213
+ n_threads = 1;
214
+ #endif
215
+ }
216
+ if (n_threads == 1) {
217
+ /* don't want the overhead of generating threads if only one is used */
218
+ for (i = 0; i < n_atoms; ++i) {
219
+ sasa[i] = sr_atom_area(i, &sr, 0);
220
+ }
221
+ }
222
+ release_sr(&sr);
223
+ return return_value;
224
+ }
225
+
226
+ #if USE_THREADS
227
+ static int
228
+ sr_do_threads(int n_threads,
229
+ sr_data *sr)
230
+ {
231
+ pthread_t thread[MAX_SR_THREADS];
232
+ sr_data srt[MAX_SR_THREADS];
233
+ int thread_block_size = sr->n_atoms / n_threads;
234
+ int res, return_value = FREESASA_SUCCESS;
235
+ int threads_created = 0, t;
236
+
237
+ /* divide atoms evenly over threads */
238
+ for (t = 0; t < n_threads; ++t) {
239
+ srt[t] = *sr;
240
+ srt[t].i1 = t * thread_block_size;
241
+ if (t == n_threads - 1)
242
+ srt[t].i2 = sr->n_atoms;
243
+ else
244
+ srt[t].i2 = (t + 1) * thread_block_size;
245
+ srt[t].thread_index = t;
246
+ res = pthread_create(&thread[t], NULL, sr_thread, (void *)&srt[t]);
247
+ if (res) {
248
+ return_value = fail_msg(freesasa_thread_error(res));
249
+ break;
250
+ }
251
+ ++threads_created;
252
+ }
253
+ for (t = 0; t < threads_created; ++t) {
254
+ res = pthread_join(thread[t], NULL);
255
+ if (res) {
256
+ return_value = fail_msg(freesasa_thread_error(res));
257
+ }
258
+ }
259
+ return return_value;
260
+ }
261
+
262
+ static void *
263
+ sr_thread(void *arg)
264
+ {
265
+ int i;
266
+ sr_data *sr = ((sr_data *)arg);
267
+
268
+ for (i = sr->i1; i < sr->i2; ++i) {
269
+ /* mutex should not be necessary, writes to non-overlapping regions */
270
+ sr->sasa[i] = sr_atom_area(i, sr, sr->thread_index);
271
+ }
272
+ pthread_exit(NULL);
273
+ }
274
+ #endif
275
+
276
+ static double
277
+ sr_atom_area(int i,
278
+ const sr_data *sr,
279
+ int thread_index)
280
+ {
281
+ const int n_points = sr->n_points;
282
+ /* this array keeps track of which testpoints belonging to
283
+ a certain atom do not overlap with any other atoms */
284
+ int *spcount = sr->spcount[thread_index];
285
+ const int nni = sr->nb->nn[i];
286
+ const int *restrict nbi = sr->nb->nb[i];
287
+ const double ri = sr->r[i];
288
+ const double *restrict r2 = sr->r2;
289
+ const double *restrict v = freesasa_coord_all(sr->xyz);
290
+ const double *restrict vi = v + 3 * i;
291
+ const double *restrict tp;
292
+ int n_surface = 0, current_nb, a, j, k;
293
+ double dx, dy, dz;
294
+ /* testpoints for this atom */
295
+ coord_t *restrict tp_coord_ri = sr->tp_local[thread_index];
296
+
297
+ freesasa_coord_copy(tp_coord_ri, sr->srp);
298
+ freesasa_coord_scale(tp_coord_ri, ri);
299
+ freesasa_coord_translate(tp_coord_ri, vi);
300
+ tp = freesasa_coord_all(tp_coord_ri);
301
+
302
+ /* initialize with all surface points hidden */
303
+ memset(spcount, 0, n_points * sizeof(int));
304
+
305
+ /* Using the trick from NSOL to check points one by one for all
306
+ atoms, start comparing with the first neighbor. If there is no
307
+ overlap for a given test-point, try with other neighbors
308
+ instead. Would probably work even better if test points were
309
+ organized in patches and not spirals. */
310
+ current_nb = 0;
311
+ for (j = 0; j < n_points; ++j) {
312
+ /* a is the index of the atom under consideration */
313
+ a = nbi[current_nb];
314
+ dx = tp[j * 3] - v[a * 3];
315
+ dy = tp[j * 3 + 1] - v[a * 3 + 1];
316
+ dz = tp[j * 3 + 2] - v[a * 3 + 2];
317
+ if (dx * dx + dy * dy + dz * dz > r2[a]) {
318
+ k = 0;
319
+ for (; k < nni; ++k) {
320
+ a = nbi[k];
321
+ dx = tp[j * 3] - v[a * 3];
322
+ dy = tp[j * 3 + 1] - v[a * 3 + 1];
323
+ dz = tp[j * 3 + 2] - v[a * 3 + 2];
324
+ if (dx * dx + dy * dy + dz * dz <= r2[a]) {
325
+ current_nb = k;
326
+ break;
327
+ }
328
+ }
329
+ /* we have gone through the whole list without overlap */
330
+ if (k == nni) spcount[j] = 1;
331
+ }
332
+ }
333
+ for (k = 0; k < n_points; ++k) {
334
+ if (spcount[k]) ++n_surface;
335
+ }
336
+
337
+ return (4.0 * M_PI * ri * ri * n_surface) / n_points;
338
+ }
.venv_haddock/include/site/python3.12/freesasa/selection.c ADDED
@@ -0,0 +1,1003 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <ctype.h>
7
+ #include <stdlib.h>
8
+
9
+ #include "freesasa_internal.h"
10
+ #include "pdb.h"
11
+ #include "selection.h"
12
+
13
+ #include "parser.h"
14
+
15
+ #include "lexer.h"
16
+
17
+ struct freesasa_selection {
18
+ char *name;
19
+ char *command;
20
+ double area;
21
+ int n_atoms;
22
+ };
23
+
24
+ struct selection {
25
+ const char *name;
26
+ int *atom;
27
+ int size;
28
+ };
29
+
30
+ static const char *
31
+ e_str(expression_type e)
32
+ {
33
+ switch (e) {
34
+ case E_SELECTION:
35
+ return "<selection>";
36
+ case E_SYMBOL:
37
+ return "symbol";
38
+ case E_NAME:
39
+ return "name";
40
+ case E_RESN:
41
+ return "resn";
42
+ case E_RESI:
43
+ return "resi";
44
+ case E_CHAIN:
45
+ return "chain";
46
+ case E_ID:
47
+ return "<id>";
48
+ case E_NUMBER:
49
+ return "<number>";
50
+ case E_NEGNUM:
51
+ return "<neg_number>";
52
+ case E_AND:
53
+ return "and";
54
+ case E_OR:
55
+ return "or";
56
+ case E_NOT:
57
+ return "not";
58
+ case E_PLUS:
59
+ return "< + >";
60
+ case E_RANGE:
61
+ return "< - >";
62
+ case E_RANGE_OPEN_R:
63
+ return "< - R >";
64
+ case E_RANGE_OPEN_L:
65
+ return "< - L >";
66
+ }
67
+ return NULL;
68
+ }
69
+
70
+ extern int freesasa_yyparse(expression **expression, yyscan_t scanner);
71
+
72
+ static expression *
73
+ expression_new()
74
+ {
75
+ struct expression *e = malloc(sizeof(expression));
76
+
77
+ if (e == NULL)
78
+ mem_fail();
79
+ else {
80
+ e->type = E_SELECTION;
81
+ e->left = NULL;
82
+ e->right = NULL;
83
+ e->value = NULL;
84
+ }
85
+ return e;
86
+ }
87
+
88
+ static void
89
+ expression_free(expression *expression)
90
+ {
91
+ if (expression) {
92
+ expression_free(expression->left);
93
+ expression_free(expression->right);
94
+ free(expression->value);
95
+ free(expression);
96
+ }
97
+ }
98
+
99
+ expression *
100
+ freesasa_selection_atom(expression_type type,
101
+ const char *val)
102
+ {
103
+ expression *e = expression_new();
104
+ int i, n;
105
+ char *buf;
106
+
107
+ assert(val);
108
+
109
+ if (e != NULL) {
110
+ if (type == E_NEGNUM) {
111
+ n = strlen(val) + 2;
112
+ buf = malloc(n);
113
+ if (buf == NULL) {
114
+ mem_fail();
115
+ expression_free(e);
116
+ return NULL;
117
+ }
118
+ sprintf(buf, "-%s", val);
119
+ e->type = E_NUMBER;
120
+ e->value = strdup(buf);
121
+ free(buf);
122
+ } else {
123
+ e->type = type;
124
+ e->value = strdup(val);
125
+ }
126
+
127
+ if (e->value == NULL) {
128
+ mem_fail();
129
+ expression_free(e);
130
+ return NULL;
131
+ }
132
+
133
+ for (i = 0; i < strlen(e->value); ++i)
134
+ e->value[i] = toupper(e->value[i]);
135
+ }
136
+ return e;
137
+ }
138
+
139
+ expression *
140
+ freesasa_selection_create(expression *selection,
141
+ const char *id)
142
+ {
143
+ expression *e = expression_new();
144
+
145
+ assert(id);
146
+
147
+ if (e == NULL)
148
+ expression_free(selection);
149
+ else {
150
+ e->type = E_SELECTION;
151
+ e->left = selection;
152
+ e->value = strdup(id);
153
+
154
+ if (e->value == NULL) {
155
+ mem_fail();
156
+ expression_free(e);
157
+ e = NULL;
158
+ }
159
+ }
160
+
161
+ return e;
162
+ }
163
+
164
+ expression *
165
+ freesasa_selection_selector(expression_type type,
166
+ expression *list)
167
+ {
168
+ expression *e = expression_new();
169
+
170
+ if (e == NULL) {
171
+ expression_free(list);
172
+ } else {
173
+ e->type = type;
174
+ e->left = list;
175
+ }
176
+
177
+ return e;
178
+ }
179
+
180
+ expression *
181
+ freesasa_selection_operation(expression_type type,
182
+ expression *left,
183
+ expression *right)
184
+ {
185
+ expression *e = expression_new();
186
+
187
+ if (e == NULL) {
188
+ expression_free(left);
189
+ expression_free(right);
190
+ } else {
191
+ e->type = type;
192
+ e->left = left;
193
+ e->right = right;
194
+ }
195
+
196
+ return e;
197
+ }
198
+
199
+ /* for debugging */
200
+ static void
201
+ print_expr(FILE *output, const expression *e, int level)
202
+ {
203
+ int i;
204
+ fprintf(output, "\n");
205
+ for (i = 0; i < level; ++i)
206
+ fprintf(output, " ");
207
+
208
+ if (e == NULL) {
209
+ fprintf(output, "()");
210
+ } else {
211
+ fprintf(output, "(%s ", e_str(e->type));
212
+ if (e->value) fprintf(output, ": %s ", e->value);
213
+ print_expr(output, e->left, level + 1);
214
+ print_expr(output, e->right, level + 1);
215
+ fprintf(output, ")");
216
+ }
217
+ fflush(output);
218
+ }
219
+
220
+ static expression *
221
+ get_expression(const char *selector)
222
+ {
223
+ freesasa_yyscan_t scanner;
224
+ YY_BUFFER_STATE state;
225
+ int err;
226
+ expression *expression = NULL;
227
+
228
+ if (freesasa_yylex_init(&scanner)) {
229
+ fail_msg("lexer failed");
230
+ } else {
231
+ state = freesasa_yy_scan_string(selector, scanner);
232
+ err = freesasa_yyparse(&expression, scanner);
233
+ if (err) {
234
+ if (err == 1) fail_msg("parser failed");
235
+ if (err == 2) mem_fail();
236
+ expression_free(expression);
237
+ expression = NULL;
238
+ }
239
+ freesasa_yy_delete_buffer(state, scanner);
240
+ freesasa_yylex_destroy(scanner);
241
+ }
242
+
243
+ return expression;
244
+ }
245
+
246
+ static struct selection *
247
+ selection_new(int n)
248
+ {
249
+ struct selection *selection = malloc(sizeof(struct selection));
250
+ int i;
251
+
252
+ if (selection == NULL) {
253
+ mem_fail();
254
+ } else {
255
+ selection->size = n;
256
+ selection->atom = malloc(sizeof(int) * n);
257
+
258
+ if (selection->atom == NULL) {
259
+ free(selection);
260
+ mem_fail();
261
+ selection = NULL;
262
+ } else {
263
+ for (i = 0; i < n; ++i)
264
+ selection->atom[i] = 0;
265
+ }
266
+ }
267
+
268
+ return selection;
269
+ }
270
+
271
+ static void
272
+ selection_free(struct selection *selection)
273
+ {
274
+ if (selection) {
275
+ free(selection->atom);
276
+ free(selection);
277
+ }
278
+ }
279
+
280
+ /* Looks for exact match between the atom-name and expr->value */
281
+ static int
282
+ match_name(const freesasa_structure *structure,
283
+ const char *id,
284
+ int i)
285
+ {
286
+ char atom[PDB_ATOM_NAME_STRL + 1];
287
+ sscanf(freesasa_structure_atom_name(structure, i), "%s", atom);
288
+ if (strcmp(atom, id) == 0)
289
+ return 1;
290
+ return 0;
291
+ }
292
+
293
+ /** Looks for match of strlen(expr->value) first characters of atom-name and expr->value */
294
+ static int
295
+ match_symbol(const freesasa_structure *structure,
296
+ const char *id,
297
+ int i)
298
+ {
299
+ char symbol[PDB_ATOM_SYMBOL_STRL + 1];
300
+ sscanf(freesasa_structure_atom_symbol(structure, i), "%s", symbol);
301
+ if (strcmp(id, symbol) == 0) {
302
+ return 1;
303
+ }
304
+ return 0;
305
+ }
306
+
307
+ static int
308
+ match_resn(const freesasa_structure *structure,
309
+ const char *id,
310
+ int i)
311
+ {
312
+ char resn[PDB_ATOM_RES_NAME_STRL + 1];
313
+ sscanf(freesasa_structure_atom_res_name(structure, i), "%s", resn);
314
+ if (strcmp(resn, id) == 0)
315
+ return 1;
316
+ return 0;
317
+ }
318
+
319
+ static int
320
+ match_resi(const freesasa_structure *structure,
321
+ const char *id,
322
+ int i)
323
+ {
324
+ char resi[PDB_ATOM_RES_NUMBER_STRL + 1];
325
+ sscanf(freesasa_structure_atom_res_number(structure, i), "%s", resi);
326
+ if (strcmp(resi, id) == 0)
327
+ return 1;
328
+ return 0;
329
+ }
330
+
331
+ static int
332
+ match_chain(const freesasa_structure *structure,
333
+ const char *id,
334
+ int i)
335
+ {
336
+ return id[0] == freesasa_structure_atom_chain(structure, i);
337
+ }
338
+
339
+ static void
340
+ select_id(expression_type parent_type,
341
+ struct selection *selection,
342
+ const freesasa_structure *structure,
343
+ const char *id)
344
+ {
345
+ int count = 0, match, i;
346
+
347
+ assert(id);
348
+
349
+ for (i = 0; i < selection->size; ++i) {
350
+ match = 0;
351
+ switch (parent_type) {
352
+ case E_NAME:
353
+ match = match_name(structure, id, i);
354
+ break;
355
+ case E_SYMBOL:
356
+ match = match_symbol(structure, id, i);
357
+ break;
358
+ case E_RESN:
359
+ match = match_resn(structure, id, i);
360
+ break;
361
+ case E_RESI:
362
+ match = match_resi(structure, id, i);
363
+ break;
364
+ case E_CHAIN:
365
+ match = match_chain(structure, id, i);
366
+ break;
367
+ default:
368
+ assert(0);
369
+ break;
370
+ }
371
+ if (match) selection->atom[i] = 1;
372
+ count += match;
373
+ }
374
+ if (count == 0) freesasa_warn("Found no matches to %s '%s', typo?",
375
+ e_str(parent_type), id);
376
+ }
377
+
378
+ static int
379
+ is_valid_id(int parent_type,
380
+ const expression *expr)
381
+ {
382
+ int type, n, warn, i;
383
+ const char *val;
384
+
385
+ assert(expr->type == E_NUMBER || expr->type == E_ID);
386
+
387
+ type = expr->type;
388
+ val = expr->value;
389
+
390
+ switch (parent_type) {
391
+ case E_NAME:
392
+ if (strlen(val) > PDB_ATOM_NAME_STRL)
393
+ return freesasa_warn("select: %s: atom name '%s' invalid (string too long), "
394
+ "will be ignored",
395
+ e_str(parent_type), val);
396
+ break;
397
+ case E_SYMBOL:
398
+ if (type != E_ID)
399
+ return freesasa_warn("select: %s: '%s' invalid (should be 1 or 2 letters, 'C', 'N', 'SE', etc), "
400
+ "will be ignored",
401
+ e_str(parent_type), val);
402
+ if (strlen(val) > 2)
403
+ return freesasa_warn("select: %s: '%s' invalid (element names have 1 or 2 characters), "
404
+ "will be ignored",
405
+ e_str(parent_type), val);
406
+ break;
407
+ case E_RESN:
408
+ if (strlen(val) > PDB_ATOM_RES_NAME_STRL)
409
+ return freesasa_warn("select: %s: '%s' invalid (string too long), "
410
+ "will be ignored",
411
+ e_str(parent_type), val);
412
+ break;
413
+ case E_RESI:
414
+ if (type == E_ID) {
415
+ /* these should have format 1, 2, 345, etc or 12A, 12B, etc. */
416
+ n = strlen(val);
417
+ if (n > PDB_ATOM_RES_NUMBER_STRL) {
418
+ return freesasa_warn("select: %s: '%s' invalid (string too long), "
419
+ "will be ignored",
420
+ e_str(parent_type), val);
421
+ } else {
422
+ warn = 0;
423
+ if (n == 1) ++warn;
424
+ if (!warn && (toupper(val[n - 1]) < 'A' || toupper(val[n - 1]) > 'Z')) {
425
+ ++warn;
426
+ }
427
+ for (i = 0; !warn && i < n - 1; ++i) {
428
+ if (val[i] < '0' || val[i] > '9') {
429
+ ++warn;
430
+ }
431
+ }
432
+ if (warn) {
433
+ return freesasa_warn("select: %s: '%s' invalid, should either be "
434
+ "number (1, 2, 3) or number with insertion code (1A, 1B, ...), "
435
+ "will be ignored",
436
+ e_str(parent_type), val);
437
+ }
438
+ }
439
+ } else if (type != E_NUMBER) {
440
+ return freesasa_warn("select: %s: '%s' invalid, will be ignored",
441
+ e_str(parent_type), val);
442
+ }
443
+ break;
444
+ case E_CHAIN:
445
+ if (strlen(val) > 1)
446
+ return freesasa_warn("select: %s: '%s' invalid (string too long), "
447
+ "will be ignored",
448
+ e_str(parent_type), val);
449
+ break;
450
+ default:
451
+ assert(0);
452
+ break;
453
+ }
454
+ return FREESASA_SUCCESS;
455
+ }
456
+
457
+ static int
458
+ select_range(expression_type range_type,
459
+ expression_type parent_type,
460
+ struct selection *selection,
461
+ const freesasa_structure *structure,
462
+ const expression *left,
463
+ const expression *right)
464
+ {
465
+ int lower, upper, i, j;
466
+
467
+ assert(range_type == E_RANGE || range_type == E_RANGE_OPEN_L || range_type == E_RANGE_OPEN_R);
468
+ assert(parent_type == E_RESI || parent_type == E_CHAIN);
469
+
470
+ if (parent_type == E_RESI) { /* residues have integer numbering */
471
+ if ((left && left->type != E_NUMBER) ||
472
+ (right && right->type != E_NUMBER)) {
473
+ return freesasa_warn("select: %s: range '%s-%s' invalid, needs to be two numbers, "
474
+ "will be ignored",
475
+ e_str(parent_type), left->value, right->value);
476
+ }
477
+ } else { /* chains can be numbered by both letters (common) and numbers (uncommon) */
478
+ if (left->type != right->type ||
479
+ (left->type == E_ID && (strlen(left->value) > 1 || strlen(right->value) > 1)))
480
+ return freesasa_warn("select: %s: range '%s-%s' invalid, should be two letters (A-C) or numbers (1-5), "
481
+ "will be ignored",
482
+ e_str(parent_type), left->value, right->value);
483
+ }
484
+ if (range_type == E_RANGE_OPEN_L) {
485
+ lower = atoi(freesasa_structure_atom_res_number(structure, 0));
486
+ upper = atoi(right->value);
487
+ } else if (range_type == E_RANGE_OPEN_R) {
488
+ lower = atoi(left->value);
489
+ upper = atoi(freesasa_structure_atom_res_number(structure, freesasa_structure_n(structure) - 1));
490
+ } else if (left->type == E_NUMBER) {
491
+ lower = atoi(left->value);
492
+ upper = atoi(right->value);
493
+ } else {
494
+ lower = (int)left->value[0];
495
+ upper = (int)right->value[0];
496
+ }
497
+ for (i = 0; i < selection->size; ++i) {
498
+ if (parent_type == E_RESI)
499
+ j = atoi(freesasa_structure_atom_res_number(structure, i));
500
+ else
501
+ j = (int)freesasa_structure_atom_chain(structure, i);
502
+ if (j >= lower && j <= upper)
503
+ selection->atom[i] = 1;
504
+ }
505
+ return FREESASA_SUCCESS;
506
+ }
507
+
508
+ static int
509
+ select_list(expression_type parent_type,
510
+ struct selection *selection,
511
+ const freesasa_structure *structure,
512
+ const expression *expr)
513
+ {
514
+ int resr, resl;
515
+ expression *left, *right;
516
+
517
+ if (expr == NULL)
518
+ return fail_msg("NULL expression");
519
+
520
+ left = expr->left;
521
+ right = expr->right;
522
+
523
+ switch (expr->type) {
524
+ case E_PLUS:
525
+ if (left == NULL || right == NULL)
526
+ return fail_msg("NULL expression");
527
+ resl = select_list(parent_type, selection, structure, left);
528
+ resr = select_list(parent_type, selection, structure, right);
529
+ if (resl == FREESASA_WARN || resr == FREESASA_WARN)
530
+ return FREESASA_WARN;
531
+ break;
532
+ case E_RANGE:
533
+ if (left == NULL || right == NULL)
534
+ return fail_msg("NULL expression");
535
+ return select_range(E_RANGE, parent_type, selection, structure, left, right);
536
+ case E_RANGE_OPEN_L:
537
+ if (left != NULL || right == NULL)
538
+ return fail_msg("NULL expression");
539
+ return select_range(E_RANGE_OPEN_L, parent_type, selection, structure, left, right);
540
+ case E_RANGE_OPEN_R:
541
+ if (left == NULL || right != NULL)
542
+ return fail_msg("NULL expression");
543
+ return select_range(E_RANGE_OPEN_R, parent_type, selection, structure, left, right);
544
+ case E_ID:
545
+ case E_NUMBER:
546
+ if (is_valid_id(parent_type, expr) == FREESASA_SUCCESS)
547
+ select_id(parent_type, selection, structure, expr->value);
548
+ else
549
+ return freesasa_warn("select: %s: '%s' invalid %s",
550
+ e_str(parent_type), expr->value, e_str(expr->type));
551
+ break;
552
+ default:
553
+ return freesasa_fail("select: parse error (expression: '%s %s')",
554
+ e_str(parent_type), e_str(expr->type));
555
+ }
556
+ return FREESASA_SUCCESS;
557
+ }
558
+
559
+ static int
560
+ selection_join(struct selection *target,
561
+ const struct selection *s1,
562
+ const struct selection *s2,
563
+ int type)
564
+ {
565
+ int n, i;
566
+
567
+ if (s1 == NULL || s2 == NULL || target == NULL)
568
+ return fail_msg("trying to join NULL selections");
569
+
570
+ assert(s1->size == s2->size);
571
+ assert(s1->size == target->size);
572
+
573
+ n = target->size;
574
+
575
+ switch (type) {
576
+ case E_AND:
577
+ for (i = 0; i < n; ++i)
578
+ target->atom[i] = s1->atom[i] && s2->atom[i];
579
+ break;
580
+ case E_OR:
581
+ for (i = 0; i < n; ++i)
582
+ target->atom[i] = s1->atom[i] || s2->atom[i];
583
+ break;
584
+ default:
585
+ assert(0);
586
+ }
587
+
588
+ return FREESASA_SUCCESS;
589
+ }
590
+
591
+ static int
592
+ selection_not(struct selection *s)
593
+ {
594
+ int i;
595
+
596
+ if (s == NULL) return fail_msg("NULL selection");
597
+
598
+ for (i = 0; i < s->size; ++i) {
599
+ s->atom[i] = !s->atom[i];
600
+ }
601
+
602
+ return FREESASA_SUCCESS;
603
+ }
604
+
605
+ /* Called recursively, the selection is built as we cover the expression tree */
606
+ static int
607
+ select_atoms(struct selection *selection,
608
+ const expression *expr,
609
+ const freesasa_structure *structure)
610
+ {
611
+ int warn = 0, err = 0, n, ret;
612
+ struct selection *sl, *sr;
613
+
614
+ assert(selection);
615
+ assert(structure);
616
+
617
+ n = selection->size;
618
+
619
+ /* this should only happen if memory allocation failed during parsing */
620
+ if (expr == NULL) return fail_msg("NULL expression");
621
+
622
+ switch (expr->type) {
623
+ case E_SELECTION:
624
+ assert(expr->value != NULL);
625
+ selection->name = expr->value;
626
+ return select_atoms(selection, expr->left, structure);
627
+ break;
628
+ case E_SYMBOL:
629
+ case E_NAME:
630
+ case E_RESN:
631
+ case E_RESI:
632
+ case E_CHAIN:
633
+ return select_list(expr->type, selection, structure, expr->left);
634
+ break;
635
+ case E_AND:
636
+ case E_OR: {
637
+ sl = selection_new(n);
638
+ sr = selection_new(n);
639
+
640
+ if (sl != NULL && sr != NULL) {
641
+ if ((ret = select_atoms(sl, expr->left, structure))) {
642
+ if (ret == FREESASA_WARN) ++warn;
643
+ if (ret == FREESASA_FAIL) ++err;
644
+ }
645
+ if ((ret = select_atoms(sr, expr->right, structure))) {
646
+ if (ret == FREESASA_WARN) ++warn;
647
+ if (ret == FREESASA_FAIL) ++err;
648
+ }
649
+ selection_join(selection, sl, sr, expr->type);
650
+ } else {
651
+ ++err;
652
+ }
653
+
654
+ selection_free(sl);
655
+ selection_free(sr);
656
+
657
+ if (err) return fail_msg("error joining selections");
658
+ break;
659
+ }
660
+ case E_NOT: {
661
+ ret = select_atoms(selection, expr->right, structure);
662
+ if (ret == FREESASA_WARN) ++warn;
663
+ if (ret == FREESASA_FAIL) return FREESASA_FAIL;
664
+ if (selection_not(selection)) return FREESASA_FAIL;
665
+ break;
666
+ }
667
+ case E_ID:
668
+ case E_NUMBER:
669
+ case E_PLUS:
670
+ case E_RANGE:
671
+ /* these four are handled by the RESN,SYMBOL,ETC */
672
+ default:
673
+ return fail_msg("parser error");
674
+ }
675
+ if (warn) return FREESASA_WARN;
676
+ return FREESASA_SUCCESS;
677
+ }
678
+
679
+ static int
680
+ select_area_impl(const char *command,
681
+ char *name,
682
+ double *area,
683
+ const freesasa_structure *structure,
684
+ const freesasa_result *result)
685
+ {
686
+ struct selection *selection = NULL;
687
+ struct expression *expression = NULL;
688
+ const int maxlen = FREESASA_MAX_SELECTION_NAME;
689
+ double sasa = 0;
690
+ int err = 0, warn = 0, n_atoms = 0, j, len;
691
+
692
+ assert(name);
693
+ assert(area);
694
+ assert(command);
695
+ assert(structure);
696
+ assert(result);
697
+ assert(freesasa_structure_n(structure) == result->n_atoms);
698
+
699
+ *area = 0;
700
+ name[0] = '\0';
701
+
702
+ expression = get_expression(command);
703
+ selection = selection_new(result->n_atoms);
704
+
705
+ if (selection == NULL) {
706
+ return fail_msg("");
707
+ }
708
+
709
+ if (expression != NULL && selection != NULL) {
710
+ switch (select_atoms(selection, expression, structure)) {
711
+ case FREESASA_FAIL:
712
+ err = 1;
713
+ break;
714
+ case FREESASA_WARN:
715
+ warn = 1; /* proceed with calculation, print warning later */
716
+ case FREESASA_SUCCESS: {
717
+ for (j = 0; j < selection->size; ++j) {
718
+ ++n_atoms;
719
+ sasa += selection->atom[j] * result->sasa[j];
720
+ }
721
+
722
+ *area = sasa;
723
+ len = strlen(selection->name);
724
+ strncpy(name, selection->name, maxlen);
725
+
726
+ if (len > maxlen) {
727
+ name[maxlen] = '\0';
728
+ } else {
729
+ name[len] = '\0';
730
+ }
731
+
732
+ break;
733
+ }
734
+ default:
735
+ assert(0);
736
+ }
737
+ } else {
738
+ err = 1;
739
+ }
740
+ selection_free(selection);
741
+ expression_free(expression);
742
+
743
+ if (err)
744
+ return fail_msg("problems parsing expression '%s'", command);
745
+ if (warn)
746
+ return freesasa_warn("in %s(): There were warnings", __func__);
747
+ return n_atoms;
748
+ }
749
+
750
+ freesasa_selection *
751
+ freesasa_selection_alloc(const char *name, const char *command)
752
+ {
753
+ freesasa_selection *selection = malloc(sizeof(freesasa_selection));
754
+
755
+ if (selection == NULL) {
756
+ mem_fail();
757
+ return NULL;
758
+ }
759
+
760
+ selection->name = NULL;
761
+ selection->command = NULL;
762
+ selection->area = 0;
763
+ selection->n_atoms = 0;
764
+
765
+ selection->name = strdup(name);
766
+ if (selection->name == NULL) {
767
+ mem_fail();
768
+ goto cleanup;
769
+ }
770
+
771
+ selection->command = strdup(command);
772
+ if (selection->command == NULL) {
773
+ mem_fail();
774
+ goto cleanup;
775
+ }
776
+
777
+ return selection;
778
+
779
+ cleanup:
780
+ freesasa_selection_free(selection);
781
+ return NULL;
782
+ }
783
+
784
+ void freesasa_selection_free(freesasa_selection *selection)
785
+ {
786
+ if (selection != NULL) {
787
+ free(selection->name);
788
+ free(selection->command);
789
+ free(selection);
790
+ }
791
+ }
792
+
793
+ freesasa_selection *
794
+ freesasa_selection_clone(const freesasa_selection *src)
795
+ {
796
+ freesasa_selection *cpy = freesasa_selection_alloc(src->name, src->command);
797
+
798
+ if (cpy == NULL) {
799
+ fail_msg("");
800
+ goto cleanup;
801
+ }
802
+
803
+ cpy->area = src->area;
804
+ cpy->n_atoms = src->n_atoms;
805
+
806
+ return cpy;
807
+
808
+ cleanup:
809
+ freesasa_selection_free(cpy);
810
+ return NULL;
811
+ }
812
+
813
+ const char *
814
+ freesasa_selection_name(const freesasa_selection *selection)
815
+ {
816
+ assert(selection);
817
+ return selection->name;
818
+ }
819
+
820
+ const char *
821
+ freesasa_selection_command(const freesasa_selection *selection)
822
+ {
823
+ assert(selection);
824
+ return selection->command;
825
+ }
826
+
827
+ double
828
+ freesasa_selection_area(const freesasa_selection *selection)
829
+ {
830
+ assert(selection);
831
+ return selection->area;
832
+ }
833
+
834
+ freesasa_selection *
835
+ freesasa_selection_new(const char *command,
836
+ const freesasa_structure *structure,
837
+ const freesasa_result *result)
838
+ {
839
+ char name[FREESASA_MAX_SELECTION_NAME];
840
+ double area;
841
+ freesasa_selection *selection;
842
+ int n_atoms;
843
+
844
+ n_atoms = select_area_impl(command, name, &area, structure, result);
845
+
846
+ if (n_atoms == FREESASA_FAIL) {
847
+ fail_msg("");
848
+ return NULL;
849
+ }
850
+
851
+ selection = freesasa_selection_alloc(name, command);
852
+ if (selection == NULL) {
853
+ mem_fail();
854
+ return NULL;
855
+ }
856
+
857
+ selection->area = area;
858
+ selection->n_atoms = n_atoms;
859
+
860
+ return selection;
861
+ }
862
+
863
+ int freesasa_select_area(const char *command,
864
+ char *name,
865
+ double *area,
866
+ const freesasa_structure *structure,
867
+ const freesasa_result *result)
868
+ {
869
+ int ret = select_area_impl(command, name, area, structure, result);
870
+ if (ret >= 0) return FREESASA_SUCCESS;
871
+ return ret;
872
+ }
873
+
874
+ int freesasa_selection_parse_error(expression *e,
875
+ yyscan_t scanner,
876
+ const char *msg)
877
+ {
878
+ if (freesasa_get_verbosity() == FREESASA_V_DEBUG) print_expr(stderr, e, 0);
879
+ if (freesasa_get_verbosity() == FREESASA_V_NORMAL) fprintf(stderr, "\n");
880
+ return freesasa_fail(msg);
881
+ }
882
+
883
+ #if USE_CHECK
884
+ #include <check.h>
885
+
886
+ START_TEST(test_selection)
887
+ {
888
+ struct selection *s1, *s2, *s3, *s4;
889
+ static const expression empty_expression = {
890
+ .right = NULL, .left = NULL, .value = NULL, .type = E_SELECTION};
891
+ freesasa_structure *structure = freesasa_structure_new();
892
+ expression r, l, e, e_symbol;
893
+
894
+ freesasa_structure_add_atom(structure, " CA ", "ALA", " 1", 'A', 0, 0, 0);
895
+ freesasa_structure_add_atom(structure, " O ", "ALA", " 1", 'A', 10, 10, 10);
896
+
897
+ s1 = selection_new(freesasa_structure_n(structure));
898
+ s2 = selection_new(freesasa_structure_n(structure));
899
+ s3 = selection_new(freesasa_structure_n(structure));
900
+ s4 = selection_new(freesasa_structure_n(structure));
901
+
902
+ r = l = e = e_symbol = empty_expression;
903
+ e.type = E_PLUS;
904
+ e.right = &r;
905
+ e.left = &l;
906
+ r.value = "C";
907
+ r.type = E_ID;
908
+ l.value = "O";
909
+ l.type = E_ID;
910
+ e_symbol.type = E_SYMBOL;
911
+ e_symbol.left = &e;
912
+
913
+ /* select_symbol */
914
+ select_list(E_SYMBOL, s1, structure, &r);
915
+ ck_assert_int_eq(s1->atom[0], 1);
916
+ ck_assert_int_eq(s1->atom[1], 0);
917
+ select_list(E_SYMBOL, s2, structure, &l);
918
+ ck_assert_int_eq(s2->atom[0], 0);
919
+ ck_assert_int_eq(s2->atom[1], 1);
920
+ select_list(E_SYMBOL, s3, structure, &e);
921
+ ck_assert_int_eq(s3->atom[0], 1);
922
+ ck_assert_int_eq(s3->atom[1], 1);
923
+ select_atoms(s4, &e_symbol, structure);
924
+ ck_assert_int_eq(s4->atom[0], 1);
925
+ ck_assert_int_eq(s4->atom[1], 1);
926
+
927
+ /* selection_join */
928
+ selection_join(s3, s1, s2, E_AND);
929
+ ck_assert_int_eq(s3->atom[0], 0);
930
+ ck_assert_int_eq(s3->atom[1], 0);
931
+ selection_join(s3, s1, s2, E_OR);
932
+ ck_assert_int_eq(s3->atom[0], 1);
933
+ ck_assert_int_eq(s3->atom[1], 1);
934
+ freesasa_set_verbosity(FREESASA_V_SILENT);
935
+ ck_assert_int_eq(selection_join(NULL, s1, s2, E_OR), FREESASA_FAIL);
936
+ ck_assert_int_eq(selection_join(s3, NULL, s1, E_OR), FREESASA_FAIL);
937
+ ck_assert_int_eq(selection_join(NULL, NULL, NULL, E_OR), FREESASA_FAIL);
938
+
939
+ /* selection_not */
940
+ ck_assert_int_eq(selection_not(s3), FREESASA_SUCCESS);
941
+ ck_assert_int_eq(s3->atom[0], 0);
942
+ ck_assert_int_eq(s3->atom[1], 0);
943
+ ck_assert_int_eq(selection_not(NULL), FREESASA_FAIL);
944
+ freesasa_set_verbosity(FREESASA_V_NORMAL);
945
+ }
946
+ END_TEST
947
+
948
+ START_TEST(test_expression)
949
+ {
950
+ int i;
951
+ expression *e = get_expression("c1, symbol O+C");
952
+
953
+ ck_assert_ptr_ne(e, NULL);
954
+ ck_assert_int_eq(e->type, E_SELECTION);
955
+ ck_assert_ptr_ne(e->left, NULL);
956
+ ck_assert_ptr_eq(e->right, NULL);
957
+ ck_assert_str_eq(e->value, "c1");
958
+ ck_assert_int_eq(e->left->type, E_SYMBOL);
959
+ ck_assert_ptr_ne(e->left->left, NULL);
960
+ ck_assert_ptr_eq(e->left->right, NULL);
961
+ ck_assert_int_eq(e->left->left->type, E_PLUS);
962
+ ck_assert_int_eq(e->left->left->left->type, E_ID);
963
+ ck_assert_int_eq(e->left->left->right->type, E_ID);
964
+ ck_assert_str_eq(e->left->left->right->value, "C");
965
+ ck_assert_str_eq(e->left->left->left->value, "O");
966
+ for (i = E_SELECTION; i <= E_RANGE_OPEN_R; ++i) {
967
+ ck_assert_ptr_ne(e_str(i), NULL);
968
+ }
969
+ ck_assert_ptr_eq(e_str(E_RANGE_OPEN_R + 1), NULL);
970
+ }
971
+ END_TEST
972
+
973
+ START_TEST(test_debug) /* this test just runs the debug output code to not get artificially low coverage */
974
+ {
975
+ FILE *devnull = fopen("/dev/null", "w");
976
+ expression *e = get_expression("c1, symbol O+C");
977
+ print_expr(devnull, e, 0);
978
+ }
979
+ END_TEST
980
+
981
+ struct selection selection_dummy = {.size = 1, .name = NULL, .atom = NULL};
982
+
983
+ void *freesasa_selection_dummy_ptr = &selection_dummy;
984
+
985
+ int freesasa_wrap_select_atoms(struct selection *selection,
986
+ const expression *expr,
987
+ const freesasa_structure *structure)
988
+ {
989
+ return select_atoms(selection, expr, structure);
990
+ }
991
+
992
+ TCase *
993
+ test_selection_static()
994
+ {
995
+ TCase *tc = tcase_create("selection.c static");
996
+ tcase_add_test(tc, test_selection);
997
+ tcase_add_test(tc, test_expression);
998
+ tcase_add_test(tc, test_debug);
999
+
1000
+ return tc;
1001
+ }
1002
+
1003
+ #endif /* USE_CHECK */
.venv_haddock/include/site/python3.12/freesasa/selection.h ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef SELECTION_H
2
+ #define SELECTION_H
3
+
4
+ typedef enum { E_SELECTION,
5
+ E_SYMBOL,
6
+ E_NAME,
7
+ E_RESN,
8
+ E_RESI,
9
+ E_CHAIN,
10
+ E_ID,
11
+ E_NUMBER,
12
+ E_NEGNUM,
13
+ E_AND,
14
+ E_OR,
15
+ E_NOT,
16
+ E_PLUS,
17
+ E_RANGE,
18
+ E_RANGE_OPEN_L,
19
+ E_RANGE_OPEN_R } expression_type;
20
+
21
+ typedef struct expression {
22
+ struct expression *left;
23
+ struct expression *right;
24
+ expression_type type;
25
+ char *value;
26
+ } expression;
27
+
28
+ /** Create an atomic value E_ID or E_NUMBER */
29
+ expression *
30
+ freesasa_selection_atom(expression_type type,
31
+ const char *val);
32
+
33
+ /** Create a top level selection (E_SELECTION) */
34
+ expression *
35
+ freesasa_selection_create(expression *selection,
36
+ const char *id);
37
+
38
+ /** Create a property selector (E_SYMBOL, E_NAME, E_RESN, E_RESI or E_CHAIN) */
39
+ expression *
40
+ freesasa_selection_selector(expression_type type,
41
+ expression *list);
42
+
43
+ /** Create an operation (E_AND, E_OR, E_NOT, E_PLUS or E_RANGE) */
44
+ expression *
45
+ freesasa_selection_operation(expression_type type,
46
+ expression *left,
47
+ expression *right);
48
+
49
+ #endif /* SELECTION_H */
.venv_haddock/include/site/python3.12/freesasa/structure.c ADDED
@@ -0,0 +1,1243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+
5
+ #include <assert.h>
6
+ #include <stdlib.h>
7
+
8
+ #include "classifier.h"
9
+ #include "coord.h"
10
+ #include "freesasa_internal.h"
11
+ #include "pdb.h"
12
+
13
+ /**
14
+ This file contains the functions that turn lines in PDB files to
15
+ atom records. It's all pretty messy because one needs to keep track
16
+ of when a new chain/new residue is encountered, and skip atoms that
17
+ are duplicates (only first of alt coordinates are used). It is both
18
+ possible to add atoms one by one, or by reading a whole file at
19
+ once, and the user can supply some options about what to do when
20
+ encountering atoms that are not recognized, whether to include
21
+ hydrogrens, hetatm, etc. The current implementation results in a
22
+ rather convoluted logic, that is difficult to maintain, debug and
23
+ extend.
24
+
25
+ TODO: Refactor.
26
+ */
27
+ #define ATOMS_CHUNK 512
28
+ #define RESIDUES_CHUNK 64
29
+ #define CHAINS_CHUNK 64
30
+
31
+ struct atom {
32
+ char *res_name;
33
+ char *res_number;
34
+ char *atom_name;
35
+ char *symbol;
36
+ char *line;
37
+ int res_index;
38
+ char chain_label;
39
+ freesasa_atom_class the_class;
40
+ };
41
+
42
+ static const struct atom empty_atom = {
43
+ NULL, /* res_name */
44
+ NULL, /* res_number */
45
+ NULL, /* atom_name */
46
+ NULL, /* symbol */
47
+ NULL, /* line */
48
+ -1, /* res_index */
49
+ '\0', /* chain_label */
50
+ FREESASA_ATOM_UNKNOWN /* the_class */
51
+ };
52
+
53
+ struct atoms {
54
+ int n;
55
+ int n_alloc;
56
+ struct atom **atom;
57
+ double *radius;
58
+ };
59
+
60
+ struct residues {
61
+ int n;
62
+ int n_alloc;
63
+ int *first_atom;
64
+ freesasa_nodearea **reference_area;
65
+ };
66
+
67
+ struct chains {
68
+ int n;
69
+ int n_alloc;
70
+ char *labels; /* all chain labels found (as string) */
71
+ int *first_atom; /* first atom of each chain */
72
+ };
73
+
74
+ struct freesasa_structure {
75
+ struct atoms atoms;
76
+ struct residues residues;
77
+ struct chains chains;
78
+ char *classifier_name;
79
+ coord_t *xyz;
80
+ int model; /* model number */
81
+ size_t cif_ref;
82
+ void (*release_cif_ref)(size_t);
83
+ };
84
+
85
+ static int
86
+ guess_symbol(char *symbol,
87
+ const char *name);
88
+
89
+ static void
90
+ atom_free(struct atom *a)
91
+ {
92
+ if (a != NULL) {
93
+ free(a->res_name);
94
+ free(a->res_number);
95
+ free(a->atom_name);
96
+ free(a->symbol);
97
+ free(a->line);
98
+ free(a);
99
+ }
100
+ }
101
+
102
+ struct atoms
103
+ atoms_init(void)
104
+ {
105
+ struct atoms atoms;
106
+ atoms.n = 0;
107
+ atoms.n_alloc = 0;
108
+ atoms.atom = NULL;
109
+ atoms.radius = NULL;
110
+ return atoms;
111
+ }
112
+
113
+ /* Allocates memory in chunks, ticks up atoms->n if allocation successful */
114
+ static int
115
+ atoms_alloc(struct atoms *atoms)
116
+ {
117
+ int i, new_size;
118
+ void *aa, *ar;
119
+
120
+ assert(atoms);
121
+ assert(atoms->n <= atoms->n_alloc);
122
+
123
+ if (atoms->n == atoms->n_alloc) {
124
+ new_size = atoms->n_alloc + ATOMS_CHUNK;
125
+ aa = atoms->atom;
126
+ ar = atoms->radius;
127
+
128
+ atoms->atom = realloc(atoms->atom, sizeof(struct atom *) * new_size);
129
+ if (atoms->atom == NULL) {
130
+ atoms->atom = aa;
131
+ return mem_fail();
132
+ }
133
+
134
+ for (i = atoms->n_alloc; i < new_size; ++i) {
135
+ atoms->atom[i] = NULL;
136
+ }
137
+
138
+ atoms->radius = realloc(atoms->radius, sizeof(double) * new_size);
139
+ if (atoms->radius == NULL) {
140
+ atoms->radius = ar;
141
+ return mem_fail();
142
+ }
143
+
144
+ atoms->n_alloc = new_size;
145
+ }
146
+ ++atoms->n;
147
+ return FREESASA_SUCCESS;
148
+ }
149
+
150
+ static void
151
+ atoms_dealloc(struct atoms *atoms)
152
+ {
153
+ int i;
154
+ struct atom **atom;
155
+
156
+ if (atoms) {
157
+ atom = atoms->atom;
158
+ if (atom) {
159
+ for (i = 0; i < atoms->n; ++i)
160
+ if (atom[i]) atom_free(atom[i]);
161
+ free(atom);
162
+ }
163
+ free(atoms->radius);
164
+ *atoms = atoms_init();
165
+ }
166
+ }
167
+
168
+ static struct atom *
169
+ atom_new(const char *residue_name,
170
+ const char *residue_number,
171
+ const char *atom_name,
172
+ const char *symbol,
173
+ char chain_label)
174
+ {
175
+ struct atom *a = malloc(sizeof(struct atom));
176
+ if (a == NULL) goto memerr;
177
+
178
+ *a = empty_atom;
179
+
180
+ a->line = NULL;
181
+ a->chain_label = chain_label;
182
+ a->res_index = -1;
183
+
184
+ a->res_name = strdup(residue_name);
185
+ a->res_number = strdup(residue_number);
186
+ a->atom_name = strdup(atom_name);
187
+ a->symbol = strdup(symbol);
188
+ a->the_class = FREESASA_ATOM_UNKNOWN;
189
+
190
+ if (!a->res_name || !a->res_number || !a->atom_name ||
191
+ !a->symbol) {
192
+ goto memerr;
193
+ }
194
+
195
+ return a;
196
+
197
+ memerr:
198
+ mem_fail();
199
+ atom_free(a);
200
+ return NULL;
201
+ }
202
+
203
+ static struct atom *
204
+ atom_new_from_line(const char *line,
205
+ char *alt_label)
206
+ {
207
+ char aname[PDB_ATOM_NAME_STRL + 1], rname[PDB_ATOM_RES_NAME_STRL + 1],
208
+ rnumber[PDB_ATOM_RES_NUMBER_STRL + 1], symbol[PDB_ATOM_SYMBOL_STRL + 1];
209
+ int flag;
210
+ struct atom *a;
211
+
212
+ assert(line);
213
+
214
+ if (alt_label) *alt_label = freesasa_pdb_get_alt_coord_label(line);
215
+
216
+ freesasa_pdb_get_atom_name(aname, line);
217
+ freesasa_pdb_get_res_name(rname, line);
218
+ freesasa_pdb_get_res_number(rnumber, line);
219
+
220
+ flag = freesasa_pdb_get_symbol(symbol, line);
221
+ if (flag == FREESASA_FAIL || (symbol[0] == ' ' && symbol[1] == ' ')) {
222
+ guess_symbol(symbol, aname);
223
+ }
224
+
225
+ a = atom_new(rname, rnumber, aname, symbol, freesasa_pdb_get_chain_label(line));
226
+
227
+ if (a != NULL) {
228
+ a->line = strdup(line);
229
+ if (a->line == NULL) {
230
+ mem_fail();
231
+ atom_free(a);
232
+ a = NULL;
233
+ }
234
+ }
235
+
236
+ return a;
237
+ }
238
+
239
+ static struct residues
240
+ residues_init(void)
241
+ {
242
+ struct residues res;
243
+
244
+ res.n = 0;
245
+ res.n_alloc = 0;
246
+ res.first_atom = 0;
247
+ res.reference_area = 0;
248
+
249
+ return res;
250
+ }
251
+
252
+ static int
253
+ residues_alloc(struct residues *residues)
254
+ {
255
+ int new_size;
256
+ void *fa, *ra;
257
+
258
+ assert(residues);
259
+ assert(residues->n <= residues->n_alloc);
260
+
261
+ if (residues->n == residues->n_alloc) {
262
+ new_size = residues->n_alloc + RESIDUES_CHUNK;
263
+ fa = residues->first_atom;
264
+ ra = residues->reference_area;
265
+
266
+ residues->first_atom = realloc(residues->first_atom,
267
+ sizeof(int) * new_size);
268
+ if (residues->first_atom == NULL) {
269
+ residues->first_atom = fa;
270
+ return mem_fail();
271
+ }
272
+
273
+ residues->reference_area = realloc(residues->reference_area,
274
+ sizeof(freesasa_nodearea *) * new_size);
275
+ if (residues->reference_area == NULL) {
276
+ residues->reference_area = ra;
277
+ return mem_fail();
278
+ }
279
+
280
+ residues->n_alloc = new_size;
281
+ }
282
+ ++residues->n;
283
+ return FREESASA_SUCCESS;
284
+ }
285
+
286
+ static void
287
+ residues_dealloc(struct residues *residues)
288
+ {
289
+ int i;
290
+
291
+ if (residues) {
292
+ free(residues->first_atom);
293
+ if (residues->reference_area) {
294
+ for (i = 0; i < residues->n; ++i) {
295
+ free(residues->reference_area[i]);
296
+ }
297
+ }
298
+ free(residues->reference_area);
299
+ *residues = residues_init();
300
+ }
301
+ }
302
+
303
+ static struct chains
304
+ chains_init(void)
305
+ {
306
+ struct chains ch;
307
+
308
+ ch.n = 0;
309
+ ch.n_alloc = 0;
310
+ ch.first_atom = NULL;
311
+ ch.labels = NULL;
312
+
313
+ return ch;
314
+ }
315
+
316
+ static int
317
+ chains_alloc(struct chains *chains)
318
+ {
319
+ int new_size;
320
+ void *fa, *lbl;
321
+
322
+ assert(chains);
323
+ assert(chains->n <= chains->n_alloc);
324
+
325
+ if (chains->n == chains->n_alloc) {
326
+ new_size = chains->n_alloc + CHAINS_CHUNK;
327
+ fa = chains->first_atom;
328
+ lbl = chains->labels;
329
+
330
+ chains->first_atom = realloc(chains->first_atom,
331
+ sizeof(int) * new_size);
332
+ if (chains->first_atom == NULL) {
333
+ chains->first_atom = fa;
334
+ return mem_fail();
335
+ }
336
+
337
+ chains->labels = realloc(chains->labels, new_size + 1);
338
+ if (chains->labels == NULL) {
339
+ chains->labels = lbl;
340
+ return mem_fail();
341
+ }
342
+
343
+ chains->n_alloc = new_size;
344
+ }
345
+ ++chains->n;
346
+ return FREESASA_SUCCESS;
347
+ }
348
+
349
+ static void
350
+ chains_dealloc(struct chains *chains)
351
+ {
352
+ if (chains) {
353
+ free(chains->first_atom);
354
+ free(chains->labels);
355
+ *chains = chains_init();
356
+ }
357
+ }
358
+
359
+ freesasa_structure *
360
+ freesasa_structure_new(void)
361
+ {
362
+ freesasa_structure *s = malloc(sizeof(freesasa_structure));
363
+
364
+ if (s == NULL) goto memerr;
365
+
366
+ s->atoms = atoms_init();
367
+ s->residues = residues_init();
368
+ s->chains = chains_init();
369
+ s->xyz = freesasa_coord_new();
370
+ s->model = 1;
371
+ s->classifier_name = NULL;
372
+ s->cif_ref = 0;
373
+ s->release_cif_ref = 0;
374
+
375
+ if (s->xyz == NULL) goto memerr;
376
+
377
+ return s;
378
+ memerr:
379
+ freesasa_structure_free(s);
380
+ mem_fail();
381
+ return NULL;
382
+ }
383
+
384
+ void freesasa_structure_free(freesasa_structure *s)
385
+ {
386
+ if (s != NULL) {
387
+ atoms_dealloc(&s->atoms);
388
+ residues_dealloc(&s->residues);
389
+ chains_dealloc(&s->chains);
390
+
391
+ if (s->xyz != NULL) {
392
+ freesasa_coord_free(s->xyz);
393
+ }
394
+
395
+ free(s->classifier_name);
396
+
397
+ if (s->cif_ref > 0 && s->release_cif_ref != NULL) {
398
+ s->release_cif_ref(s->cif_ref);
399
+ }
400
+
401
+ free(s);
402
+ }
403
+ }
404
+
405
+ /**
406
+ This function is called when either the symbol field is missing
407
+ from an ATOM record, or when an atom is added directly using
408
+ freesasa_structure_add_atom() or
409
+ freesasa_structure_add_atom_wopt(). The symbol is in turn only
410
+ used if the atom cannot be recognized by the classifier.
411
+ */
412
+ static int
413
+ guess_symbol(char *symbol,
414
+ const char *name)
415
+ {
416
+ /* if the first position is empty, or a number, assume that it is
417
+ a one letter element e.g. " C ", or "1H " */
418
+ if (name[0] == ' ' || (name[0] >= '1' && name[0] <= '9')) {
419
+ symbol[0] = ' ';
420
+ symbol[1] = name[1];
421
+ symbol[2] = '\0';
422
+ } else {
423
+ /* if the string has padding to the right, it's a
424
+ two-letter element, e.g. "FE " */
425
+ if (name[3] == ' ') {
426
+ strncpy(symbol, name, 2);
427
+ symbol[2] = '\0';
428
+ } else {
429
+ /* If it's a four-letter string, it's hard to say,
430
+ assume only the first letter signifies the element */
431
+ symbol[0] = ' ';
432
+ symbol[1] = name[0];
433
+ symbol[2] = '\0';
434
+ return freesasa_warn("guessing that atom '%s' is symbol '%s'",
435
+ name, symbol);
436
+ }
437
+ }
438
+ return FREESASA_SUCCESS;
439
+ }
440
+ static int
441
+ structure_add_chain(freesasa_structure *s,
442
+ char chain_label,
443
+ int i_latest_atom)
444
+ {
445
+ int n;
446
+ if (s->chains.n == 0 || strchr(s->chains.labels, chain_label) == NULL) {
447
+
448
+ if (chains_alloc(&s->chains) == FREESASA_FAIL)
449
+ return fail_msg("");
450
+
451
+ n = s->chains.n;
452
+ s->chains.labels[n - 1] = chain_label;
453
+ s->chains.labels[n] = '\0';
454
+
455
+ assert(strlen(s->chains.labels) == s->chains.n);
456
+
457
+ s->chains.first_atom[n - 1] = i_latest_atom;
458
+ }
459
+ return FREESASA_SUCCESS;
460
+ }
461
+
462
+ static int
463
+ structure_add_residue(freesasa_structure *s,
464
+ const freesasa_classifier *classifier,
465
+ const struct atom *a,
466
+ int i_latest_atom)
467
+ {
468
+ int n = s->residues.n + 1;
469
+ const freesasa_nodearea *reference = NULL;
470
+
471
+ /* register a new residue if it's the first atom, or if the
472
+ residue number or chain label of the current atom is different
473
+ from the previous one */
474
+ if (!(s->residues.n == 0 ||
475
+ (i_latest_atom > 0 &&
476
+ (strcmp(a->res_number, s->atoms.atom[i_latest_atom - 1]->res_number) ||
477
+ a->chain_label != s->atoms.atom[i_latest_atom - 1]->chain_label)))) {
478
+ return FREESASA_SUCCESS;
479
+ }
480
+
481
+ if (residues_alloc(&s->residues) == FREESASA_FAIL) {
482
+ return fail_msg("");
483
+ }
484
+ s->residues.first_atom[n - 1] = i_latest_atom;
485
+
486
+ s->residues.reference_area[n - 1] = NULL;
487
+ reference = freesasa_classifier_residue_reference(classifier, a->res_name);
488
+ if (reference != NULL) {
489
+ s->residues.reference_area[n - 1] = malloc(sizeof(freesasa_nodearea));
490
+ if (s->residues.reference_area[n - 1] == NULL)
491
+ return mem_fail();
492
+ *s->residues.reference_area[n - 1] = *reference;
493
+ }
494
+
495
+ return FREESASA_SUCCESS;
496
+ }
497
+
498
+ /**
499
+ Get the radius of an atom, and fail, warn and/or guess depending
500
+ on the options.
501
+ */
502
+ static int
503
+ structure_check_atom_radius(double *radius,
504
+ struct atom *a,
505
+ const freesasa_classifier *classifier,
506
+ int options)
507
+ {
508
+ *radius = freesasa_classifier_radius(classifier, a->res_name, a->atom_name);
509
+ if (*radius < 0) {
510
+ if (options & FREESASA_HALT_AT_UNKNOWN) {
511
+ return fail_msg("atom '%s %s' unknown",
512
+ a->res_name, a->atom_name);
513
+ } else if (options & FREESASA_SKIP_UNKNOWN) {
514
+ return freesasa_warn("skipping unknown atom '%s %s'",
515
+ a->res_name, a->atom_name, a->symbol, *radius);
516
+ } else {
517
+ *radius = freesasa_guess_radius(a->symbol);
518
+ if (*radius < 0) {
519
+ *radius = +0.;
520
+ freesasa_warn("atom '%s %s' unknown and "
521
+ "can't guess radius of symbol '%s', "
522
+ "assigning radius 0 A",
523
+ a->res_name, a->atom_name, a->symbol);
524
+ } else {
525
+ freesasa_warn("atom '%s %s' unknown, guessing element is '%s', "
526
+ "and radius %.3f A",
527
+ a->res_name, a->atom_name, a->symbol, *radius);
528
+ }
529
+ /* do not return FREESASA_WARN here, because we will keep the atom */
530
+ }
531
+ }
532
+ return FREESASA_SUCCESS;
533
+ }
534
+
535
+ static int
536
+ structure_register_classifier(freesasa_structure *structure,
537
+ const freesasa_classifier *classifier)
538
+ {
539
+ if (structure->classifier_name == NULL) {
540
+ structure->classifier_name = strdup(freesasa_classifier_name(classifier));
541
+ if (structure->classifier_name == NULL) {
542
+ return mem_fail();
543
+ }
544
+ } else if (strcmp(structure->classifier_name, freesasa_classifier_name(classifier)) != 0) {
545
+ structure->classifier_name = strdup(FREESASA_CONFLICTING_CLASSIFIERS);
546
+ if (structure->classifier_name == NULL) {
547
+ return mem_fail();
548
+ }
549
+ return FREESASA_WARN;
550
+ }
551
+
552
+ return FREESASA_SUCCESS;
553
+ }
554
+
555
+ /**
556
+ Adds an atom to the structure using the rules specified by
557
+ 'options'. If it includes FREESASA_RADIUS_FROM_* a dummy radius is
558
+ assigned and the caller is expected to replace it with a correct
559
+ radius later.
560
+
561
+ The atom a should be a pointer to a heap address, this will not be cloned.
562
+ */
563
+ static int
564
+ structure_add_atom(freesasa_structure *structure,
565
+ struct atom *atom,
566
+ double *xyz,
567
+ const freesasa_classifier *classifier,
568
+ int options)
569
+ {
570
+ int na, ret;
571
+ double r;
572
+
573
+ assert(structure);
574
+ assert(atom);
575
+ assert(xyz);
576
+
577
+ /* let the stricter option override if both are specified */
578
+ if (options & FREESASA_SKIP_UNKNOWN && options & FREESASA_HALT_AT_UNKNOWN)
579
+ options &= ~FREESASA_SKIP_UNKNOWN;
580
+
581
+ if (classifier == NULL) {
582
+ classifier = &freesasa_default_classifier;
583
+ }
584
+ structure_register_classifier(structure, classifier);
585
+
586
+ /* calculate radius and check if we should keep the atom (based on options) */
587
+ if (options & FREESASA_RADIUS_FROM_OCCUPANCY) {
588
+ r = 1; /* fix it later */
589
+ } else {
590
+ ret = structure_check_atom_radius(&r, atom, classifier, options);
591
+ if (ret == FREESASA_FAIL) return fail_msg("halting at unknown atom");
592
+ if (ret == FREESASA_WARN) return FREESASA_WARN;
593
+ }
594
+ assert(r >= 0);
595
+
596
+ /* If it's a keeper, allocate memory */
597
+ if (atoms_alloc(&structure->atoms) == FREESASA_FAIL)
598
+ return fail_msg("");
599
+ na = structure->atoms.n;
600
+
601
+ /* Store coordinates */
602
+ if (freesasa_coord_append(structure->xyz, xyz, 1) == FREESASA_FAIL)
603
+ return mem_fail();
604
+
605
+ /* Check if this is a new chain and if so add it */
606
+ if (structure_add_chain(structure, atom->chain_label, na - 1) == FREESASA_FAIL)
607
+ return mem_fail();
608
+
609
+ /* Check if this is a new residue, and if so add it */
610
+ if (structure_add_residue(structure, classifier, atom, na - 1) == FREESASA_FAIL)
611
+ return mem_fail();
612
+
613
+ atom->the_class = freesasa_classifier_class(classifier, atom->res_name, atom->atom_name);
614
+ atom->res_index = structure->residues.n - 1;
615
+ structure->atoms.radius[na - 1] = r;
616
+ structure->atoms.atom[na - 1] = atom;
617
+
618
+ return FREESASA_SUCCESS;
619
+ }
620
+
621
+ /**
622
+ Handles the reading of PDB-files, returns NULL if problems reading
623
+ or input or malloc failure. Error-messages should explain what
624
+ went wrong.
625
+ */
626
+ static freesasa_structure *
627
+ from_pdb_impl(FILE *pdb_file,
628
+ struct file_range it,
629
+ const freesasa_classifier *classifier,
630
+ int options)
631
+ {
632
+ char line[PDB_MAX_LINE_STRL];
633
+ char alt, the_alt = ' ';
634
+ double v[3], r;
635
+ int ret;
636
+ struct atom *a = NULL;
637
+ freesasa_structure *s = freesasa_structure_new();
638
+
639
+ assert(pdb_file);
640
+
641
+ if (s == NULL) return NULL;
642
+
643
+ fseek(pdb_file, it.begin, SEEK_SET);
644
+
645
+ while (fgets(line, PDB_MAX_LINE_STRL, pdb_file) != NULL && ftell(pdb_file) <= it.end) {
646
+
647
+ if (strncmp("ATOM", line, 4) == 0 || ((options & FREESASA_INCLUDE_HETATM) &&
648
+ (strncmp("HETATM", line, 6) == 0))) {
649
+ if (freesasa_pdb_ishydrogen(line) &&
650
+ !(options & FREESASA_INCLUDE_HYDROGEN))
651
+ continue;
652
+
653
+ a = atom_new_from_line(line, &alt);
654
+ if (a == NULL)
655
+ goto cleanup;
656
+
657
+ if ((alt != ' ' && the_alt == ' ') || (alt == ' '))
658
+ the_alt = alt;
659
+ else if (alt != ' ' && alt != the_alt) {
660
+ atom_free(a);
661
+ a = NULL;
662
+ continue;
663
+ }
664
+
665
+ ret = freesasa_pdb_get_coord(v, line);
666
+ if (ret == FREESASA_FAIL)
667
+ goto cleanup;
668
+
669
+ ret = structure_add_atom(s, a, v, classifier, options);
670
+ if (ret == FREESASA_FAIL) {
671
+ goto cleanup;
672
+ } else if (ret == FREESASA_WARN) {
673
+ atom_free(a);
674
+ a = NULL;
675
+ continue;
676
+ }
677
+
678
+ if (options & FREESASA_RADIUS_FROM_OCCUPANCY) {
679
+ ret = freesasa_pdb_get_occupancy(&r, line);
680
+ if (ret == FREESASA_FAIL)
681
+ goto cleanup;
682
+ s->atoms.radius[s->atoms.n - 1] = r;
683
+ }
684
+ }
685
+
686
+ if (!(options & FREESASA_JOIN_MODELS)) {
687
+ if (strncmp("MODEL", line, 5) == 0) sscanf(line + 10, "%d", &s->model);
688
+ if (strncmp("ENDMDL", line, 6) == 0) break;
689
+ }
690
+ }
691
+
692
+ if (s->atoms.n == 0) {
693
+ fail_msg("input had no valid ATOM or HETATM lines");
694
+ goto cleanup;
695
+ }
696
+
697
+ return s;
698
+
699
+ cleanup:
700
+ fail_msg("");
701
+ atom_free(a);
702
+ freesasa_structure_free(s);
703
+ return NULL;
704
+ }
705
+
706
+ static int
707
+ structure_add_atom_wopt_impl(freesasa_structure *structure,
708
+ const char *atom_name,
709
+ const char *residue_name,
710
+ const char *residue_number,
711
+ const char *symbol,
712
+ char chain_label,
713
+ double x, double y, double z,
714
+ const freesasa_classifier *classifier,
715
+ int options)
716
+ {
717
+ struct atom *a;
718
+ char my_symbol[PDB_ATOM_SYMBOL_STRL + 1];
719
+ double v[3] = {x, y, z};
720
+ int ret, warn = 0;
721
+
722
+ assert(structure);
723
+ assert(atom_name);
724
+ assert(residue_name);
725
+ assert(residue_number);
726
+
727
+ /* this option can not be used here, and needs to be unset */
728
+ options &= ~FREESASA_RADIUS_FROM_OCCUPANCY;
729
+
730
+ if (symbol != NULL) {
731
+ strncpy(my_symbol, symbol, sizeof(my_symbol));
732
+ } else if (guess_symbol(my_symbol, atom_name) == FREESASA_WARN &&
733
+ options & FREESASA_SKIP_UNKNOWN) {
734
+ ++warn;
735
+ }
736
+
737
+ a = atom_new(residue_name, residue_number, atom_name, my_symbol, chain_label);
738
+ if (a == NULL) return mem_fail();
739
+
740
+ ret = structure_add_atom(structure, a, v, classifier, options);
741
+
742
+ if (ret == FREESASA_FAIL ||
743
+ (ret == FREESASA_WARN && options & FREESASA_SKIP_UNKNOWN))
744
+ atom_free(a);
745
+
746
+ if (!ret && warn) return FREESASA_WARN;
747
+
748
+ return ret;
749
+ }
750
+
751
+ int freesasa_structure_add_atom_wopt(freesasa_structure *structure,
752
+ const char *atom_name,
753
+ const char *residue_name,
754
+ const char *residue_number,
755
+ char chain_label,
756
+ double x, double y, double z,
757
+ const freesasa_classifier *classifier,
758
+ int options)
759
+ {
760
+ return structure_add_atom_wopt_impl(structure, atom_name, residue_name, residue_number, NULL,
761
+ chain_label, x, y, z, classifier, options);
762
+ }
763
+ int freesasa_structure_add_atom(freesasa_structure *structure,
764
+ const char *atom_name,
765
+ const char *residue_name,
766
+ const char *residue_number,
767
+ char chain_label,
768
+ double x, double y, double z)
769
+ {
770
+ return structure_add_atom_wopt_impl(structure, atom_name, residue_name, residue_number, NULL,
771
+ chain_label, x, y, z, NULL, 0);
772
+ }
773
+
774
+ int freesasa_structure_add_cif_atom(freesasa_structure *structure,
775
+ freesasa_cif_atom *atom,
776
+ const freesasa_classifier *classifier,
777
+ int options)
778
+ {
779
+ char res_number[PDB_ATOM_RES_NUMBER_STRL + 1];
780
+
781
+ if (atom->pdbx_PDB_ins_code[0] != '?') {
782
+ snprintf(res_number, sizeof res_number, "%s%c", atom->auth_seq_id, atom->pdbx_PDB_ins_code[0]);
783
+ } else {
784
+ snprintf(res_number, sizeof res_number, "%s", atom->auth_seq_id);
785
+ }
786
+
787
+ return structure_add_atom_wopt_impl(structure, atom->auth_atom_id, atom->auth_comp_id,
788
+ res_number, atom->type_symbol, atom->auth_asym_id,
789
+ atom->Cartn_x, atom->Cartn_y, atom->Cartn_z,
790
+ classifier, options);
791
+ }
792
+
793
+ freesasa_structure *
794
+ freesasa_structure_from_pdb(FILE *pdb_file,
795
+ const freesasa_classifier *classifier,
796
+ int options)
797
+ {
798
+ assert(pdb_file);
799
+ return from_pdb_impl(pdb_file, freesasa_whole_file(pdb_file),
800
+ classifier, options);
801
+ }
802
+
803
+ freesasa_structure **
804
+ freesasa_structure_array(FILE *pdb,
805
+ int *n,
806
+ const freesasa_classifier *classifier,
807
+ int options)
808
+ {
809
+ struct file_range *models = NULL, *chains = NULL;
810
+ struct file_range whole_file;
811
+ int n_models = 0, n_chains = 0, j0, n_new_chains, i, j;
812
+ freesasa_structure **ss = NULL, **ssb;
813
+
814
+ assert(pdb);
815
+ assert(n);
816
+
817
+ if (!(options & FREESASA_SEPARATE_MODELS ||
818
+ options & FREESASA_SEPARATE_CHAINS)) {
819
+ fail_msg("options need to specify at least one of FREESASA_SEPARATE_CHAINS "
820
+ "and FREESASA_SEPARATE_MODELS");
821
+ return NULL;
822
+ }
823
+
824
+ whole_file = freesasa_whole_file(pdb);
825
+ n_models = freesasa_pdb_get_models(pdb, &models);
826
+
827
+ if (n_models == FREESASA_FAIL) {
828
+ fail_msg("problems reading PDB-file");
829
+ return NULL;
830
+ }
831
+ if (n_models == 0) {
832
+ models = &whole_file;
833
+ n_models = 1;
834
+ }
835
+
836
+ /* only keep first model if option not provided */
837
+ if (!(options & FREESASA_SEPARATE_MODELS)) n_models = 1;
838
+
839
+ /* for each model read chains if requested */
840
+ if (options & FREESASA_SEPARATE_CHAINS) {
841
+ for (i = 0; i < n_models; ++i) {
842
+ chains = NULL;
843
+ n_new_chains = freesasa_pdb_get_chains(pdb, models[i], &chains, options);
844
+
845
+ if (n_new_chains == FREESASA_FAIL) goto cleanup;
846
+ if (n_new_chains == 0) {
847
+ freesasa_warn("in %s(): no chains found (in model %d)", __func__, i + 1);
848
+ continue;
849
+ }
850
+
851
+ ssb = ss;
852
+ ss = realloc(ss, sizeof(freesasa_structure *) * (n_chains + n_new_chains));
853
+
854
+ if (!ss) {
855
+ ss = ssb;
856
+ mem_fail();
857
+ goto cleanup;
858
+ }
859
+
860
+ j0 = n_chains;
861
+ n_chains += n_new_chains;
862
+
863
+ for (j = 0; j < n_new_chains; ++j)
864
+ ss[j0 + j] = NULL;
865
+
866
+ for (j = 0; j < n_new_chains; ++j) {
867
+ ss[j0 + j] = from_pdb_impl(pdb, chains[j], classifier, options);
868
+ if (ss[j0 + j] == NULL) goto cleanup;
869
+ ss[j0 + j]->model = i + 1;
870
+ }
871
+
872
+ free(chains);
873
+ }
874
+ *n = n_chains;
875
+ } else {
876
+ ss = malloc(sizeof(freesasa_structure *) * n_models);
877
+ if (!ss) {
878
+ mem_fail();
879
+ goto cleanup;
880
+ }
881
+
882
+ for (i = 0; i < n_models; ++i)
883
+ ss[i] = NULL;
884
+ *n = n_models;
885
+
886
+ for (i = 0; i < n_models; ++i) {
887
+ ss[i] = from_pdb_impl(pdb, models[i], classifier, options);
888
+ if (ss[i] == NULL) goto cleanup;
889
+ ss[i]->model = i + 1;
890
+ }
891
+ }
892
+
893
+ if (*n == 0) goto cleanup;
894
+
895
+ if (models != &whole_file) free(models);
896
+
897
+ return ss;
898
+
899
+ cleanup:
900
+ if (ss)
901
+ for (i = 0; i < *n; ++i)
902
+ freesasa_structure_free(ss[i]);
903
+ if (models != &whole_file) free(models);
904
+ free(chains);
905
+ *n = 0;
906
+ free(ss);
907
+ return NULL;
908
+ }
909
+
910
+ freesasa_structure *
911
+ freesasa_structure_get_chains(const freesasa_structure *structure,
912
+ const char *chains,
913
+ const freesasa_classifier *classifier,
914
+ int options)
915
+ {
916
+ freesasa_structure *new_s;
917
+ struct atom *ai;
918
+ int i, res;
919
+ char c;
920
+ const double *v;
921
+
922
+ assert(structure);
923
+ if (strlen(chains) == 0) return NULL;
924
+
925
+ new_s = freesasa_structure_new();
926
+
927
+ if (!new_s) {
928
+ mem_fail();
929
+ return NULL;
930
+ }
931
+
932
+ new_s->model = structure->model;
933
+
934
+ for (i = 0; i < structure->atoms.n; ++i) {
935
+ ai = structure->atoms.atom[i];
936
+ c = ai->chain_label;
937
+ if (strchr(chains, c) != NULL) {
938
+ v = freesasa_coord_i(structure->xyz, i);
939
+ res = structure_add_atom_wopt_impl(new_s, ai->atom_name,
940
+ ai->res_name, ai->res_number, ai->symbol,
941
+ c, v[0], v[1], v[2], classifier, options);
942
+ if (res == FREESASA_FAIL) {
943
+ fail_msg("");
944
+ goto cleanup;
945
+ }
946
+ }
947
+ }
948
+
949
+ /* the following two tests could have been done by comparing the
950
+ chain-strings before the loop, but this logic is simpler. */
951
+ if (new_s->atoms.n == 0) {
952
+ goto cleanup;
953
+ }
954
+ if (strlen(new_s->chains.labels) != strlen(chains)) {
955
+ fail_msg("structure has chains '%s', but '%s' requested",
956
+ structure->chains.labels, chains);
957
+ goto cleanup;
958
+ }
959
+
960
+ return new_s;
961
+
962
+ cleanup:
963
+ freesasa_structure_free(new_s);
964
+ return NULL;
965
+ }
966
+
967
+ const char *
968
+ freesasa_structure_chain_labels(const freesasa_structure *structure)
969
+ {
970
+ assert(structure);
971
+ return structure->chains.labels;
972
+ }
973
+
974
+ const coord_t *
975
+ freesasa_structure_xyz(const freesasa_structure *structure)
976
+ {
977
+ assert(structure);
978
+ return structure->xyz;
979
+ }
980
+
981
+ int freesasa_structure_n(const freesasa_structure *structure)
982
+ {
983
+ assert(structure);
984
+ return structure->atoms.n;
985
+ }
986
+
987
+ int freesasa_structure_n_residues(const freesasa_structure *structure)
988
+ {
989
+ assert(structure);
990
+ return structure->residues.n;
991
+ }
992
+
993
+ const char *
994
+ freesasa_structure_atom_name(const freesasa_structure *structure,
995
+ int i)
996
+ {
997
+ assert(structure);
998
+ assert(i < structure->atoms.n && i >= 0);
999
+ return structure->atoms.atom[i]->atom_name;
1000
+ }
1001
+
1002
+ const char *
1003
+ freesasa_structure_atom_res_name(const freesasa_structure *structure,
1004
+ int i)
1005
+ {
1006
+ assert(structure);
1007
+ assert(i < structure->atoms.n && i >= 0);
1008
+ return structure->atoms.atom[i]->res_name;
1009
+ }
1010
+
1011
+ const char *
1012
+ freesasa_structure_atom_res_number(const freesasa_structure *structure,
1013
+ int i)
1014
+ {
1015
+ assert(structure);
1016
+ assert(i < structure->atoms.n && i >= 0);
1017
+ return structure->atoms.atom[i]->res_number;
1018
+ }
1019
+
1020
+ char freesasa_structure_atom_chain(const freesasa_structure *structure,
1021
+ int i)
1022
+ {
1023
+ assert(structure);
1024
+ assert(i < structure->atoms.n && i >= 0);
1025
+ return structure->atoms.atom[i]->chain_label;
1026
+ }
1027
+ const char *
1028
+ freesasa_structure_atom_symbol(const freesasa_structure *structure,
1029
+ int i)
1030
+ {
1031
+ assert(structure);
1032
+ assert(i < structure->atoms.n && i >= 0);
1033
+ return structure->atoms.atom[i]->symbol;
1034
+ }
1035
+
1036
+ double
1037
+ freesasa_structure_atom_radius(const freesasa_structure *structure,
1038
+ int i)
1039
+ {
1040
+ assert(structure);
1041
+ assert(i < structure->atoms.n && i >= 0);
1042
+ return structure->atoms.radius[i];
1043
+ }
1044
+
1045
+ void freesasa_structure_atom_set_radius(freesasa_structure *structure,
1046
+ int i,
1047
+ double radius)
1048
+ {
1049
+ assert(structure);
1050
+ assert(i < structure->atoms.n && i >= 0);
1051
+ structure->atoms.radius[i] = radius;
1052
+ }
1053
+
1054
+ freesasa_atom_class
1055
+ freesasa_structure_atom_class(const freesasa_structure *structure,
1056
+ int i)
1057
+ {
1058
+ assert(structure);
1059
+ assert(i < structure->atoms.n && i >= 0);
1060
+ return structure->atoms.atom[i]->the_class;
1061
+ }
1062
+
1063
+ const char *
1064
+ freesasa_structure_atom_pdb_line(const freesasa_structure *structure,
1065
+ int i)
1066
+ {
1067
+ assert(structure);
1068
+ assert(i < structure->atoms.n && i >= 0);
1069
+ return structure->atoms.atom[i]->line;
1070
+ }
1071
+ const freesasa_nodearea *
1072
+ freesasa_structure_residue_reference(const freesasa_structure *structure,
1073
+ int r_i)
1074
+ {
1075
+ assert(structure);
1076
+ assert(r_i >= 0 && r_i < structure->residues.n);
1077
+
1078
+ return structure->residues.reference_area[r_i];
1079
+ }
1080
+ int freesasa_structure_residue_atoms(const freesasa_structure *structure,
1081
+ int r_i,
1082
+ int *first,
1083
+ int *last)
1084
+ {
1085
+ int naa;
1086
+ assert(structure);
1087
+ assert(first);
1088
+ assert(last);
1089
+
1090
+ naa = structure->residues.n;
1091
+
1092
+ assert(r_i >= 0 && r_i < naa);
1093
+
1094
+ *first = structure->residues.first_atom[r_i];
1095
+ if (r_i == naa - 1)
1096
+ *last = structure->atoms.n - 1;
1097
+ else
1098
+ *last = structure->residues.first_atom[r_i + 1] - 1;
1099
+ assert(*last >= *first);
1100
+
1101
+ return FREESASA_SUCCESS;
1102
+ }
1103
+
1104
+ const char *
1105
+ freesasa_structure_residue_name(const freesasa_structure *structure,
1106
+ int r_i)
1107
+ {
1108
+ assert(structure);
1109
+ assert(r_i < structure->residues.n && r_i >= 0);
1110
+ return structure->atoms.atom[structure->residues.first_atom[r_i]]->res_name;
1111
+ }
1112
+
1113
+ const char *
1114
+ freesasa_structure_residue_number(const freesasa_structure *structure,
1115
+ int r_i)
1116
+ {
1117
+ assert(structure);
1118
+ assert(r_i < structure->residues.n && r_i >= 0);
1119
+ return structure->atoms.atom[structure->residues.first_atom[r_i]]->res_number;
1120
+ }
1121
+
1122
+ char freesasa_structure_residue_chain(const freesasa_structure *structure,
1123
+ int r_i)
1124
+ {
1125
+ assert(structure);
1126
+ assert(r_i < structure->residues.n && r_i >= 0);
1127
+
1128
+ return structure->atoms.atom[structure->residues.first_atom[r_i]]->chain_label;
1129
+ }
1130
+
1131
+ int freesasa_structure_n_chains(const freesasa_structure *structure)
1132
+ {
1133
+ return structure->chains.n;
1134
+ }
1135
+
1136
+ int freesasa_structure_chain_index(const freesasa_structure *structure,
1137
+ char chain)
1138
+ {
1139
+ int i;
1140
+
1141
+ assert(structure);
1142
+
1143
+ for (i = 0; i < structure->chains.n; ++i) {
1144
+ if (structure->chains.labels[i] == chain) return i;
1145
+ }
1146
+ return fail_msg("chain %c not found", chain);
1147
+ }
1148
+
1149
+ int freesasa_structure_chain_atoms(const freesasa_structure *structure,
1150
+ char chain,
1151
+ int *first,
1152
+ int *last)
1153
+ {
1154
+ int c_i, n;
1155
+
1156
+ assert(structure);
1157
+
1158
+ c_i = freesasa_structure_chain_index(structure, chain);
1159
+ n = freesasa_structure_n_chains(structure);
1160
+
1161
+ if (c_i < 0) return fail_msg("");
1162
+
1163
+ *first = structure->chains.first_atom[c_i];
1164
+ if (c_i == n - 1)
1165
+ *last = freesasa_structure_n(structure) - 1;
1166
+ else
1167
+ *last = structure->chains.first_atom[c_i + 1] - 1;
1168
+ assert(*last >= *first);
1169
+
1170
+ return FREESASA_SUCCESS;
1171
+ }
1172
+
1173
+ int freesasa_structure_chain_residues(const freesasa_structure *structure,
1174
+ char chain,
1175
+ int *first,
1176
+ int *last)
1177
+ {
1178
+ int first_atom, last_atom;
1179
+
1180
+ assert(structure);
1181
+
1182
+ if (freesasa_structure_chain_atoms(structure, chain, &first_atom, &last_atom))
1183
+ return fail_msg("");
1184
+
1185
+ *first = structure->atoms.atom[first_atom]->res_index;
1186
+ *last = structure->atoms.atom[last_atom]->res_index;
1187
+
1188
+ return FREESASA_SUCCESS;
1189
+ }
1190
+
1191
+ const char *
1192
+ freesasa_structure_classifier_name(const freesasa_structure *structure)
1193
+ {
1194
+ assert(structure);
1195
+ return structure->classifier_name;
1196
+ }
1197
+
1198
+ int freesasa_structure_model(const freesasa_structure *structure)
1199
+ {
1200
+ return structure->model;
1201
+ }
1202
+
1203
+ const double *
1204
+ freesasa_structure_coord_array(const freesasa_structure *structure)
1205
+ {
1206
+ return freesasa_coord_all(structure->xyz);
1207
+ }
1208
+
1209
+ const double *
1210
+ freesasa_structure_radius(const freesasa_structure *structure)
1211
+ {
1212
+ assert(structure);
1213
+ return structure->atoms.radius;
1214
+ }
1215
+
1216
+ void freesasa_structure_set_radius(freesasa_structure *structure,
1217
+ const double *radii)
1218
+ {
1219
+ assert(structure);
1220
+ assert(radii);
1221
+ memcpy(structure->atoms.radius, radii, structure->atoms.n * sizeof(double));
1222
+ }
1223
+
1224
+ void freesasa_structure_set_model(freesasa_structure *structure,
1225
+ int model)
1226
+ {
1227
+ structure->model = model;
1228
+ }
1229
+
1230
+ void freesasa_structure_set_cif_ref(freesasa_structure *structure,
1231
+ size_t ref,
1232
+ void (*release_func)(size_t))
1233
+ {
1234
+ assert(structure);
1235
+ structure->cif_ref = ref;
1236
+ structure->release_cif_ref = release_func;
1237
+ }
1238
+
1239
+ size_t freesasa_structure_cif_ref(const freesasa_structure *structure)
1240
+ {
1241
+ assert(structure);
1242
+ return structure->cif_ref;
1243
+ }
.venv_haddock/include/site/python3.12/freesasa/util.c ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if HAVE_CONFIG_H
2
+ #include <config.h>
3
+ #endif
4
+ #include <assert.h>
5
+ #include <errno.h>
6
+ #include <stdarg.h>
7
+ #include <stdio.h>
8
+ #include <string.h>
9
+
10
+ #include "freesasa_internal.h"
11
+
12
+ #ifdef PACKAGE_NAME
13
+ const char *freesasa_name = PACKAGE_NAME;
14
+ #else
15
+ const char *freesasa_name = "freesasa";
16
+ #endif
17
+
18
+ static FILE *errlog = NULL;
19
+
20
+ struct file_range
21
+ freesasa_whole_file(FILE *file)
22
+ {
23
+ struct file_range range;
24
+
25
+ assert(file);
26
+ rewind(file);
27
+ range.begin = ftell(file);
28
+ fseek(file, 0, SEEK_END);
29
+ range.end = ftell(file);
30
+ rewind(file);
31
+ assert(range.begin <= range.end);
32
+
33
+ return range;
34
+ }
35
+
36
+ static void
37
+ freesasa_err_impl(int err,
38
+ const char *format,
39
+ va_list arg)
40
+ {
41
+ FILE *fp = stderr;
42
+
43
+ if (errlog != NULL) fp = errlog;
44
+
45
+ fprintf(fp, "%s: ", freesasa_name);
46
+ switch (err) {
47
+ case FREESASA_FAIL:
48
+ fputs("error: ", fp);
49
+ break;
50
+ case FREESASA_WARN:
51
+ fputs("warning: ", fp);
52
+ break;
53
+ default:
54
+ break;
55
+ }
56
+ vfprintf(fp, format, arg);
57
+ va_end(arg);
58
+ fputc('\n', fp);
59
+ fflush(fp);
60
+ }
61
+
62
+ int freesasa_fail(const char *format, ...)
63
+ {
64
+ va_list arg;
65
+
66
+ if (freesasa_get_verbosity() == FREESASA_V_SILENT) return FREESASA_FAIL;
67
+
68
+ va_start(arg, format);
69
+ freesasa_err_impl(FREESASA_FAIL, format, arg);
70
+ va_end(arg);
71
+
72
+ return FREESASA_FAIL;
73
+ }
74
+
75
+ int freesasa_warn(const char *format, ...)
76
+ {
77
+ va_list arg;
78
+ int v = freesasa_get_verbosity();
79
+
80
+ if (v == FREESASA_V_NOWARNINGS || v == FREESASA_V_SILENT) return FREESASA_WARN;
81
+
82
+ va_start(arg, format);
83
+ freesasa_err_impl(FREESASA_WARN, format, arg);
84
+ va_end(arg);
85
+
86
+ return FREESASA_WARN;
87
+ }
88
+
89
+ int freesasa_fail_wloc(const char *file,
90
+ int line,
91
+ const char *format,
92
+ ...)
93
+ {
94
+ FILE *fp = stderr;
95
+ va_list arg;
96
+
97
+ if (freesasa_get_verbosity() == FREESASA_V_SILENT) return FREESASA_FAIL;
98
+ if (errlog != NULL) fp = errlog;
99
+
100
+ fprintf(fp, "%s:%s:%d: error: ", freesasa_name, file, line);
101
+ va_start(arg, format);
102
+ vfprintf(fp, format, arg);
103
+ va_end(arg);
104
+ fputc('\n', fp);
105
+ fflush(fp);
106
+
107
+ return FREESASA_FAIL;
108
+ }
109
+
110
+ int freesasa_mem_fail(const char *file, int line)
111
+ {
112
+ return freesasa_fail_wloc(file, line, "Out of memory");
113
+ }
114
+
115
+ const char *
116
+ freesasa_thread_error(int error_code)
117
+ {
118
+ switch (error_code) {
119
+ case EDEADLK:
120
+ return "deadlock (EDEADLK)";
121
+ case EINVAL:
122
+ return "(EINVAL)";
123
+ case ESRCH:
124
+ return "no matching thread (ESRCH)";
125
+ case EAGAIN:
126
+ return "no resources to create thread (EAGAIN)";
127
+ }
128
+ return "Unknown thread error";
129
+ }
130
+
131
+ void freesasa_set_err_out(FILE *fp)
132
+ {
133
+ assert(fp);
134
+ errlog = fp;
135
+ }
136
+
137
+ FILE *
138
+ freesasa_get_err_out()
139
+ {
140
+ return errlog;
141
+ }
.venv_haddock/lib/python3.12/site-packages/Bio/Affy/CelFile.py ADDED
@@ -0,0 +1,577 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2004 by Harry Zuzan. All rights reserved.
2
+ # Copyright 2016 by Adam Kurkiewicz. All rights reserved.
3
+ # This file is part of the Biopython distribution and governed by your
4
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
5
+ # Please see the LICENSE file that should have been included as part of this
6
+ # package.
7
+
8
+ """Reading information from Affymetrix CEL files version 3 and 4."""
9
+
10
+ import struct
11
+
12
+ try:
13
+ import numpy as np
14
+ except ImportError:
15
+ from Bio import MissingPythonDependencyError
16
+
17
+ raise MissingPythonDependencyError(
18
+ "Install NumPy if you want to use Bio.Affy.CelFile"
19
+ ) from None
20
+
21
+
22
+ class ParserError(ValueError):
23
+ """Affymetrix parser error."""
24
+
25
+ def __init__(self, *args):
26
+ """Initialise class."""
27
+ super().__init__(*args)
28
+
29
+
30
+ class Record:
31
+ """Stores the information in a cel file.
32
+
33
+ Example usage:
34
+
35
+ >>> from Bio.Affy import CelFile
36
+ >>> with open("Affy/affy_v3_example.CEL") as handle:
37
+ ... c = CelFile.read(handle)
38
+ ...
39
+ >>> print(c.ncols, c.nrows)
40
+ 5 5
41
+ >>> print(c.intensities)
42
+ [[ 234. 170. 22177. 164. 22104.]
43
+ [ 188. 188. 21871. 168. 21883.]
44
+ [ 188. 193. 21455. 198. 21300.]
45
+ [ 188. 182. 21438. 188. 20945.]
46
+ [ 193. 20370. 174. 20605. 168.]]
47
+ >>> print(c.stdevs)
48
+ [[ 24. 34.5 2669. 19.7 3661.2]
49
+ [ 29.8 29.8 2795.9 67.9 2792.4]
50
+ [ 29.8 88.7 2976.5 62. 2914.5]
51
+ [ 29.8 76.2 2759.5 49.2 2762. ]
52
+ [ 38.8 2611.8 26.6 2810.7 24.1]]
53
+ >>> print(c.npix)
54
+ [[25 25 25 25 25]
55
+ [25 25 25 25 25]
56
+ [25 25 25 25 25]
57
+ [25 25 25 25 25]
58
+ [25 25 25 25 25]]
59
+
60
+ """
61
+
62
+ def __init__(self):
63
+ """Initialize the class."""
64
+ self.version = None
65
+ self.GridCornerUL = None
66
+ self.GridCornerUR = None
67
+ self.GridCornerLR = None
68
+ self.GridCornerLL = None
69
+ self.DatHeader = None
70
+ self.Algorithm = None
71
+ self.AlgorithmParameters = None
72
+ self.NumberCells = None
73
+ self.intensities = None
74
+ self.stdevs = None
75
+ self.npix = None
76
+ self.nrows = None
77
+ self.ncols = None
78
+ self.nmask = None
79
+ self.mask = None
80
+ self.noutliers = None
81
+ self.outliers = None
82
+ self.modified = None
83
+
84
+
85
+ def read(handle, version=None):
86
+ """Read Affymetrix CEL file and return Record object.
87
+
88
+ CEL files format versions 3 and 4 are supported.
89
+ Please specify the CEL file format as 3 or 4 if known for the version
90
+ argument. If the version number is not specified, the parser will attempt
91
+ to detect the version from the file contents.
92
+
93
+ The Record object returned by this function stores the intensities from
94
+ the CEL file in record.intensities.
95
+ Currently, record.mask and record.outliers are not set in when parsing
96
+ version 4 CEL files.
97
+
98
+ Example Usage:
99
+
100
+ >>> from Bio.Affy import CelFile
101
+ >>> with open("Affy/affy_v3_example.CEL") as handle:
102
+ ... record = CelFile.read(handle)
103
+ ...
104
+ >>> record.version == 3
105
+ True
106
+ >>> print("%i by %i array" % record.intensities.shape)
107
+ 5 by 5 array
108
+
109
+ >>> with open("Affy/affy_v4_example.CEL", "rb") as handle:
110
+ ... record = CelFile.read(handle, version=4)
111
+ ...
112
+ >>> record.version == 4
113
+ True
114
+ >>> print("%i by %i array" % record.intensities.shape)
115
+ 5 by 5 array
116
+
117
+ """
118
+ try:
119
+ data = handle.read(0)
120
+ except AttributeError:
121
+ raise ValueError("handle should be a file handle") from None
122
+ data = handle.read(4)
123
+ if not data:
124
+ raise ValueError("Empty file.")
125
+ if data == b"[CEL":
126
+ raise ValueError("CEL file in version 3 format should be opened in text mode")
127
+ if data == "[CEL":
128
+ # Version 3 format. Continue to read the header here before passing
129
+ # control to _read_v3 to avoid having to seek to the beginning of
130
+ # the file.
131
+ data += next(handle)
132
+ if data.strip() != "[CEL]":
133
+ raise ValueError("Failed to parse Affy Version 3 CEL file.")
134
+ line = next(handle)
135
+ keyword, value = line.split("=", 1)
136
+ if keyword != "Version":
137
+ raise ValueError("Failed to parse Affy Version 3 CEL file.")
138
+ version = int(value)
139
+ if version != 3:
140
+ raise ValueError("Incorrect version number in Affy Version 3 CEL file.")
141
+ return _read_v3(handle)
142
+ try:
143
+ magicNumber = struct.unpack("<i", data)
144
+ except TypeError:
145
+ raise ValueError(
146
+ "CEL file in version 4 format should be opened in binary mode"
147
+ ) from None
148
+ except struct.error:
149
+ raise ValueError(
150
+ "Failed to read magic number from Affy Version 4 CEL file"
151
+ ) from None
152
+ if magicNumber != (64,):
153
+ raise ValueError("Incorrect magic number in Affy Version 4 CEL file")
154
+ return _read_v4(handle)
155
+
156
+
157
+ def _read_v4(f):
158
+ # We follow the documentation here:
159
+ # http://www.affymetrix.com/estore/support/developer/powertools/changelog/gcos-agcc/cel.html.affx
160
+ record = Record()
161
+ preHeaders = ["version", "columns", "rows", "cellNo", "headerLen"]
162
+ preHeadersMap = {}
163
+ headersMap = {}
164
+
165
+ # Load pre-headers. The magic number was already parsed in the read
166
+ # function calling _read_v4.
167
+ preHeadersMap["magic"] = 64
168
+ try:
169
+ for name in preHeaders:
170
+ preHeadersMap[name] = struct.unpack("<i", f.read(4))[0]
171
+ except struct.error:
172
+ raise ParserError("Failed to parse CEL version 4 file") from None
173
+
174
+ char = f.read(preHeadersMap["headerLen"])
175
+ header = char.decode("ascii", "ignore")
176
+ for line in header.split("\n"):
177
+ if "=" in line:
178
+ headline = line.split("=")
179
+ headersMap[headline[0]] = "=".join(headline[1:])
180
+
181
+ record.version = preHeadersMap["version"]
182
+ if record.version != 4:
183
+ raise ParserError("Incorrect version number in CEL version 4 file")
184
+
185
+ record.GridCornerUL = headersMap["GridCornerUL"]
186
+ record.GridCornerUR = headersMap["GridCornerUR"]
187
+ record.GridCornerLR = headersMap["GridCornerLR"]
188
+ record.GridCornerLL = headersMap["GridCornerLL"]
189
+ record.DatHeader = headersMap["DatHeader"]
190
+ record.Algorithm = headersMap["Algorithm"]
191
+ record.AlgorithmParameters = headersMap["AlgorithmParameters"]
192
+ record.NumberCells = preHeadersMap["cellNo"]
193
+ # record.intensities are set below
194
+ # record.stdevs are set below
195
+ # record.npix are set below
196
+ record.nrows = int(headersMap["Rows"])
197
+ record.ncols = int(headersMap["Cols"])
198
+
199
+ # These cannot be reliably set in v4, because of discrepancies between real
200
+ # data and the documented format.
201
+ record.nmask = None
202
+ record.mask = None
203
+ record.noutliers = None
204
+ record.outliers = None
205
+ record.modified = None
206
+
207
+ # Real data never seems to have anything but zeros here, but we don't want
208
+ # to take chances. Raising an error is better than returning unreliable
209
+ # data.
210
+ def raiseBadHeader(field, expected):
211
+ actual = int(headersMap[field])
212
+ message = f"The header {field} is expected to be 0, not {actual}"
213
+ if actual != expected:
214
+ raise ParserError(message)
215
+
216
+ raiseBadHeader("Axis-invertX", 0)
217
+
218
+ raiseBadHeader("AxisInvertY", 0)
219
+
220
+ raiseBadHeader("OffsetX", 0)
221
+
222
+ raiseBadHeader("OffsetY", 0)
223
+
224
+ # This is unfortunately undocumented, but it turns out that real data has
225
+ # the record.AlgorithmParameters repeated in the data section, until an
226
+ # EOF, i.e. b"\x04".
227
+ char = b"\x00"
228
+ safetyValve = 10**4
229
+ for i in range(safetyValve):
230
+ char = f.read(1)
231
+ # For debugging
232
+ # print([i for i in char], end="")
233
+ if char == b"\x04":
234
+ break
235
+ if i == safetyValve:
236
+ raise ParserError(
237
+ "Parse Error. The parser expects a short, "
238
+ "undocumented binary blob terminating with "
239
+ "ASCII EOF, x04"
240
+ )
241
+
242
+ # After that there are precisely 15 bytes padded. Again, undocumented.
243
+ padding = f.read(15)
244
+
245
+ # That's how we pull out the values (triplets of the form float, float,
246
+ # signed short).
247
+ structa = struct.Struct("< f f h")
248
+
249
+ # There are 10 bytes in our struct.
250
+ structSize = 10
251
+
252
+ # We initialize the most important: intensities, stdevs and npixs.
253
+ record.intensities = np.empty(record.NumberCells, dtype=float)
254
+ record.stdevs = np.empty(record.NumberCells, dtype=float)
255
+ record.npix = np.empty(record.NumberCells, dtype=int)
256
+
257
+ b = f.read(structSize * record.NumberCells)
258
+ for i in range(record.NumberCells):
259
+ binaryFragment = b[i * structSize : (i + 1) * structSize]
260
+ intensity, stdevs, npix = structa.unpack(binaryFragment)
261
+ record.intensities[i] = intensity
262
+ record.stdevs[i] = stdevs
263
+ record.npix[i] = npix
264
+
265
+ # reshape without copying.
266
+ def reshape(array):
267
+ view = array.view()
268
+ view.shape = (record.nrows, record.ncols)
269
+ return view
270
+
271
+ record.intensities = reshape(record.intensities)
272
+ record.stdevs = reshape(record.stdevs)
273
+ record.npix = reshape(record.npix)
274
+
275
+ return record
276
+
277
+
278
+ def _read_v3(handle):
279
+ # Needs error handling.
280
+ # Needs to know the chip design.
281
+ record = Record()
282
+ # The version number was already obtained when the read function calling
283
+ # _read_v3 parsed the CEL section.
284
+ record.version = 3
285
+ section = ""
286
+ for line in handle:
287
+ line = line.rstrip("\r\n")
288
+ if not line:
289
+ continue
290
+ # Set current section
291
+ if line.startswith("[HEADER]"):
292
+ section = "HEADER"
293
+ elif line.startswith("[INTENSITY]"):
294
+ section = "INTENSITY"
295
+ record.intensities = np.zeros((record.nrows, record.ncols))
296
+ record.stdevs = np.zeros((record.nrows, record.ncols))
297
+ record.npix = np.zeros((record.nrows, record.ncols), int)
298
+ elif line.startswith("[MASKS]"):
299
+ section = "MASKS"
300
+ record.mask = np.zeros((record.nrows, record.ncols), bool)
301
+ elif line.startswith("[OUTLIERS]"):
302
+ section = "OUTLIERS"
303
+ record.outliers = np.zeros((record.nrows, record.ncols), bool)
304
+ elif line.startswith("[MODIFIED]"):
305
+ section = "MODIFIED"
306
+ record.modified = np.zeros((record.nrows, record.ncols))
307
+ elif line.startswith("["):
308
+ raise ParserError("Unknown section found in version 3 CEL file")
309
+ else: # read the data in a section
310
+ if section == "HEADER":
311
+ # Set record.ncols and record.nrows, remaining data goes into
312
+ # record.header dict
313
+ key, value = line.split("=", 1)
314
+ if key == "Cols":
315
+ record.ncols = int(value)
316
+ elif key == "Rows":
317
+ record.nrows = int(value)
318
+ elif key == "GridCornerUL":
319
+ x, y = value.split()
320
+ record.GridCornerUL = (int(x), int(y))
321
+ elif key == "GridCornerUR":
322
+ x, y = value.split()
323
+ record.GridCornerUR = (int(x), int(y))
324
+ elif key == "GridCornerLR":
325
+ x, y = value.split()
326
+ record.GridCornerLR = (int(x), int(y))
327
+ elif key == "GridCornerLL":
328
+ x, y = value.split()
329
+ record.GridCornerLL = (int(x), int(y))
330
+ elif key == "DatHeader":
331
+ # not sure if all parameters here are interpreted correctly
332
+ record.DatHeader = {}
333
+ i = value.find(":")
334
+ if i >= 0:
335
+ min_max_pixel_intensity, filename = value[:i].split()
336
+ record.DatHeader["filename"] = filename
337
+ assert min_max_pixel_intensity[0] == "["
338
+ assert min_max_pixel_intensity[-1] == "]"
339
+ (
340
+ min_pixel_intensity,
341
+ max_pixel_intensity,
342
+ ) = min_max_pixel_intensity[1:-1].split("..")
343
+ record.DatHeader["min-pixel_intensity"] = int(
344
+ min_pixel_intensity
345
+ )
346
+ record.DatHeader["max-pixel_intensity"] = int(
347
+ max_pixel_intensity
348
+ )
349
+ value = value[i + 1 :]
350
+ index = 0
351
+ field = value[index : index + 9]
352
+ if field[:4] != "CLS=" or field[8] != " ":
353
+ raise ValueError(
354
+ "Field does not start with 'CLS=' or have a blank space at position 8"
355
+ )
356
+ record.DatHeader["CLS"] = int(field[4:8])
357
+ index += 9
358
+ field = value[index : index + 9]
359
+ if field[:4] != "RWS=" or field[8] != " ":
360
+ raise ValueError(
361
+ "Field does not start with 'RWS=' or have a blank space at position 8"
362
+ )
363
+ record.DatHeader["RWS"] = int(field[4:8])
364
+ index += 9
365
+ field = value[index : index + 7]
366
+ if field[:4] != "XIN=" or field[6] != " ":
367
+ raise ValueError(
368
+ "Field does not start with 'XIN=' or have a blank space at position 6"
369
+ )
370
+ record.DatHeader["XIN"] = int(field[4:6])
371
+ index += 7
372
+ field = value[index : index + 7]
373
+ if field[:4] != "YIN=" or field[6] != " ":
374
+ raise ValueError(
375
+ "Field does not start with 'YIN=' or have a blank space at poition 6"
376
+ )
377
+ record.DatHeader["YIN"] = int(field[4:6])
378
+ index += 7
379
+ field = value[index : index + 6]
380
+ if field[:3] != "VE=" or field[5] != " ":
381
+ raise ValueError(
382
+ "Field does not start with 'VE=' or have a blank space at position 5"
383
+ )
384
+ record.DatHeader["VE"] = int(field[3:5])
385
+ index += 6
386
+ field = value[index : index + 7]
387
+ if field[6] != " ":
388
+ raise ValueError(
389
+ "Field value for position 6 isn't a blank space"
390
+ )
391
+ temperature = field[:6].strip()
392
+ if temperature:
393
+ record.DatHeader["temperature"] = int(temperature)
394
+ else:
395
+ record.DatHeader["temperature"] = None
396
+ index += 7
397
+ field = value[index : index + 4]
398
+ if not field.endswith(" "):
399
+ raise ValueError("Field doesn't end with a blank space")
400
+ record.DatHeader["laser-power"] = float(field)
401
+ index += 4
402
+ field = value[index : index + 18]
403
+ if field[8] != " ":
404
+ raise ValueError(
405
+ "Field value for position 8 isn't a blank space"
406
+ )
407
+ record.DatHeader["scan-date"] = field[:8]
408
+ if field[17] != " ":
409
+ raise ValueError(
410
+ "Field value for position 17 isn't a blank space"
411
+ )
412
+ record.DatHeader["scan-date"] = field[:8]
413
+ record.DatHeader["scan-time"] = field[9:17]
414
+ index += 18
415
+ value = value[index:]
416
+ subfields = value.split("\x14")
417
+ if len(subfields) != 12:
418
+ ValueError("Subfields length isn't 12")
419
+ subfield = subfields[0]
420
+ try:
421
+ scanner_id, scanner_type = subfield.split()
422
+ except ValueError:
423
+ scanner_id = subfield.strip()
424
+ else:
425
+ record.DatHeader["scanner-type"] = scanner_type
426
+ record.DatHeader["scanner-id"] = scanner_id
427
+ record.DatHeader["array-type"] = subfields[2].strip()
428
+ field = subfields[7].strip()
429
+ if field:
430
+ record.DatHeader["filter-wavelength"] = int(field)
431
+ field = subfields[8].strip()
432
+ if field:
433
+ record.DatHeader["arc-radius"] = float(field)
434
+ field = subfields[9].strip()
435
+ if field:
436
+ record.DatHeader["laser-spotsize"] = float(field)
437
+ field = subfields[10].strip()
438
+ if field:
439
+ record.DatHeader["pixel-size"] = float(field)
440
+ field = subfields[11].strip()
441
+ if field:
442
+ record.DatHeader["image-orientation"] = int(field)
443
+ elif key == "Algorithm":
444
+ record.Algorithm = value
445
+ elif key == "AlgorithmParameters":
446
+ parameters = value.split(";")
447
+ values = {}
448
+ for parameter in parameters:
449
+ key, value = parameter.split(":", 1)
450
+ if key in (
451
+ "Percentile",
452
+ "CellMargin",
453
+ "FullFeatureWidth",
454
+ "FullFeatureHeight",
455
+ "PoolWidthExtenstion",
456
+ "PoolHeightExtension",
457
+ "NumPixelsToUse",
458
+ "ExtendPoolWidth",
459
+ "ExtendPoolHeight",
460
+ "OutlierRatioLowPercentile",
461
+ "OutlierRatioHighPercentile",
462
+ "HalfCellRowsDivisor",
463
+ "HalfCellRowsRemainder",
464
+ "HighCutoff",
465
+ "LowCutoff",
466
+ "featureRows",
467
+ "featureColumns",
468
+ ):
469
+ values[key] = int(value)
470
+ elif key in (
471
+ "OutlierHigh",
472
+ "OutlierLow",
473
+ "StdMult",
474
+ "PercentileSpread",
475
+ "PairCutoff",
476
+ "featureWidth",
477
+ "featureHeight",
478
+ ):
479
+ values[key] = float(value)
480
+ elif key in (
481
+ "FixedCellSize",
482
+ "IgnoreOutliersInShiftRows",
483
+ "FeatureExtraction",
484
+ "UseSubgrids",
485
+ "RandomizePixels",
486
+ "ImageCalibration",
487
+ "IgnoreShiftRowOutliers",
488
+ ):
489
+ if value == "TRUE":
490
+ value = True
491
+ elif value == "FALSE":
492
+ value = False
493
+ else:
494
+ raise ValueError("Unexpected boolean value")
495
+ values[key] = value
496
+ elif key in (
497
+ "AlgVersion",
498
+ "ErrorBasis",
499
+ "CellIntensityCalculationType",
500
+ ):
501
+ values[key] = value
502
+ else:
503
+ raise ValueError("Unexpected tag in AlgorithmParameters")
504
+ record.AlgorithmParameters = values
505
+ elif section == "INTENSITY":
506
+ if line.startswith("NumberCells="):
507
+ key, value = line.split("=", 1)
508
+ record.NumberCells = int(value)
509
+ elif line.startswith("CellHeader="):
510
+ key, value = line.split("=", 1)
511
+ if value.split() != ["X", "Y", "MEAN", "STDV", "NPIXELS"]:
512
+ raise ParserError(
513
+ "Unexpected CellHeader in INTENSITY "
514
+ "section CEL version 3 file"
515
+ )
516
+ else:
517
+ words = line.split()
518
+ y = int(words[0])
519
+ x = int(words[1])
520
+ record.intensities[x, y] = float(words[2])
521
+ record.stdevs[x, y] = float(words[3])
522
+ record.npix[x, y] = int(words[4])
523
+ elif section == "MASKS":
524
+ if line.startswith("NumberCells="):
525
+ key, value = line.split("=", 1)
526
+ record.nmask = int(value)
527
+ elif line.startswith("CellHeader="):
528
+ key, value = line.split("=", 1)
529
+ if value.split() != ["X", "Y"]:
530
+ raise ParserError(
531
+ "Unexpected CellHeader in MASKS "
532
+ "section in CEL version 3 file"
533
+ )
534
+ else:
535
+ words = line.split()
536
+ y = int(words[0])
537
+ x = int(words[1])
538
+ record.mask[x, y] = True
539
+ elif section == "OUTLIERS":
540
+ if line.startswith("NumberCells="):
541
+ key, value = line.split("=", 1)
542
+ record.noutliers = int(value)
543
+ elif line.startswith("CellHeader="):
544
+ key, value = line.split("=", 1)
545
+ if value.split() != ["X", "Y"]:
546
+ raise ParserError(
547
+ "Unexpected CellHeader in OUTLIERS "
548
+ "section in CEL version 3 file"
549
+ )
550
+ else:
551
+ words = line.split()
552
+ y = int(words[0])
553
+ x = int(words[1])
554
+ record.outliers[x, y] = True
555
+ elif section == "MODIFIED":
556
+ if line.startswith("NumberCells="):
557
+ key, value = line.split("=", 1)
558
+ record.nmodified = int(value)
559
+ elif line.startswith("CellHeader="):
560
+ key, value = line.split("=", 1)
561
+ if value.split() != ["X", "Y", "ORIGMEAN"]:
562
+ raise ParserError(
563
+ "Unexpected CellHeader in MODIFIED "
564
+ "section in CEL version 3 file"
565
+ )
566
+ else:
567
+ words = line.split()
568
+ y = int(words[0])
569
+ x = int(words[1])
570
+ record.modified[x, y] = float(words[2])
571
+ return record
572
+
573
+
574
+ if __name__ == "__main__":
575
+ from Bio._utils import run_doctest
576
+
577
+ run_doctest()
.venv_haddock/lib/python3.12/site-packages/Bio/Affy/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # This file is part of the Biopython distribution and governed by your
2
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
3
+ # Please see the LICENSE file that should have been included as part of this
4
+ # package.
5
+
6
+ """Deal with Affymetrix related data such as cel files."""
.venv_haddock/lib/python3.12/site-packages/Bio/Affy/__pycache__/CelFile.cpython-312.pyc ADDED
Binary file (21.5 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Affy/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (269 Bytes). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/AlignInfo.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2000 Brad Chapman. All rights reserved.
2
+ #
3
+ # This file is part of the Biopython distribution and governed by your
4
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
5
+ # Please see the LICENSE file that should have been included as part of this
6
+ # package.
7
+ """Extract information from alignment objects.
8
+
9
+ In order to try and avoid huge alignment objects with tons of functions,
10
+ functions which return summary type information about alignments should
11
+ be put into classes in this module.
12
+ """
13
+
14
+ import warnings
15
+
16
+ from Bio import BiopythonDeprecationWarning
17
+
18
+
19
+ class SummaryInfo:
20
+ """Calculate summary info about the alignment. (DEPRECATED)
21
+
22
+ This class should be used to calculate information summarizing the
23
+ results of an alignment. This may either be straight consensus info
24
+ or more complicated things.
25
+ """
26
+
27
+ def __init__(self, alignment):
28
+ """Initialize with the alignment to calculate information on.
29
+
30
+ ic_vector attribute. A list of ic content for each column number.
31
+ """
32
+ warnings.warn(
33
+ """\
34
+ The class SummaryInfo has been deprecated. Instead of
35
+
36
+ >>> align_info = AlignInfo.SummaryInfo(msa)
37
+ >>> sequence = align_info.get_column(1)
38
+
39
+ please use
40
+
41
+ >>> alignment = msa.alignment # to get a new-style Alignment object
42
+ >>> sequence = alignment[:, 1]
43
+
44
+ Here, `msa` is a MultipleSeqAlignment object and `alignment` is an
45
+ `Alignment` object.""",
46
+ BiopythonDeprecationWarning,
47
+ )
48
+ self.alignment = alignment
49
+ self.ic_vector = []
50
+
51
+ def get_column(self, col):
52
+ """Return column of alignment."""
53
+ # TODO - Deprecate this and implement slicing?
54
+ return self.alignment[:, col]
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__init__.py ADDED
The diff for this file is too large to render. See raw diff
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/AlignInfo.cpython-312.pyc ADDED
Binary file (1.94 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/a2m.cpython-312.pyc ADDED
Binary file (5.54 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/analysis.cpython-312.pyc ADDED
Binary file (49.8 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bed.cpython-312.pyc ADDED
Binary file (10.4 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigbed.cpython-312.pyc ADDED
Binary file (91.3 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigmaf.cpython-312.pyc ADDED
Binary file (15.3 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/bigpsl.cpython-312.pyc ADDED
Binary file (20.7 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/chain.cpython-312.pyc ADDED
Binary file (9.58 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/clustal.cpython-312.pyc ADDED
Binary file (8.27 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/emboss.cpython-312.pyc ADDED
Binary file (9.03 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/exonerate.cpython-312.pyc ADDED
Binary file (21.6 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/fasta.cpython-312.pyc ADDED
Binary file (4 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/hhr.cpython-312.pyc ADDED
Binary file (10.3 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/interfaces.cpython-312.pyc ADDED
Binary file (13.6 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/maf.cpython-312.pyc ADDED
Binary file (18.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/mauve.cpython-312.pyc ADDED
Binary file (10.7 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/msf.cpython-312.pyc ADDED
Binary file (7.34 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/nexus.cpython-312.pyc ADDED
Binary file (9.18 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Align/__pycache__/phylip.cpython-312.pyc ADDED
Binary file (8.13 kB). View file