CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test.cpp File Reference
#include "../config.h"
#include <stdexcept>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include "gene_family.h"
#include <utils_string.h>
#include <cafe_shell.h>
#include <tree.h>
#include <cafe.h>
#include <chooseln_cache.h>
#include <cafe_commands.h>
#include <lambda.h>
#include <reports.h>
#include <likelihood_ratio.h>
#include <pvalue.h>
#include <branch_cutting.h>
#include <conditional_distribution.h>
#include <simerror.h>
#include <error_model.h>
#include <Globals.h>
#include <viterbi.h>
#include "CppUTest/TestHarness.h"
#include "CppUTest/CommandLineTestRunner.h"

Functions

void show_sizes (FILE *, pCafeTree pcafe, family_size_range *range, pCafeFamilyItem pitem, int i)
 
void phylogeny_lambda_parse_func (pTree ptree, pTreeNode ptnode)
 
 TEST_GROUP (FirstTestGroup)
 
 TEST_GROUP (LikelihoodRatio)
 
 TEST_GROUP (TreeTests)
 
 TEST_GROUP (PValueTests)
 
 TEST (TreeTests, node_set_birthdeath_matrix)
 
 TEST (TreeTests, cafe_tree_clustered_likelihood)
 
 TEST (TreeTests, node_set_birthdeath_matrix2)
 
 TEST (TreeTests, thousand_node_tree_to_string_and_back)
 
 TEST (FirstTestGroup, TestStringSplitter)
 
 TEST (FirstTestGroup, Tokenize)
 
 TEST (TreeTests, TestCafeTree)
 
 TEST (FirstTestGroup, TestShellDispatcher)
 
 TEST (FirstTestGroup, TestShowSizes)
 
 TEST (FirstTestGroup, TestPhylogenyLoadFromString)
 
void build_matrix (square_matrix &m)
 
 TEST (TreeTests, compute_internal_node_likelihood)
 
pCafeTree create_small_tree (family_size_range &range)
 
 TEST (TreeTests, compute_tree_likelihood)
 
 TEST (TreeTests, add_key)
 
 TEST (TreeTests, add_key_skips_matching_keys)
 
 TEST (FirstTestGroup, compute_likelihoods)
 
 TEST (FirstTestGroup, compute_posterior)
 
 TEST (FirstTestGroup, cafe_tree_p_values)
 
 TEST (FirstTestGroup, cafe_set_prior_rfsize_empirical)
 
 TEST (FirstTestGroup, cafe_set_prior_rfsize_poisson_lambda)
 
 TEST (FirstTestGroup, list_commands)
 
void store_node_id (pTree ptree, pTreeNode ptnode, va_list ap1)
 
 TEST (FirstTestGroup, tree_traversal_prefix)
 
 TEST (FirstTestGroup, tree_traversal_infix)
 
 TEST (FirstTestGroup, tree_traversal_postfix)
 
 TEST (TreeTests, cafe_tree_random_probabilities)
 
 TEST (FirstTestGroup, cafe_tree_new_empty_node)
 
 TEST (FirstTestGroup, chooseln_cache)
 
 TEST (FirstTestGroup, birthdeath_rate_with_log_alpha)
 
 TEST (FirstTestGroup, birthdeath_likelihood_with_s_c)
 
 TEST (FirstTestGroup, square_matrix_resize)
 
 TEST (FirstTestGroup, square_matrix_multiply)
 
 TEST (FirstTestGroup, compute_birthdeath_rates)
 
 TEST (FirstTestGroup, compute_birthdeath_rates2)
 
std::ostream & operator<< (std::ostream &ost, square_matrix &matrix)
 
 TEST (FirstTestGroup, compute_birthdeath_rates_without_mu)
 
 TEST (FirstTestGroup, clear_tree_viterbis)
 
int get_family_size (pTree ptree, int id)
 
 TEST (FirstTestGroup, cafe_tree_random_familysize)
 
 TEST (FirstTestGroup, cafe_tree_random_familysize__must_be_less_than_cache_size)
 
 TEST (FirstTestGroup, reset_birthdeath_cache)
 
 TEST (FirstTestGroup, birthdeath_cache_get_matrix_ignores_fractional_branch_lengths)
 
 TEST (FirstTestGroup, get_num_trials)
 
 TEST (FirstTestGroup, viterbi_sum_probabilities)
 
 TEST (FirstTestGroup, initialize_leaf_likelihoods)
 
 TEST (FirstTestGroup, initialize_leaf_likelihoods_clustered)
 
 TEST (FirstTestGroup, get_clusters)
 
 TEST (FirstTestGroup, write_node_headers)
 
 TEST (FirstTestGroup, write_version)
 
 TEST (FirstTestGroup, compute_viterbis)
 
