1 // $Id: constants.h,v 1.106 2012/04/26 23:54:36 ewalkup Exp $
2 
3 /*
4   Copyright 2002 Peter Beerli, Mary Kuhner, Jon Yamato and Joseph Felsenstein
5 
6   This software is distributed free of charge for non-commercial use
7   and is copyrighted.  Of course, we do not guarantee that the software
8   works, and are not responsible for any damage you may cause or have.
9 */
10 
11 #ifndef CONSTANTS_H
12 #define CONSTANTS_H
13 
14 // Defines various symbols used to control debugging of experimental code blocks.
15 #include "local_build.h"
16 
17 #include <string>
18 #include "definitions.h"
19 
20 using std::string;
21 
22 /***************************************************************
23   This file contains constants which control the behavior of
24 the program.  They are divided into sections:
25 
26 (1)  Constants which the user may wish to change, in order
27      to adapt the program to his/her needs
28 (2)  Debugging constants which the user should probably not
29      change unless sure of his/her reasons
30 (3)  Internal constants which should not be changed at all
31 (4)  The tag library (relating tags to literals) which should
32      not be changed except to translate the program to a
33      different language
34 
35 If you change anything in this file you must 'make clean' the
36 entire project.  Unix Make utilities may not think you need to
37 go so far; but they lie.
38 
39 ****************************************************************/
40 
41 class Registry;
42 
43 extern Registry registry;
44 
45 //------------------------------------------------------------------------------------
46 //  User-changable constants
47 //------------------------------------------------------------------------------------
48 
49 // Only for Metrowerks compiles, see Makefile for other platforms
50 // If you do not want to use the menu at all, set this constant
51 // to 0.  The program will then read from 'infile' and
52 // write to 'outfile' and no menu will be displayed.  Be sure
53 // that all necessary information is present in 'infile' if
54 // you use this option.
55 #ifdef __MWERKS__
56 #define MENU 1
57 #endif
58 
59 // Enumerations
60 enum verbosity_type {CONCISE, NORMAL, VERBOSE, NONE};
61 enum paramlistcondition { paramlist_YES, paramlist_MIX, paramlist_NO };
62 enum likelihoodtype { ltype_ssingle, ltype_replicate, ltype_region,
63                       ltype_gammaregion };
64 enum proftype { profile_PERCENTILE, profile_FIX, profile_NONE };
65 enum noval {noval_none}; //used when I need a null instantiation for a template
66 
67 // if you edit model_type, also edit numPossibleDataModels and allDataModels()
68 // in defaults.cpp
69 enum model_type {F84,Brownian,Stepwise,KAllele,GTR,MixedKS};
70 enum method_type {method_PROGRAMDEFAULT, method_USER, method_FST, method_WATTERSON};
71 enum priortype {LINEAR, LOGARITHMIC};
72 enum force_type { force_COAL, force_MIG, force_DISEASE, force_REC,
73                   force_GROW, force_REGION_GAMMA, force_EXPGROWSTICK,
74                   force_LOGISTICSELECTION, force_LOGSELECTSTICK, force_DIVERGENCE,
75                   force_DIVMIG, force_NONE };
76 
77 enum pstatus { pstat_invalid, pstat_unconstrained, pstat_constant, pstat_identical, pstat_identical_head,
78                pstat_multiplicative, pstat_multiplicative_head };
79 /* Invalid--nonexistant parameter such as diagonal migration value
80    Unconstrained--ordinary parameter
81    Constant--constrained to constant value
82    Identical_head--first member of group constrained to be identical (in ParamVec order)
83    Identical--any other member of group constrained to be identical
84    Multiplicative_head--first member of multiplicative group
85    Multiplicative--any other member of multiplicative group
86    Epochtime--boundary time of an epoch (handled specially because can't be Bayes-arranged)
87 */
88 /* Deleted (for now?) pstatus values:  valid, symmetricNm, symmetricM
89    (use 'mean' instead of symmetricM, 'standard' instead of valid, and don't
90    use symmetricNm unless we allow our general migration model to vary based
91    on population size.
92 */
93 
94 enum growth_type {growth_CURVE, growth_STICK, growth_STICKEXP};
95 enum growth_scheme {growth_EXP, growth_STAIRSTEP};
96 enum selection_type {selection_DETERMINISTIC, selection_STOCHASTIC};
97 
98 // for marking study samples vs panel sources
99 enum data_source {dsource_study, dsource_panel };
100 
101 
102 //---------------------------------------------------------------
103 // Debugging constants
104 // (you had better know what you are doing before changing any of
105 // these)
106 //---------------------------------------------------------------
107 
108 // When STATIONARIES is true, the program will run without use of
109 // data, producing a report of the stationary distribution of the sampler
110 // This is a useful debugging tool and can also be used to obtain
111 // stationaries of otherwise difficult distributions via Monte Carlo.
112 // NEVER turn this on if you mean to analyze your data--it will
113 // cause the data to be totally ignored!
114 #ifdef STATIONARIES
115 const string INTERVALFILE = "interval.out";
116 const string MIGFILE = "migcount";
117 const string DISFILE = "discount";
118 const string RECFILE = "reccount";
119 const string DISRECFILE = "disreccount";
120 const string SELECTFILE = "selectstuff";
121 const string EPOCHFILE = "epochtimes";
122 #endif // STATIONARIES
123 
124 #ifdef LAMARC_QA_SINGLE_DENOVOS
125 // When LAMARC_QA_SINGLE_DENOVOS is true, the program generates
126 // a slew of denovo trees and calculates the likely parameter
127 // values of each separately. See lamarc/config/local_build.h
128 // for more info
129 const std::string SINGLE_DENOVO_INFO = "denovo_info.txt";
130 const std::string SINGLE_DENOVO_FILE = "denovo_params.txt";
131 #endif // LAMARC_QA_SINGLE_DENOVOS
132 
133 // When true, track data likelihoods into file 'like1'
134 #define LIKETRACK 0
135 
136 //---------------------------------------------------------------
137 //  Internal program constants
138 //  (you had better know *exactly* what you are doing if you
139 //  change any of these--the program may not survive)
140 //---------------------------------------------------------------
141 
142 const double MAX_LENGTH = 200.0;     // maximum branch length
143                                      // this must be less than
144                                      // DBL_MAX because of use in
145                                      // Active/InactiveStairStickCoal
146                                      // events.
147 
148 const long BASEBRANCH_NSITES = 3L;   // the number of sites that
149                                      // the base branch in a timelist
150                                      // will represent...this value
151                                      // should never be used in
152                                      // any calculations (and so can be
153                                      // any integer greater than 1).
154 
155 const long BASES = 4;                // number of nucleotides
156 const long baseA = 0;                // codes for nucleotides
157 const long baseC = 1;
158 const long baseG = 2;
159 const long baseT = 3;
160 const long baseEnd = 4;              // allows one-past-the-end use
161 
162 const int  INVARIANTS   = 4;         // possible invariant sites
163 const std::string SINGLEBASES[INVARIANTS] = {"A","C","G","T"};
164 
165 const long markerCell     = 0;       // indicates a marker dlcell
166 const long invariantCell  = 1;       // indicates a invariant dlcell
167 
168 const long FLAGLONG     = -99;       // arbitrary flag values
169 const double FLAGDOUBLE = -99.0;
170 const long FLAGINVAR    = -999;
171 
172 const double DF         = 2.0;       // degrees of freedom for
173                                      // likelihood ratio test
174 const long NCHAINTYPES = 2;          // how many kinds of chains?
175 const long IDSIZE = 2;               // size of branch ID number
176 const long NELEM = 2;                // allowed parents or children
177                                      // of a branch
178 
179 const long XML_RANDOM_NAME_LENGTH   = 100000;
180 
181 // The following should be provided by the compiler, but
182 // we have found this to be unportable, so we define them
183 // ourselves.
184 
185 const double NEG_MAX = -999999999.9; // the smallest reasonable double
186 
187 //------------------------------------------------------------------------------------
188 // Registry of constant string tags
189 // (you might wish to change these if changing language)
190 //------------------------------------------------------------------------------------
191 
192 const unsigned long INDENT_DEPTH = 2;  // output of input xml indentation depth
193 
194 // The precision of the numbers written to the summary output file.
195 // NOTE:  When writing tree summaries with growth, the precision *must*
196 // be at least as large as the minimum timestep allowable.
197 const int SUMFILE_PRECISION = 18;
198 
199 class lamarccodes
200 {
201   public:
202     static const int cleanReturn;
203     static const int badAllocation;
204     static const int fileError;
205     static const int optionError;
206     static const int denovoCompileError;
207     static const int unknownError;
208 };
209 
210 class lamarcstrings
211 {
212   public:
213     static const std::string COAL       ;
214     static const std::string MIG        ;
215     static const std::string DISEASE    ;
216     static const std::string REC        ;
217     static const std::string GROW       ;
218     static const std::string LOGISTICSELECTION;
219     static const std::string DIVERGENCE ;
220     static const std::string DIVMIG     ;
221 
222     static const std::string REGION_GAMMA;
223     static const std::string INVALID    ;
224     static const std::string STICK      ;
225     static const std::string TIP        ;
226     static const std::string BASE       ;
227     static const std::string SNP        ;
228     static const std::string DNA        ;
229     static const std::string NUC        ;
230     static const std::string MICROSAT   ;
231     static const std::string EXPGROWSTICK;
232     static const std::string LOGSELECTSTICK;
233 
234     static const std::string PANEL;
235     static const std::string STUDY;
236     static const std::string EMPTY;
237 
238     static const std::string F84;
239     static const std::string GTR;
240     static const std::string STEPWISE;
241     static const std::string BROWNIAN;
242     static const std::string KALLELE;
243     static const std::string MIXEDKS;
244 
245     static const std::string ELECTRO    ;
246 
247     static const std::string longNameUSER;
248     static const std::string longNamePROGRAMDEFAULT;
249     static const std::string longNameFST;
250     static const std::string longNameWATTERSON;
251 
252     static const std::string shortNameUSER;
253     static const std::string shortNamePROGRAMDEFAULT;
254     static const std::string shortNameFST;
255     static const std::string shortNameWATTERSON;
256 
257     static const std::string longBrownianName;
258     static const std::string longF84Name;
259     static const std::string longGTRName;
260     static const std::string longKAlleleName;
261     static const std::string longStepwiseName;
262     static const std::string longMixedKSName;
263 
264     static const std::string shortBrownianName;
265     static const std::string shortF84Name;
266     static const std::string shortGTRName;
267     static const std::string shortKAlleleName;
268     static const std::string shortStepwiseName;
269     static const std::string shortMixedKSName;
270 
271     static const std::string longCurveName;
272     static const std::string longStickExpName;
273     static const std::string longStickName;
274     static const std::string shortCurveName;
275     static const std::string shortStickExpName;
276     static const std::string shortStickName;
277 
278     static const std::string longExpName;
279     static const std::string longStairStepName;
280     static const std::string shortExpName;
281     static const std::string shortStairStepName;
282 
283     static const std::string longDSelectionName;
284     static const std::string longSSelectionName;
285     static const std::string shortDSelectionName;
286     static const std::string shortSSelectionName;
287 };
288 
289 #endif // CONSTANTS_H
290 
291 //____________________________________________________________________________________
292