/
update_gtree_common.h
83 lines (75 loc) · 3.75 KB
/
update_gtree_common.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
/* MigSelect 2013-2019 Arun Sethuraman, Vitor Sousa, Jody Hey */
/* This code was developed based on IMa2 2009-2010 Jody Hey, Rasmus Nielsen and Sang Chul Choi*/
#ifndef _UPDATE_GTREE_COMMON_H_
#define _UPDATE_GTREE_COMMON_H_
#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
__BEGIN_DECLS
/* updating ancestral alleles at nodes, under stepwise model */
#define updateAfrac 0.05 // inverse of updateAi, just a useful proportion, don't need to do all of the nodes every step
#define updateAi 20
void init_update_assignment (void);
void free_update_assignment (void);
/* prototypes */
//void summiginfo(struct edgemiginfo *e, struct edgemiginfo *s); //debug
double likelihoodDG (int ci, int li);
int findperiod_Assignment (int ci, double t);
void treeweight_Assignment (int ci, int li);
void integrate_tree_prob_Assignment (int ci,
struct genealogy_weights *gweight,
struct probcalc *pcalc);
void copyfraclike_Assignment (int ci, int li);
void storescalefactors_Assignment (int ci, int li);
void restorescalefactors_Assignment (int ci, int li);
double finishSWupdateA_Assignment (int ci, int li, int ai, int edge,
int downedge, int sisedge, int newsisedge,
double u, double *Aterm);
double updateA_Assignment (int ci, int li, int ai, double u, int *count);
void init_gtreecommon (void);
void free_gtreecommon (void);
double calcmrate (int mc, double mt);
void joinsisdown (int ci, int li, int sis, int *tmrcachange);
void splitsisdown (int ci, int li, int slidingedge, int down, int newsis);
void getm (int ci, struct edgemiginfo *edgem,struct edgemiginfo *sisem, struct edgemiginfo *oldedgem,struct edgemiginfo *oldsisem);
void slider (int ci, int li, int slidingedge, int *sis, double *timepoint,
double *slidedist);
void slider_nomigration (int ci, int li, int slidingedge, int *sis,
double *timepoint, double *slidedist);
void IMA_reset_edgemiginfo (struct edgemiginfo *em);
void storeoldedges (int ci, int li, int edge, int sisedge, int downedge);
void restoreedges (int ci, int li, int edge, int sisedge, int downedge,
int newsisedge);
double getmprob(int ci, struct edgemiginfo *edgem,
struct edgemiginfo *sisem,struct edgemiginfo *oldedgem,
struct edgemiginfo *oldsisem);
void storeAinfo (int li, struct edge *gtree, int edge, int sisedge,
int downedge);
void fillmiginfoperiods (int ci, struct edgemiginfo *em);
void fillmiginfo (int ci, int li, struct edge *gtree, int edge, int sisedge);
void copynewmig_to_gtree (int ci, int li);
void storegenealogystats (int ci, int li, int mode);
int picktopop (int nowpop, int plist[], int numpops);
int picktopop2 (int nowpop, int plist[], int numpops, int notother);
int mwork_single_edge (int ci, struct edgemiginfo *edgem,struct edgemiginfo *oldedgem, int lastmigperiod);
//int mwork_single_edge (int ci, struct edgemiginfo *edgem,struct edgemiginfo *oldedgem, int lastmigperiod,int ei);//8_30_10
void mwork_two_edges(int ci, struct edgemiginfo *edgem, struct edgemiginfo *sisem,
struct edgemiginfo *oldedgem, struct edgemiginfo *oldsisem,int lastmigperiod, int* empall, int* smpall);
double getnewt (int timeperiod, double t_u_prior, double t_d_prior,
double oldt, int whichupdate);
//debug//8_30_10
/*int checkpp;
double pp;
int ptype[2][5];
int checkptype[2][5];
double rr[2][5];
double checkrr[2][5];
*/
__END_DECLS
#endif /* _UPDATE_GTREE_COMMON_H_ */