source: branches/ali/GDE/PHYML20130708/phyml/src/rates.h

Last change on this file was 10307, checked in by aboeckma, 11 years ago

added most recent version of phyml

File size: 10.3 KB
Line 
1/*
2
3PhyML:  a program that  computes maximum likelihood phylogenies from
4DNA or AA homologous sequences.
5
6Copyright (C) Stephane Guindon. Oct 2003 onward.
7
8All parts of the source except where indicated are distributed under
9the GNU public licence. See http://www.opensource.org for details.
10
11*/
12
13#include <config.h>
14
15#ifndef RATES_H
16#define RATES_H
17
18#include "utilities.h"
19#include "spr.h"
20#include "lk.h"
21#include "optimiz.h"
22#include "bionj.h"
23#include "models.h"
24#include "free.h"
25#include "help.h"
26#include "simu.h"
27#include "eigen.h"
28#include "pars.h"
29#include "alrt.h"
30#include "time.h"
31#include "m4.h"
32#include "draw.h"
33#include "mcmc.h"
34#include "stats.h"
35
36void RATES_Monte_Carlo_Mean_Rates(t_tree *tree);
37void RATES_Monte_Carlo_Mean_Rates_Pre(t_node *a, t_node *d, t_edge *b, phydbl curr_rate, t_tree *tree);
38void RATES_Print_Rates(t_tree *tree);
39void RATES_Print_Rates_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
40t_rate *RATES_Make_Rate_Struct(int n_otu);
41void RATES_Init_Rate_Struct(t_rate *rates, t_rate *existing_rates, int n_otu);
42void RATES_Classify_Branches(t_tree *tree);
43void RATES_Adjust_Rates(t_tree *tree);
44void RATES_Adjust_Rates_Local_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
45void RATES_Adjust_Rates_Local(t_node *a, t_node *d, t_edge *b1, t_tree *tree);
46void RATES_Record_T(t_tree *tree);
47void RATES_Restore_T(t_tree *tree);
48void RATES_Monte_Carlo_Mean_Rates_Core(phydbl t_lim_sup, phydbl t_lim_inf, phydbl *curr_rate, phydbl *mean_rate, phydbl lexp, phydbl alpha);
49phydbl RATES_Lk_Rates(t_tree *tree);
50void RATES_Lk_Rates_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
51void RATES_Fill_Node_Rates_Pre(t_node *a, t_node *d, t_edge *b, phydbl *node_r, t_tree *tree);
52void RATES_Fill_Node_Rates(phydbl *node_r, t_tree *tree);
53void RATES_Optimize_Node_Times_Serie_Fixed_Br_Len(t_node *a, t_node *d, t_tree *tree);
54void RATES_Optimize_Lexp(t_tree *tree);
55void RATES_Round_Optimize(t_tree *tree);
56void RATES_Optimize_Lexp(t_tree *tree);
57void RATES_Optimize_Alpha(t_tree *tree);
58phydbl RATES_Dmu(phydbl mu, int n_jumps, phydbl dt, phydbl a, phydbl b, phydbl lexp, int min_n, int jps_dens);
59phydbl RATES_Dr_X_Dx(phydbl r, phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp);
60phydbl RATES_Dmu_Given_Y_Trpzd(phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp, 
61                               int nsteps, phydbl beg, phydbl end, phydbl prevs);
62phydbl RATES_Dmu_Given_Y_Std(phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp);
63phydbl RATES_Dmu_Given_Y_Romb(phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp);
64phydbl RATES_Dmu_Given_Y(phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp);
65phydbl RATES_Dy_Given_Mu(phydbl mu, phydbl y, phydbl dt, phydbl a, phydbl b, phydbl lexp);
66phydbl RATES_Dmu2_Given_Y_X_Dy_Given_Mu1(phydbl mu1, phydbl mu2, phydbl y, phydbl dt1, phydbl dt2, phydbl a, phydbl b, phydbl lexp);
67phydbl RATES_Dmu2_Given_Mu1_Trpz(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl a, phydbl b, phydbl lexp,
68                                 int nsteps, phydbl beg, phydbl end, phydbl prevs);
69phydbl RATES_Dmu2_And_Mu1(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl a, phydbl b, phydbl lexp);
70phydbl RATES_Dmu2_Given_Mu1(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl a, phydbl b, phydbl lexp);
71phydbl RATES_Dmu2_Given_Mu1_Romb(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl a, phydbl b, phydbl lexp);
72void RATES_Random_Branch_Lengths(t_tree *tree);
73void RATES_Bracket_N_Jumps(int *up, int *down, phydbl param);
74void RATES_Set_Node_Times(t_tree *tree);
75void RATES_Set_Node_Times_Pre(t_node *a, t_node *d, t_tree *tree);
76void RATES_Optimize_Node_Times(t_tree *tree);
77phydbl RATES_Exp_Y(phydbl mu1, phydbl mu2, phydbl dt1, phydbl lexp);
78phydbl RATES_Dmu2_Given_Mu1_Bis(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl alpha, phydbl beta, phydbl lexp);
79void RATES_Replace_Br_Lengths_By_Rates_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
80void RATES_Replace_Br_Lengths_By_Rates(t_tree *tree);
81
82void RATES_Get_Mean_Rates(t_tree *tree);
83void RATES_Get_Mean_Rates_Pre(t_node *a, t_node *d, t_edge *b, phydbl r_a, t_tree *tree);
84void RATES_Expect_Number_Subst(phydbl t_beg, phydbl t_end, phydbl r_beg,  int *n_jumps, phydbl *mean_r, phydbl *r_end, t_rate *rates, t_tree *tree);
85void RATES_Optimize_Clock_Rate(t_tree *tree);
86phydbl RATES_Dmu1_Given_Lbda_And_Mu2(phydbl lbda, phydbl mu1, phydbl mu2, phydbl alpha, phydbl beta);
87phydbl RATES_Dmu1_And_Mu2_One_Jump_Trpz(phydbl mu1, phydbl mu2, phydbl a, phydbl b,
88                                          int nsteps, phydbl beg, phydbl end, phydbl prevs);
89phydbl RATES_Dmu1_And_Mu2_One_Jump_One_Interval(phydbl mu1, phydbl mu2, phydbl a, phydbl b);
90phydbl RATES_Dmu1_And_Mu2_One_Jump_Two_Intervals(phydbl dt1, phydbl dt2, phydbl mu1, phydbl mu2, phydbl a, phydbl b);
91
92phydbl RATES_Dmu1_And_Mu2_One_Jump_Old(phydbl mu1, phydbl mu2, phydbl a, phydbl b);
93
94phydbl RATES_Dmu2_And_Min_N_Given_Mu1(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, int n_min, phydbl a, phydbl b, phydbl lexp);
95phydbl RATES_Dmu2_And_Mu1_Given_N(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, int n, phydbl a, phydbl b, phydbl lexp);
96phydbl RATES_Lk_Rates_Core(phydbl br_r_a, phydbl br_r_d, phydbl nd_r_a, phydbl nd_r_d, int n_a, int n_d, phydbl dt_a, phydbl dt_d, t_tree *tree);
97void RATES_Init_Triplets(t_tree *tree);
98phydbl RATES_Lk_Change_One_Time(t_node *n, phydbl new_t, t_tree *tree);
99void RATES_Update_Triplet(t_node *n, t_tree *tree);
100void RATES_Print_Triplets(t_tree *tree);
101phydbl RATES_Lk_Change_One_Rate(t_node *d, phydbl new_rate, t_tree *tree);
102phydbl RATES_Dmu2_And_Mu1_Given_Min_N(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, int n_min, phydbl a, phydbl b, phydbl lexp);
103phydbl RATES_Dmu2_And_Mu1_Given_N_Normal(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, int n, phydbl a, phydbl b, phydbl lexp);
104phydbl RATES_Coeff_Corr(phydbl alpha, phydbl beta, int n1, int n2);
105phydbl RATES_Dmu2_And_Mu1_Given_N_Full(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, int n, phydbl a, phydbl b, phydbl lexp);
106phydbl RATES_Dmu1_Given_V_And_N(phydbl mu1, phydbl v, int n, phydbl dt1, phydbl a, phydbl b);
107phydbl RATES_Yule(t_tree *tree);
108phydbl RATES_Check_Mean_Rates(t_tree *tree);
109void RATES_Check_Mean_Rates_Pre(t_node *a, t_node *d, t_edge *b, phydbl *sum, t_tree *tree);
110void RATES_Discretize_Rates(t_tree *tree);
111void RATES_Discretize_Rates_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
112phydbl RATES_Dmu_Given_V_And_MinN(phydbl mu, phydbl dt, phydbl v, int minn, phydbl a, phydbl b, phydbl lexp);
113phydbl RATES_Dmu_One(phydbl mu, phydbl dt, phydbl a, phydbl b, phydbl lexp);
114phydbl RATES_Compound_Core(phydbl mu1, phydbl mu2, int n1, int n2, phydbl dt1, phydbl dt2, phydbl alpha, phydbl beta, phydbl lexp, phydbl eps, int approx);
115void RATES_Record_Rates(t_tree *tree);
116void RATES_Reset_Rates(t_tree *tree);
117void RATES_Record_Times(t_tree *tree);
118void RATES_Reset_Times(t_tree *tree);
119void RATES_Update_T_Rates_Pre(t_node *a, t_node *d, t_tree *tree);
120void RATES_Update_T_Rates(t_tree *tree);
121void RATES_Get_Rates_From_Bl(t_tree *tree);
122phydbl RATES_Compound_Core_Joint(phydbl mu1, phydbl mu2, int n1, int n2, phydbl dt1, phydbl dt2, 
123                                 phydbl alpha, phydbl beta, phydbl lexp, phydbl eps, int approx);
124phydbl RATES_Dmu_Joint(phydbl mu, int n, phydbl dt, phydbl a, phydbl b, phydbl lexp, int min_n);
125phydbl RATES_Compound_Core_Marginal(phydbl mu1, phydbl mu2, phydbl dt1, phydbl dt2, phydbl alpha, 
126                                    phydbl beta, phydbl lexp, phydbl eps, int approx);
127phydbl RATES_Lk_Jumps(t_tree *tree);
128void RATES_Posterior_Rates(t_tree *tree);
129void RATES_Posterior_One_Rate(t_node *a, t_node *d, int traversal, t_tree *tree);
130void RATES_Free_Rates(t_rate *rates);
131void RATES_Initialize_True_Rates(t_tree *tree);
132void RATES_Posterior_Times(t_tree *tree);
133void RATES_Posterior_One_Time(t_node *a, t_node *d, int traversal, t_tree *tree);
134void RATES_Update_Cur_Bl(t_tree *tree);
135void RATES_Update_Cur_Bl_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
136void RATES_Get_Cov_Matrix_Rooted(phydbl *unroot_cov, t_tree *tree);
137void RATES_Get_Cov_Matrix_Rooted_Pre(t_node *a, t_node *d, t_edge *b, phydbl *cov, t_tree *tree);
138void RATES_Bl_To_Ml(t_tree *tree);
139void RATES_Bl_To_Ml_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
140int RATES_Check_Node_Times(t_tree *tree);
141void RATES_Check_Node_Times_Pre(t_node *a, t_node *d, int *err, t_tree *tree);
142void RATES_Covariance_Mu(t_tree *tree);
143void RATES_Variance_Mu_Pre(t_node *a, t_node *d, t_tree *tree);
144void RATES_Fill_Lca_Table(t_tree *tree);
145void RATES_Posterior_Clock_Rate(t_tree *tree);
146void RATES_Get_Conditional_Variances(t_tree *tree);
147void RATES_Get_All_Reg_Coeff(t_tree *tree);
148void RATES_Posterior_Time_Root(t_tree *tree);
149void RATES_Get_Trip_Conditional_Variances(t_tree *tree);
150void RATES_Get_All_Trip_Reg_Coeff(t_tree *tree);
151void RATES_Check_Lk_Rates(t_tree *tree, int *err);
152phydbl RATES_Expected_Tree_Length(t_tree *tree);
153void RATES_Expected_Tree_Length_Pre(t_node *a, t_node *d, phydbl eranc, phydbl *mean, int *n, t_tree *tree);
154void RATES_Normalise_Rates(t_tree *tree);
155phydbl RATES_Check_Mean_Rates_True(t_tree *tree);
156phydbl RATES_Find_Min_Dt_Bisec(phydbl r0, phydbl r1, phydbl t0, phydbl t1, phydbl nu, phydbl threshp, int inf);
157phydbl RATES_Find_Max_Dt_Bisec(phydbl r0, phydbl r1, phydbl t0, phydbl t1, phydbl nu, phydbl threshp, int inf);
158void RATES_Min_Max_Interval(phydbl u0, phydbl u1, phydbl u2, phydbl u3, phydbl t0, phydbl t2, phydbl t3, 
159                            phydbl *t_min, phydbl *t_max, phydbl nu, phydbl p_thresh, t_tree *tree);
160
161
162phydbl RATES_Get_Correction_Factor(phydbl mode, phydbl sd, int *err, t_tree *tree);
163phydbl RATES_Average_Substitution_Rate(t_tree *tree);
164void RATES_Update_Norm_Fact(t_tree *tree);
165void RATES_Update_Mean_Br_Len(int iter, t_tree *tree);
166void RATES_Update_Cov_Br_Len(int iter, t_tree *tree);
167void RATES_Set_Mean_L(t_tree *tree);
168void RATES_Fill_All_Param(t_rate *rate, t_tree *tree);
169void RATES_Record_Rates(t_tree *tree);
170void RATES_Reset_Rates(t_tree *tree);
171phydbl RATES_Average_Rate(t_tree *tree);
172void RATES_Set_Clock_And_Nu_Max(t_tree *tree);
173void RATES_Write_Mean_R_On_Edge_Label(t_node *a, t_node *d, t_edge *b, t_tree *tree);
174phydbl RATES_Lk_Linreg(t_tree *tree);
175phydbl RATES_Get_Mean_Rate_In_Subtree(t_node *root, t_tree *tree);
176void RATES_Get_Mean_Rate_In_Subtree_Pre(t_node *a, t_node *d, phydbl *sum, int *n, t_tree *tree);
177char *RATES_Get_Model_Name(int model);
178void RATES_Get_Survival_Ranks(t_tree *tree);
179void RATES_Bl_To_Bl(t_tree *tree);
180void RATES_Bl_To_Bl_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
181void RATES_Set_Birth_Rate_Boundaries(t_tree *tree);
182
183#endif
Note: See TracBrowser for help on using the repository browser.