File: ajphylo.h

package info (click to toggle)
emboss 6.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 571,544 kB
  • sloc: ansic: 460,579; java: 29,439; perl: 13,573; sh: 12,754; makefile: 3,283; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (334 lines) | stat: -rw-r--r-- 10,259 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/* @include ajphylo ***********************************************************
**
** AJAX Phylogeny functions
** These functions create and control linked lists.
**
** @author Copyright (C) 2003 Peter Rice
** @version $Revision: 1.18 $
** @modified $Date: 2011/10/18 14:23:40 $ by $Author: rice $
** @@
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA  02110-1301,  USA.
**
******************************************************************************/

#ifndef AJPHYLO_H
#define AJPHYLO_H

/* ========================================================================= */
/* ============================= include files ============================= */
/* ========================================================================= */

#include "ajdefine.h"
#include "ajstr.h"

AJ_BEGIN_DECLS




/* ========================================================================= */
/* =============================== constants =============================== */
/* ========================================================================= */




/* ========================================================================= */
/* ============================== public data ============================== */
/* ========================================================================= */




/* @data AjPPhyloDist *********************************************************
**
** Ajax phylogeny distance matrix
**
** Input can be square (all values) or lower-triangular (diagonal and below)
** or upper-triangular (diagonal and above). We can count values for the
** first 2 species to identify the format.
**
** S-format allows degree of replication for each distance (integer)
** we can check for this (twice as many numbers) otherwise we set the
** replicates to 1.
**
** @alias AjSPhyloDist
** @alias AjOPhyloDist
**
** @attr Size [ajint] Size - number of rows and number of columns
** @attr HasReplicates [AjBool] Has (some) replicates data in file
** @attr Names [AjPStr*] Row names, NULL at end
** @attr Data [float*] Distance matrix Size*Size with diagonal 0.0
** @attr Replicates [ajint*] Replicate count default=1 missing=0
** @attr HasMissing [AjBool] Has missing data in file
** @attr Padding [char[4]] Padding to alignment boundary
** @@
******************************************************************************/

typedef struct AjSPhyloDist
{
    ajint Size;
    AjBool HasReplicates;
    AjPStr* Names;
    float* Data;
    ajint* Replicates;
    AjBool HasMissing;
    char Padding[4];
} AjOPhyloDist;

#define AjPPhyloDist AjOPhyloDist*




/* @data AjPPhyloFreq *********************************************************
**
** Ajax phylogeny frequencies.
**
** For continuous data there are always 2 alleles
** For gene frequency data there can be more than 2 alleles
**
** @alias AjSPhyloFreq
** @alias AjOPhyloFreq
**
** @attr Size [ajint] Number of rows
** @attr Loci [ajint] Number of loci per name
** @attr Len [ajint] Number of values per name
**                    may be more than 1 per locus
** @attr ContChar [AjBool] Continuous character data if true
** @attr Names [AjPStr*] Row names array (size is Size)
**
** @cc row grouping - multiple individual values for one 'species'
**     ContChar data only, otherwise NULL
**
** @attr Species [ajint*] Species number 1, 2, 3 for each value
**                    array size is Len
** @attr Individuals [ajint*] Allele countNumber of individuals
**                    1 or more per species
**                    array size is Loci
**
** @cc column grouping - multiple frequency values for alleles of a locus
**
** @attr Locus [ajint*] Locus number 1, 2, 3 for each value
**                     array size is Len
** @attr Allele [ajint*] Allele count 2 or more per locus
**                     array size is Loci
** @attr Data [float*] Frequency for each allele for each Name
** @attr Within [AjBool] Individual data within species if true
** @attr Padding [char[4]] Padding to alignment boundary
** @@
******************************************************************************/

typedef struct AjSPhyloFreq
{
    ajint Size;
    ajint Loci;
    ajint Len;
    AjBool ContChar;

    AjPStr* Names;

    ajint* Species;
    ajint* Individuals;

    ajint* Locus;
    ajint* Allele;
    float* Data;

    AjBool Within;
    char Padding[4];
} AjOPhyloFreq;

#define AjPPhyloFreq AjOPhyloFreq*




/* @data AjPPhyloProp *********************************************************
**
** Ajax phylogeny properties: weights, ancestral states, factors.
**
** Basically, all of these are one value per position
**
** Weights are converted to integers 0-9, A=10 Z=35 by phylip
** There are programs that can use multiple weights
** We can handle this by making all of these multiple,
** and using ACD to limit them to 1 for non-weight data.
**
** Ancestral states are character data
**
** Factors are multi-state character data where the factor character changes
** when moving to a new character. Without this, all factors are assumed to
** be different. The default would be to make each character distinct by
** alternating 12121212 or to use 12345678901234567890.
**
** We can, in fact, convert any input string into this format for factors
** but probably we can leave them unchanged.
**
** @alias AjSPhyloProp
** @alias AjOPhyloProp
**
** @attr Len [ajint] string length
** @attr Size [ajint] number of strings
** @attr IsWeight [AjBool] is phylip weight values if true
** @attr IsFactor [AjBool] is phylip factor values if true
** @attr Str [AjPStr*] The original string(s)
** @@
******************************************************************************/

