CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cafe_commands.h
Go to the documentation of this file.
1 #ifndef CAFE_COMMANDS_H_B2201016_8693_4379_9225_8FFEC3562AFE
2 #define CAFE_COMMANDS_H_B2201016_8693_4379_9225_8FFEC3562AFE
3 
4 #include <vector>
5 #include <string>
6 #include <map>
7 #include <iosfwd>
8 #include <stdexcept>
9 
10 extern "C" {
11 #include "family.h"
12 #include "cafe_shell.h"
13 }
14 
15 struct Argument
16 {
17  std::string opt;
18  int argc;
19  char** argv;
20 };
21 
23 
24 
25 class Globals;
26 
27 typedef int(*cafe_command2)(Globals& globals, std::vector<std::string>);
28 
29 #define MAKE_FN_NAME(x) int cafe_cmd_##x (Globals& globals, std::vector<std::string>)
30 #define COMMAND(signal) MAKE_FN_NAME(signal)
31 
32 COMMAND(accuracy);
33 COMMAND(branchlength);
34 COMMAND(cvfamily);
35 COMMAND(cvspecies);
36 COMMAND(date);
37 COMMAND(echo);
38 COMMAND(errormodel);
39 COMMAND(esterror);
40 COMMAND(exit);
41 COMMAND(extinct);
42 COMMAND(family);
43 COMMAND(gainloss);
44 COMMAND(generate_random_family);
45 COMMAND(lambdamu);
46 COMMAND(lhtest);
47 COMMAND(list);
48 COMMAND(load);
49 COMMAND(log);
50 COMMAND(noerrormodel);
51 COMMAND(print_param);
53 COMMAND(retrieve);
54 COMMAND(rootdist);
55 COMMAND(save);
56 COMMAND(score);
57 COMMAND(seed);
59 COMMAND(simextinct);
60 COMMAND(source);
61 COMMAND(tree);
64 
65 std::map<std::string, cafe_command2> get_dispatcher();
66 int cafe_shell_dispatch_command(Globals& globals, char* cmd);
67 void list_commands(std::ostream& ost);
68 
69 std::vector<Argument> build_argument_list(std::vector<std::string> tokens);
70 
71 // these functions should be moved to another file
73 int get_num_trials(std::vector<std::string> args);
74 int write_family_gainloss(std::ostream& ofst, std::string family_id, pCafeTree tree1, pCafeTree tree2);
75 std::vector<int> get_clusters(int parameterized_k_value, int num_families, double* k_weights);
76 void write_node_headers(std::ostream& s1, std::ostream& s2, pCafeTree pcafe);
77 void write_leaves(std::ostream& ofst, pCafeTree pcafe, int *k, int i, int id, bool evens);
78 void write_version(std::ostream &ost);
79 void write_family(std::ostream& ost, pCafeFamily family);
80 void viterbi_write(std::ostream& ost, pCafeTree pcafe, pCafeFamily pfamily);
81 void tree_set_branch_lengths(pCafeTree pcafe, std::vector<int> lengths);
82 
83 struct load_args {
86  int max_size;
87  double pvalue;
88  bool filter;
89  std::string log_file_name;
90  std::string family_file_name;
91 };
92 
93 struct viterbi_args {
94  bool all;
95  std::string file;
96  int idx;
97  std::string item_id;
98 };
99 
101 {
102  std::string infile;
103  std::string outfile;
104  int index;
105 };
106 
108 {
109  std::string directory;
110  std::string tree;
111  std::string outfile;
112  double lambda;
113 };
114 
116 {
117  std::string outfile;
118  std::vector<std::string> data_error_files;
119  bool symmetric;
120  bool peakzero;
121  std::string truth_file;
122  int max_diff;
123 };
124 
125 load_args get_load_arguments(std::vector<Argument> pargs);
126 viterbi_args get_viterbi_arguments(std::vector<Argument> pargs);
127 pvalue_args get_pvalue_arguments(std::vector<Argument> pargs);
128 lhtest_args get_lhtest_arguments(std::vector<Argument> pargs);
129 esterror_args get_esterror_arguments(std::vector<Argument> pargs);
131 
132 struct roots
133 {
134  std::vector<double> extinct;
135  std::vector<int> size;
136  std::vector<int> num;
137  std::vector<double> avg_extinct;
139 
142 };
143 
144 void run_viterbi_sim(pCafeTree pcafe, pCafeFamily pfamily, roots& roots);
145 int init_histograms(int rfsize, roots& roots, int nsamples);
146 void get_doubles_array(std::vector<double>& loc, pArgument parg);
147 void log_param_values(std::ostream& ost, Globals& globals);
148 
149 const int REQUIRES_FAMILY = 0x01;
150 const int REQUIRES_TREE = 0x02;
151 const int REQUIRES_LAMBDA = 0x04;
152 const int REQUIRES_ERRORMODEL = 0x08;
153 
154 void prereqs(pCafeParam param, int flags);
155 
156 class io_error : public std::runtime_error
157 {
158  std::string text;
159 public:
160  io_error(std::string source, std::string file, bool write);
161  virtual ~io_error() throw() {}
162 
163  virtual const char* what() const throw()
164  {
165  return text.c_str();
166  }
167 };
168 
169 
170 #endif
171 
viterbi_args get_viterbi_arguments(std::vector< Argument > pargs)
int argc
Definition: cafe_commands.h:18
Definition: cafe_commands.h:156
void run_viterbi_sim(pCafeTree pcafe, pCafeFamily pfamily, roots &roots)
Definition: cafe_commands.cpp:1180
virtual const char * what() const
Definition: cafe_commands.h:163
pvalue_args get_pvalue_arguments(std::vector< Argument > pargs)
int write_family_gainloss(std::ostream &ofst, std::string family_id, pCafeTree tree1, pCafeTree tree2)
bool peakzero
Definition: cafe_commands.h:120
int num_random_samples
Definition: cafe_commands.h:85
int get_num_trials(std::vector< std::string > args)
pHistogram * phist_data
Definition: cafe_commands.h:140
void write_leaves(std::ostream &ofst, pCafeTree pcafe, int *k, int i, int id, bool evens)
io_error(std::string source, std::string file, bool write)
Definition: cafe_commands.cpp:228
std::string tree
Definition: cafe_commands.h:110
int total_extinct
Definition: cafe_commands.h:138
std::string family_file_name
Definition: cafe_commands.h:90
std::vector< int > num
Definition: cafe_commands.h:136
const int REQUIRES_LAMBDA
Definition: cafe_commands.h:151
void validate(esterror_args args)
Definition: cafe_commands.cpp:1616
Definition: cafe_commands.h:93
double simerror(pCafeFamily pcf, std::string prefix, int repeat)
Definition: simerror.cpp:128
int num_threads
Definition: cafe_commands.h:84
std::string outfile
Definition: cafe_commands.h:111
double pvalue
Definition: cafe_commands.h:87
load_args get_load_arguments(std::vector< Argument > pargs)
void log_param_values(std::ostream &ost, Globals &globals)
Definition: cafe_commands.cpp:1845
int idx
Definition: cafe_commands.h:96
double lambda
Definition: cafe_commands.h:112
Definition: Globals.h:13
std::string outfile
Definition: cafe_commands.h:103
void clear_tree_viterbis(pCafeTree psum)
Definition: cafe_commands.cpp:422
std::string infile
Definition: cafe_commands.h:102
std::string item_id
Definition: cafe_commands.h:97
std::vector< double > avg_extinct
Definition: cafe_commands.h:137
void write_node_headers(std::ostream &s1, std::ostream &s2, pCafeTree pcafe)
Definition: cafe_commands.h:132
std::string truth_file
Definition: cafe_commands.h:121
string version
Definition: conf.py:69
Definition: cafe_commands.h:15
std::vector< int > get_clusters(int parameterized_k_value, int num_families, double *k_weights)
Definition: cafe_commands.cpp:647
bool filter
Definition: cafe_commands.h:88
int init_histograms(int rfsize, roots &roots, int nsamples)
Definition: cafe_commands.cpp:1203
esterror_args get_esterror_arguments(std::vector< Argument > pargs)
const int REQUIRES_TREE
Definition: cafe_commands.h:150
bool all
Definition: cafe_commands.h:94
pHistogram * phist_sim
Definition: cafe_commands.h:141
Argument * pArgument
Definition: cafe_commands.h:22
std::string directory
Definition: cafe_commands.h:109
std::vector< double > extinct
Definition: cafe_commands.h:134
std::string log_file_name
Definition: cafe_commands.h:89
viterbi_parameters * viterbi
Definition: Globals.h:23
void write_family(std::ostream &ost, pCafeFamily family)
std::string outfile
Definition: cafe_commands.h:117
int(* cafe_command2)(Globals &globals, std::vector< std::string >)
Definition: cafe_commands.h:27
void tree_set_branch_lengths(pCafeTree pcafe, std::vector< int > lengths)
Definition: cafe_commands.cpp:1703
bool symmetric
Definition: cafe_commands.h:119
const int REQUIRES_ERRORMODEL
Definition: cafe_commands.h:152
Definition: cafe_commands.h:107
int index
Definition: cafe_commands.h:104
Singleton structure that holds all of the global data that Cafe acts on.
Definition: family.h:115
const int REQUIRES_FAMILY
Definition: cafe_commands.h:149
char ** argv
Definition: cafe_commands.h:19
Definition: cafe_commands.h:115
std::map< std::string, cafe_command2 > get_dispatcher()
Holds the list of commands that are available in Cafe.
Definition: cafe_commands.cpp:173
std::vector< int > size
Definition: cafe_commands.h:135
void viterbi_write(std::ostream &ost, pCafeTree pcafe, pCafeFamily pfamily)
double pvalue(double v, const double *conddist, int size)
Definition: mathfunc.c:663
#define COMMAND(signal)
Definition: cafe_commands.h:30
virtual ~io_error()
Definition: cafe_commands.h:161
tuple args
Definition: mcl2rawcafe.py:48
std::vector< std::string > data_error_files
Definition: cafe_commands.h:118
int max_diff
Definition: cafe_commands.h:122
void prereqs(pCafeParam param, int flags)
Definition: cafe_commands.cpp:459
std::string file
Definition: cafe_commands.h:95
Definition: cafe_commands.h:83
std::string opt
Definition: cafe_commands.h:17
lhtest_args get_lhtest_arguments(std::vector< Argument > pargs)
Structure representing a matrix of values of family sizes.
Definition: family.h:88
Definition: cafe_commands.h:100
Definition: family.h:17
int cafe_shell_dispatch_command(Globals &globals, char *cmd)
Definition: cafe_commands.cpp:503
Definition: mathfunc.h:108
void get_doubles_array(std::vector< double > &loc, pArgument parg)
void list_commands(std::ostream &ost)
Definition: cafe_commands.cpp:389
std::vector< Argument > build_argument_list(std::vector< std::string > tokens)
void write_version(std::ostream &ost)
int max_size
Definition: cafe_commands.h:86