00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00029 #ifndef SEQPP_PMM_FOREST_H
00030 #define SEQPP_PMM_FOREST_H
00031
00032 #include <seqpp/pmm_tree.h>
00033
00039 class pmm_forest {
00040
00041 public:
00051 pmm_forest( Partition & part,
00052 short alphabet_size,
00053 int depth,
00054 vector<double>& prior_alpha, bool motif_prior = true,
00055 double penalty = 0. );
00056
00058 ~pmm_forest();
00059
00065 pmm_tree select( const unsigned long * count );
00066
00067
00069
00072 bool extended_tree( const unsigned long * count );
00073
00075 bool extended_tree(){
00076 return extended_tree(NULL);
00077 }
00078
00079 bool extended_ok() const{
00080 return (_ftree!=NULL);
00081 }
00082
00084
00087 double mean_post_log_likelihood( const unsigned long * count_e );
00088
00090
00093 double mean_post_log_likelihood( );
00094
00096
00098
00101 pmm_tree draw( gsl_rng * r );
00102
00104 double post_log_likelihood( const unsigned long * count_e );
00105
00106 double post_log_likelihood_2( const unsigned long * count_e );
00107
00108
00109 void set_penalty( double penalty ){
00110 _penalty = penalty;
00111 }
00112
00114 pmm_tree& current_pmm_tree( ){
00115 return _curr_p_t;
00116 }
00117
00118 protected:
00119
00120
00121
00123 Partition _part;
00125 long _part_nbposs;
00126
00128 short _alphabet_size;
00130 short _syn_size;
00132 int _depth;
00133
00134
00136 vector<double> _prior_alpha;
00137 vector<double> _tmp_prior_alpha;
00138 bool _motif_prior;
00139
00141 double _penalty;
00142
00144 pmm_tree _curr_p_t;
00145
00147 bool _completed;
00148
00149
00150
00151 short * _corresp;
00153 int ** _code;
00155 vector<unsigned long> _count;
00156 int * _codeinterm;
00157 Partition::const_iterator _it;
00158 Partition::const_iterator _end;
00159 Partition::const_iterator _bestpart;
00160 vector<short>::const_iterator * _tab;
00161 vector<short>::const_iterator * _tabend;
00162
00163
00168 double * _ftree;
00169 double _sum_ftree;
00170 double * _ftree_mlike;
00171 double * _ftree_to_extend;
00173 double ** _alpha;
00175 double* _theta;
00177 long _nbposs;
00182 Coder * _path;
00187 vector<int> _vpath;
00189 long _cpath;
00190
00191
00192
00193
00199 long count_hmotif( vector< int > & path,
00200 vector<long> & counts, short howmany_next ) ;
00201
00202 double select_r( pmm_tree_rep& rep, node_base& node ) ;
00203
00204
00205 double extended_tree_core( const unsigned long * count, bool clear_count=true );
00207 double extended_tree_r( short depth );
00208
00210 void draw_r( node_base& node, short depth, gsl_rng * r );
00211
00213 double mean_post_likelihood_r( short depth );
00214
00216 void draw_dist(double * alpha, gsl_rng * r) ;
00217
00219 double ln_sumexp(const double * logs, int nlogs) ;
00220
00221
00222 double post_log_likelihood_r( const unsigned long * count_e,
00223 node_base& node, bool force=false );
00224
00226 int count_hmotif( vector< int > & path,
00227 vector<long> & counts_t,
00228 const unsigned long * count_e, vector<long> & counts_e,
00229 short howmany_next );
00230
00231
00232
00233 void set_code();
00234
00235 void set_count( const unsigned long * count, bool clear_count=true );
00236 void set_count_r( const unsigned long * count,
00237 unsigned long code, unsigned long codesyn, short depth );
00238
00239
00241 int nbword_in_vmotif( const vector< int > & path );
00243 int nbword_in_cmotif( long cpath );
00244 };
00245
00246 #endif //PMM_FOREST