typedef struct AjSPhyloProp
{
    ajint Len;
    ajint Size;
    AjBool IsWeight;
    AjBool IsFactor;
    AjPStr* Str;
} AjOPhyloProp;

#define AjPPhyloProp AjOPhyloProp*




/* @data AjPPhyloState ********************************************************
**
** Ajax discrete state data.
**
** Basically, all of these are one value per position
**
** States have a limited character set, usually defined through ACD
**
** @alias AjSPhyloState
** @alias AjOPhyloState
**
** @attr Len [ajint] string length
** @attr Size [ajint] number of strings
** @attr Characters [AjPStr] The allowed state characters
** @attr Names [AjPStr*] The names
** @attr Str [AjPStr*] The original string(s)
** @attr Count [ajint] number of enzymes for restriction data
** @attr Padding [char[4]] Padding to alignment boundary
** @@
******************************************************************************/

typedef struct AjSPhyloState
{
    ajint Len;
    ajint Size;
    AjPStr Characters;
    AjPStr* Names;
    AjPStr* Str;
    ajint Count;
    char Padding[4];
} AjOPhyloState;

#define AjPPhyloState AjOPhyloState*




/* @data AjPPhyloTree *********************************************************
**
** Ajax phylogeny trees
**
** For programs that read multiple tree inputs we use an array,
** and let ACD limit the others to 1 tree.
**
** @alias AjSPhyloTree
** @alias AjOPhyloTree
**
** @attr Multifurcated [AjBool] Multifurcating (..(a,b,c)..)
** @attr BaseTrifurcated [AjBool] 3-way base (a,b,c)
** @attr BaseBifurcated [AjBool] Rooted 2-way base (a,b)
** @attr BaseQuartet [AjBool] Unrooted quartet ((a,b),(c,d));
** @attr HasLengths [AjBool] Tree has branch lengths
** @attr Size [ajint] Number of nodes
** @attr Tree [AjPStr] Newick tree string
** @@
******************************************************************************/

typedef struct AjSPhyloTree
{
    AjBool Multifurcated;
    AjBool BaseTrifurcated;
    AjBool BaseBifurcated;
    AjBool BaseQuartet;
    AjBool HasLengths;
    ajint Size;
    AjPStr Tree;
} AjOPhyloTree;

#define AjPPhyloTree AjOPhyloTree*




/* ========================================================================= */
/* =========================== public functions ============================ */
/* ========================================================================= */




/*
** Prototype definitions
*/

void           ajPhyloDistDel(AjPPhyloDist* pthis);
AjPPhyloDist   ajPhyloDistNew(void);
AjPPhyloDist*  ajPhyloDistRead(const AjPStr filename, ajint size,
                               AjBool missing);
void           ajPhyloDistTrace(const AjPPhyloDist thys);

void           ajPhyloExit(void);

void           ajPhyloFreqDel(AjPPhyloFreq* pthis);
AjPPhyloFreq   ajPhyloFreqNew(void);
AjPPhyloFreq   ajPhyloFreqRead(const AjPStr filename, AjBool contchar,
                               AjBool genedata, AjBool indiv);
void           ajPhyloFreqTrace(const AjPPhyloFreq thys);

void           ajPhyloPropDel(AjPPhyloProp* pthis);
ajint          ajPhyloPropGetSize(const AjPPhyloProp thys);
AjPPhyloProp   ajPhyloPropNew(void);
AjPPhyloProp   ajPhyloPropRead(const AjPStr filename, const AjPStr propchars,
                               ajint len, ajint size);
void           ajPhyloPropTrace(const AjPPhyloProp thys);

void           ajPhyloStateDel(AjPPhyloState* pthis);
void           ajPhyloStateDelarray(AjPPhyloState** pthis);
AjPPhyloState  ajPhyloStateNew(void);
AjPPhyloState* ajPhyloStateRead(const AjPStr filename,
                                const AjPStr statechars);
void           ajPhyloStateTrace(const AjPPhyloState thys);

void           ajPhyloTreeDel(AjPPhyloTree* pthis);
void           ajPhyloTreeDelarray(AjPPhyloTree** pthis);
AjPPhyloTree   ajPhyloTreeNew(void);
AjPPhyloTree*  ajPhyloTreeRead(const AjPStr filename, ajint size);
void           ajPhyloTreeTrace(const AjPPhyloTree thys);

/*
** End of prototype definitions
*/




AJ_END_DECLS

#endif /* !AJPHYLO_H */