void set_familysize_to_node_times_three (pTree ptree, pTreeNode pnode, va_list ap1)
 
 TEST (FirstTestGroup, write_leaves)
 
 TEST (FirstTestGroup, run_viterbi_sim)
 
 TEST (FirstTestGroup, init_histograms)
 
 TEST (FirstTestGroup, init_family_size)
 
 TEST (FirstTestGroup, cafe_tree_set_parameters)
 
 TEST (FirstTestGroup, cut_branch)
 
 TEST (FirstTestGroup, conditional_distribution)
 
 TEST (FirstTestGroup, set_size_for_split)
 
 TEST (FirstTestGroup, compute_cutpvalues)
 
 TEST (FirstTestGroup, simulate_misclassification)
 
 TEST (FirstTestGroup, get_random)
 
 TEST (FirstTestGroup, tree_set_branch_lengths)
 
 TEST (FirstTestGroup, initialize_k_bd_no_lambda)
 
 TEST (FirstTestGroup, initialize_k_bd_with_lambda)
 
 TEST (FirstTestGroup, globals_Clear__clears_probability_cache)
 
 TEST (FirstTestGroup, input_values_randomize__with_k)
 
 TEST (FirstTestGroup, input_values_randomize__without_k)
 
 TEST (FirstTestGroup, set_birth_death_probabilities3)
 
 TEST (FirstTestGroup, initialize_k_weights)
 
double my_pvalue (double v, std::vector< double > &conddist)
 
 TEST (PValueTests, pvalue3)
 
 TEST (PValueTests, pvalue2)
 
 TEST (PValueTests, pvalue)
 
 TEST (PValueTests, pvalues_for_family)
 
 TEST (PValueTests, read_pvalues)
 
 TEST (LikelihoodRatio, cafe_likelihood_ratio_test)
 
 TEST (LikelihoodRatio, likelihood_ratio_report)
 
 TEST (LikelihoodRatio, update_branchlength)
 
 TEST (FirstTestGroup, sync_sanity_check_passes)
 
 TEST (FirstTestGroup, viterbi_max_p)
 
int main (int ac, char **av)
 

Variables

pCafeParam cafe_param
 Holds the global program state that user commands act on. More...
 
pBirthDeathCacheArray probability_cache
 
struct chooseln_cache cache
 A cache of values of chooseln. More...
 

Function Documentation

