bpp-phyl3  3.0.0
WordFrequencySet.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_MODEL_FREQUENCYSET_WORDFREQUENCYSET_H
6 #define BPP_PHYL_MODEL_FREQUENCYSET_WORDFREQUENCYSET_H
7 
10 
11 #include "FrequencySet.h"
12 
13 namespace bpp
14 {
15 /*********************************************************************/
16 /**** Frequencies Set in Words *****/
17 /*********************************************************************/
18 
19 
29  public virtual FrequencySetInterface
30 {
31 protected:
32  virtual size_t getSizeFromVector(const std::vector<std::unique_ptr<FrequencySetInterface>>& freqVector) = 0;
33 
34 public:
35  WordFrequencySetInterface* clone() const override = 0;
36 
37  virtual std::shared_ptr<const CoreWordAlphabet> getWordAlphabet() const = 0;
38 
42  virtual const FrequencySetInterface& frequencySetForLetter(size_t i) const = 0;
43 
47  virtual size_t getLength() const = 0;
48 };
49 
50 
52  public virtual WordFrequencySetInterface,
54 {
55 protected:
56  size_t getSizeFromVector(const std::vector<std::unique_ptr<FrequencySetInterface>>& freqVector) override;
57 
58 public:
59  AbstractWordFrequencySet(std::shared_ptr<const StateMapInterface> stateMap, const std::string& prefix = "", const std::string& name = "");
60 
61  AbstractWordFrequencySet* clone() const override = 0;
62 
65 
67  {
69  return *this;
70  }
71 
72  std::shared_ptr<const CoreWordAlphabet> getWordAlphabet() const override
73  {
74  return std::dynamic_pointer_cast<const CoreWordAlphabet>(getAlphabet());
75  }
76 
77  virtual ~AbstractWordFrequencySet();
78 
82  size_t getLength() const override;
83 };
84 
85 
93 {
94 protected:
95  std::vector<std::unique_ptr<FrequencySetInterface>> vFreq_;
96  std::vector<std::string> vNestedPrefix_;
97 
98 public:
104  std::shared_ptr<const WordAlphabet> pWA,
105  std::vector<std::unique_ptr<FrequencySetInterface>>& freqVector,
106  const std::string& prefix = "",
107  const std::string& name = "WordFromIndependent");
108 
110  std::shared_ptr<const CodonAlphabet> pWA,
111  std::vector<std::unique_ptr<FrequencySetInterface>>& freqVector,
112  const std::string& prefix = "",
113  const std::string& name = "WordFromIndependent");
114 
116 
118 
120 
122  {
123  return new WordFromIndependentFrequencySet(*this);
124  }
125 
126 public:
127  void fireParameterChanged(const ParameterList& pl) override;
128 
129  virtual void updateFrequencies();
130 
137  virtual void setFrequencies(const std::vector<double>& frequencies) override;
138 
142  const FrequencySetInterface& frequencySetForLetter(size_t i) const override
143  {
144  return *vFreq_[i];
145  }
146 
150  virtual size_t getLength() const override;
151 
152  void setNamespace(const std::string& prefix) override;
153 
154  std::string getDescription() const;
155 };
156 
159 {
160 protected:
161  std::unique_ptr<FrequencySetInterface> pFreq_;
162  std::string NestedPrefix_;
163  size_t length_;
164 
165 public:
171  std::shared_ptr<const WordAlphabet> pWA,
172  std::unique_ptr<FrequencySetInterface> pabsfreq,
173  const std::string& prefix = "",
174  const std::string& name = "WordFromUnique");
175 
177  std::shared_ptr<const CodonAlphabet> pWA,
178  std::unique_ptr<FrequencySetInterface> pabsfreq,
179  const std::string& prefix = "",
180  const std::string& name = "WordFromUnique");
181 
183 
185 
186  virtual ~WordFromUniqueFrequencySet();
187 
189  {
190  return new WordFromUniqueFrequencySet(*this);
191  }
192 
193 public:
194  virtual void fireParameterChanged(const ParameterList& pl) override;
195 
203  virtual void setFrequencies(const std::vector<double>& frequencies) override;
204 
205  virtual void updateFrequencies();
206 
210  const FrequencySetInterface& frequencySetForLetter(size_t i) const override
211  {
212  return *pFreq_;
213  }
214 
215  size_t getLength() const override { return length_; }
216 
217  void setNamespace(const std::string& prefix) override;
218 
219  std::string getDescription() const;
220 };
221 } // end of namespace bpp.
222 #endif // BPP_PHYL_MODEL_FREQUENCYSET_WORDFREQUENCYSET_H
Basic implementation of the FrequencySet interface.
Definition: FrequencySet.h:102
std::shared_ptr< const Alphabet > getAlphabet() const override
Definition: FrequencySet.h:140
AbstractFrequencySet & operator=(const AbstractFrequencySet &af)
Definition: FrequencySet.h:129
const StateMapInterface & stateMap() const override
Definition: FrequencySet.h:144
size_t getLength() const override
AbstractWordFrequencySet(const AbstractWordFrequencySet &af)
std::shared_ptr< const CoreWordAlphabet > getWordAlphabet() const override
AbstractWordFrequencySet & operator=(const AbstractWordFrequencySet &af)
AbstractWordFrequencySet * clone() const override=0
AbstractWordFrequencySet(std::shared_ptr< const StateMapInterface > stateMap, const std::string &prefix="", const std::string &name="")
size_t getSizeFromVector(const std::vector< std::unique_ptr< FrequencySetInterface >> &freqVector) override
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Frequencies in words computed from the frequencies on letters. The parameters are the parameters of t...
virtual size_t getLength() const =0
Returns the length of the words.
virtual const FrequencySetInterface & frequencySetForLetter(size_t i) const =0
Returns the n-th FrequencySet.
virtual size_t getSizeFromVector(const std::vector< std::unique_ptr< FrequencySetInterface >> &freqVector)=0
WordFrequencySetInterface * clone() const override=0
virtual std::shared_ptr< const CoreWordAlphabet > getWordAlphabet() const =0
the Frequencies in words are the product of Independent Frequencies in letters
WordFromIndependentFrequencySet(std::shared_ptr< const WordAlphabet > pWA, std::vector< std::unique_ptr< FrequencySetInterface >> &freqVector, const std::string &prefix="", const std::string &name="WordFromIndependent")
Constructor from a WordAlphabet* and a vector of different std::shared_ptr<FrequencySet>....
std::vector< std::string > vNestedPrefix_
WordFromIndependentFrequencySet & operator=(const WordFromIndependentFrequencySet &iwfs)
const FrequencySetInterface & frequencySetForLetter(size_t i) const override
Return the n-th FrequencySet&.
WordFromIndependentFrequencySet * clone() const override
virtual size_t getLength() const override
Return the length of the words.
void setNamespace(const std::string &prefix) override
void fireParameterChanged(const ParameterList &pl) override
std::vector< std::unique_ptr< FrequencySetInterface > > vFreq_
virtual void setFrequencies(const std::vector< double > &frequencies) override
Independent letter frequencies from given word frequencies. The frequencies of a letter at a position...
size_t getLength() const override
virtual void fireParameterChanged(const ParameterList &pl) override
std::unique_ptr< FrequencySetInterface > pFreq_
WordFromUniqueFrequencySet * clone() const override
WordFromUniqueFrequencySet & operator=(const WordFromUniqueFrequencySet &iwfs)
const FrequencySetInterface & frequencySetForLetter(size_t i) const override
Return the n-th FrequencySet&.
virtual void setFrequencies(const std::vector< double > &frequencies) override
letter frequencies from given word frequencies. The frequencies of a letter at a position is the sum ...
WordFromUniqueFrequencySet(std::shared_ptr< const WordAlphabet > pWA, std::unique_ptr< FrequencySetInterface > pabsfreq, const std::string &prefix="", const std::string &name="WordFromUnique")
Constructor from a WordAlphabet* and a std::shared_ptr<FrequencySet> repeated as many times as the le...
void setNamespace(const std::string &prefix) override
Defines the basic types of data flow nodes.