| 1 | #ifndef _PHYLIP_H_ |
|---|
| 2 | #define _PHYLIP_H_ |
|---|
| 3 | |
|---|
| 4 | /* version 3.6a3. (c) Copyright 1993-2002 by the University of Washington. |
|---|
| 5 | Written by Joseph Felsenstein, Akiko Fuseki, Sean Lamont, Andrew Keeffe, |
|---|
| 6 | Mike Palczewski, Doug Buxton and Dan Fineman. |
|---|
| 7 | Permission is granted to copy and use this program provided no fee is |
|---|
| 8 | charged for it and provided that this copyright notice is not removed. */ |
|---|
| 9 | |
|---|
| 10 | #define VERSION "3.6a3" |
|---|
| 11 | |
|---|
| 12 | /* machine-specific stuff: |
|---|
| 13 | based on a number of factors in the library stdlib.h, we will try |
|---|
| 14 | to determine what kind of machine/compiler this program is being |
|---|
| 15 | built on. However, it doesn't always succeed. However, if you have |
|---|
| 16 | ANSI conforming C, it will probably work. |
|---|
| 17 | |
|---|
| 18 | We will try to figure out machine type |
|---|
| 19 | based on defines in stdio, and compiler-defined things as well.: */ |
|---|
| 20 | |
|---|
| 21 | #include <stdio.h> |
|---|
| 22 | #include <stdlib.h> |
|---|
| 23 | #ifdef WIN32 |
|---|
| 24 | #include <windows.h> |
|---|
| 25 | |
|---|
| 26 | void phyClearScreen(void); |
|---|
| 27 | void phySaveConsoleAttributes(void); |
|---|
| 28 | void phySetConsoleAttributes(void); |
|---|
| 29 | void phyRestoreConsoleAttributes(void); |
|---|
| 30 | void phyFillScreenColor(void); |
|---|
| 31 | |
|---|
| 32 | #endif |
|---|
| 33 | #ifndef WIN32 |
|---|
| 34 | #include <unistd.h> /* Contains the close(FILE *f) declaration */ |
|---|
| 35 | #endif |
|---|
| 36 | |
|---|
| 37 | #ifdef GNUDOS |
|---|
| 38 | #define DJGPP |
|---|
| 39 | #define DOS |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | #ifdef THINK_C |
|---|
| 43 | #define MAC |
|---|
| 44 | #endif |
|---|
| 45 | #ifdef __MWERKS__ |
|---|
| 46 | #ifndef WIN32 |
|---|
| 47 | #define MAC |
|---|
| 48 | #endif |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | #ifdef __CMS_OPEN |
|---|
| 52 | #define CMS |
|---|
| 53 | #define EBCDIC true |
|---|
| 54 | #define INFILE "infile data" |
|---|
| 55 | #define OUTFILE "outfile data" |
|---|
| 56 | #define FONTFILE "fontfile data" |
|---|
| 57 | #define PLOTFILE "plotfile data" |
|---|
| 58 | #define INTREE "intree data" |
|---|
| 59 | #define INTREE2 "intree data 2" |
|---|
| 60 | #define OUTTREE "outtree data" |
|---|
| 61 | #define CATFILE "categories data" |
|---|
| 62 | #define WEIGHTFILE "weights data" |
|---|
| 63 | #define ANCFILE "ancestors data" |
|---|
| 64 | #define MIXFILE "mixture data" |
|---|
| 65 | #define FACTFILE "factors data" |
|---|
| 66 | #else |
|---|
| 67 | #define EBCDIC false |
|---|
| 68 | #define INFILE "infile" |
|---|
| 69 | #define OUTFILE "outfile" |
|---|
| 70 | #define FONTFILE "fontfile" /* on unix this might be /usr/local/lib/fontfile */ |
|---|
| 71 | #define PLOTFILE "plotfile" |
|---|
| 72 | #define INTREE "intree" |
|---|
| 73 | #define INTREE2 "intree2" |
|---|
| 74 | #define OUTTREE "outtree" |
|---|
| 75 | #define CATFILE "categories" |
|---|
| 76 | #define WEIGHTFILE "weights" |
|---|
| 77 | #define ANCFILE "ancestors" |
|---|
| 78 | #define MIXFILE "mixture" |
|---|
| 79 | #define FACTFILE "factors" |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | #ifdef L_ctermid /* try and detect for sysV or V7. */ |
|---|
| 83 | #define SYSTEM_FIVE |
|---|
| 84 | #endif |
|---|
| 85 | |
|---|
| 86 | #ifdef sequent |
|---|
| 87 | #define SYSTEM_FIVE |
|---|
| 88 | #endif |
|---|
| 89 | |
|---|
| 90 | #ifndef SYSTEM_FIVE |
|---|
| 91 | #include <stdlib.h> |
|---|
| 92 | # if defined(_STDLIB_H_) || defined(_H_STDLIB) || defined(H_SCCSID) || defined(unix) |
|---|
| 93 | # define UNIX |
|---|
| 94 | # define MACHINE_TYPE "BSD Unix C" |
|---|
| 95 | # endif |
|---|
| 96 | #endif |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | #ifdef __STDIO_LOADED |
|---|
| 100 | #define VMS |
|---|
| 101 | #define MACHINE_TYPE "VAX/VMS C" |
|---|
| 102 | #endif |
|---|
| 103 | |
|---|
| 104 | #ifdef __WATCOMC__ |
|---|
| 105 | #define QUICKC |
|---|
| 106 | #define WATCOM |
|---|
| 107 | #define DOS |
|---|
| 108 | #include "graph.h" |
|---|
| 109 | #endif |
|---|
| 110 | /* watcom-c has graphics library calls that are almost identical to * |
|---|
| 111 | * quick-c, so the "QUICKC" symbol name stays. */ |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | #ifdef _QC |
|---|
| 115 | #define MACHINE_TYPE "MS-DOS / Quick C" |
|---|
| 116 | #define QUICKC |
|---|
| 117 | #include "graph.h" |
|---|
| 118 | #define DOS |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | #ifdef _DOS_MODE |
|---|
| 122 | #define MACHINE_TYPE "MS-DOS /Microsoft C " |
|---|
| 123 | #define DOS /* DOS is always defined if on a DOS machine */ |
|---|
| 124 | #define MSC /* MSC is defined for microsoft C */ |
|---|
| 125 | #endif |
|---|
| 126 | |
|---|
| 127 | #ifdef __MSDOS__ /* TURBO c compiler, ONLY (no other DOS C compilers) */ |
|---|
| 128 | #define DOS |
|---|
| 129 | #define TURBOC |
|---|
| 130 | #include <stdlib.h> |
|---|
| 131 | #include <graphics.h> |
|---|
| 132 | #endif |
|---|
| 133 | |
|---|
| 134 | #ifdef DJGPP /* DJ Delorie's original gnu C/C++ port */ |
|---|
| 135 | #include <graphics.h> |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | #ifndef MACHINE_TYPE |
|---|
| 139 | #define MACHINE_TYPE "ANSI C" |
|---|
| 140 | #endif |
|---|
| 141 | |
|---|
| 142 | #ifdef DOS |
|---|
| 143 | #define MALLOCRETURN void |
|---|
| 144 | #else |
|---|
| 145 | #define MALLOCRETURN void |
|---|
| 146 | #endif |
|---|
| 147 | #ifdef VMS |
|---|
| 148 | #define signed /* signed doesn't exist in VMS */ |
|---|
| 149 | #endif |
|---|
| 150 | |
|---|
| 151 | /* default screen types */ |
|---|
| 152 | /* if on a DOS but not a Windows system can use IBM PC screen controls */ |
|---|
| 153 | #ifdef DOS |
|---|
| 154 | #ifndef WIN32 |
|---|
| 155 | #define IBMCRT true |
|---|
| 156 | #define ANSICRT false |
|---|
| 157 | #endif |
|---|
| 158 | #endif |
|---|
| 159 | /* if on a Mac cannot use screen controls */ |
|---|
| 160 | #ifdef MAC |
|---|
| 161 | #define IBMCRT false |
|---|
| 162 | #define ANSICRT false |
|---|
| 163 | #endif |
|---|
| 164 | /* if on a Windows system cannot use screen controls */ |
|---|
| 165 | #ifdef WIN32 |
|---|
| 166 | #define IBMCRT false |
|---|
| 167 | #define ANSICRT false |
|---|
| 168 | #endif |
|---|
| 169 | /* otherwise, let's assume we are on a Linux or Unix system |
|---|
| 170 | with no ANSI terminal controls */ |
|---|
| 171 | #ifndef MAC |
|---|
| 172 | #ifndef DOS |
|---|
| 173 | #ifndef WIN32 |
|---|
| 174 | #define IBMCRT false |
|---|
| 175 | #define ANSICRT false |
|---|
| 176 | #endif |
|---|
| 177 | #endif |
|---|
| 178 | #endif |
|---|
| 179 | |
|---|
| 180 | #ifdef DJGPP |
|---|
| 181 | #undef MALLOCRETURN |
|---|
| 182 | #define MALLOCRETURN void |
|---|
| 183 | #endif |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | /* includes: */ |
|---|
| 187 | #ifdef UNIX |
|---|
| 188 | #include <strings.h> |
|---|
| 189 | #else |
|---|
| 190 | #include <string.h> |
|---|
| 191 | #endif |
|---|
| 192 | |
|---|
| 193 | #include <math.h> |
|---|
| 194 | #include <ctype.h> |
|---|
| 195 | |
|---|
| 196 | #ifdef MAC |
|---|
| 197 | /* debug beerli */ |
|---|
| 198 | #ifdef DRAW |
|---|
| 199 | #include "interface.h" |
|---|
| 200 | #else |
|---|
| 201 | #include "macface.h" |
|---|
| 202 | #endif |
|---|
| 203 | #define getch gettch |
|---|
| 204 | #endif |
|---|
| 205 | |
|---|
| 206 | /* directory delimiters */ |
|---|
| 207 | #ifdef MAC |
|---|
| 208 | #define DELIMITER ':' |
|---|
| 209 | #else |
|---|
| 210 | #ifdef WIN32 |
|---|
| 211 | #define DELIMITER '\\' |
|---|
| 212 | #else |
|---|
| 213 | #define DELIMITER '/' |
|---|
| 214 | #endif |
|---|
| 215 | #endif |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | #define FClose(file) if (file) fclose(file) ; file=NULL |
|---|
| 219 | #define Malloc(x) mymalloc((long)x) |
|---|
| 220 | |
|---|
| 221 | typedef void *Anyptr; |
|---|
| 222 | #define Signed signed |
|---|
| 223 | #define Const const |
|---|
| 224 | #define Volatile volatile |
|---|
| 225 | #define Char char /* Characters (not bytes) */ |
|---|
| 226 | #define Static static /* Private global funcs and vars */ |
|---|
| 227 | #define Local static /* Nested functions */ |
|---|
| 228 | |
|---|
| 229 | typedef unsigned char boolean; |
|---|
| 230 | |
|---|
| 231 | #define true 1 |
|---|
| 232 | #define false 0 |
|---|
| 233 | #define SETBITS 31 |
|---|
| 234 | |
|---|
| 235 | MALLOCRETURN *mymalloc(long); |
|---|
| 236 | |
|---|
| 237 | #define FNMLNGTH 200 /* length of array to store a file name */ |
|---|
| 238 | #define MAXNCH 20 |
|---|
| 239 | #define nmlngth 10 /* number of characters in species name */ |
|---|
| 240 | #define maxcategs 9 /* maximum number of site types */ |
|---|
| 241 | #define maxcategs2 11 /* maximum number of site types + 2 */ |
|---|
| 242 | #define point "." |
|---|
| 243 | #define pointe '.' |
|---|
| 244 | #define down 2 |
|---|
| 245 | |
|---|
| 246 | #define smoothings 4 /* number of passes through smoothing algorithm */ |
|---|
| 247 | #define iterations 4 /* number of iterates for each branch */ |
|---|
| 248 | #define epsilon 0.0001 /* small number used in makenewv */ |
|---|
| 249 | #define EPSILON 0.00001 /* small number used in hermite root-finding */ |
|---|
| 250 | #define initialv 0.1 /* starting branch length unless otherwise */ |
|---|
| 251 | #define over 60 /* maximum width all branches of tree on screen */ |
|---|
| 252 | #define SQRTPI 1.7724538509055160273 |
|---|
| 253 | #define SQRT2 1.4142135623730950488 |
|---|
| 254 | |
|---|
| 255 | typedef long *steptr; |
|---|
| 256 | typedef long longer[6]; |
|---|
| 257 | typedef char naym[MAXNCH]; |
|---|
| 258 | typedef long *bitptr; |
|---|
| 259 | typedef double raterootarray[maxcategs2][maxcategs2]; |
|---|
| 260 | |
|---|
| 261 | typedef struct bestelm { |
|---|
| 262 | long *btree; |
|---|
| 263 | boolean gloreange; |
|---|
| 264 | boolean locreange; |
|---|
| 265 | boolean collapse; |
|---|
| 266 | } bestelm; |
|---|
| 267 | |
|---|
| 268 | extern FILE *infile, *outfile, *intree, *intree2, *outtree, |
|---|
| 269 | *weightfile, *catfile, *ancfile, *mixfile, *factfile; |
|---|
| 270 | extern long spp, words, bits; |
|---|
| 271 | extern boolean ibmpc, ansi, tranvsp; |
|---|
| 272 | extern naym *nayme; /* names of species */ |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | #define ebcdic EBCDIC |
|---|
| 276 | |
|---|
| 277 | typedef Char plotstring[MAXNCH]; |
|---|
| 278 | |
|---|
| 279 | /* Approx. 1GB, used to test for memory request errors */ |
|---|
| 280 | #define TOO_MUCH_MEMORY 1000000000 |
|---|
| 281 | |
|---|
| 282 | |
|---|
| 283 | /* The below pre-processor commands define the type used to store |
|---|
| 284 | group arrays. We can't use #elif for metrowerks, so we use |
|---|
| 285 | cascaded if statements */ |
|---|
| 286 | #include <limits.h> |
|---|
| 287 | |
|---|
| 288 | /* K&R says that there should be a plus in front of the number, but no |
|---|
| 289 | machine we've seen actually uses one; we'll include it just in |
|---|
| 290 | case. */ |
|---|
| 291 | #define MAX_32BITS 2147483647 |
|---|
| 292 | #define MAX_32BITS_PLUS +2147483647 |
|---|
| 293 | |
|---|
| 294 | /* If ints are 4 bytes, use them */ |
|---|
| 295 | #if INT_MAX == MAX_32BITS |
|---|
| 296 | typedef int group_type; |
|---|
| 297 | |
|---|
| 298 | #else |
|---|
| 299 | #if INT_MAX == MAX_32BITS_PLUS |
|---|
| 300 | typedef int group_type; |
|---|
| 301 | |
|---|
| 302 | #else |
|---|
| 303 | /* Else, if longs are 4 bytes, use them */ |
|---|
| 304 | #if LONG_MAX == MAX_32BITS |
|---|
| 305 | typedef long group_type; |
|---|
| 306 | |
|---|
| 307 | #else |
|---|
| 308 | #if LONG_MAX == MAX_32BITS_PLUS |
|---|
| 309 | typedef long group_type; |
|---|
| 310 | |
|---|
| 311 | /* Default to longs */ |
|---|
| 312 | #else |
|---|
| 313 | typedef long group_type; |
|---|
| 314 | #endif |
|---|
| 315 | |
|---|
| 316 | #endif |
|---|
| 317 | #endif |
|---|
| 318 | #endif |
|---|
| 319 | |
|---|
| 320 | /* for restml */ |
|---|
| 321 | |
|---|
| 322 | #define maxcutter 8 /* maximum number of bases in a site in restml */ |
|---|
| 323 | |
|---|
| 324 | /* for many programs */ |
|---|
| 325 | |
|---|
| 326 | #define maxuser 1000 /* maximum number of user-defined trees */ |
|---|
| 327 | |
|---|
| 328 | typedef Char **sequence; |
|---|
| 329 | |
|---|
| 330 | typedef enum { |
|---|
| 331 | A, C, G, T, O |
|---|
| 332 | } bases; |
|---|
| 333 | |
|---|
| 334 | typedef enum { |
|---|
| 335 | alanine, arginine, asparagine, aspartic, cysteine, |
|---|
| 336 | glutamine, glutamic, glycine, histidine, isoleucine, |
|---|
| 337 | leucine, lysine, methionine, phenylalanine, proline, |
|---|
| 338 | serine, threonine, tryptophan, tyrosine, valine |
|---|
| 339 | } acids; |
|---|
| 340 | |
|---|
| 341 | /* for Pars */ |
|---|
| 342 | |
|---|
| 343 | typedef enum { |
|---|
| 344 | ZERO = 0, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN |
|---|
| 345 | } discbases; |
|---|
| 346 | |
|---|
| 347 | /* for Protpars */ |
|---|
| 348 | |
|---|
| 349 | typedef enum { |
|---|
| 350 | ala, arg, asn, asp, cys, gln, glu, gly, his, ileu, leu, lys, met, phe, pro, |
|---|
| 351 | ser1, ser2, thr, trp, tyr, val, del, stop, asx, glx, ser, unk, quest |
|---|
| 352 | } aas; |
|---|
| 353 | |
|---|
| 354 | typedef double sitelike[(long)T - (long)A + 1]; /* used in dnaml, dnadist */ |
|---|
| 355 | typedef double psitelike[(long)valine - (long)alanine + 1]; |
|---|
| 356 | /* used in proml */ |
|---|
| 357 | |
|---|
| 358 | typedef long *baseptr; /* baseptr used in dnapars, dnacomp & dnapenny */ |
|---|
| 359 | typedef long *baseptr2; /* baseptr used in dnamove */ |
|---|
| 360 | typedef unsigned char *discbaseptr; /* discbaseptr used in pars */ |
|---|
| 361 | typedef sitelike *ratelike; /* used in dnaml ... */ |
|---|
| 362 | typedef psitelike *pratelike; /* used in proml */ |
|---|
| 363 | typedef ratelike *phenotype; /* phenotype used in dnaml, dnamlk, dnadist */ |
|---|
| 364 | typedef pratelike *pphenotype; /* phenotype used in proml */ |
|---|
| 365 | typedef double sitelike2[maxcutter + 1]; |
|---|
| 366 | typedef sitelike2 *phenotype2; /* phenotype2 used in restml */ |
|---|
| 367 | typedef double *phenotype3; /* for continuous char programs */ |
|---|
| 368 | |
|---|
| 369 | typedef double *vector; /* used in distance programs */ |
|---|
| 370 | |
|---|
| 371 | typedef long nucarray[(long)O - (long)A + 1]; |
|---|
| 372 | typedef long discnucarray[(long)SEVEN - (long)ZERO + 1]; |
|---|
| 373 | |
|---|
| 374 | typedef enum { nocollap, tocollap, undefined } collapstates; |
|---|
| 375 | |
|---|
| 376 | typedef enum { bottom, nonbottom, hslength, tip, iter, length, |
|---|
| 377 | hsnolength, treewt, unittrwt } initops; |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | typedef double **transmatrix; |
|---|
| 381 | typedef transmatrix *transptr; /* transptr used in restml */ |
|---|
| 382 | |
|---|
| 383 | typedef long sitearray[3]; |
|---|
| 384 | typedef sitearray *seqptr; /* seqptr used in protpars */ |
|---|
| 385 | |
|---|
| 386 | typedef struct node { |
|---|
| 387 | struct node *next, *back; |
|---|
| 388 | plotstring nayme; |
|---|
| 389 | long naymlength, tipsabove, index; |
|---|
| 390 | double times_in_tree; /* Previously known as cons_index */ |
|---|
| 391 | double xcoord, ycoord; |
|---|
| 392 | long long_xcoord, long_ycoord; /* for use in cons. */ |
|---|
| 393 | double oldlen, length, r, theta, oldtheta, width, depth, |
|---|
| 394 | tipdist, lefttheta, righttheta; |
|---|
| 395 | group_type *nodeset; /* used by accumulate -plc */ |
|---|
| 396 | long ymin, ymax; /* used by printree -plc */ |
|---|
| 397 | boolean haslength; /* haslength used in dnamlk */ |
|---|
| 398 | boolean iter; /* iter used in dnaml, fitch & restml */ |
|---|
| 399 | boolean initialized; /* initialized used in dnamlk & restml */ |
|---|
| 400 | long branchnum; /* branchnum used in restml */ |
|---|
| 401 | phenotype x; /* x used in dnaml, dnamlk, dnadist */ |
|---|
| 402 | phenotype2 x2; /* x2 used in restml */ |
|---|
| 403 | phenotype3 view; /* contml etc */ |
|---|
| 404 | pphenotype protx; /* protx used in proml */ |
|---|
| 405 | aas *seq; /* the sequence used in protpars */ |
|---|
| 406 | seqptr siteset; /* temporary storage for aa's used in protpars*/ |
|---|
| 407 | double v, deltav, ssq; /* ssq used only in contrast */ |
|---|
| 408 | double bigv; /* bigv used in contml */ |
|---|
| 409 | double tyme, oldtyme; /* used in dnamlk */ |
|---|
| 410 | double t; /* time in kitsch */ |
|---|
| 411 | boolean sametime; /* bookkeeps scrunched nodes in kitsch */ |
|---|
| 412 | double weight; /* weight of node used by scrunch in kitsch */ |
|---|
| 413 | boolean processed; /* used by evaluate in kitsch */ |
|---|
| 414 | boolean deleted; /* true if node is deleted (retree) */ |
|---|
| 415 | boolean hasname; /* true if tip has a name (retree) */ |
|---|
| 416 | double beyond; /* distance beyond this node to most distant tip */ |
|---|
| 417 | /* (retree) */ |
|---|
| 418 | boolean deadend; /* true if no undeleted nodes beyond this node */ |
|---|
| 419 | /* (retree) */ |
|---|
| 420 | boolean onebranch; /* true if there is one undeleted node beyond */ |
|---|
| 421 | /* this node (retree) */ |
|---|
| 422 | struct node *onebranchnode; |
|---|
| 423 | /* if there is, a pointer to that node (retree)*/ |
|---|
| 424 | double onebranchlength; /* if there is, the distance from here to there*/ |
|---|
| 425 | /* (retree) */ |
|---|
| 426 | boolean onebranchhaslength; /* true if there is a valid combined length*/ |
|---|
| 427 | /* from here to there (retree) */ |
|---|
| 428 | collapstates collapse; /* used in dnapars & dnacomp */ |
|---|
| 429 | boolean tip; |
|---|
| 430 | boolean bottom; /* used in dnapars & dnacomp, disc char */ |
|---|
| 431 | boolean visited; /* used in dnapars & dnacomp disc char */ |
|---|
| 432 | baseptr base; /* the sequence in dnapars/comp/penny */ |
|---|
| 433 | discbaseptr discbase; /* the sequence in pars */ |
|---|
| 434 | baseptr2 base2; /* the sequence in dnamove */ |
|---|
| 435 | baseptr oldbase; /* record previous sequence */ |
|---|
| 436 | discbaseptr olddiscbase; /* record previous sequence */ |
|---|
| 437 | long numdesc; /* number of immediate descendants */ |
|---|
| 438 | nucarray *numnuc; /* bookkeeps number of nucleotides */ |
|---|
| 439 | discnucarray *discnumnuc; /* bookkeeps number of nucleotides */ |
|---|
| 440 | steptr numsteps; /* bookkeeps steps */ |
|---|
| 441 | steptr oldnumsteps; /* record previous steps */ |
|---|
| 442 | double sumsteps; /* bookkeeps sum of steps */ |
|---|
| 443 | nucarray cumlengths; /* bookkeeps cummulative minimum lengths */ |
|---|
| 444 | discnucarray disccumlengths; /* bookkeeps cummulative minimum lengths */ |
|---|
| 445 | nucarray numreconst; /* bookkeeps number of reconstructions */ |
|---|
| 446 | discnucarray discnumreconst; /* bookkeeps number of reconstructions */ |
|---|
| 447 | vector d, w; /* for distance matrix programs */ |
|---|
| 448 | double dist; /* dist used in fitch */ |
|---|
| 449 | bitptr stateone, statezero; /* discrete char programs */ |
|---|
| 450 | long maxpos; /* maxpos used in Clique */ |
|---|
| 451 | Char state; /* state used in Dnamove, Dolmove & Move */ |
|---|
| 452 | } node; |
|---|
| 453 | |
|---|
| 454 | typedef node **pointarray; |
|---|
| 455 | |
|---|
| 456 | typedef struct tree { |
|---|
| 457 | pointarray nodep; |
|---|
| 458 | double likelihood; |
|---|
| 459 | transptr trans, transprod; /* trans and transprod used in restml */ |
|---|
| 460 | node *start; /* start used in dnaml & restml */ |
|---|
| 461 | node *root; /* root used in dnamlk */ |
|---|
| 462 | } tree; |
|---|
| 463 | |
|---|
| 464 | typedef void (*initptr)(node **, node **, node *, long, long, |
|---|
| 465 | long *, long *, initops, pointarray, |
|---|
| 466 | pointarray, Char *, Char *, FILE *); |
|---|
| 467 | |
|---|
| 468 | #ifndef OLDC |
|---|
| 469 | /* function prototypes */ |
|---|
| 470 | void scan_eoln(FILE *); |
|---|
| 471 | boolean eoff(FILE *); |
|---|
| 472 | boolean eoln(FILE *); |
|---|
| 473 | int filexists(char *); |
|---|
| 474 | const char* get_command_name (const char *); |
|---|
| 475 | void getstryng(char *); |
|---|
| 476 | void openfile(FILE **,const char *,const char *,const char *,const char *, |
|---|
| 477 | char *); |
|---|
| 478 | void cleerhome(void); |
|---|
| 479 | void loopcount(long *, long); |
|---|
| 480 | double randum(longer); |
|---|
| 481 | void randumize(longer, long *); |
|---|
| 482 | double normrand(longer); |
|---|
| 483 | long readlong(const char *); |
|---|
| 484 | |
|---|
| 485 | void uppercase(Char *); |
|---|
| 486 | void initseed(long *, long *, longer); |
|---|
| 487 | void initjumble(long *, long *, longer, long *); |
|---|
| 488 | void initoutgroup(long *, long); |
|---|
| 489 | void initthreshold(double *); |
|---|
| 490 | void initcatn(long *); |
|---|
| 491 | void initcategs(long, double *); |
|---|
| 492 | void initprobcat(long, double *, double *); |
|---|
| 493 | double logfac (long); |
|---|
| 494 | double halfroot(double (*func)(long , double), long, double, double); |
|---|
| 495 | double hermite(long, double); |
|---|
| 496 | void initlaguerrecat(long, double, double *, double *); |
|---|
| 497 | void root_hermite(long, double *); |
|---|
| 498 | void hermite_weight(long, double *, double *); |
|---|
| 499 | void inithermitcat(long, double, double *, double *); |
|---|
| 500 | void lgr(long, double, raterootarray); |
|---|
| 501 | double glaguerre(long, double, double); |
|---|
| 502 | void initgammacat(long, double, double *, double *); |
|---|
| 503 | void inithowmany(long *, long); |
|---|
| 504 | void inithowoften(long *); |
|---|
| 505 | |
|---|
| 506 | void initlambda(double *); |
|---|
| 507 | void initfreqs(double *, double *, double *, double *); |
|---|
| 508 | void initratio(double *); |
|---|
| 509 | void initpower(double *); |
|---|
| 510 | void initdatasets(long *); |
|---|
| 511 | void justweights(long *); |
|---|
| 512 | void initterminal(boolean *, boolean *); |
|---|
| 513 | void initnumlines(long *); |
|---|
| 514 | void initbestrees(bestelm *, long, boolean); |
|---|
| 515 | void newline(FILE *, long, long, long); |
|---|
| 516 | |
|---|
| 517 | void inputnumbers(long *, long *, long *, long); |
|---|
| 518 | void inputnumbersold(long *, long *, long *, long); |
|---|
| 519 | void inputnumbers2(long *, long *, long n); |
|---|
| 520 | void inputnumbers3(long *, long *); |
|---|
| 521 | void samenumsp(long *, long); |
|---|
| 522 | void samenumsp2(long); |
|---|
| 523 | void readoptions(long *, const char *); |
|---|
| 524 | void matchoptions(Char *, const char *); |
|---|
| 525 | void inputweights(long, steptr, boolean *); |
|---|
| 526 | void inputweightsold(long, steptr, boolean *); |
|---|
| 527 | void inputweights2(long, long, long *, steptr, boolean *, const char *); |
|---|
| 528 | void printweights(FILE *, long, long, steptr, const char *); |
|---|
| 529 | |
|---|
| 530 | void inputcategs(long, long, steptr, long, const char *); |
|---|
| 531 | void printcategs(FILE *, long, steptr, const char *); |
|---|
| 532 | void inputfactors(long, Char *, boolean *); |
|---|
| 533 | void inputfactorsnew(long, Char *, boolean *); |
|---|
| 534 | void printfactors(FILE *, long, Char *, const char *); |
|---|
| 535 | void headings(long, const char *, const char *); |
|---|
| 536 | void initname(long); |
|---|
| 537 | void findtree(boolean *,long *,long,long *,bestelm *); |
|---|
| 538 | void addtree(long,long *,boolean,long *,bestelm *); |
|---|
| 539 | long findunrearranged(bestelm *, long, boolean); |
|---|
| 540 | boolean torearrange(bestelm *, long); |
|---|
| 541 | |
|---|
| 542 | void reducebestrees(bestelm *, long *); |
|---|
| 543 | void shellsort(double *, long *, long); |
|---|
| 544 | void getch(Char *, long *, FILE *); |
|---|
| 545 | void getch2(Char *, long *); |
|---|
| 546 | void findch(Char, Char *, long); |
|---|
| 547 | void findch2(Char, long *, long *, Char *); |
|---|
| 548 | void findch3(Char, Char *, long, long); |
|---|
| 549 | void processlength(double *,double *,Char *,boolean *,FILE *,long *); |
|---|
| 550 | void writename(long, long, long *); |
|---|
| 551 | void memerror(void); |
|---|
| 552 | |
|---|
| 553 | void odd_malloc(long); |
|---|
| 554 | |
|---|
| 555 | void gnu(node **, node **); |
|---|
| 556 | void chuck(node **, node *); |
|---|
| 557 | void zeronumnuc(node *, long); |
|---|
| 558 | void zerodiscnumnuc(node *, long); |
|---|
| 559 | void allocnontip(node *, long *, long); |
|---|
| 560 | void allocdiscnontip(node *, long *, unsigned char *, long ); |
|---|
| 561 | void allocnode(node **, long *, long); |
|---|
| 562 | void allocdiscnode(node **, long *, unsigned char *, long ); |
|---|
| 563 | void gnutreenode(node **, node **, long, long, long *); |
|---|
| 564 | void gnudisctreenode(node **, node **, long , long, long *, |
|---|
| 565 | unsigned char *); |
|---|
| 566 | |
|---|
| 567 | void chucktreenode(node **, node *); |
|---|
| 568 | void setupnode(node *, long); |
|---|
| 569 | long count_sibs (node *); |
|---|
| 570 | void inittrav (node *); |
|---|
| 571 | void commentskipper(FILE ***, long *); |
|---|
| 572 | long countcomma(FILE **, long *); |
|---|
| 573 | long countsemic(FILE **); |
|---|
| 574 | void hookup(node *, node *); |
|---|
| 575 | void link_trees(long, long , long, pointarray); |
|---|
| 576 | void allocate_nodep(pointarray *, FILE **, long *); |
|---|
| 577 | |
|---|
| 578 | void malloc_pheno(node *, long, long); |
|---|
| 579 | void malloc_ppheno(node *, long, long); |
|---|
| 580 | long take_name_from_tree (Char *, Char *, FILE *); |
|---|
| 581 | void match_names_to_data (Char *, pointarray, node **, long); |
|---|
| 582 | void addelement(node **, node *, Char *, long *, FILE *, pointarray, |
|---|
| 583 | boolean *, boolean *, pointarray, long *, long *, boolean *, |
|---|
| 584 | node **, initptr); |
|---|
| 585 | void treeread (FILE *, node **, pointarray, boolean *, boolean *, |
|---|
| 586 | pointarray, long *, boolean *, node **, initptr); |
|---|
| 587 | void addelement2(node *, Char *, long *, FILE *, pointarray, boolean, |
|---|
| 588 | double *, boolean *, long *, long *, long, boolean *); |
|---|
| 589 | void treeread2 (FILE *, node **, pointarray, boolean, double *, |
|---|
| 590 | boolean *, boolean *, long *); |
|---|
| 591 | void exxit (int); |
|---|
| 592 | void countup(long *loopcount, long maxcount); |
|---|
| 593 | char gettc(FILE* file); |
|---|
| 594 | void init(int argc, char** argv); |
|---|
| 595 | #endif /* OLDC */ |
|---|
| 596 | #endif /* _PHYLIP_H_ */ |
|---|