-
Notifications
You must be signed in to change notification settings - Fork 0
/
comus.h
297 lines (206 loc) · 6.21 KB
/
comus.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <sys/time.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#define NS 5000
#define NBRANCH (NS*2-2)
#define MAXNSONS 20
#define LSPNAME 50
#define NCODE 64
#define NCATG 40
#define ADDSIZE 50
#define SITESINC 10
#define MAXTREESTRING 10000
#define FILESIZE 256
#define MAXTRIALS 500
enum {PrBranch=1, PrNodeNum=2, PrLabel=4, PrAge=8, PrOmega=16} OutTreeOptions;
struct CommonInfo {
char *z[2*NS-1], spname[NS][LSPNAME+1], daafile[96], cleandata, readpattern;
int ns, ls, npatt, np, ntime, ncode, clock, rooted, model, icode;
int seqtype, *pose, ncatG, NSsites;
double *fpatt, kappa, omega, alpha, pi[64], *conP, daa[20*20];
double freqK[NCATG], rK[NCATG];
char *siteID; /* used if ncatG>1 */
double *siterates; /* rates for gamma or omega for site or branch-site models */
double *omegaBS, *QfactorBS; /* omega IDs for branch-site models */
} com;
struct devent {
double time;
int popi;
int popj;
int isSpeciation;
double paramv;
double **mat ;
char detype ;
struct devent *nextde;
} ;
struct deventArray {
int type;
int nevents;
double time;
int sp1;
int sp2;
int popi;
int popj;
int isSpeciation;
double paramv;
double **mat;
char detype;
int id;
} *pastEvents;
struct c_params {
int npop;
int nsam;
int *config;
double *samplingTime;
double **mig_mat;
int **ignoreSpeciationJoints;
double r;
int nsites;
int msites;
double f;
double track_len;
double *size;
double *alphag;
struct devent *deventlist ;
} ;
struct m_params {
double theta;
int segsitesin;
int treeflag;
int timeflag;
int mfreq;
} ;
struct params {
struct c_params cp;
struct m_params mp;
int commandlineseedflag ;
int output_precision;
};
struct initial_devent {
double time;
int popi;
int popj;
double paramv;
double **mat ;
char detype ;
struct devent *nextde;
} ;
struct initial_c_params {
int npop;
int nsam;
int *config;
double **mig_mat;
int **ignoreSpeciationJoints;
double r;
int nsites;
double f;
double track_len;
double *size;
double *alphag;
struct devent *deventlist ;
} ;
struct initial_m_params {
double theta;
int segsitesin;
int treeflag;
int timeflag;
int mfreq;
} ;
struct initial_params {
struct c_params cp;
struct m_params mp;
int commandlineseedflag ;
int output_precision;
};
struct TREEB {
int nbranch, nnode, root, branches[NBRANCH][2], leaves, internalNodes;
} tree;
struct TREEN {
int father, nson, sons[MAXNSONS], ibranch, nodeID, spID, originalIndex,
sampleSize, *samplePops, npop, offset, *pops, maxIndPop, sumofnodespop, isLeaf, nseqs;
double branch, age, omega, label, *conP, coalAge, isolationTime,
theta, rho, Ne, partialDuration, partialMaxMigration;
char *nodeStr, fossil;
} *nodes, *initialNodes;
/* struct SPECIES { */
/* int sampleSize, /\* total sample size for the species *\/ */
/* *samplePops, /\* sample size of each pop of the species *\/ */
/* npop, /\* the number of populations that the species contains *\/ */
/* offset; /\* from which population we should start to count the species *\/ */
/* double theta, /\* theta = 4Nmu per species *\/ */
/* rho, /\* rho = 4Nr per species *\/ */
/* Ne; /\* relative population sizes for species *\/ */
/* //struct devent *deventlist ; */
/* } *spConf; */
/* struct MIG{ */
/* /\* stores the migration events set by the command line *\/ */
/* int events, */
/* *fromSpecies, */
/* *toSpecies, */
/* *fromPop, */
/* *toPop; */
/* } cmdMigEvents; */
struct GLOBAL{
int multipleSpecies;
int partialIsolationModel;
int readMigration;
int readSampling;
int readN;
int readG;
int readeG;
int readej;
int smt;
int readeN;
int totalPops;
int currentEvents;
int maxEventsSize;
int finiteSiteModel;
int printSeparator;
int printInSeparateFiles;
} globalVar;
struct segl {
int beg;
int length;
int recLength;
struct node *ptree;
int next;
} ;
/* source code based on Fletcher and Yang's INDELible */
void randomTreeGeneration(int ntaxa, double birth, double death, double sample, double mut, int option, char *outputTree, int mode, double torigin, FILE *phyloTreeOut, double oldestOrigin, double *samplingTime );
void speciationToCoalescentTimes(double theta, double scale);
int OutTreeN (FILE *fout, int spnames, int printopt);
struct params pars ;
struct params initial_pars;
void seedit( const char * ) ;
void getpars( int argc, char *argv[], int *howmany, FILE **CoalescentFile, char CoalescentFileName[FILESIZE] ) ;
void getparsCMD_multiSpeciesSimulate(int argc, char *argv[], int *phowmany, FILE **phyloOut, char phyloFileName[FILESIZE], FILE **CoalescentFile, char CoalescentFileName[FILESIZE], double *partIsoPeriod, double *partMaxMigration, double *samplingRate, double *mu, double *lambda, double *mut, char phyloInputFileName[FILESIZE], FILE **phyloInputFile, int *phyloMode, double *torigin, double *oldestOrigin , unsigned int *timeSeed);
void addtoelist( struct devent *pt, struct devent *elist );
int gensam( char **list, double *probss, double *ptmrca, double *pttot, struct segl **seglst, FILE *ResultFile, int *nsegs, FILE* InfoFile, int simindex, char* microsatOutputFileName) ;
void constructUpdatedCommandLine();
void addtoelist( struct devent *pt, struct devent *elist );
void argcheck( int arg, int argc, char ** ) ;
int commandlineseed( char ** ) ;
void free_eventlist( struct devent *pt, int npop );
void phyTreeToCoalEvents(int *current_node, int *smallerSon);
void phyTreeToCoalEvents2();
void nodesToCoalEvents();
int pick2(int n, int *i, int *j);
int isseg(int start, int c, int *psg);
int links(int c);
int xover(int nsam,int ic, int is);
int ca(int nsam, int nsites, int c1, int c2);
int pick2_chrom(int pop, int config[], int *pc1, int *pc2);
int ranvec(int n, double pbuf[]);
void free_streec_variables();
void free_rand1_file();
int readTreeFromFile(FILE *infile, int nspecies, int *positionsArray);
int readNumberOfReplications(FILE *infile);
int checkTreeSamplingConsistency(double *samplingTime, int n);