15 size_t l = freqVector.size();
17 for (
size_t i = 0; i < l; i++)
19 s *= freqVector[i]->getAlphabet()->getSize();
42 std::shared_ptr<const WordAlphabet> pWA,
43 vector<std::unique_ptr<FrequencySetInterface>>& freqVector,
54 if (pWA->getSize() != sf)
57 size_t l = freqVector.size();
59 for (
size_t i = 0; i < l; ++i)
61 vFreq_.push_back(std::move(freqVector[i]));
70 std::shared_ptr<const CodonAlphabet> pWA,
71 vector<std::unique_ptr<FrequencySetInterface>>& freqVector,
82 if (pWA->getSize() != sf)
85 size_t l = freqVector.size();
87 for (
size_t i = 0; i < l; ++i)
90 vFreq_.push_back(std::move(freqVector[i]));
100 vFreq_(iwfs.vFreq_.size()),
101 vNestedPrefix_(iwfs.vNestedPrefix_)
103 for (
unsigned i = 0; i < iwfs.
vFreq_.size(); i++)
120 for (
unsigned i = 0; i <
vFreq_.size(); i++)
134 for (
size_t i = 0; i < l; i++)
136 f |=
vFreq_[i]->matchParametersValues(pl);
147 vector< vector<double>> f(l);
151 for (i = 0; i < l; i++)
153 f[i] =
vFreq_[i]->getFrequencies();
156 for (i = 0; i < s; i++)
160 for (p = l; p > 0; p--)
162 t =
vFreq_[p - 1]->getAlphabet()->getSize();
174 size_t size = frequencies.size();
175 for (
size_t i = 0; i < size; i++)
177 sum += frequencies[i];
179 if (fabs(1. - sum) > 0.000001)
182 size_t d, i, j, k, s, l =
vFreq_.size();
186 for (i = 0; i < l; i++)
188 s =
vFreq_[i]->getAlphabet()->getSize();
191 for (j = 0; j < s; j++)
195 for (k = 0; k < size; k++)
197 freq[(k / d) % s] += frequencies[k];
199 vFreq_[i]->setFrequencies(freq);
202 for (i = 0; i < l; i++)
219 for (
size_t i = 0; i <
vFreq_.size(); i++)
228 for (
size_t i = 1; i <
vFreq_.size(); i++)
230 s +=
" * " +
vFreq_[i]->getName();
240 std::shared_ptr<const WordAlphabet> pWA,
241 std::unique_ptr<FrequencySetInterface> pabsfreq,
242 const string& prefix,
243 const string& name) :
248 pFreq_(std::move(pabsfreq)),
249 NestedPrefix_(pFreq_->getNamespace()),
250 length_(pWA->getLength())
267 std::shared_ptr<const CodonAlphabet> pWA,
268 std::unique_ptr<FrequencySetInterface> pabsfreq,
269 const string& prefix,
270 const string& name) :
275 pFreq_(std::move(pabsfreq)),
276 NestedPrefix_(pFreq_->getNamespace()),
277 length_(pWA->getLength())
295 pFreq_(iwfs.pFreq_->clone()),
296 NestedPrefix_(iwfs.NestedPrefix_),
297 length_(iwfs.length_)
321 if (
pFreq_->matchParametersValues(pl))
329 size_t letsi =
pFreq_->getAlphabet()->getSize();
333 f =
pFreq_->getFrequencies();
335 for (i = 0; i < s; i++)
352 size_t size = frequencies.size();
353 for (
size_t i = 0; i < size; i++)
355 sum += frequencies[i];
357 if (fabs(1. - sum) > 0.000001)
363 size_t letsi =
pFreq_->getAlphabet()->getSize();
366 for (j = 0; j < letsi; j++)
375 for (k = 0; k < size; k++)
377 freq[(k / d) % letsi] += frequencies[k];
380 for (j = 0; j < letsi; j++)
382 freq[j] /=
static_cast<double>(
length_);
385 pFreq_->setFrequencies(freq);
395 for (
unsigned i = 0; i <
length_; i++)
Basic implementation of the FrequencySet interface.
double & getFreq_(size_t i)
std::string getName() const override
void addParameters_(const ParameterList ¶meters)
void setNamespace(const std::string &prefix)
bool matchParametersValues(const ParameterList ¶meters) override
std::string getNamespace() const override
const ParameterList & getParameters() const override
size_t getLength() const override
virtual ~AbstractWordFrequencySet()
std::shared_ptr< const CoreWordAlphabet > getWordAlphabet() const override
AbstractWordFrequencySet & operator=(const AbstractWordFrequencySet &af)
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
This class implements a state map where all resolved states are modeled.
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>....
virtual ~WordFromIndependentFrequencySet()
std::vector< std::string > vNestedPrefix_
virtual void updateFrequencies()
WordFromIndependentFrequencySet & operator=(const WordFromIndependentFrequencySet &iwfs)
std::string getDescription() const
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...
virtual ~WordFromUniqueFrequencySet()
std::string NestedPrefix_
std::string getDescription() const
virtual void fireParameterChanged(const ParameterList &pl) override
std::unique_ptr< FrequencySetInterface > pFreq_
virtual void updateFrequencies()
WordFromUniqueFrequencySet & operator=(const WordFromUniqueFrequencySet &iwfs)
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
std::string toString(T t)
Defines the basic types of data flow nodes.