/*****************************************************************************
******************************************************************************
*****                                                                    *****
*****                           RSTYPES.H v1.1                           *****
*****    Copyright (c) 1990 by Joyce C. Miller.  All Rights Reserved.    *****
*****                                                                    *****
***** This header file contains  TYPE DEFINITIONS and SYMBOLIC CONSTANTS *****
***** required by the RESTSITE programs,  which analyze restriction site *****
***** and fragment data.                                                 *****
*****                                                                    *****
******************************************************************************
*****************************************************************************/
/*****************************************************************************
**                            SYMBOLIC CONSTANTS                            **
*****************************************************************************/
#define MAXSTRLEN 255                        /* maximum length of text line */
#define FILELEN   50                       /* maximum length of a file name */
#define PREWORDS  8             /* number of items on line before frag data */
#define IDLEN     9                             /* max. length of ID number */
#define KEYLEN    21                        /* max. length of genus/species */
#define PRBLEN    9                            /* max. length of probe name */
#define ENZLEN    9                           /* max. length of enzyme name */
#define NUMFS     50             /* max # fragments or sites per individual */
#define MAXFS     50        /* max # frags or sites per prb/enz combination */
#define MAXOTU    200                                 /* max # OTUs allowed */
#define MAXPEC    500            /* max # probe/enzyme combinations allowed */
#define MAXRVS    10     /* max # of enzyme classes (diff sized restr sites */
#define TEST      0.000001            /* test value for iterative equations */
#define BOOTSTRAP 200                         /* number of bootstrap cycles */
#define FLLMT     1000  /* maximum number of files made by program WRITETXT */
#define CALCG       sqrt(sqrt(F*(3-2*G1)))        /* function to compute G2 */
#define prbmatch    ((strcmp(t.prb,d.prb)) == NULL)     /* do probes match? */
#define enzmatch    ((strcmp(t.enz,d.enz)) == NULL)    /* do enzymes match? */
#define rvmatch     (t.rv == d.rv)                  /* do site sizes match? */
#define treatmatch  (prbmatch && enzmatch && rvmatch)  /* treatments match? */
/*****************************************************************************
**                            TYPE DEFINITIONS                              **
*****************************************************************************/
/********************* RECORD STRUCTURE FOR THE DATABASE ********************/
typedef struct {                       /* structure that contains all info: */
  char id[IDLEN];                                              /* ID number */
  char key1[KEYLEN];                                       /* sorting key 1 */
  char key2[KEYLEN];                                       /* sorting key 2 */
  char key3[KEYLEN];                                       /* sorting key 3 */
  char key4[KEYLEN];                                       /* sorting key 4 */
  char prb[PRBLEN];                                                /* probe */
  char enz[ENZLEN];                                               /* enzyme */
  float rv;                                     /* size of recognition site */
  float f[NUMFS];                     /* number of fragments or sites found */
} fragdat;                                         /* TOTAL SIZE: 316 bytes */
/*********** RECORD STRUCTURE FOR FRAGMENT/SITE AND ITS FREQUENCY ***********/
typedef struct {      /* structure that holds pooled info about frags/sites */
  float f;                                              /* fragment or site */
  int no;                        /* number of occurrences of that frag/site */
} fragsite;                                          /* TOTAL SIZE: 6 bytes */
/******************* RECORD STRUCTURE FOR THE POOLED DATA *******************/
typedef struct {                    /* structure that contains pooled data: */
  char otu[KEYLEN];                                                  /* OTU */
  char prb[PRBLEN];                                                /* probe */
  char enz[ENZLEN];                                               /* enzyme */
  float rv;                                     /* size of recognition site */
  fragsite fs[MAXFS];         /* info on different fragments or sites found */
  long tn;             /* total number of sites/fragments found in this OTU */
  int ni;                                          /* number of individuals */
} pooldat;                                         /* TOTAL SIZE: 350 bytes */
/******************** RECORD STRUCTURE FOR THE OTU NAMES ********************/
/* List of all of the OTU names found in the datafile(s) */
typedef char otuname[KEYLEN];                       /* TOTAL SIZE: 21 bytes */
/************ RECORD STRUCTURE FOR THE PROBE/ENZYME COMBINATIONS ************/
typedef struct {                       /* structure containing "treatment"  */
  char prb[PRBLEN];                                                /* probe */
  char enz[ENZLEN];                                               /* enzyme */
  float rv;                                     /* size of recognition site */
} treatment;                                        /* TOTAL SIZE: 22 bytes */
/***************** RECORD STRUCTURE FOR THE ENZYME CLASSES ******************/
typedef struct {         /* structure with info for each OTU/OTU comparison */
  float rv;                            /* size of enzyme's recognition site */
  int nt;                         /* # of treatments w/in this enzyme class */
  float xmx;                              /* Within-population Nx for OTU X */
  float xmy;                              /* Within-population Ny for OTU X */
  float xmz;                             /* Within-population Nxy for OTU X */
  float ymx;                              /* Within-population Nx for OTU Y */
  float ymy;                              /* Within-population Ny for OTU Y */
  float ymz;                             /* Within-population Nxy for OTU Y */
  float mx;                                    /* # of frags/sites in OTU X */
  float my;                                    /* # of frags/sites in OTU Y */
  float mz;                                   /* # of frags/sites in common */
} rclass;                                           /* TOTAL SIZE: 42 bytes */
/***** ARRAY TO HOLD m-HAT AND Mxy FOR EACH PEC, FOR USE IN JACK & BOOT *****/
typedef struct {
  float rv;                                         /* r for this treatment */
  float xmxy;                    /* (Mx + My) for within-OTU X for this PEC */
  float xmz;                         /* (Mxy) for within-OTU X for this PEC */
  float ymxy;                    /* (Mx + My) for within-OTU Y for this PEC */
  float ymz;                         /* (Mxy) for within-OTU Y for this PEC */
  float mxy;                  /* (Mx + My) for OTU X vs. OTU Y for this PEC */
  float mz;                       /* (Mxy) for OTU X vs. OTU Y for this PEC */
} bjtrt;                                            /* TOTAL SIZE: 16 bytes */
/***************** TEMPORARY STRUCTURE USED TO HOLD RESULTS *****************/
typedef struct {            /* structure to hold results from both analysis */
  float rv;         /* r for each enzyme class, or "0" for weighted results */
  float xm;    /* for OTU X: m-hat for each enzyme class, or weighted m-hat */
  float ym;    /* for OTU Y: m-hat for each enzyme class, or weighted m-hat */
  float zm;      /* for X-Y: m-hat for each enzyme class, or weighted m-hat */
  float xS;                           /* within-population S or F for OTU X */
  float yS;                           /* within-population S or F for OTU Y */
  float zS;                 /* between-population S or F for X-Y comparison */
  float AS;       /* corrected between-population S or F for X-Y comparison */
  float xSse;      /* standard error for within-population S or F for OTU X */
  float ySse;      /* standard error for within-population S or F for OTU Y */
  float zSse;    /* standard error for between-population S or F for X by Y */
  float ASse;    /* s.e. for corrected between-population S or F for X by Y */
  float xp;                           /* within-population p or d for OTU X */
  float yp;                           /* within-population p or d for OTU Y */
  float zp;                 /* between-population p or d for X-Y comparison */
  float Ap;       /* corrected between-population p or d for X-Y comparison */
  float xpse;      /* standard error for within-population p or d for OTU X */
  float ypse;      /* standard error for within-population p or d for OTU Y */
  float zpse;      /* s.e. for between-population p or d for X-Y comparison */
  float Apse; /* se for corr'd between-population p or d for X-Y comparison */
  float xJC;                          /* within-OTU X Jukes-Cantor distance */
  float yJC;                          /* within-OTU Y Jukes-Cantor distance */
  float zJC;                     /* between-OTU X & Y Jukes-Cantor distance */
  float AJC;           /* corrected between-OTU X & Y Jukes-Cantor distance */
  float xJCse;               /* s.e. for within-OTU X Jukes-Cantor distance */
  float yJCse;               /* s.e. for within-OTU Y Jukes-Cantor distance */
  float zJCse;          /* s.e. for between-OTU X & Y Jukes-Cantor distance */
  float AJCse;  /* se for corrected between-OTU X & Y Jukes-Cantor distance */
  float xNL;                                /* within-OTU X Nei-Li distance */
  float yNL;                                /* within-OTU Y Nei-Li distance */
  float zNL;                           /* between-OTU X & Y Nei-Li distance */
  float ANL;                           /* between-OTU X & Y Nei-Li distance */
  float xNLse;                     /* s.e. for within-OTU X Nei-Li distance */
  float yNLse;                     /* s.e. for within-OTU Y Nei-Li distance */
  float zNLse;                /* s.e. for between-OTU X & Y Nei-Li distance */
  float ANLse;                /* s.e. for between-OTU X & Y Nei-Li distance */
} results;                                         /* TOTAL SIZE: 144 bytes */
/************** STRUCTURE TO HOLD # OF TREATMENTS IN EACH S.E. **************/
typedef struct {
  float xSnt;             /* # treatments that go into the OTU X S-hat s.e. */
  float ySnt;             /* # treatments that go into the OTU Y S-hat s.e. */
  float zSnt;        /* # treatments that go into the OTU X by Y S-hat s.e. */
  float ASnt;         /* # treatments that go into the corrected S-hat s.e. */
  float xpnt;             /* # treatments that go into the OTU X p-hat s.e. */
  float ypnt;             /* # treatments that go into the OTU Y p-hat s.e. */
  float zpnt;        /* # treatments that go into the OTU X by Y p-hat s.e. */
  float Apnt;         /* # treatments that go into the corrected p-hat s.e. */
  float xJCnt;            /* # treatments that go into the OTU X d-hat s.e. */
  float yJCnt;            /* # treatments that go into the OTU Y d-hat s.e. */
  float zJCnt;       /* # treatments that go into the OTU X by Y d-hat s.e. */
  float AJCnt;        /* # treatments that go into the corrected d-hat s.e. */
  float xNLnt;            /* # treatments that go into the OTU X d-hat s.e. */
  float yNLnt;            /* # treatments that go into the OTU Y d-hat s.e. */
  float zNLnt;       /* # treatments that go into the OTU X by Y d-hat s.e. */
  float ANLnt;        /* # treatments that go into the corrected d-hat s.e. */
} bjnt;                                             /* TOTAL SIZE: 64 bytes */
/****************************************************************************/

