HMSBEAGLE  1.0.0
examples/fourtaxon/fourtaxon.h
00001 #include <vector>
00002 #include <string>
00003 #include "libhmsbeagle/beagle.h"
00004 
00005 typedef std::vector<int> CodedSequence;
00006 typedef std::vector<double> PartialVector;
00007 
00008 /*-----------------------------------------------------------------------------
00009 |       FourTaxonExample reads in DNA sequence data for four taxa and simply 
00010 |       recomputes the likelihood of the following unrooted tree numerous times:
00011 |       
00012 |       (1:0.01, 2:0.02, (3:0.03, 4:0.04):0.05)
00013 |       
00014 |       Future improvements:
00015 |       - estimate something
00016 */
00017 class FourTaxonExample
00018         {
00019         public:
00020                 FourTaxonExample();
00021                 void interpretCommandLineParameters(int argc, char* argv[]);
00022                 void run();
00023                 
00024         private:
00025                 void helpMessage();
00026                 void abort(std::string msg);
00027                 void initBeagleLib();
00028                 void readData();
00029                 void writeData();
00030                 void updateBrlen(unsigned brlen_index);
00031                 void defineOperations();
00032                 double calcLnL(int return_value);
00033                 
00034         private:
00035                 bool                                            quiet;
00036                 unsigned                                        niters;
00037                 unsigned                                        like_root_node;
00038                 unsigned                                        like_parent_index;
00039                 unsigned                                        like_child_index;
00040                 unsigned                                        transmat_index;
00041                 std::string                                     data_file_name;
00042         bool                        scaling;
00043         bool                        single;
00044         bool                        require_double;
00045                 const unsigned                          ntaxa;
00046                 unsigned                                        nsites;
00047         unsigned                    nrates;
00048                 double                                          delta;
00049                 double                                          mu;
00050                 unsigned                                        seed;
00051                 std::vector<std::string>        taxon_name;
00052                 std::vector<CodedSequence>      data;
00053                 std::vector<PartialVector>      partial;
00054                 std::vector<int>                        transition_matrix_index;
00055                 std::vector<double>                     brlens;
00056                 std::vector<int>                        operations;
00057         std::vector<int>            scaleIndices;
00058                 int                                                     instance_handle;
00059                 int                                                     rsrc_number;
00060                 bool                                            use_tip_partials;
00061         bool                        accumulate_on_the_fly;
00062         bool                        dynamic_scaling;
00063         bool                        do_rescaling;
00064         bool                        auto_scaling;
00065                 int                         calculate_derivatives;
00066         bool                        empirical_derivatives;
00067         bool                        sse_vectorization;
00068         };