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

vlm_tree.h

00001 
00002 /* seqpp/vlm_tree.h
00003  *
00004  * Copyright (C) 2003 Laboratoire Statistique & Génome
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or (at
00009  * your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 
00033 #ifndef SEQPP_VLM_TREE_H
00034 #define SEQPP_VLM_TREE_H
00035 
00036 #include <seqpp/tree_t.h>
00037 #include <seqpp/SequenceSet.h>
00038 #include <seqpp/Coder.h>
00039 
00047 class vlm_tree:public tree_t < vector<double> >
00048 { 
00049  public:
00050   typedef tree_iterator < vector<double>, vector<double> &, vector<double> * >iterator; 
00051   typedef tree_t < vector<double> > tree;       
00052   typedef tree_node < vector<double> > node;    
00053 
00054 
00060   vlm_tree (Coder & coder, 
00061           int size, int maxdepth, vector<double> & init)
00062     :tree( size, init,  maxdepth )
00063   {      
00064     _size = size;
00065     _nbleaves = 0;
00066     _coder = &coder;
00067     _max_depth = maxdepth;
00068     _tmpcounts = new long[_size];
00069   };
00070 
00076   vlm_tree (Coder & coder,
00077           int size, vector<double> & init, int maxdepth, 
00078           const unsigned long * _count, int min_count = 3)
00079     :tree (size, init)
00080   {
00081     _size = size;
00082     _nbleaves = 0;
00083     _coder = &coder;
00084     _max_depth = maxdepth;
00085     _tmpcounts = new long[_size];
00086     iterator it = begin ();
00087     set_count( _count );
00088     filltree (size, init, 0, it, min_count);
00089   };
00090   
00092   virtual ~vlm_tree(){
00093     delete[] _tmpcounts;
00094   }
00095 
00103   long estimate_context ( const unsigned long * count, double cutoff );
00104 
00109   double loglikelihood( const unsigned long * count );
00110   
00114   int depth () const;
00115 
00119   int nb_leaves() const{
00120     return _nbleaves;
00121   }
00122   
00126   void tree_to_matrix( double* mat );
00127 
00128   // on verra + tard
00129   //void fig_output (char *FigFile);
00130 
00137   //double proba(const vector<short> word, short next) const;
00138   
00143   /*
00144     double likelihood (const SequenceSet & seq);
00145   */
00146 
00147   /*
00148     double BIC (const SequenceSet & seq, double cutoof){ 
00149     nb_leaves = arbre.estimate_context( arrseq, cutoff );
00150     return -2*likelihood(seq)
00151     +2*(_size-1)*nb_leaves*log( double(seq.tell_total_length()) );
00152     }
00153   */
00154   
00155  private:
00156   int _max_depth;               
00157   int _size;            
00158   int _nbleaves;        
00159 
00161   const unsigned long * _count;
00162 
00163   // tools
00164   long *_tmpcounts;
00165   Coder * _coder;
00166 
00167 
00173   void filltree (int size, vector<double> & init, int depth,
00174                  iterator & it,  int min_count = 3);
00175   
00181   void transitions ( iterator & it);
00182   
00183   
00189   bool estimate_context ( double &cutoff,
00190                           vlm_tree::iterator & it);
00191  
00198   void transitions( );
00199 
00200  
00207   long estimate_leaves( );
00208 
00210   void set_count( const unsigned long * count ){    
00211     _count = count; 
00212   }
00213  
00215   long path_code( iterator & it )
00216   {
00217     iterator tmpit( it ); // a netoyer!!!!!
00218     _coder->clear();
00219     while (!tmpit.on_root ())
00220       {
00221         _coder->push_back( tmpit.label () );
00222         tmpit.father ();
00223       }
00224     return _coder->_code; 
00225   }
00226 };
00227 #endif



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


Generated on Thu Aug 4 18:34:04 2005 for seqpp by doxygen 1.3.9.1