void build_matrix ( square_matrix m)
pCafeTree create_small_tree ( family_size_range range)
int get_family_size ( pTree  ptree,
int  id 
)
int main ( int  ac,
char **  av 
)
double my_pvalue ( double  v,
std::vector< double > &  conddist 
)
std::ostream& operator<< ( std::ostream &  ost,
square_matrix matrix 
)
void phylogeny_lambda_parse_func ( pTree  ptree,
pTreeNode  ptnode 
)
void set_familysize_to_node_times_three ( pTree  ptree,
pTreeNode  pnode,
va_list  ap1 
)
void show_sizes ( FILE *  ,
pCafeTree  pcafe,
family_size_range range,
pCafeFamilyItem  pitem,
int  i 
)
void store_node_id ( pTree  ptree,
pTreeNode  ptnode,
va_list  ap1 
)
TEST ( TreeTests  ,
node_set_birthdeath_matrix   
)
TEST ( TreeTests  ,
cafe_tree_clustered_likelihood   
)
TEST ( TreeTests  ,
node_set_birthdeath_matrix2   
)
TEST ( TreeTests  ,
thousand_node_tree_to_string_and_back   
)
TEST ( FirstTestGroup  ,
TestStringSplitter   
)
TEST ( FirstTestGroup  ,
Tokenize   
)
TEST ( TreeTests  ,
TestCafeTree   
)
TEST ( FirstTestGroup  ,
TestShellDispatcher   
)
TEST ( FirstTestGroup  ,
TestShowSizes   
)
TEST ( FirstTestGroup  ,
TestPhylogenyLoadFromString   
)
TEST ( TreeTests  ,
compute_internal_node_likelihood   
)
TEST ( TreeTests  ,
compute_tree_likelihood   
)
TEST ( TreeTests  ,
add_key   
)
TEST ( TreeTests  ,
add_key_skips_matching_keys   
)
TEST ( FirstTestGroup  ,
compute_likelihoods   
)
TEST ( FirstTestGroup  ,
compute_posterior   
)
TEST ( FirstTestGroup  ,
cafe_tree_p_values   
)
TEST ( FirstTestGroup  ,
cafe_set_prior_rfsize_empirical   
)
TEST ( FirstTestGroup  ,
cafe_set_prior_rfsize_poisson_lambda   
)
TEST ( FirstTestGroup  ,
list_commands   
)
TEST ( FirstTestGroup  ,
tree_traversal_prefix   
)
TEST ( FirstTestGroup  ,
tree_traversal_infix   
)
TEST ( FirstTestGroup  ,
tree_traversal_postfix   
)
TEST ( TreeTests  ,
cafe_tree_random_probabilities   
)
TEST ( FirstTestGroup  ,
cafe_tree_new_empty_node   
)
TEST ( FirstTestGroup  ,
chooseln_cache   
)
TEST ( FirstTestGroup  ,
birthdeath_rate_with_log_alpha   
)
TEST ( FirstTestGroup  ,
birthdeath_likelihood_with_s_c   
)
TEST ( FirstTestGroup  ,
square_matrix_resize   
)
TEST ( FirstTestGroup  ,
square_matrix_multiply   
)
TEST ( FirstTestGroup  ,
compute_birthdeath_rates   
)
TEST ( FirstTestGroup  ,
compute_birthdeath_rates2   
)
TEST ( FirstTestGroup  ,
compute_birthdeath_rates_without_mu   
)
TEST ( FirstTestGroup  ,
clear_tree_viterbis   
)
TEST ( FirstTestGroup  ,
cafe_tree_random_familysize   
)
TEST ( FirstTestGroup  ,
cafe_tree_random_familysize__must_be_less_than_cache_size   
)
TEST ( FirstTestGroup  ,
reset_birthdeath_cache   
)
TEST ( FirstTestGroup  ,
birthdeath_cache_get_matrix_ignores_fractional_branch_lengths   
)
TEST ( FirstTestGroup  ,
get_num_trials   
)
TEST ( FirstTestGroup  ,
viterbi_sum_probabilities   
)
TEST ( FirstTestGroup  ,
initialize_leaf_likelihoods   
)
TEST ( FirstTestGroup  ,
initialize_leaf_likelihoods_clustered   
)
TEST ( FirstTestGroup  ,
get_clusters   
)
TEST ( FirstTestGroup  ,
write_node_headers   
)
TEST ( FirstTestGroup  ,
write_version   
)
TEST ( FirstTestGroup  ,
compute_viterbis   
)
TEST ( FirstTestGroup  ,
write_leaves   
)
TEST ( FirstTestGroup  ,
run_viterbi_sim   
)
TEST ( FirstTestGroup  ,
init_histograms   
)
TEST ( FirstTestGroup  ,
init_family_size   
)
TEST ( FirstTestGroup  ,
cafe_tree_set_parameters   
)
TEST ( FirstTestGroup  ,
cut_branch   
)
TEST ( FirstTestGroup  ,
conditional_distribution   
)
TEST ( FirstTestGroup  ,
set_size_for_split   
)
TEST ( FirstTestGroup  ,
compute_cutpvalues   
)
TEST ( FirstTestGroup  ,
simulate_misclassification   
)
TEST ( FirstTestGroup  ,
get_random   
)
TEST ( FirstTestGroup  ,
tree_set_branch_lengths   
)
TEST ( FirstTestGroup  ,
initialize_k_bd_no_lambda   
)
TEST ( FirstTestGroup  ,
initialize_k_bd_with_lambda   
)
TEST ( FirstTestGroup  ,
globals_Clear__clears_probability_cache   
)
TEST ( FirstTestGroup  ,
input_values_randomize__with_k   
)
TEST ( FirstTestGroup  ,
input_values_randomize__without_k   
)
TEST ( FirstTestGroup  ,
set_birth_death_probabilities3   
)
TEST ( FirstTestGroup  ,
initialize_k_weights   
)
TEST ( PValueTests  ,
pvalue3   
)
TEST ( PValueTests  ,
pvalue2   
)
TEST ( PValueTests  ,
pvalue   
)
TEST ( PValueTests  ,
pvalues_for_family   
)
TEST ( PValueTests  ,
read_pvalues   
)
TEST ( LikelihoodRatio  ,
cafe_likelihood_ratio_test   
)
TEST ( LikelihoodRatio  ,
likelihood_ratio_report   
)
TEST ( LikelihoodRatio  ,
update_branchlength   
)
TEST ( FirstTestGroup  ,
sync_sanity_check_passes   
)
TEST ( FirstTestGroup  ,
viterbi_max_p   
)
TEST_GROUP ( FirstTestGroup  )
TEST_GROUP ( LikelihoodRatio  )
TEST_GROUP ( TreeTests  )
TEST_GROUP ( PValueTests  )

Variable Documentation

struct chooseln_cache cache

A cache of values of chooseln.

Chooseln evaluates the natural logarithm of Gamma(n+1)/(Gamma(k+1)*Gamma(n-k+1)) The cache holds values for integer values of n and k. It does not appear to be threadsafe.

P(X(t) = c | X(0) = s) = {j=0}^{(s,c)} {s}{j}{s+c-j-1}{s-1} ^{s+c-2j}(1-2)^j

pCafeParam cafe_param

Holds the global program state that user commands act on.

pBirthDeathCacheArray probability_cache

The variable cafe_param is a global singleton that holds general program state. cafe_param holds pcafe, a CafeTree, and pfamily, a CafeFamily . These are set by the user via the commands "tree" and "load" respectively. When the user calls the command "lambda" calculations are performed on the pcafe and pfamily variables.