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

PrimaryCount.h

Go to the documentation of this file.
00001 /* seqpp/PrimaryCount.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 
00029 #ifndef SEQPP_PRIMARYCOUNT_H
00030 #define SEQPP_PRIMARYCOUNT_H
00031 
00032 #include <seqpp/Coder.h>
00033 
00064 class PrimaryCount
00065 {
00066  protected:
00067    //-----------------------
00069    short _order;
00071    long _nbvalue;
00073    short _nbinv;   
00074 
00076    Coder * _coder;
00078    bool _coder_in;
00079   
00080    //-----------------------
00082    unsigned long * * _count;
00084    bool _count_ok; 
00086    short _phase;
00087     
00089    void init_count() const;
00090 
00091    //----------------------- 
00093    virtual unsigned long tell_max_count() const = 0;  
00095    virtual void compute_count( unsigned long * * extern_count, 
00096                                short phase,
00097                                short initial_phase,
00098                                unsigned long beg,
00099                                unsigned long end ) const = 0;
00100    //----------------------- 
00101                           
00102  public:
00103 
00104   PrimaryCount(){ 
00105     //cout<<"default constr pr.count"<<endl;
00106     _order = -1;_nbvalue=0;_nbinv=0;_coder=NULL;_coder_in=false;
00107     _count=NULL;_count_ok=false;_phase=0;
00108   };
00109 
00110 
00112    virtual ~PrimaryCount(){
00113      //cout<<"debut destruct. pr.count"<<endl;
00114      if (_coder_in)
00115        delete _coder;
00116      //cout<<"c ici"<<endl;
00117      this->clear_count();
00118      //cout<<"fin destruct. pr.count"<<endl;
00119    }
00120 
00121    //-----------------------  
00123    void clear_count() const;
00124 
00126   void null_count() const;
00127 
00129    short tell_order() const{
00130            return _order;
00131    }
00133    int tell_nb_value() const{
00134      return _nbvalue;
00135    }    
00137    long tell_jump() const{
00138      return _coder->tell_jump();
00139    }
00140 
00142   long * get_jump() const{
00143      return _coder->get_jump();
00144    }
00145    
00147    Coder &  get_coder() const{
00148      return *_coder;
00149    }
00150   
00151   //-----------------------
00153   bool is_count_ok() const{
00154     return _count_ok;
00155   }
00156   
00158   unsigned long * * get_p_count() const{
00159     return _count;
00160   } 
00161   
00163 
00166   unsigned long * get_count( short p = 0 ) const{
00167      return _count[p];
00168    }
00169 
00171   short tell_phase() const{
00172     return _phase;
00173   }
00174   
00175   //--------------------------------------------- 
00177 
00183    void count_p_occurencies( short phase,
00184                              short initial_phase,
00185                              unsigned long beg,
00186                              unsigned long end ) const{
00187      compute_count( const_cast< PrimaryCount* >( this )->_count,
00188                     phase, initial_phase, beg, end );       
00189    }
00190   
00192 
00199   void count_p_occurencies( unsigned long * * extern_count, 
00200                             short phase,
00201                             short initial_phase,
00202                             unsigned long beg,
00203                             unsigned long end ) const{
00204     compute_count( extern_count, phase, initial_phase, beg, end );
00205    }
00206     
00208 
00213   void count_p_occurencies( unsigned long * * extern_count, 
00214                             short phase,
00215                             short initial_phase = 0 ) const{
00216     count_p_occurencies(  extern_count, phase, initial_phase, 0, 0 );
00217   }
00218   
00220 
00224   void count_p_occurencies( short phase,
00225                             short initial_phase = 0 ) const{
00226     count_p_occurencies( phase, initial_phase, 0, 0 );
00227   } 
00228   
00229   //---------------------------------------------
00231 
00235   void count_occurencies( unsigned long beg,
00236                           unsigned long end ) const {
00237     count_p_occurencies(1,0,beg,end);
00238   }
00239 
00241   void count_occurencies( ) const{
00242     count_p_occurencies( 1, 0, 0, 0 );
00243   } 
00244  
00245   //---------------------------------------------
00247   unsigned long tell_p_occurencies( long code, short numphase ) const;
00248 
00250   unsigned long tell_occurencies( long code ) const {
00251     return tell_p_occurencies( code, 0 ) ;
00252   }
00253 };
00254 #endif



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


Generated on Sun Apr 3 14:16:10 2005 for seqpp by doxygen 1.3.9.1