Version 4.0.0
Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

pmm_tree.h

00001 /* seqpp/pmm_tree.h
00002  *
00003  * Copyright (C) 2003 Laboratoire Statistique & Génome
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or (at
00008  * your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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   // Optimization Tools ----------------------------
00111   // code("A", i) = code("A") en position i sur depth+1 posit
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



Download seq++ 4.0.0
Download previous versions
Statistique & Genome Home


Generated on Wed Mar 23 09:25:57 2005 for seqpp by doxygen 1.3.9.1