bpp-phyl  2.2.0
SubstitutionCount.h
Go to the documentation of this file.
1 //
2 // File: SubstitutionCount.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Apr 5 11:08 2006
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004, 2005, 2006)
9 
10  This software is a computer program whose purpose is to provide classes
11  for phylogenetic data analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _SUBSTITUTIONCOUNT_H_
41 #define _SUBSTITUTIONCOUNT_H_
42 
43 #include "SubstitutionRegister.h"
44 #include "../Model/SubstitutionModel.h"
45 
46 #include <Bpp/Numeric/Matrix/Matrix.h>
47 
48 //From the STL:
49 #include <vector>
50 
51 namespace bpp
52 {
53 
71  public virtual Clonable
72  {
73  public:
75  virtual ~SubstitutionCount() {}
76  virtual SubstitutionCount* clone() const = 0;
77 
78  public:
82  virtual bool hasSubstitutionRegister() const = 0;
83 
87  virtual const SubstitutionRegister* getSubstitutionRegister() const = 0;
88 
93 
98  virtual void setSubstitutionRegister(SubstitutionRegister* reg) = 0;
99 
106 
112  virtual const Alphabet* getAlphabet() const { return getSubstitutionRegister()->getAlphabet(); }
113 
119  virtual size_t getNumberOfStates() const { return getSubstitutionRegister()->getAlphabet()->getSize(); }
120 
121 
132  virtual double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type) const = 0;
133 
141  virtual Matrix<double>* getAllNumbersOfSubstitutions(double length, size_t type) const = 0;
142 
151  virtual std::vector<double> getNumberOfSubstitutionsForEachType(size_t initialState, size_t finalState, double length) const = 0;
152 
158  virtual void setSubstitutionModel(const SubstitutionModel* model) = 0;
159  };
160 
167  public virtual SubstitutionCount
168  {
169  protected:
170  std::auto_ptr<SubstitutionRegister> register_;
171 
172  public:
174  register_(reg)
175  {}
176 
178  register_(asc.register_.get() ? asc.register_->clone() : 0)
179  {}
180 
182  if (asc.register_.get())
183  register_.reset(asc.register_->clone());
184  else
185  register_.reset();
186  return *this;
187  }
188 
190 
191  public:
192  bool hasSubstitutionRegister() const { return (register_.get() != 0); }
193 
202  register_.reset(reg);
204  }
205 
206  const SubstitutionRegister* getSubstitutionRegister() const { return register_.get(); }
207 
209 
210  protected:
211  virtual void substitutionRegisterHasChanged() = 0;
212  };
213 
214 } //end of namespace bpp.
215 
216 #endif //_SUBSTITUTIONCOUNT_H_
217 
Interface for all substitution models.
void setSubstitutionRegister(SubstitutionRegister *reg)
attribution of a SubstitutionRegister
AbstractSubstitutionCount & operator=(const AbstractSubstitutionCount &asc)
std::auto_ptr< SubstitutionRegister > register_
virtual size_t getNumberOfStates() const
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Basic implementation of the the SubstitutionCount interface.
The SubstitutionRegister interface.
virtual double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type) const =0
Get the number of susbstitutions on a branch, given the initial and final states, and the branch leng...
virtual SubstitutionCount * clone() const =0
virtual const SubstitutionRegister * getSubstitutionRegister() const =0
virtual std::vector< double > getNumberOfSubstitutionsForEachType(size_t initialState, size_t finalState, double length) const =0
Get the numbers of susbstitutions on a branch for all types, for an initial and final states...
virtual size_t getNumberOfSubstitutionTypes() const
Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes().
AbstractSubstitutionCount(const AbstractSubstitutionCount &asc)
const SubstitutionRegister * getSubstitutionRegister() const
virtual const Alphabet * getAlphabet() const
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
The SubstitutionsCount interface.
virtual size_t getNumberOfSubstitutionTypes() const =0
SubstitutionRegister * getSubstitutionRegister()
AbstractSubstitutionCount(SubstitutionRegister *reg)
virtual bool hasSubstitutionRegister() const =0
virtual void setSubstitutionModel(const SubstitutionModel *model)=0
Set the substitution model associated with this count, if relevent.
virtual Matrix< double > * getAllNumbersOfSubstitutions(double length, size_t type) const =0
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branc...
virtual void substitutionRegisterHasChanged()=0
virtual void setSubstitutionRegister(SubstitutionRegister *reg)=0
virtual const Alphabet * getAlphabet() const =0