51 for (
size_t i = 0; i <
set.vpHyperNodes_.size(); i++)
89 for (
size_t i = 0; i <
set.vpHyperNodes_.size(); i++)
117 for (i = 0; i < nbm; i++)
131 for (i = 0; i < nbm; i++)
137 int snd =
static_cast<int>(nd.
size());
144 while ((k < snd) && (nd[static_cast<size_t>(k)] < j))
146 if ((k >= snd) || (nd[static_cast<size_t>(k)] > j))
160 throw BadIntegerException(
"MixedSubstitutionModelSet::addToHyperNode. Bad HyperNode number", nH);
165 throw IndexOutOfBoundsException(
"MixedSubstitutionModelSet::addToHyperNode. Bad Mixed Model number", nM, 0,
getNumberOfModels());
175 for (
size_t i = 0; i < nhn; i++)
204 for (fmM = 0; fmM < nbm; fmM++)
219 for (
size_t nh = 0; nh < nbh; nh++)
225 for (
size_t i = 0; i < fnd.
size(); i++)
234 for (
size_t iM = fmM + 1; iM < nbm; iM++)
239 for (
size_t nh = 0; nh < nbh; nh++)
244 for (
size_t j = 0; j < fnd.
size(); j++)
250 for (
size_t j = 0; j < fnd.
size(); j++)
262 for (
size_t nh = 0; nh < nbh; nh++)
266 for (
size_t j = 0; j < fnd.
size(); j++)
280 for (
size_t fmM = 0; fmM < nbm; fmM++)
288 for (
size_t i = 0; i < fnd.
size(); i++)
313 vUnused_.push_back(static_cast<int>(i));
318 vUnused_(hn.vUnused_),
327 for (
size_t i = 0; i < hn.
vNumbers_.size(); i++)
332 vUnused_.resize(hn.
vUnused_.size());
333 for (
size_t i = 0; i < hn.
vUnused_.size(); i++)
345 if (nM >= vNumbers_.size())
346 throw IndexOutOfBoundsException(
"MixedSubstitutionModelSet::HyperNode::addToModel. Bad Mixed model Number", nM, 0, vNumbers_.size());
348 vNumbers_[nM].insertN(vnS);
353 if (nM >= vNumbers_.size())
354 throw IndexOutOfBoundsException(
"MixedSubstitutionModelSet::HyperNode::setModel. Bad Mixed model Number", nM, 0, vNumbers_.size());
362 size_t vUs = vUnused_.size();
363 for (
size_t i = 0; i < vNumbers_.size(); ++i)
365 for (k = 0; k < vUs; k++)
367 if (vUnused_[k] == static_cast<int>(i))
370 if ((k == vUs) && vNumbers_[i].size() == 0)
378 for (
size_t i = 0; i < vNumbers_.size(); i++)
389 for (
size_t i = 0; i < vNumbers_.size(); i++)
391 if (vNumbers_[i].intersects(hn.
vNumbers_[i]))
405 for (
size_t i = 0; i < vNumbers_.size(); i++)
419 vector<int>::iterator it;
420 vector<int>::const_iterator it2;
422 for (it2 = vn.begin(); it2 != vn.end(); it2++)
424 for (it = vNumb_.begin(); it != vNumb_.end(); it++)
429 if (it == vNumb_.end())
430 vNumb_.push_back(*it2);
431 else if (*it != *it2)
432 vNumb_.insert(it, *it2);
445 vector<int>::const_iterator it(vNumb_.begin());
446 vector<int>::const_iterator it2(n.
vNumb_.begin());
448 for ( ; it != vNumb_.end(); it++)
450 while (it2 != n.
vNumb_.end() && (*it2 < *it))
452 if (it2 == n.
vNumb_.end() || (*it2 > *it))
466 vector<int>::const_iterator it(vNumb_.begin());
467 vector<int>::const_iterator it2(n.
vNumb_.begin());
469 for ( ; it != vNumb_.end(); it++)
471 while (it2 != n.
vNumb_.end() && (*it2 < *it))
474 if (it2 == n.
vNumb_.end())
void addHyperNode(const HyperNode &hn)
Vint vNumb_
A vector<int> where all elements are different and in increasing order.
bool hasExclusivePaths() const
Substitution models manager for non-homogeneous / non-reversible models of evolution.
void setModel(size_t nM, const Vint &vnS)
sets submodel numbers in the nMth mixed model. Checks if all the numbers are valid.
void computeHyperNodesProbabilities()
bool operator>=(const Node &) const
checks if this HyperNode includes another one.
const SubstitutionModel * getModel(size_t i) const
Get one model from the set knowing its index.
MixedSubstitutionModelSet(const Alphabet *alpha)
Create a model set according to the specified alphabet.
virtual double getNProbability(size_t i) const =0
Returns the probability of a specific model from the mixture.
MixedSubstitutionModelSet & operator=(const MixedSubstitutionModelSet &set)
double getHyperNodeProbability(const HyperNode &hn) const
bool operator>=(const HyperNode &) const
checks if this HyperNode includes another one.
void setProbability(double x)
sets the probability
HyperNode & getHyperNode(size_t i)
const Node & getNode(size_t i) const
bool isComplete() const
checks if this HyperNode includes at least a submodel of each mixed model
bool operator<=(const Node &) const
checks if this Node is included in another one.
void clear()
Resets the list of the HyperNodes.
double proba_
probability of this HyperNode.
void clear()
Resets all the information contained in this object.
virtual void normalizeVRates()=0
Normalizes the rates of the submodels so that the mean rate of the mixture equals rate_...
Vint vUnused_
the coordinates of the Nodes that are not used.
void addToHyperNode(size_t nM, const Vint &vnS, int nH=-1)
virtual void setNProbability(size_t i, double prob)=0
Sets the probability of a specific model from the mixture.
~MixedSubstitutionModelSet()
HyperNode(const MixedSubstitutionModelSet *)
double getProbability() const
returns the probability
Substitution models manager for Mixed Substitution Models. This class inherits from SubstitutionModel...
std::vector< Node > vNumbers_
HyperNode & operator+=(const HyperNode &)
Cumulates the Nodes of the given HyperNode into this one.
HyperNode & operator=(const HyperNode &)
virtual void fireParameterChanged(const ParameterList ¶meters)
void addToModel(size_t nM, const Vint &vnS)
adds submodel numbers to the nMth mixed model. Checks if all the numbers are valid.
virtual size_t getNumberOfModels() const =0
size_t getNumberOfModels() const
SubstitutionModelSet & operator=(const SubstitutionModelSet &set)
bool intersects(const HyperNode &) const
checks if this HyperNode intersects another one.
void fireParameterChanged(const ParameterList ¶meters)
bool operator<=(const HyperNode &) const
checks if this HyperNode is included in another one.
size_t getNumberOfHyperNodes() const
bool intersects(const Node &) const
checks if this Node intersects another one.
std::vector< HyperNode * > vpHyperNodes_
Node & operator+=(const Node &)
Cumulates the elements of the given Node into this one.
void insertN(const Vint &vn)
Interface for Substitution models, defined as a mixture of "simple" substitution models.