home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / SeqPups / apps / fastdnaml.src / fastDNAml_1_0.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  6.4 KB  |  180 lines  |  [TEXT/R*ch]

  1. /*  fastDNAml_1_0.h  */
  2.  
  3. #ifndef dnaml_h
  4.  
  5. /*  Compile time switches for various updates to program:
  6.  *    0 gives original version
  7.  *    1 gives new version
  8.  */
  9.  
  10. #define ReturnSmoothedView    1  /* Propagate changes back after smooth */
  11. #define BestInsertAverage     1  /* Build three taxon tree analytically */
  12. #define DeleteCheckpointFile  0  /* Remove checkpoint file when done */
  13.  
  14. #define Debug                 0
  15.  
  16. /* dgg addition */
  17. #include <time.h>
  18. #define TIMER(x)            clock(x)
  19. #ifndef CLOCKS_PER_SEC
  20.     /* ?? microseconds default for unix clock() ???? */
  21. #define CLOCKS_PER_SEC     1000000.0
  22. #endif
  23. #define TIMETOSECS(time)     (double)(time) / (double)(CLOCKS_PER_SEC) 
  24.  
  25. #ifdef __MWERKS__
  26. /* Macintosh MetroWerks CodeWarrior flags */
  27. #define SmallMemorySystem           /* for Mac/CodeWar, can't have >32k local data */
  28. #define NoSTDIN                    /* mimic for stdin/stdout package has broken stdin */
  29. #define HasStrLib                /* for Mac/CodeWar, has strstr, strchr */
  30. #endif
  31.  
  32. #ifdef MSDOS
  33. #define SmallMemorySystem
  34. #define NoSTDIN
  35. #endif
  36.  
  37.  
  38. /*  Program constants and parameters  */
  39.  
  40. #define maxsp          150  /* maximum number of species */
  41. #define maxsites      6400  /* maximum number of sites */
  42. #define maxpatterns   4800  /* maximum number of different site patterns */
  43. #define maxcategories   35  /* maximum number of site types */
  44. #define maxkeep          1  /* maximum number of user trees */
  45. #define maxlogf    maxkeep  /* maximum number of user trees */
  46. #define smoothings      32  /* maximum smoothing passes through tree */
  47. #define iterations      10  /* maximum iterations of makenewz per insert */
  48. #define newzpercycle     1  /* iterations of makenewz per tree traversal */
  49. #define nmlngth         10  /* number of characters in species name */
  50. #define deltaz     0.00001  /* test of net branch length change in update */
  51. #define zmin       1.0E-15  /* max branch prop. to -log(zmin) (= 34) */
  52. #define zmax (1.0 - 1.0E-6) /* min branch prop. to 1.0-zmax (= 1.0E-6) */
  53. #define defaultz       0.9  /* value of z assigned as starting point */
  54. #define unlikely  -1.0E300  /* low likelihood for initialization */
  55. #define down             2
  56. #define over            60
  57. #define decimal_point   '.'
  58. #define checkpointname "checkpoint"
  59.  
  60. #ifndef TRUE
  61. #define TRUE             1
  62. #endif
  63. #ifndef FALSE
  64. #define FALSE            0
  65. #endif
  66.  
  67. #define ABS(x)    (((x)<0)   ? (-(x)) : (x))
  68. #define MIN(x,y)  (((x)<(y)) ?   (x)  : (y))
  69. #define MAX(x,y)  (((x)>(y)) ?   (x)  : (y))
  70. #define LOG(x)    (((x)>0)   ? log(x) : hang("log domain error"))
  71. #define nint(x)   ((int) ((x)>0 ? ((x)+0.5) : ((x)-0.5)))
  72. #define aint(x)   ((double) ((int) (x)))
  73.  
  74.  
  75. typedef  int  boolean;
  76. typedef  int  longer[6];
  77.  
  78. typedef  double  xtype;
  79.  
  80. typedef  struct  xmantyp {
  81.     struct xmantyp  *prev;
  82.     struct xmantyp  *next;
  83.     struct noderec  *owner;
  84.     xtype           *a, *c, *g, *t;
  85.     } xarray;
  86.  
  87. typedef  struct noderec {
  88.     double           z, z0;
  89.     struct noderec  *next;
  90.     struct noderec  *back;
  91.     int              number;
  92.     xarray          *x;
  93.     int              xcoord, ycoord, ymin, ymax;
  94.     char             name[nmlngth+1]; /*  Space for null termination  */
  95.     char            *tip;             /*  Pointer to sequence data  */
  96.     } node, *nodeptr;
  97.  
  98. typedef  struct {
  99.     double           likelihood;
  100.     double           log_f[maxpatterns]; /* info for signif. of trees */
  101.     node            *nodep[2*maxsp];  /* one extra node for tree reading */
  102.     node            *start;
  103.     node            *outgrnode;
  104.     int              mxtips;
  105.     int              ntips;
  106.     int              nextnode;
  107.     int              opt_level;
  108.     int              log_f_valid; /* log_f value sites */
  109.     int              global;      /* branches to cross in full tree */
  110.     int              partswap;    /* branches to cross in partial tree */
  111.     int              outgr;       /* sequence number to use in rooting tree */
  112.     boolean          smoothed;
  113.     boolean          rooted;
  114.     boolean          userlen;     /* use user-supplied branch lengths */
  115.     boolean          usertree;    /* use user-supplied trees */
  116.     boolean          userwgt;     /* use user-supplied position weight mask */
  117.     } tree;
  118.  
  119. typedef struct conntyp {
  120.     double           z;           /* branch length */
  121.     node            *p, *q;       /* parent and child sectors */
  122.     void            *valptr;      /* pointer to value of subtree */
  123.     int              descend;     /* pointer to first connect of child */
  124.     int              sibling;     /* next connect from same parent */
  125.     } connect, *connptr;
  126.  
  127. typedef  struct {
  128.     double           likelihood;
  129.     double          *log_f;       /* info for signif. of trees */
  130.     connect         *links;       /* pointer to first connect (start) */
  131.     node            *start;
  132.     int              nextlink;    /* index of next available connect */
  133.                                   /* tr->start = tpl->links->p */
  134.     int              ntips;
  135.     int              nextnode;
  136.     int              opt_level;   /* degree of branch swapping explored */
  137.     int              scrNum;      /* position in sorted list of scores */
  138.     int              tplNum;      /* position in sorted list of trees */
  139.     int              log_f_valid; /* log_f value sites */
  140.     boolean          smoothed;    /* branch optimization converged? */
  141.     } topol;
  142.  
  143. typedef struct {
  144.     double           best;        /* highest score saved */
  145.     double           worst;       /* lowest score saved */
  146.     topol           *start;       /* starting tree for optimization */
  147.     topol           *byScore[maxkeep+1];
  148.     topol           *byTopol[maxkeep+1];
  149.     int              nkeep;       /* maximum topologies to save */
  150.     int              nvalid;      /* number of topologies saved */
  151.     int              ninit;       /* number of topologies initialized */
  152.     int              numtrees;    /* number of alternatives tested */
  153.     boolean          improved;
  154.     } bestlist;
  155.  
  156. typedef  struct {
  157.     double           tipmax;
  158.     int              tipy;
  159.     } drawdata;
  160.  
  161. void  exit();
  162.  
  163. char *strstr();  /* Not needed starting with version 1.0.5 */
  164. char *strchr();  /* Not needed starting with version 1.0.5 */
  165. char *index();   /* Not needed starting with version 1.0.5 */
  166.  
  167. #if  ANSI
  168.    void *malloc();
  169. #else
  170.    char *malloc();
  171. #endif
  172.  
  173. char *likelihood_key   = "likelihood";
  174. char *ntaxa_key        = "ntaxa";
  175. char *opt_level_key    = "opt_level";
  176. char *smoothed_key     = "smoothed";
  177.  
  178. #define dnaml_h
  179. #endif  /* #if undef dnaml_h */
  180.