00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00029 #ifndef SEQPP_PMM_TREE_H
00030 #define SEQPP_PMM_TREE_H
00031
00032 #include <seqpp/pmm_node.h>
00033 #include <seqpp/pmm_leaf.h>
00034 #include <seqpp/SequenceSet.h>
00035 #include <seqpp/Partition.h>
00036 #include <string>
00037 #include <gsl/gsl_sf.h>
00038
00039 #ifdef HAVE_LIBXML2
00040 #include <libxml/tree.h>
00041 #endif
00042 using namespace std ;
00043
00044
00051 class pmm_tree {
00052 public:
00061 pmm_tree::pmm_tree( short alphabet_size,
00062 Partition & partition,
00063 int depth,
00064 double prior_alpha = -1.,
00065 double penalty = 0. );
00066
00068 ~pmm_tree() ;
00069
00075 double select( const unsigned long * count, bool decal_required,
00076 Partition & partition );
00077
00081 int nb_leaves() const{
00082 return _nbleaves;
00083 }
00084
00088 void tree_to_matrix( double* mat );
00089
00090
00091 #ifdef HAVE_LIBXML2
00092 void save( const Translator & trans,
00093 xmlNodePtr parent_node, const string &treename );
00094 #endif
00095
00096 private:
00097
00098 short _alphabet_size;
00100 pmm_node * _root ;
00102 int _depth;
00104 int _nbleaves;
00106 double _prior_alpha;
00108 double _penalty;
00109
00110
00111
00112 int ** _code;
00114 vector<unsigned long> _count;
00115
00116 int * _codeinterm;
00117 Partition::const_iterator _it;
00118 Partition::const_iterator _end;
00119 Partition::const_iterator _bestpart;
00120
00121 vector<short>::iterator * _tab;
00122 vector<short>::iterator * _tabend;
00123
00124 vector< vector<short> > _synonymous;
00125 short _syn_size;
00126 short * _corresp;
00127
00128 vector< vector<short> > _list;
00129 int _motifdefault;
00130 short _motifdefault_skip;
00131
00132
00136 double select_step(node_base * noeud, Partition & partition) ;
00137
00138 double complete(node_base * noeud) ;
00139
00145 long count_hmotif( vector< int > & path,
00146 vector<long> & counts, short howmany_next ) ;
00147
00148 inline pmm_node & getRoot() {
00149 return *_root ;
00150 };
00151 pmm_leaf & getLeaf(vector<short> & rpath) ;
00152
00153 pmm_leaf & getLeaf(unsigned long code) ;
00154
00156 void prune( pmm_node * n );
00157
00158
00159
00160 void set_code();
00161
00162 void set_count( const unsigned long * count, bool decal_required );
00163 void set_count_r( const unsigned long * count,
00164 unsigned long code, unsigned long codesyn, short depth );
00165
00167 int nbword_in_vmotif( const vector< int > & path ){
00168 short i;
00169 int nb = 1;
00170 for ( i=0; i<_depth; i++)
00171 nb *= _list[ path[i] ].size();
00172 return nb;
00173 }
00174 };
00175 #endif