49 distanceMatrix_(4, 4),
77 if (alpha_->isGap(state1) || !alpha_->isIntInAlphabet(state1))
78 throw BadIntException(state1,
"DefaultNucleotideScore::getIndex(). Invalid state1.", alpha_);
79 if (alpha_->isGap(state2) || !alpha_->isIntInAlphabet(state2))
80 throw BadIntException(state2,
"DefaultNucleotideScore::getIndex(). Invalid state1.", alpha_);
81 if (!alpha_->isUnresolved(state1) && !alpha_->isUnresolved(state2))
82 return distanceMatrix_(
83 static_cast<size_t>(state1),
84 static_cast<size_t>(state2));
85 vector<int> states1 = alpha_->getAlias(state1);
86 vector<int> states2 = alpha_->getAlias(state2);
89 for (
size_t i = 0; i < states1.size(); i++)
91 for (
size_t j = 0; j < states2.size(); j++)
93 tmp_score = getIndex(states1[i], states2[j]);
94 if (tmp_score > score)
98 return score /
static_cast<double>(states1.size() + states2.size() - 1);
104 return distanceMatrix_(
105 static_cast<size_t>(alpha_->charToInt(state1)),
106 static_cast<size_t>(alpha_->charToInt(state2)));
An alphabet exception thrown when trying to specify a bad char to the alphabet.
This alphabet is used to deal NumericAlphabet.
LinearMatrix< double > * getIndexMatrix() const
double getIndex(int state1, int state2) const
Get the index associated to a pair of states.
LinearMatrix< double > distanceMatrix_
An alphabet exception thrown when trying to specify a bad int to the alphabet.
The abstract base class for nucleic alphabets.