bpp-phyl  2.2.0
WordFrequenciesSet.h
Go to the documentation of this file.
1 //
2 // File: WordFrequenciesSet.h
3 // Created by: Laurent Gueguen
4 // Created on: lundi 2 avril 2012, à 13h 59
5 //
6 
7 /*
8  Copyright or (c) or Copr. Bio++ Development Team, (November 16, 2004)
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 _WORDFREQUENCIESSET_H_
41 #define _WORDFREQUENCIESSET_H_
42 
43 #include <Bpp/Seq/Alphabet/WordAlphabet.h>
44 #include "FrequenciesSet.h"
45 
46 namespace bpp
47 {
48 
49  /*********************************************************************/
50 /**** Frequencies Set in Words *****/
51 /*********************************************************************/
52 
53 
64  public virtual FrequenciesSet
65 {
66 protected:
67 
68  virtual size_t getSizeFromVector(const std::vector<FrequenciesSet*>& freqVector) = 0;
69 
70 public:
71 #ifndef NO_VIRTUAL_COV
72  WordFrequenciesSet* clone() const = 0;
73 
74  const WordAlphabet* getAlphabet() const = 0;
75 #endif
76 
81  virtual const FrequenciesSet& getFrequenciesSetForLetter(size_t i) const = 0;
82 
87  virtual size_t getLength() const = 0;
88 };
89 
90 
92  public virtual WordFrequenciesSet,
94 {
95 protected:
96  size_t getSizeFromVector(const std::vector<FrequenciesSet*>& freqVector);
97 
98 public:
99  AbstractWordFrequenciesSet(StateMap* stateMap, const std::string& prefix = "", const std::string& name="");
100 
101 #ifndef NO_VIRTUAL_COV
103 #else
104  Clonable*
105 #endif
106  clone() const = 0;
107 
110 
112  {
114  return *this;
115  }
116 
117 #ifndef NO_VIRTUAL_COV
118  const WordAlphabet* getAlphabet() const
119  {
120  return dynamic_cast<const WordAlphabet*>(AbstractFrequenciesSet::getAlphabet());
121  }
122 #endif
123 
124  virtual ~AbstractWordFrequenciesSet();
125 
130  size_t getLength() const;
131 };
132 
133 
141 {
142 protected:
143  std::vector<FrequenciesSet*> vFreq_;
144  std::vector<std::string> vNestedPrefix_;
145 
146 public:
151  WordFromIndependentFrequenciesSet(const WordAlphabet* pWA, const std::vector<FrequenciesSet*>& freqVector, const std::string& prefix = "", const std::string& name="WordFromIndependent");
152 
154 
156 
158 
160 
161 public:
162  void fireParameterChanged(const ParameterList& pl);
163 
164  virtual void updateFrequencies();
165 
172  virtual void setFrequencies(const std::vector<double>& frequencies);
173 
177  const FrequenciesSet& getFrequenciesSetForLetter(size_t i) const { return *vFreq_[i]; }
178 
183  virtual size_t getLength() const;
184 
185  void setNamespace(const std::string& prefix);
186 
187  std::string getDescription() const;
188 };
189 
192 {
193 protected:
195  std::string NestedPrefix_;
196  size_t length_;
197 
198 public:
203  WordFromUniqueFrequenciesSet(const WordAlphabet* pWA, FrequenciesSet* pabsfreq, const std::string& prefix = "", const std::string& name = "WordFromUnique");
204 
206 
208 
210 
212 
213 public:
214  virtual void fireParameterChanged(const ParameterList& pl);
215 
223  virtual void setFrequencies(const std::vector<double>& frequencies);
224 
225  virtual void updateFrequencies();
226 
230  const FrequenciesSet& getFrequenciesSetForLetter(size_t i) const { return *pFreq_; }
231 
232  size_t getLength() const { return length_; }
233 
234  void setNamespace(const std::string& prefix);
235 
236  std::string getDescription() const;
237 };
238 
239 } // end of namespace bpp.
240 
241 #endif // _WORDFREQUENCIESSET_H_
242 
243 
virtual const FrequenciesSet & getFrequenciesSetForLetter(size_t i) const =0
virtual size_t getLength() const =0
const WordAlphabet * getAlphabet() const =0
WordFromUniqueFrequenciesSet(const WordAlphabet *pWA, FrequenciesSet *pabsfreq, const std::string &prefix="", const std::string &name="WordFromUnique")
Constructor from a WordAlphabet* and a FrequenciesSet* repeated as many times as the length of the wo...
AbstractWordFrequenciesSet & operator=(const AbstractWordFrequenciesSet &af)
WordFromIndependentFrequenciesSet * clone() const
const FrequenciesSet & getFrequenciesSetForLetter(size_t i) const
size_t getSizeFromVector(const std::vector< FrequenciesSet *> &freqVector)
const WordAlphabet * getAlphabet() const
Parametrize a set of state frequencies.
void setNamespace(const std::string &prefix)
WordFromIndependentFrequenciesSet & operator=(const WordFromIndependentFrequenciesSet &iwfs)
std::vector< FrequenciesSet * > vFreq_
AbstractWordFrequenciesSet * clone() const =0
const FrequenciesSet & getFrequenciesSetForLetter(size_t i) const
Frequencies in words computed from the frequencies on letters. The parameters are the parameters of t...
virtual void setFrequencies(const std::vector< double > &frequencies)
virtual void fireParameterChanged(const ParameterList &pl)
WordFromUniqueFrequenciesSet * clone() const
WordFromIndependentFrequenciesSet(const WordAlphabet *pWA, const std::vector< FrequenciesSet *> &freqVector, const std::string &prefix="", const std::string &name="WordFromIndependent")
Constructor from a WordAlphabet* and a vector of different FrequenciesSet*. Throws an Exception if th...
virtual size_t getSizeFromVector(const std::vector< FrequenciesSet *> &freqVector)=0
const Alphabet * getAlphabet() const
virtual void setFrequencies(const std::vector< double > &frequencies)
AbstractWordFrequenciesSet(const AbstractWordFrequenciesSet &af)
the Frequencies in words are the product of Independent Frequencies in letters
std::vector< std::string > vNestedPrefix_
AbstractWordFrequenciesSet(StateMap *stateMap, const std::string &prefix="", const std::string &name="")
WordFrequenciesSet * clone() const =0
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:58
void setNamespace(const std::string &prefix)
AbstractFrequenciesSet & operator=(const AbstractFrequenciesSet &af)
void fireParameterChanged(const ParameterList &pl)
WordFromUniqueFrequenciesSet & operator=(const WordFromUniqueFrequenciesSet &iwfs)
Basic implementation of the FrequenciesSet interface.