1 #ifndef _PHYLIP_H_
2 #define _PHYLIP_H_
3 
4 /* version 3.697.
5    Written by Joseph Felsenstein, Akiko Fuseki, Sean Lamont, Andrew Keeffe,
6    Mike Palczewski, Doug Buxton and Dan Fineman.
7 
8    Copyright (c) 1980-2017, Joseph Felsenstein
9    All rights reserved.
10 
11    Redistribution and use in source and binary forms, with or without
12    modification, are permitted provided that the following conditions are met:
13 
14    1. Redistributions of source code must retain the above copyright notice,
15       this list of conditions and the following disclaimer.
16 
17    2. Redistributions in binary form must reproduce the above copyright notice,
18       this list of conditions and the following disclaimer in the documentation
19       and/or other materials provided with the distribution.
20 
21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31    POSSIBILITY OF SUCH DAMAGE.
32 */
33 
34 #define PHY_VERSION "3.697"
35 
36 /* Debugging options */
37 /* Define this to disable assertions */
38 //#define NDEBUG
39 
40 /* Define this to enable debugging code */
41 /* #define DEBUG */
42 
43 /* machine-specific stuff:
44    based on a number of factors in the library stdlib.h, we will try
45    to determine what kind of machine/compiler this program is being
46    built on.  However, it doesn't always succeed.  However, if you have
47    ANSI conforming C, it will probably work.
48 
49    We will try to figure out machine type
50    based on defines in stdio, and compiler-defined things as well.: */
51 
52 #include <stdio.h>
53 #include <stdlib.h>
54 
55 void ugene_exit(const char* message);
56 
57 
58 namespace U2 {
59 
60     class TaskStateInfo;
61 
62     TaskStateInfo* getTaskInfo();
63     void setTaskInfo(TaskStateInfo* ts);
64 
65     bool isBootstr();
66     void setBootstr(bool bootstr);
67 
68 }
69 
70 
71 #ifdef WIN32
72 #include <windows.h>
73 
74 void phyClearScreen(void);
75 void phySaveConsoleAttributes(void);
76 void phySetConsoleAttributes(void);
77 void phyRestoreConsoleAttributes(void);
78 void phyFillScreenColor(void);
79 
80 
81 #endif
82 
83 #ifdef  GNUDOS
84 #define DJGPP
85 #define DOS
86 #endif
87 
88 #ifdef THINK_C
89 #define MAC
90 #endif
91 #ifdef __MWERKS__
92 #ifndef WIN32
93 #define MAC
94 #endif
95 #endif
96 
97 #ifdef __CMS_OPEN
98 #define CMS
99 #define EBCDIC true
100 #define INFILE "infile data"
101 #define OUTFILE "outfile data"
102 #define FONTFILE "fontfile data"
103 #define PLOTFILE "plotfile data"
104 #define INTREE "intree data"
105 #define INTREE2 "intree data 2"
106 #define OUTTREE "outtree data"
107 #define CATFILE "categories data"
108 #define WEIGHTFILE "weights data"
109 #define ANCFILE "ancestors data"
110 #define MIXFILE "mixture data"
111 #define FACTFILE "factors data"
112 #else
113 #define EBCDIC false
114 #define INFILE "infile"
115 #define OUTFILE "outfile"
116 #define FONTFILE "fontfile" /* on unix this might be /usr/local/lib/fontfile */
117 #define PLOTFILE "plotfile"
118 #define INTREE "intree"
119 #define INTREE2 "intree2"
120 #define OUTTREE "outtree"
121 #define CATFILE "categories"
122 #define WEIGHTFILE "weights"
123 #define ANCFILE "ancestors"
124 #define MIXFILE "mixture"
125 #define FACTFILE "factors"
126 #endif
127 
128 #ifdef L_ctermid            /* try and detect for sysV or V7. */
129 #define SYSTEM_FIVE
130 #endif
131 
132 #ifdef sequent
133 #define SYSTEM_FIVE
134 #endif
135 
136 #ifndef SYSTEM_FIVE
137 #include <stdlib.h>
138 # if defined(_STDLIB_H_) || defined(_H_STDLIB) || defined(H_SCCSID) || defined(unix)
139 # define UNIX
140 # define MACHINE_TYPE "BSD Unix C"
141 # endif
142 #endif
143 
144 
145 #ifdef __STDIO_LOADED
146 #define VMS
147 #define MACHINE_TYPE "VAX/VMS C"
148 #endif
149 
150 #ifdef __WATCOMC__
151 #define QUICKC
152 #define WATCOM
153 #define DOS
154 #include "graph.h"
155 #endif
156 /* watcom-c has graphics library calls that are almost identical to    *
157  * quick-c, so the "QUICKC" symbol name stays.                         */
158 
159 
160 #ifdef _QC
161 #define MACHINE_TYPE "MS-DOS / Quick C"
162 #define QUICKC
163 #include "graph.h"
164 #define DOS
165 #endif
166 
167 #ifdef _DOS_MODE
168 #define MACHINE_TYPE "MS-DOS /Microsoft C "
169 #define DOS           /* DOS is always defined if on a DOS machine */
170 #define MSC           /* MSC is defined for microsoft C              */
171 #endif
172 
173 #ifdef __MSDOS__      /* TURBO c compiler, ONLY (no other DOS C compilers) */
174 #define DOS
175 #define TURBOC
176 #include <stdlib.h>
177 #include <graphics.h>
178 #endif
179 
180 #ifdef DJGPP          /* DJ Delorie's original gnu  C/C++ port */
181 #include <graphics.h>
182 #endif
183 
184 #ifndef MACHINE_TYPE
185 #define MACHINE_TYPE "ANSI C"
186 #endif
187 
188 #ifdef DOS
189 #define MALLOCRETURN void
190 #else
191 #define MALLOCRETURN void
192 #endif
193 #ifdef VMS
194 #define signed /* signed doesn't exist in VMS */
195 #endif
196 
197 /* default screen types */
198 /*  if on a DOS but not a Windows system can use IBM PC screen controls */
199 #ifdef DOS
200 #ifndef WIN32
201 #define IBMCRT true
202 #define ANSICRT false
203 #endif
204 #endif
205 /*  if on a Mac cannot use screen controls */
206 #ifdef MAC
207 #define IBMCRT false
208 #define ANSICRT false
209 #endif
210 /*  if on a Windows system can use IBM PC screen controls */
211 #ifdef WIN32
212 #define IBMCRT true
213 #define ANSICRT false
214 #endif
215 /* otherwise, let's assume we are on a Linux or Unix system
216    with ANSI terminal controls */
217 #ifndef MAC
218 #ifndef DOS
219 #ifndef WIN32
220 #define IBMCRT false
221 #define ANSICRT true
222 #endif
223 #endif
224 #endif
225 
226 #ifdef DJGPP
227 #undef MALLOCRETURN
228 #define MALLOCRETURN void
229 #endif
230 
231 
232 /* includes: */
233 #ifdef UNIX
234 #include <strings.h>
235 #else
236 #include <string.h>
237 #endif
238 
239 #include <assert.h>
240 #include <math.h>
241 #include <ctype.h>
242 
243 /* folder delimiters */
244 #ifdef MAC
245 #define DELIMITER ':'
246 #else
247 #ifdef WIN32
248 #define DELIMITER '\\'
249 #else
250 #define DELIMITER '/'
251 #endif
252 #endif
253 
254 
255 #define FClose(file) if (file) fclose(file) ; file=NULL
256 #define Malloc(x) mymalloc((long)x)
257 
258 typedef void *Anyptr;
259 //Does not compile with Qt4.6.x : #define Signed     signed
260 #define Const     const
261 #define Volatile  volatile
262 #define Phylip_Char        char      /* Characters (not bytes) */
263 #define Static     static     /* Private global funcs and vars */
264 #define Local      static     /* Nested functions */
265 
266 typedef unsigned char boolean;
267 
268 #ifdef _MSC_VER
269 #  if _MSC_VER < 1900
270 #    define true    1
271 #    define false   0
272 #  endif
273 #else
274 #  define true    1
275 #  define false   0
276 #endif
277 
278 
279 /* Number of items per machine word in set.
280  * Used in consensus programs and clique */
281 #define SETBITS 31
282 
283 MALLOCRETURN    *mymalloc(long);
284 
285 /*** UI behavior ***/
286 
287 /* Set to 1 to not ask before overwriting files */
288 #define OVERWRITE_FILES 0
289 
290 /*** Static memory parameters ***/
291 
292 #define FNMLNGTH        200  /* length of array to store a file name */
293 #define nmlngth         20   /* number of characters in species name    */
294 #define MAXNCH          30   /* must be greater than or equal to nmlngth */
295 #define maxcategs       9    /* maximum number of site types */
296 #define maxcategs2     11    /* maximum number of site types + 2 */
297 #define pointe          '.'
298 #define down            2
299 #define MAXSHIMOTREES 100
300 
301 /*** Maximum likelihood parameters ***/
302 
303 
304 /* Used in proml, promlk, dnaml, dnamlk, etc. */
305 #define UNDEFINED 1.0           /* undefined or invalid likelihood */
306 #define smoothings      4       /* number of passes through smoothing algorithm */
307 #define iterations      8       /* number of iterates for each branch           */
308 #define phylip_epsilon         0.0001  /* small number used in makenewv */
309 #define EPSILON         0.00001 /* small number used in hermite root-finding */
310 #define initialv        0.1     /* starting branch length unless otherwise */
311 #define INSERT_MIN_TYME 0.0001  /* Minimum tyme between nodes during inserts */
312 #define over            60      /* maximum width all branches of tree on screen */
313 #define LIKE_EPSILON    1e-10   /* Estimate of round-off error in likelihood
314                                  * calculations. */
315 
316 /*** Math constants ***/
317 
318 #define SQRTPI 1.7724538509055160273
319 #define SQRT2  1.4142135623730950488
320 
321 /*** Rearrangement parameters ***/
322 
323 #define NLRSAVES 5 /* number of views that need to be saved during local  *
324                     * rearrangement                                       */
325 
326 /*** Output options ***/
327 
328 /* Number of significant figures to display in numeric output */
329 #define PRECISION               6
330 
331 /* Maximum line length of matrix output - 0 for unlimited */
332 #define OUTPUT_TEXTWIDTH        78
333 
334 /** output_matrix() flags **/
335 
336 /* Block output: Matrices are vertically split into blocks that
337  * fit within OUTPUT_TEXTWIDTH columns */
338 #define MAT_BLOCK       0x1
339 /* Lower triangle: Values on or above the diagonal are not printed */
340 #define MAT_LOWER       0x2
341 /* Print a border between headings and data */
342 #define MAT_BORDER      0x4
343 /* Do not print the column header */
344 #define MAT_NOHEAD      0x8
345 /* Output the number of columns before the matrix */
346 #define MAT_PCOLS       0x10
347 /* Do not enforce maximum line width */
348 #define MAT_NOBREAK     0x20
349 /* Pad row header with spaces to 10 char */
350 #define MAT_PADHEAD     0x40
351 /* Human-readable format. */
352 #define MAT_HUMAN       MAT_BLOCK
353 /* Machine-readable format. */
354 #define MAT_MACHINE     (MAT_PCOLS | MAT_NOHEAD | MAT_PADHEAD)
355 /* Lower-triangular format. */
356 #define MAT_LOWERTRI    (MAT_LOWER | MAT_MACHINE)
357 
358 typedef long *steptr;
359 typedef long longer[6];
360 typedef char naym[MAXNCH];
361 typedef long *bitptr;
362 typedef double raterootarray[maxcategs2][maxcategs2];
363 
364 typedef struct bestelm {
365   long *btree;
366   boolean gloreange;
367   boolean locreange;
368   boolean collapse;
369 } bestelm;
370 
371 extern FILE *infile, *outfile,  *intree, *intree2, *outtree,
372     *weightfile, *catfile, *ancfile, *mixfile, *factfile;
373 extern long spp, words, bits;
374 extern boolean ibmpc, ansi, tranvsp;
375 extern naym *nayme;                     /* names of species */
376 
377 #define ebcdic          EBCDIC
378 
379 typedef Phylip_Char plotstring[MAXNCH];
380 
381 /* Approx. 1GB, used to test for memory request errors */
382 #define TOO_MUCH_MEMORY 1000000000
383 
384 
385 /* The below pre-processor commands define the type used to store
386    group arrays.  We can't use #elif for metrowerks, so we use
387    cascaded if statements */
388 #include <limits.h>
389 
390 /* minimum double we feel safe with, anything less will be considered
391    underflow */
392 #define MIN_DOUBLE 10e-100
393 
394 /* K&R says that there should be a plus in front of the number, but no
395    machine we've seen actually uses one; we'll include it just in
396    case. */
397 #define MAX_32BITS        2147483647
398 #define MAX_32BITS_PLUS  +2147483647
399 
400 /* If ints are 4 bytes, use them */
401 #if INT_MAX == MAX_32BITS
402 typedef int  group_type;
403 
404 #else
405      #if INT_MAX == MAX_32BITS_PLUS
406      typedef int  group_type;
407 
408      #else
409           /* Else, if longs are 4 bytes, use them */
410           #if LONG_MAX == MAX_32BITS
411           typedef long group_type;
412 
413           #else
414                #if LONG_MAX == MAX_32BITS_PLUS
415                 typedef long group_type;
416 
417                /* Default to longs */
418                #else
419                     typedef long group_type;
420                #endif
421 
422           #endif
423      #endif
424 #endif
425 
426 /* for many programs */
427 
428 #define maxuser         1000  /* maximum number of user-defined trees    */
429 
430 typedef Phylip_Char **sequence;
431 
432 typedef enum {
433   A, C, G, T, O
434 } bases;
435 
436 bases& operator++(bases& b, int);  // int denotes postfix++
437 
438 typedef enum {
439   alanine, arginine, asparagine, aspartic, cysteine,
440   glutamine, glutamic, glycine, histidine, isoleucine,
441   leucine, lysine, methionine, phenylalanine, proline,
442   serine, threonine, tryptophan, tyrosine, valine
443 } acids;
444 
445 /* for Pars */
446 
447 typedef enum {
448   zero = 0, one, two, three, four, five, six, seven
449 } discbases;
450 
451 /* for Protpars */
452 
453 typedef enum {
454   ala, arg, asn, asp, cys, gln, glu, gly, his, ileu, leu, lys, met, phe, pro,
455   ser1, ser2, thr, trp, tyr, val, del, stop, asx, glx, ser, unk, quest
456 } aas;
457 
458 typedef double sitelike[(long)T - (long)A + 1];   /* used in dnaml, dnadist */
459 typedef double psitelike[(long)valine - (long)alanine + 1];
460                              /* used in proml                                    */
461 
462 typedef long *baseptr;       /* baseptr used in dnapars, dnacomp & dnapenny */
463 typedef long *baseptr2;      /* baseptr used in dnamove                     */
464 typedef unsigned char *discbaseptr;         /* discbaseptr used in pars     */
465 typedef sitelike *ratelike;                    /* used in dnaml ...            */
466 typedef psitelike *pratelike;                    /* used in proml                    */
467 typedef ratelike *phenotype;    /* phenotype used in dnaml, dnamlk, dnadist */
468 typedef pratelike *pphenotype;  /* phenotype used in proml                    */
469 typedef double *sitelike2;
470 typedef sitelike2 *phenotype2;              /* phenotype2 used in restml    */
471 typedef double *phenotype3;                 /* for continuous char programs */
472 
473 typedef double *vector;                     /* used in distance programs    */
474 
475 typedef long nucarray[(long)O - (long)A + 1];
476 typedef long discnucarray[(long)seven - (long)zero + 1];
477 
478 typedef enum { nocollap, tocollap, undefined } collapstates;
479 
480 typedef enum { bottom, nonbottom, hslength, tip, iter, length,
481                  hsnolength, treewt, unittrwt } initops;
482 
483 
484 typedef double **transmatrix;
485 typedef transmatrix *transptr;                /* transptr used in restml */
486 
487 typedef long sitearray[3];
488 typedef sitearray *seqptr;                    /* seqptr used in protpars */
489 
490 typedef struct node {
491   struct node *next, *back;
492   plotstring nayme;
493   long naymlength, tipsabove, index;
494   double times_in_tree;            /* Previously known as cons_index */
495   double xcoord, ycoord;
496   long long_xcoord, long_ycoord;         /* for use in cons.               */
497   double oldlen, length, r, theta, oldtheta, width, depth,
498          tipdist, lefttheta, righttheta;
499   group_type *nodeset;                   /* used by accumulate      -plc   */
500   long ymin, ymax;                       /* used by printree        -plc   */
501   boolean haslength;               /* haslength used in dnamlk             */
502   boolean iter;                    /* iter used in dnaml, fitch & restml   */
503   boolean initialized;             /* initialized used in dnamlk & restml  */
504   long branchnum;                  /* branchnum used in restml             */
505   phenotype x;                     /* x used in dnaml, dnamlk, dnadist     */
506   phenotype2 x2;                   /* x2 used in restml                    */
507   phenotype3 view;                 /* contml etc                           */
508   pphenotype protx;                /* protx used in proml */
509   aas *seq;                  /* the sequence used in protpars              */
510   seqptr siteset;            /* temporary storage for aa's used in protpars*/
511   double v, deltav, ssq;       /* ssq used only in contrast                */
512   double bigv;                 /* bigv used in contml                      */
513   double tyme, oldtyme;        /* used in dnamlk                           */
514   double t;                    /* time in kitsch                           */
515   boolean sametime;            /* bookkeeps scrunched nodes in kitsch      */
516   double weight;               /* weight of node used by scrunch in kitsch */
517   boolean processed;           /* used by evaluate in kitsch               */
518   boolean deleted;        /* true if node is deleted (retree)              */
519   boolean hasname;        /* true if tip has a name (retree)               */
520   double beyond;          /* distance beyond this node to most distant tip */
521                             /* (retree) */
522   boolean deadend;          /* true if no undeleted nodes beyond this node */
523                             /* (retree) */
524   boolean onebranch;        /* true if there is one undeleted node beyond  */
525                             /* this node (retree)                          */
526   struct node *onebranchnode;
527                             /* if there is, a pointer to that node (retree)*/
528   double onebranchlength;   /* if there is, the distance from here to there*/
529                                 /* (retree)                                */
530   boolean onebranchhaslength;   /* true if there is a valid combined length*/
531                                  /* from here to there (retree)            */
532   collapstates collapse;         /* used in dnapars & dnacomp              */
533   boolean tip;
534   boolean bottom;                /* used in dnapars & dnacomp, disc char   */
535   boolean visited;               /* used in dnapars & dnacomp  disc char   */
536   baseptr base;                  /* the sequence in dnapars/comp/penny     */
537   discbaseptr discbase;          /* the sequence in pars                   */
538   baseptr2 base2;                /* the sequence in dnamove                */
539   baseptr oldbase;               /* record previous sequence               */
540   discbaseptr olddiscbase;       /* record previous sequence               */
541   long numdesc;                  /* number of immediate descendants        */
542   nucarray *numnuc;              /* bookkeeps number of nucleotides        */
543   discnucarray *discnumnuc;      /* bookkeeps number of nucleotides        */
544   steptr numsteps;               /* bookkeeps steps                        */
545   steptr oldnumsteps;            /* record previous steps                  */
546   double sumsteps;               /* bookkeeps sum of steps                 */
547   nucarray cumlengths;           /* bookkeeps cummulative minimum lengths  */
548   discnucarray disccumlengths;   /* bookkeeps cummulative minimum lengths  */
549   nucarray numreconst;           /* bookkeeps number of  reconstructions   */
550   discnucarray discnumreconst;   /* bookkeeps number of  reconstructions   */
551   vector d, w;                   /* for distance matrix programs           */
552   double dist;                   /* dist used in fitch                     */
553   bitptr stateone, statezero;    /* discrete char programs                 */
554   long maxpos;                   /* maxpos used in Clique                  */
555   Phylip_Char state;                    /* state used in Dnamove, Dolmove & Move  */
556   double* underflows;            /* used to record underflow               */
557 } node;
558 
559 typedef node **pointarray;
560 
561 
562 /*** tree structure ***/
563 
564 typedef struct tree {
565 
566   /* An array of pointers to nodes. Each tip node and ring of nodes has a
567    * unique index starting from one. The nodep array contains pointers to each
568    * one, starting from 0. In the case of internal nodes, the entries in nodep
569    * point to the rootward node in the group. Since the trees are otherwise
570    * entirely symmetrical, except at the root, this is the only way to resolve
571    * parent, child, and sibling relationships.
572    *
573    * Indices in range [0, spp) point to tips, while indices [spp, nonodes)
574    * point to fork nodes
575    */
576   pointarray nodep;
577 
578   /* A pointer to the first node. Typically, root is used when the tree is rooted,
579    * and points to an internal node with no back link. */
580   node *root;
581 
582   /* start is used when trees are unrooted. It points to an internal node whose
583    * back link typically points to the outgroup leaf. */
584   node *start;
585 
586   /* In maximum likelihood programs, the most recent evaluation is stored here */
587   double likelihood;
588 
589   /* Branch transition matrices for restml */
590   transptr trans;                 /* all transition matrices */
591   long *freetrans;                /* an array of indexes of free matrices */
592   long transindex;                /* index of last valid entry in freetrans[] */
593 } tree;
594 
595 typedef void (*initptr)(node **, node **, node *, long, long,
596                          long *, long *, initops, pointarray,
597                          pointarray, Phylip_Char *, Phylip_Char *, FILE *);
598 
599 
600 #ifndef OLDC
601 /* function prototypes */
602 void   scan_eoln(FILE *);
603 boolean    eoff(FILE *);
604 boolean    eoln(FILE *);
605 int    filexists(char *);
606 const char*  get_command_name (const char *);
607 void   EOF_error(void);
608 void   getstryng(char *);
609 void   openfile(FILE **,const char *,const char *,const char *,const char *,
610                 char *);
611 void   cleerhome(void);
612 void   loopcount(long *, long);
613 double randum(longer);
614 void   randumize(longer, long *);
615 double normrand(longer);
616 long   readlong(const char *);
617 
618 void   uppercase(Phylip_Char *);
619 void   initseed(long *, long *, longer);
620 void   initjumble(long *, long *, longer, long *);
621 void   initoutgroup(long *, long);
622 void   initthreshold(double *);
623 void   initcatn(long *);
624 void   initcategs(long, double *);
625 void   initprobcat(long, double *, double *);
626 double logfac (long);
627 double halfroot(double (*func)(long , double), long, double, double);
628 double hermite(long, double);
629 void initlaguerrecat(long, double, double *, double *);
630 void   root_hermite(long, double *);
631 void   hermite_weight(long, double *, double *);
632 void   inithermitcat(long, double, double *, double *);
633 void   lgr(long, double, raterootarray);
634 double glaguerre(long, double, double);
635 void   initgammacat(long, double, double *, double *);
636 void   inithowmany(long *, long);
637 void   inithowoften(long *);
638 
639 void   initlambda(double *);
640 void   initfreqs(double *, double *, double *, double *);
641 void   initratio(double *);
642 void   initpower(double *);
643 void   initdatasets(long *);
644 void   justweights(long *);
645 void   initterminal(boolean *, boolean *);
646 void   initnumlines(long *);
647 void   initbestrees(bestelm *, long, boolean);
648 void   newline(FILE *, long, long, long);
649 
650 void   inputnumbers(long *, long *, long *, long);
651 void   inputnumbersold(long *, long *, long *, long);
652 void   inputnumbers2(long *, long *, long n);
653 void   inputnumbers3(long *, long *);
654 void   samenumsp(long *, long);
655 void   samenumsp2(long);
656 void   readoptions(long *, const char *);
657 void   matchoptions(Phylip_Char *, const char *);
658 void   inputweights(long, steptr, boolean *);
659 void   inputweightsold(long, steptr, boolean *);
660 void   inputweights2(long, long, long *, steptr, boolean *, const char *);
661 void   printweights(FILE *, long, long, steptr, const char *);
662 
663 void   inputcategs(long, long, steptr, long, const char *);
664 void   printcategs(FILE *, long, steptr, const char *);
665 void   inputfactors(long, Phylip_Char *, boolean *);
666 void   inputfactorsnew(long, Phylip_Char *, boolean *);
667 void   printfactors(FILE *, long, Phylip_Char *, const char *);
668 void   headings(long, const char *, const char *);
669 void   initname(long);
670 void   findtree(boolean *,long *,long,long *,bestelm *);
671 void   addtree(long,long *,boolean,long *,bestelm *);
672 long   findunrearranged(bestelm *, long, boolean);
673 boolean torearrange(bestelm *, long);
674 
675 void   reducebestrees(bestelm *, long *);
676 void   shellsort(double *, long *, long);
677 void   getch(Phylip_Char *, long *, FILE *);
678 void   getch2(Phylip_Char *, long *);
679 void   findch(Phylip_Char, Phylip_Char *, long);
680 void   findch2(Phylip_Char, long *, long *, Phylip_Char *);
681 void   findch3(Phylip_Char, Phylip_Char *, long, long);
682 void   processlength(double *,double *,Phylip_Char *,boolean *,FILE *,long *);
683 void   writename(long, long, long *);
684 void   memerror(void);
685 
686 void   odd_malloc(long);
687 
688 void   gnu(node **, node **);
689 void   chuck(node **, node *);
690 void   zeronumnuc(node *, long);
691 void   zerodiscnumnuc(node *, long);
692 void   allocnontip(node *, long *, long);
693 void   allocdiscnontip(node *, long *, unsigned char *, long );
694 void   allocnode(node **, long *, long);
695 void   allocdiscnode(node **, long *, unsigned char *, long );
696 void   gnutreenode(node **, node **, long, long, long *);
697 void   gnudisctreenode(node **, node **, long , long, long *,
698                 unsigned char *);
699 
700 void   setupnode(node *, long);
701 node * pnode(tree *t, node *p);
702 long   count_sibs (node *);
703 void   inittrav (node *);
704 void   commentskipper(FILE ***, long *);
705 long   countcomma(FILE **, long *);
706 long   countsemic(FILE **);
707 void   hookup(node *, node *);
708 void   unhookup(node *, node *);
709 void   link_trees(long, long , long, pointarray);
710 void   allocate_nodep(pointarray *, FILE **, long  *);
711 
712 void   malloc_pheno(node *, long, long);
713 void   malloc_ppheno(node *, long, long);
714 long   take_name_from_tree (Phylip_Char *, Phylip_Char *, FILE *);
715 void   match_names_to_data (Phylip_Char *, pointarray, node **, long);
716 void   addelement(node **, node *, Phylip_Char *, long *, FILE *, pointarray,
717                 boolean *, boolean *, pointarray, long *, long *, boolean *,
718                 node **, initptr,boolean,long);
719 void   treeread (FILE *, node **, pointarray, boolean *, boolean *,
720                 pointarray, long *, boolean *, node **, initptr,boolean,long);
721 void   addelement2(node *, Phylip_Char *, long *, FILE *, pointarray, boolean,
722                 double *, boolean *, long *, long *, long, boolean *,boolean,
723                 long);
724 void   treeread2 (FILE *, node **, pointarray, boolean, double *,
725                 boolean *, boolean *, long *,boolean,long);
726 void   exxit (int);
727 void countup(long *loopcount, long maxcount);
728 char gettc(FILE* file);
729 void unroot_r(node* p,node ** nodep, long nonodes);
730 void unroot(tree* t,long nonodes);
731 void unroot_here(node* root, node** nodep, long nonodes);
732 void clear_connections(tree *t, long nonodes);
733 void init(int argc, char** argv);
734 char **stringnames_new(void);
735 void stringnames_delete(char **names);
736 int fieldwidth_double(double val, unsigned int precision);
737 void output_matrix_d(FILE *fp, double **matrix,
738     unsigned long rows, unsigned long cols,
739     char **row_head, char **col_head, int flags);
740 void debugtree (tree *, FILE *);
741 void debugtree2 (pointarray, long, FILE *);
742 #endif /* OLDC */
743 #endif /* _PHYLIP_H_ */
744